User manual
612
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
dim GLCD_CS1_Direction as sbit at TRISB4_bit
GLCD_CS2_Direction as sbit at TRISB5_bit
GLCD_RS_Direction as sbit at TRISF0_bit
GLCD_RW_Direction as sbit at TRISF1_bit
GLCD_EN_Direction as sbit at TRISF4_bit
GLCD_RST_Direction as sbit at TRISF5_bit
‘ eEnd Glcd module connections
‘ Touch Panel module connections
dim DriveA as sbit at LATC13_bit
DriveB as sbit at LATC14_bit
DriveA_Direction as sbit at TRISC13_bit
DriveB_Direction as sbit at TRISC14_bit
‘ end Touch Panel module connections
dim write_erase as bit
pen_size as byte
x_coord, y_coord as word
write_msg, clear_msg, erase_msg as char[5] ‘ GLCD menu messages
sub procedure Initialize()
ADPCFG = 0xFF3F ‘ set AN6 and AN7 channel pins as analog
DriveA_Direction = 0 ‘ Set DriveA pin as output
DriveB_Direction = 0 ‘ Set DriveB pin as output
Glcd_Init() ‘ Initialize GLCD
Glcd_Fill(0) ‘ Clear GLCD
ADC1_Init() ‘ Initialize ADC
TP_Init(128, 64, 6, 7) ‘ Initialize touch panel
TP_Set_ADC_Threshold(3900) ‘ Set touch panel ADC threshold
end sub
sub procedure Calibrate()
Glcd_Dot(0,63,1) ‘ Draw bottom left dot
Glcd_Write_Text(“TOUCH BOTTOM LEFT”,12,3,1)
TP_Calibrate_Bottom_Left() ‘ Calibration of bottom left corner
Delay_ms(1000)
Glcd_Dot(0,63,0) ‘ Clear bottom left dot
Glcd_Dot(127,0,1) ‘ Draw upper right dot
Glcd_Write_Text(“ “,12,3,1)
Glcd_Write_Text(“TOUCH UPPER RIGHT”,12,4,1)
TP_Calibrate_Upper_Right() ‘ Calibration of upper right corner
Delay_ms(1000)
end sub
main:
write_msg = “WRITE”
clear_msg = “CLEAR”
erase_msg = “ERASE”