For my test I use a PIC32MX4 MMB. The touch panel work perfectly with the examples or with a Visual TFT project.
But I'm unable to make it work alone. There is surely something I don't understand or don't do correctly to make the library work. Here is the simplest code I can see to test the Touch Panel, the TFT itself is not initialized I just want to test the Touch Screen.
Code: Select all
// Touch Panel module connections
sbit DriveX_Left at LATB13_bit;
sbit DriveX_Right at LATB11_bit;
sbit DriveY_Up at LATB12_bit;
sbit DriveY_Down at LATB10_bit;
sbit DriveX_Left_Direction at TRISB13_bit;
sbit DriveX_Right_Direction at TRISB11_bit;
sbit DriveY_Up_Direction at TRISB12_bit;
sbit DriveY_Down_Direction at TRISB10_bit;
// End Touch Panel module connections
// Global variables
unsigned int Xcoord, Ycoord;
void main() {
char txt[12];
AD1PCFG = 0xFFFF;
PCFG12_bit = 0;
PCFG13_bit = 0;
UART2_Init(115200);
ADC1_Init();
TP_TFT_Init(320, 240, 13, 12); // Initialize touch panel
TP_TFT_Set_ADC_Threshold(1000); // Set touch panel ADC threshold
TP_TFT_Set_Calibration_Consts(76, 907, 77, 915); // Set calibration constants
while(1) {
if (TP_TFT_Press_Detect()) {
// After a PRESS is detected read X-Y and convert it to Display dimensions space
UART2_Write_Text("Press Detected\r\n"); // This work
if (TP_TFT_Get_Coordinates(&Xcoord, &Ycoord) == 0) { // This don't
WordToStr(Xcoord,txt);
UART2_Write_Text(txt);
UART2_Write_Text("\r\n");
WordToStr(Ycoord,txt);
UART2_Write_Text(txt);
UART2_Write_Text("\r\n");
}
}
delay_ms(500);
}
}
Please help me understand how the Touch Panel TFT Library is working. Thank you.