SHOWALL FUN PRANKS HIGH VOLTAGE LAZARUS-64 PHOTOGRAPHY SPY GADGETS VIDEO GAME
Figure 14 - An image is converted from a bitmap into data bytes
Figure 14 - An image is converted from a bitmap into data bytes

For the next version, I have decided to exercise the video DAC a bit and display a 256 color image directly from the AVR program memory to the monitor. For this task, I hacked together a simply Visual Basic program that would open a bitmap and then create a file containing comma delimited data bytes that correspond to the colors in the image. The conversion is not perfect because the PC bitmap contains 8 bit per color (24 bit image), and the DAC on this project can only display a fixed 2 bits per color. I just made a table and tried to match the best possible color.



Figure 15 - King Tut shown at 128 by 240 pixels using 256 colors
Figure 15 - King Tut shown at 128 by 240 pixels using 256 colors

Not much has changed in the source code except that in the active pixel loop "HORIZONTAL ACTIVE LINE = 512 CYCLES / 4 = 128 PIXELS". The bytes are fetched from the internal program memory and then sent to the DAC. Because the LPM and OUT commands take up a total of 4 cycles, the maximum pixel rate that can be achieved using this method is 128 pixels (512/4 =128). Considering the low resolution and bad conversion from 24 bit color, the displayed image looks pretty good.

< Here is the progmem image generator source code >

Looking at the new source code, you can see that the active pixel loop just issues the command "lpm r16,z+ ;3", and "out portc,r16 ;1" for a total of 512 lines, basically reading and sending a byte every 4 clock cycles for the next 512 cycles. The image data is loaded into the program memory as one huge table located at "PIC:" under the heading "128 x 240 RRGGBBII IMAGE DATA". This basic VGA generator can now store and display low resolution images, but that is not much use since you cannot dynamically alter the display in the main loop yet. The LED just keeps on flashing, letting you know that there are over 65000 free cycles for you to use.

Back Home Last Next
You are Viewing... Page 8 of 16
Lucid Science Electronics from the Fringe AtomicZombie Hack-a-day SparkFun