Search This Blog

Monday, January 7, 2013

Displaying Bitmap on Graphic LCD

Monochrome GLCD provides control for each and every pixel on the screen. As it has no colors barring black and white its pixel controllers are pretty simple. Basically a 128x64 resolution graphic LCD has 2 controllers each controlling 64x64 pixels on the screen. In short the screen is divided into 2 columns. (Left and Right).

Different manufacturers use different controllers. The most common is the ks0108 controllers. The code shown here is tested on a GLCD ks0108 controlled interfaced with an AVR atmega16/32. But as written in C can be ported to any other AVR controller.

Bitmap images can be easily displayed on the screen as bmp files are basicall hexadecimal code stored in either RLE compression or directly into a bmp container. To be used with non sd card reading controllers, one can convert these bitmaps into an equivalent header files. 

See image below.
Ya!! its popye the sailor man image.

Its equivalent header file looks like this...

static uint8_t sailor_man[] PROGMEM = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xF0,0x78,0x28,0x28,0x68,0x48,0x48,0xD8,
0x90,0x10,0x10,0xF0,0x00,0x00,0x00,0x00,
.
.
.
0x1A,0x18,0x1A,0x72,0x32,0x7A,0x3A,0x76,
0x0C,0x18,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};


The array is basically stored as 64 rows and 128 columns format. 
Meaning the first 128 values in the array is for the 1st row. 2nd 128 values for 2nd row and so on....
Depending on the converter you use these set can be arranged in any form. The converter i used is a small application called FastLCD. (Download).

The tutorial to use FastLCD though very simple is shown here.

Yes one more thing store this array in the program memory of the AVR.
Now we require a loop to read these values from the program memory in the form of row and columns and display on the screen. The below loop will do the trick.

uint16_t i, j,by;
for(i=0; i<64; i+=8)
       for(j=0; j<128; j++)
      {
             by=pgm_read_byte(bitmap++);
             ks0108GotoXY(j, i);
             ks0108WriteData(by);
      }


So as the ks0108 controller can directly read hexa decimal values we just read the byte from the program memory and arrange it in rows and columns and just write the data....
Is it really this simple.???
Yes it is....

same can be converted into a function to improve portability.

void LoadBitmap(unsigned char *bitmap)
{
uint16_t i, j,by;
for(i=0; i<64; i+=8)

                                for(j=0; j<128; j++)
                                {
                                                by=pgm_read_byte(bitmap++);
                                                ks0108GotoXY(j, i);
                                                ks0108WriteData(by);
                                }
}

This is how one can display various monochrome bitmaps in the GLCD.
See images from my experiments...
Addidas Logo on GLCD

Sailor Man on GLCD.
You can download source code from here.

Sunday, December 9, 2012

The Schematics – The Review

Well I am very lazy about making schematics and all that boring paperwork stuff. So I am just gonna provide the reviews of various schematics out available on the internet.  I just see the datasheet and do connection skipping the paperwork. I have also noticed that though there are lots of schematics but no review post!! Surprising. Well so here is one…


GLCD Schematic from All About Embedded System
This one is taken from All about embedded system. This is the most basic,compact and port efficient non spi connection one can make. This is almost the one I have done except that I kept Vout, RST and Vo open.  It will work either way as I had no need for those three pins.  Data bus goes to one port and control pins to other making it easier to work with standard company libraries of the controller.(Here in this case ks0108).
GLCD Schematic from ScienceProject
This one is a complete circuit diagram for an avr board containing ISP, Serial Port,3 adc pin out and glcd connection. This is actually a proper most perfect schematic I have seen. Here Databus of glcd is connected at Port C, CS1, CS2, EN, RW and D/I are connected to PA4, PA3, PA2, PA1 and PA0. Here the rest of Port A pins PA5,PA6 and PA7 are outputted to be used as ADC. This is a nice but a more efficient one has been made by guys at extremeelectronics. The one at extremeelectronics is basically a GLCD centric Development Board.
The GLCD Based Development Board from extremeelectronics
asd

  if in your application gui plays a major role than this is the board that one should prefer cause it is glcd centric has all essential keys and easy to program using progfx library created by exteremeelectronics.