Displaying Images and Icons on GLCD using PIC microcontroller

Displaying Images and Icons on GLCD using PIC microcontroller

The GLCD that we use has a monochrome display with a resolution of 128*64. With the help of the GLCD, we can display custom images, icon and other characters. In this article, we will be covering how to display an image on the GLCD. So to display an image we need to configure the image accordingly. This can be done with any photo editing application such as Photoshop. Here we will be using windows built-in tool Paint.

Image Editing with Paint

First, open the image in paint.

Displaying Images and Icons on GLCD

To adjust the resolution of the image, choose Resize and select Pixels option. After disabling “Maintain aspect ratio” checkbox, set the width as 128 and height as 64. Then press ‘OK’.

Displaying Images and Icons on GLCD

Then save this image using ‘Save as’ option under file. Give an appropriate file name and choose the file type as ‘Monochrome Bitmap’. Click ‘OK’ to the warnings that may follow.

Displaying Images and Icons on GLCD

Now the 128*64 resolution Monochrome image of the required image is obtained.

Displaying Images and Icons on GLCD

Creating GLCD compatible Hex code of the image

Now run the LCD Assistant (Download) application and load the monochrome image saved in the previous step with ‘Load image’ option under ‘File’.

Displaying Images and Icons on GLCD

Now select ‘Save output’ option in ‘File’. In the ‘Save As’ window give an appropriate file name with ‘.txt’ extension.
The created text file will contain the required hex values of the image as an array.

Displaying Images and Icons on GLCD

Display Image in GLCD

To display the image in the GLCD we need to write the values in the previously created array at the appropriate locations. We need to go to the required page and column and then write the data. Here we use a character pointer ‘*bmp’ to point to the next character to print. Variables x and y are used to specify the initial location to start the display. Variables dx and dy specify the resolution of the GLCD.

Firmware Example:

void GLCD_Bitmap(char * bmp, unsigned char x, unsigned char y, unsigned char dx, unsigned char dy)
{
    unsigned char i, j;
    for(j = 0; j < dy / 8; j++)
    {
        GLCD_GoTo(x,y + j);
        for(i = 0; i < dx; i++) 
        {
            GLCD_WriteData(*bmp);
            bmp++;
        }
    }
}

The address of the array of hex values that we previously generated is then passed to the above function to obtain the image on the GLCD. Here we provide the initial position as ( 0, 0 ) and the resolution of GLCD as 128*64.

Firmware Example:

GLCD_Bitmap(OpenLabPro_logo_header,0,0,128,64);