User manual
mikroC PRO for dsPIC
MikroElektronika
639
sbit GLCD_CS1 at LATB4_bit;
sbit GLCD_CS2 at LATB5_bit;
sbit GLCD_RS at LATF0_bit;
sbit GLCD_RW at LATF1_bit;
sbit GLCD_EN at LATF4_bit;
sbit GLCD_RST at LATF5_bit;
sbit GLCD_CS1_Direction at TRISB4_bit;
sbit GLCD_CS2_Direction at TRISB5_bit;
sbit GLCD_RS_Direction at TRISF0_bit;
sbit GLCD_RW_Direction at TRISF1_bit;
sbit GLCD_EN_Direction at TRISF4_bit;
sbit GLCD_RST_Direction at TRISF5_bit;
// End Glcd module connections
// Touch Panel module connections
sbit DriveA at LATC13_bit;
sbit DriveB at LATC14_bit;
sbit DriveA_Direction at TRISC13_bit;
sbit DriveB_Direction at TRISC14_bit;
// End Touch Panel module connections
bit write_erase;
char pen_size;
char write_msg[] = “WRITE”; // GLCD menu messages
char clear_msg[] = “CLEAR”;
char erase_msg[] = “ERASE”;
unsigned int x_coord, y_coord;
void 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(); // Initalize ADC module
TP_Init(128, 64, 6, 7); // Initialize touch panel
TP_Set_ADC_Threshold(3900); // Set touch panel ADC threshold
}
void 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);