Arduino Uno Driver, Hardware Acceleration Example

A project log for VGA Graphics Over SPI and Serial - VGATonic

640x480 (and 848x480!) Color VGA Video Card for Microcontrollers and Single Board Computers

PKPK 08/16/2015 at 19:240 Comments

I just pushed some Arduino Uno driver code to the Github Repository showing how to skip to individual lines. You can find it in the User Driver directory, and I called it "SPI_test". Just hook up VGATonic SCK, MOSI, and CS to pins 13, 11, and 9, respectively, on the Uno, then power it up!

If all goes well, you should see the pattern covered at around 1:19 in my prototype video now running on your VGATonic:

That's the third and the arguably the most subtle of the hardware acceleration methods on VGATonic, but is very useful for slow parts. Take the 2 MHz SPI from the example code - normally, that can push under one frame per second at 640x480x8 bit color (which requires roughly 2.5 million bits per total screen)... but by skipping to specific lines it creates the illusion that VGATonic is actually writing from bottom to top!

I forsee this being most useful for GUI development on slow serial parts - imagine having a constantly refreshing menubar on the bottom of the screen, but not needing to refresh the entire screen content if only the menubar changes. It's also useful for something like a mouse cursor, where only some of the screen needs a redraw and blasting the entire screen is a waste of resources.

Here are all three forms of acceleration onboard:

  1. Resolution and Bit Depth Changes - the bread and butter of the video card; reducing bit depth and/or resolution requires less serial bytes per screen refresh. Ranges from 640x480 @ 8 bit (2,457,600 bits) down to 80x60 @ 1 bit (4,800 bits).
  2. Chip Select Toggling - toggling chip select without any additional commands will reset the writing position to the upper left column and row, regardless of where it was previously positioned. This means a device can write an arbitrary number of pixels (assuming at least 2 bytes are sent; 1 byte is a special control character, detailed in the User Guide), and doesn't need to write until the last pixel in the lower right.
  3. Hardware Accelerated Positioning - detailed in this article and in the example code, this lets a device skip to individual rows for writing instead of starting from the upper right hand corner. For 640x480, this allows skipping 8 rows at a time (320x240 4, 160x120 2, and 80x60 1), vastly increasing throughput for slower parts.