Hi I'm using STemWin 5.22, got stuck at the touch driver.
It's a 3.2" LCD with analog touch screen, the touch screen controller is XPT2046. I've already written the 4 hardware routines GUI_TOUCH_X_ActivateX(), GUI_TOUCH_X_ActivateY(), GUI_TOUCH_X_MeasureX(), and GUI_TOUCH_X_MeasureY(), and I've called the GUI_TOUCH_Exec() every 10ms from an interrupt.
When I tried to run the TOUCH_Calibrate.c in the Win32 simulator's /sample/tutorial folder, the code was stuck at the welcome screen because it couldn't detect the touch at the screen.
[img]http://i.imgur.com/EbyA8b9.jpg[/img]
screenshot of TOUCH_Calibrate.c
Then I tried TOUCH_Sample.c, it ran and I could see the displayed "Analog input" was changing with the move of the pen, but the "Position" display was always 'x:0000 y:0000'. This could be an evidence that the A/D converter was working properly, it's also verified by written a small code of just calling the 4 hardware routine and display the return values. I've also checked the interface with a oscilloscope and I'm sure the touch screen chip was read every 10ms as required.
[img]http://i.imgur.com/hdHIxpK.jpg[/img] screenshot of TOUCH_Sample.c without pen touch
[img]http://i.imgur.com/iL8pnRp.jpg[/img] screenshot of TOUCH_Sample.c with pen touch.
I read the user manual again and again but still couldn't figure out the problem, could any body help or give some advice? Thanks.
the source code of TOUCH_Sample.c
/*********************************************************************
*
* MainTask
*/
void MainTask(void) {
GUI_PID_STATE TouchState;
int xPhys;
int yPhys;
GUI_Init();
//
// Check if recommended memory for the sample is available
//
if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY) {
GUI_ErrorOut("Not enough memory available.");
return;
}
GUI_CURSOR_Show();
GUI_CURSOR_Select(&GUI_CursorCrossL);
GUI_SetBkColor(GUI_WHITE);
GUI_SetColor(GUI_BLACK);
GUI_Clear();
GUI_DispString("Measurement of\nA/D converter values");
while (1) {
GUI_TOUCH_GetState(&TouchState); // Get the touch position in pixel
xPhys = GUI_TOUCH_GetxPhys(); // Get the A/D mesurement result in x
yPhys = GUI_TOUCH_GetyPhys(); // Get the A/D mesurement result in y
//
// Display the measurement result
//
GUI_SetColor(GUI_BLUE);
GUI_DispStringAt("Analog input:\n", 0, 20);
GUI_GotoY(GUI_GetDispPosY() + 2);
GUI_DispString("x:");
GUI_DispDec(xPhys, 4);
GUI_DispString(", y:");
GUI_DispDec(yPhys, 4);
//
// Display the according position
//
GUI_SetColor(GUI_RED);
GUI_GotoY(GUI_GetDispPosY() + 4);
GUI_DispString("\nPosition:\n");
GUI_GotoY(GUI_GetDispPosY() + 2);
GUI_DispString("x:");
GUI_DispDec(TouchState.x,4);
GUI_DispString(", y:");
GUI_DispDec(TouchState.y,4);
//
// Wait a while
//
GUI_Delay(100);
};
}
It's a 3.2" LCD with analog touch screen, the touch screen controller is XPT2046. I've already written the 4 hardware routines GUI_TOUCH_X_ActivateX(), GUI_TOUCH_X_ActivateY(), GUI_TOUCH_X_MeasureX(), and GUI_TOUCH_X_MeasureY(), and I've called the GUI_TOUCH_Exec() every 10ms from an interrupt.
When I tried to run the TOUCH_Calibrate.c in the Win32 simulator's /sample/tutorial folder, the code was stuck at the welcome screen because it couldn't detect the touch at the screen.
[img]http://i.imgur.com/EbyA8b9.jpg[/img]
screenshot of TOUCH_Calibrate.c
Then I tried TOUCH_Sample.c, it ran and I could see the displayed "Analog input" was changing with the move of the pen, but the "Position" display was always 'x:0000 y:0000'. This could be an evidence that the A/D converter was working properly, it's also verified by written a small code of just calling the 4 hardware routine and display the return values. I've also checked the interface with a oscilloscope and I'm sure the touch screen chip was read every 10ms as required.
[img]http://i.imgur.com/hdHIxpK.jpg[/img] screenshot of TOUCH_Sample.c without pen touch
[img]http://i.imgur.com/iL8pnRp.jpg[/img] screenshot of TOUCH_Sample.c with pen touch.
I read the user manual again and again but still couldn't figure out the problem, could any body help or give some advice? Thanks.
the source code of TOUCH_Sample.c
/*********************************************************************
*
* MainTask
*/
void MainTask(void) {
GUI_PID_STATE TouchState;
int xPhys;
int yPhys;
GUI_Init();
//
// Check if recommended memory for the sample is available
//
if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY) {
GUI_ErrorOut("Not enough memory available.");
return;
}
GUI_CURSOR_Show();
GUI_CURSOR_Select(&GUI_CursorCrossL);
GUI_SetBkColor(GUI_WHITE);
GUI_SetColor(GUI_BLACK);
GUI_Clear();
GUI_DispString("Measurement of\nA/D converter values");
while (1) {
GUI_TOUCH_GetState(&TouchState); // Get the touch position in pixel
xPhys = GUI_TOUCH_GetxPhys(); // Get the A/D mesurement result in x
yPhys = GUI_TOUCH_GetyPhys(); // Get the A/D mesurement result in y
//
// Display the measurement result
//
GUI_SetColor(GUI_BLUE);
GUI_DispStringAt("Analog input:\n", 0, 20);
GUI_GotoY(GUI_GetDispPosY() + 2);
GUI_DispString("x:");
GUI_DispDec(xPhys, 4);
GUI_DispString(", y:");
GUI_DispDec(yPhys, 4);
//
// Display the according position
//
GUI_SetColor(GUI_RED);
GUI_GotoY(GUI_GetDispPosY() + 4);
GUI_DispString("\nPosition:\n");
GUI_GotoY(GUI_GetDispPosY() + 2);
GUI_DispString("x:");
GUI_DispDec(TouchState.x,4);
GUI_DispString(", y:");
GUI_DispDec(TouchState.y,4);
//
// Wait a while
//
GUI_Delay(100);
};
}