
Use graphic LCD display
A graphic LCD (GLCD) provides an advanced method for displaying visual messages. While the character LCD can display only alphanumeric characters, the GLCD can also display messages in the form of drawings and bitmaps. The most commonly used graphic LCD has a screen resolution of 128x64 pixel. The GLCD contrast can be adjusted by means of potentiometer P1. Here, the GLCD displays a truck the bitmap of which is stored in thetruck_bmp.mbas file.

'Header******************************************************
program example_14 ' Program name
dim GLCD_DataPORT as byte at PORTD
dim GLCD_CS1 as sbit at RB0_bit ' Glcd module connections
GLCD_CS2 as sbit at RB1_bit
GLCD_RS as sbit at RB2_bit
GLCD_RW as sbit at RB3_bit
GLCD_EN as sbit at RB4_bit
GLCD_RST as sbit at RB5_bit
dim GLCD_CS1_Direction as sbit at TRISB0_bit
GLCD_CS2_Direction as sbit at TRISB1_bit
GLCD_RS_Direction as sbit at TRISB2_bit
GLCD_RW_Direction as sbit at TRISB3_bit
GLCD_EN_Direction as sbit at TRISB4_bit
GLCD_RST_Direction as sbit at TRISB5_bit ' End Glcd module connections
dim counter as byte
someText as char[18]
sub procedure Delay2S() ' 2 seconds delay sub function
Delay_ms(2000)
end sub
main: ' Start of program
ANSEL = 0 ' Configure analog pins as digital I/O
ANSELH = 0
Glcd_Init() ' Initialize Glcd
Glcd_Fill(0x00) ' Clear Glcd
while TRUE ' Endless loop
Glcd_Image(@truck_bmp) ' Draw image
Delay2S() delay2S()
Glcd_Fill(0x00) ' Clear Glcd
Glcd_Box(62,40,124,63,1) ' Draw box
Glcd_Rectangle(5,5,84,35,1) ' Draw rectangle
Glcd_Line(0, 0, 127, 63, 1) ' Draw line
Delay2S()
counter = 5
while (counter <= 59) ' Draw horizontal and vertical lines
Delay_ms(250)
Glcd_V_Line(2, 54, counter, 1)
Glcd_H_Line(2, 120, counter, 1)
Counter = counter + 5
wend
Delay2S()
Glcd_Fill(0x00) ' Clear Glcd
Glcd_Set_Font(@Character8x7, 8, 7, 32) ' Choose font "Character8x7"
Glcd_Write_Text("mikroE", 1, 7, 2) ' Write string
for counter = 1 to 10 ' Draw circles
Glcd_Circle(63,32, 3*counter, 1)
next counter
Delay2S()
Glcd_Box(10,20, 70,63, 2) ' Draw box
Delay2S()
Glcd_Fill(0xFF) ' Fill Glcd
Glcd_Set_Font(@Character8x7, 8, 7, 32) ' Change font
someText = "8x7 Font"
Glcd_Write_Text(someText, 5, 0, 2) ' Write string
delay2S()
Glcd_Set_Font(@System3x5, 3, 5, 32) ' Change font
someText = "3X5 CAPITALS ONLY"
Glcd_Write_Text(someText, 60, 2, 2) ' Write string
delay2S()
Glcd_Set_Font(@font5x7, 5, 7, 32) ' Change font
someText = "5x7 Font"
Glcd_Write_Text(someText, 5, 4, 2) ' Write string
delay2S()
Glcd_Set_Font(@FontSystem5x7_v2, 5, 7, 32) ' Change font
someText = "5x7 Font (v2)"
Glcd_Write_Text(someText, 5, 6, 2) ' Write string
delay2S()
wend
end. ' End of program
truck_bmp.mbas file:
module bitmap ' Module with bitmap code const truck_bmp as byte[1024] = (0,0,0,0,0,248,8,8,8,8,8,8,12,12,12,12,12,10,10,10,10,10,10,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,137,137,137,137,137,137,137,137,137,137,137,137,137,9,9,9,9,9, 9,9,9,9,9,9,13,253,13,195,6,252,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,0, 0,0,0,0,0,0,0,0,0,240,240,240,240,240,224,224,240,240,240,240,240,224,192,192,22 4,240,240,240,240,240,224,192,0,0,0,255,255,255,255,255,195,195,195,195,195,195, 195,3,0,0,0,0,0,0,0,0,0,0,0,0,255,240,79,224,255,96,96,96,32,32,32,32,32,32,32,3 2,32,32,32,32,32,64,64,64,64,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,0,0 ,0,0,255,255,255,255,255,0,0,0,0,255,255,255,255,255,0,0,0,255,255,255,255,255,1 29,129,129,129,129,129,129,128,0,0,0,0,0,0,0,0,0,0,0,0,255,1,248,8,8,8,8,8,8,8,8 ,8,8,8,8,8,8,16,224,24,36,196,70,130,130,133,217,102,112,160,192,96,96,32,32,160 ,160,224,224,192,64,64,128,128,192,64,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 63,96,96,96,224,96,96,96,96,96,96,99,99,99,99,99,96,96,96,96,99,99,99,99,99,96,9 6,96,96,99,99,99,99,99,96,96,96,99,99,99,99,99,99,99,99,99,99,99,99,99,96,96,96, 96,96,96,96,64,64,64,224,224,255,246,1,14,6,6,2,2,2,2,2,2,2,2,2,2,2,130,67,114,6 2,35,16,16,0,7,3,3,2,4,4,4,4,4,4,4,28,16,16,16,17,17,9,9,41,112,32,67,5,240,126, 174,128,56,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,127,127,127,127,255 ,255,247,251,123,191,95,93,125,189,189,63,93,89,177,115,243,229,207,27,63,119,25 5,207,191,255,255,255,255,255,255,255,255,127,127,127,127,127,127,127,127,255,25 5,255,127,127,125,120,120,120,120,120,248,120,120,120,120,120,120,248,248,232,14 3,0,0,0,0,0,0,0,0,128,240,248,120,188,220,92,252,28,28,60,92,92,60,120,248,248,9 6,192,143,168,216,136,49,68,72,50,160,96,0,0,0,0,0,0,0,0,0,128,192,248,248,248,2 48,252,254,254,254,254,254,254,254,254,254,254,254,255,255,255,255,255,246,239,2 08,246,174,173,169,128,209,208,224,247,249,255,255,252,220,240,127,255,223,255,2 55,255,255,255,255,254,254,255,255,255,255,255,255,255,254,255,255,255,255,255,2 55,255,254,254,254,254,254,254,254,254,254,254,254,254,254,254,255,255,255,255,2 55,255,254,255,190,255,255,253,240,239,221,223,254,168,136,170,196,208,228,230,2 48,127,126,156,223,226,242,242,242,242,242,177,32,0,0,0,0,0,0,0,0,0,0,1,1,1,1,3, 3,3,7,7,7,7,7,15,15,15,7,15,15,15,7,7,15,14,15,13,15,47,43,43,43,43,43,47,111,23 9,255,253,253,255,254,255,255,255,255,255,191,191,239,239,239,191,255,191,255,25 5,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,25 5,255,255,255,255,255,255,127,127,127,127,255,255,191,191,191,191,255,254,255,25 3,255,255,255,251,255,255,255,127,125,63,31,31,31,31,31,31,63,15,15,7,7,3,3,3,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,3,3,3,11,11,11 ,11,7,3,14,6,6,6,2,18,19,19,3,23,21,21,17,1,19,19,3,6,6,14,15,15,7,15,15,15,11,2 ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0) implements end. ' End of moduleIn order to make this example work properly, it is necessary to check the GLCD library in the Library Manager before compilation. Also, it is necessary to include the
Bitmap.mbas document into the project.