Now that was a cool project! (the VGA monitor) ![]()
In my case it's a little bit more manageable in the sense that I have 25*25 = 625 "pixels" (LEDs) with only 4bit for each (16 tones of gray), so for a full screen it's only 13 bytes per row with 25 rows = 325 bytes to hold the full screen. It's happily scrolling a large font message streamed "live" from MegaMan (the Arduino Mega 2560 that is the I2C master) behind me as I write this.
You're right in that I avoid interrupts for the I2C bit. This is because the screen refresh is very timing sensitive indeed. And Peggy (as this pegboard is called) only really does two things: 1) constantly update the screen through a timer interrupt with whatever is currently in the frameBuffer (a 325B char array), and 2) wait for I2C input and trigger corresponding actions. Those actions are either a) display whatever data comes over I2C raw (like for my scrolling message), or b) run an animation (like the "please wait"-animation).
This is the reason I don't have an interrupt for the I2C: reading I2C data is the only purpose of it, so an eternal loop processing I2C data is really all I need. Normally I'd written that in the main loop() function, but the gentleman who wrote the original code took a "standard C" approach with main() which in turn calls serviceInputData().It's really serviceInputData() that serves as the loop() equivalent in this code. I thought about making it more Arduino'ish, but I did initially not want to make changes to the code. The original code only streamed data over I2C with no animation functions. This was done because the original project was to stream live video from a webcam to the LED display. Which, if I may say so, looked pretty awesome ![]()
It was however not so useful for me, who wanted it to report status messages & such, and I decided to move some of the animation (like fade-out, fade-in, wait, error and such) to the Peggy, so that MegaMan would be free do some other things than just generate images to be sent vi I2C to Peggy. MegaMan also plays MP3 files and communicates with the third and last member of what is actually a trio of Arduinos/clones over XBee wireless (the last guys is called Wally, and is a living-room sentry turret with movement sensors and lasers - don't ask, I have too much free time on my hands at the moment!). ![]()
Anyway, my hope was that perhaps some I2C guru could slap me with a trout and say something like "why don't you simply check the XXXX register afters setting the Y bit you silly noob" or something, because I can't believe it's not doable. But, as I've exhausted all the options that seemed to make sense to me to no avail, and despite reading the TWI/I2C section of the data sheet to exhaustion, I still can not understand why not any of my checks would trigger when the next message comes in (or always trigger, which is just as useless)...