Here is my simple test code :
Code: Select all
sbit LED at LATA0_bit;
sbit LED_dir at TRISA0_bit;
// 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
void main()
{
char txt[12];
char valid;
unsigned int x_coord,y_coord;
JTAGEN_bit = 0;
AD1PCFG = 0xCFFF; // AN12-13 analog
LED_dir = 0;
LATA = 0xFFFF;
UART2_Init(115200);
UART2_Write_Text("Test Touch Screen PIC32\r\n");
ADC1_Init(); // Initalize ADC module
TP_TFT_Init(320, 240, 13, 12); // Initialize touch panel
TP_TFT_Set_ADC_Threshold(900); // Set touch panel ADC threshold
while(1)
{
if (TP_TFT_Press_Detect())
{
if (TP_TFT_Get_Coordinates(&x_coord, &y_coord) == 0)
{
WordToStr(x_coord, txt);
UART2_Write_Text("X Coordinate = ");
UART2_Write_Text(txt);
UART2_Write_Text("\r\n");
WordToStr(y_coord, txt);
UART2_Write_Text("Y Coordinate = ");
UART2_Write_Text(txt);
UART2_Write_Text("\r\n");
}
LED = ~LED;
delay_ms(300);
}
}
}
Am I using the library correctly ? Is there something I missed ? I have followed the exemple.
Thank you for any help.