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 mikroPascal 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; uses __Lib_Glcd_Images; var ii : byte; jj : word; someText : array[20] of char; procedure Delay2S; begin Delay_ms(2000); end; begin ADPCFG := $FFFF; Glcd_Init(PORTB, 2, PORTB,3, PORTB,4, PORTB,5, PORTB,7, PORTB,6, PORTD); Glcd_Fill(0xAA); Delay2S(); // Main loop while TRUE do begin Glcd_Fill(0x00); // Clear screen // Draw image Glcd_Image(truck_bmp); Delay2S(); Glcd_Fill(0x00); // Clear screen // Draw dots for jj := 0 to 40 do begin Glcd_Dot(jj, jj, 1); end; 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 do Glcd_Circle(63, 31, 3*ii, 1); 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: 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(); end; //while end.