hlxldb

单片机控制诺基亚2600彩屏(八)

0
阅读(1965)

 

Step 9Drawing Optimizations

When drawing moving objects on the LCD, you can greatly speed up the frame rate and eliminate screen glitches by only redrawing the moving parts of an object rather than redrawing the entire screen or entire object.  For instance, if a ball is moving across the screen, rather than redrawing the entire ball you can just draw the pixels along the edge that has moved and clear the pixels on the edge that has moved away.  Techniques such as frame buffering and double buffering can be used, where a new frame buffer is compared against an old frame buffer and only differing pixels are written to the display.  However, given the limitations of AVR and similar 8-bit microcontrollers, these techniques are probably out of range.  If you are using an ARM or other 32-bit microcontroller with a higher performance CPU, more RAM, etc. then you can take advantage of double buffering for a much more efficient screen drawing system.
 

Step 10Drawing Pictures Using the Serial Port

Drawing Pictures Using the Serial Port

Drawing Pictures Using the Serial Port

It is actually very easy to draw full color photos on the LCD!  I simply used the serial port to transfer the image from the PC to the AVR which displays it on the LCD.  To convert the image into the correct format, I wrote a small application in Visual Basic (VS 2010) that takes a 130x130 .bmp formatted image and transforms it into the 12 bit per pixel color format needed to display on the LCD.  The Visual Basic VS2010 project is included with the code package at the end of this Instructable.

The serial port uses 115200 baud which is very fast for a microcontroller.  This enables a quick transfer of image data to the microcontroller and it can draw a full 130x130 image in less than 1 second.  To do this, the microcontroller must be running at around 20MHz (it must be exactly 20MHz to use the code unmodified, but it may work at 16MHz if the baud rate calculation is changed).  A MAX232 level shifter is used to convert the RS-232 signal into a 0-5V TTL signal.  Although the ATMega168 is only running at 3.3V, the inputs are 5V tolerant so you may connect the 5V signal to the Rx pin and it will still work.