Code example : Displaying a bitmap on Graphic LCD

Bitmap2LCD is a tool for programming small Graphic LCDs in embedded systems and a programmable graphic and text processing tool.

Code example : Displaying a bitmap on a Graphic LCD

Example for an Atmel AVR Microcontroller + a monochrome 128 x 64 Dot Matrix GLCD + using a KS0108 GLCD Controller Library.

 

#include <avr/io.h>
#include “C:\Users\BE\GLCD Lib\KS0108.c”
#include “C:\Users\BE\GLCD Lib\KS0108-AVR.c”
#include “C:\Users\BE\Documents\Bitmap2LCD Project\Output Files\NewBitmap.h”
void LoadBitmap(const uint8_t *bitmap)
{
uint8_t i, j;
for(i=0; i<64; i+=8)
for(j=0; j<128; j++)
{
GLCD_GoTo(j, i);
GLCD_WriteData(pgm_read_byte(bitmap++));
}
}
int main(void)
{
while(1)
{
LoadBitmap(NewBitmap);
}
}

 

Newbitmap.h

The 128 x 64 pixels bitmap converted to data array

#include <avr/pgmspace.h>
 
 const uint8_t  NewBitmap [] = {
 
 0x20 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x02,
 0x10 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x04,
…  Bitmap 1024 Data bytes in Total
0x80 , 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
};