NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Microcontroller Programming » Why is width of image divided by 256?
April 13, 2012 by jeffspc88mx |
I'm programming a VFD display to show a simple bar (filled rectangle) and I can do it, but I'm not sure why this code (from the manufacturer) is working:
The spec sheet says that the width>>8 statement ought to be 0 in all cases, but it's only 0 when width is <256. Otherwise it's 1 (and maxed out, as this is a 512 bit wide array of bits). Y is always starting at zero, why not X? So why is it ever 1? Why not just make this value 0 all the time? Or is it always going to be zero because of the re-cast as an 8 bit integer in the function header? In which case my question becomes "Why didn't they just say 0 instead of "width >> 8"? Here's the spec:
Another way to state the question is: Why should xL be xH>>8 all the time? |
---|---|
April 16, 2012 by hevans (NerdKits Staff) |
Hi jeffspc88mx, I think what is going on here is that you are setting the the width of the image in two different steps. You are first sending over the low byte, and then the high bite. I bet the command() function takes an 8-bit integer as its input, so when you call command(width) it will cast the width variable to an 8-bit integer, thereby ignoring the higher bits. Then to send over the high byte you shift width down by one byte and send that. If in fact the width is always less than 256 (and width is unsigned) then the high byte of width will always be 0. Humberto |
April 16, 2012 by jeffspc88mx |
Ahhh - that explains why the spec refers to them as low-byte/high byte. I had a feeling that low-byte/high-byte meant what you said, but I chose not to believe it. Explains a lot of other things about the Noritake code that I'm seeing as well. Right on! That solves that and a lot more, thanks! I'm off to turn this thing into a sound meter.... |
Please log in to post a reply.
Did you know that you can read diagnostic data from some cars with a NerdKit? Learn more...
|