
The example shows the connection of a «dot-matrix» graphical alpha-numeric LCD module (GLCD) to a dsPIC30F microcontroller. The example covers the initialization of the GLCD, writing text, drawing lines, boxes, and circles. The realization is carried out by using the mikroBasic compiler for dsPIC30F microcontrollers. The interconnection of the GLCD module and a dsPIC30F device is shown in Fig. 13-3.

Fig. 13-3 Interconnection of the GLCD module and a dsPIC30F device.
program GlcdDemo
include "__Lib_Glcd_Images"
dim ii as byte
jj as word
someText as char[20]
sub procedure Delay2S
Delay_ms(2000)
end sub
main:
ADPCFG = $FFFF
TBLPAG = 0
'** dsPICPro3
Glcd_Init(PORTB, 2, PORTB,3, PORTB,4, PORTB,5, PORTB,7, PORTB,6, PORTD)
Glcd_Fill(0xAA)
Delay2S()
' Main loop
while TRUE
Glcd_Fill(0x00) ' Clear screen
' Draw image
Glcd_Image(truck_bmp)
Delay2S()
' Draw dots
for jj = 0 to 40
Glcd_Dot(jj, jj, 1)
next jj
Delay2S()
' Draw lines
Glcd_Fill(0x00)
Glcd_Line(120, 1, 5, 60, 1)
Delay2S()
Glcd_Line(12, 42, 5, 60, 1)
Delay2S()
Glcd_H_Line(5, 15, 6, 1)
Glcd_V_Line(6, 15, 15, 1)
' Draw rectangle
Glcd_Rectangle(12, 20, 93,57, 1)
Delay2S()
' Draw lines
Glcd_Line(120, 12, 12,60, 1)
Delay2S()
Glcd_H_Line(5, 15, 6, 1)
Glcd_Line(0, 12, 120, 60, 1)
Glcd_V_Line(7, 63, 127, 1)
Delay2S()
' Draw circles
for ii = 1 to 10
Glcd_Circle(63, 31, 3*ii, 1)
next ii
Delay2S()
' Draw box
Glcd_Box(12, 20, 70, 57, 2)
Delay2S()
Glcd_Fill(0x00)
' Font demo
Glcd_Set_Font(@System3x6, 3, 6, 32)
someText = "SMALL FONT AS 3X6"
Glcd_Write_Text(someText, 20, 5, 1)
Glcd_Set_Font(@FontSystem5x8, 5, 8, 32)
someText = "Large Font 5x8"
Glcd_Write_Text(someText, 3, 4, 1)
Delay2S()
wend
end.