Touchgfx Touch Panel Routine
Hello Dear Engineers,
I am looking for a standard touch handling routine using Touchgfx. The touch panel I am using is resistive which is handled by XPT2046 (TSC2046). The touch controller IC is controlled by SPI.
The main problem I have been encountered is that the touch screen response on the run time test is really sharp and fast, it shouldn't be as usual devices like iPhone or Android devices have some sort of delay. Furthermore, when a button or selectable item is touched, it shouldn't lose focus until the press is released. The routine I have used so far is as follows.
bool STM32TouchController::sampleTouch(int32_t &x, int32_t &y) {
static int32_t prev_x = 0, prev_y = 0;
if (XPT2046_TouchPressed()) {
XPT2046_TouchGetCoordinates((uint16_t*) &x, (uint16_t*) &y);
if ((abs(prev_x - x)>20) &(abs(prev_y- y)>20)) {
if ((x != 0) & (y != 0)) {
prev_x = x;
prev_y = y;
return true;
}
}
}
/**
* By default sampleTouch returns false,
* return true if a touch has been detected, otherwise false.
*
* Coordinates are passed to the caller by reference by x and y.
*
* This function is called by the TouchGFX framework.
* By default sampleTouch is called every tick, this can be adjusted by HAL::setTouchSampleRate(int8_t);
*
*/
return false;
}I have also yet another question. Is there any standard page by Touchgfx for calibrating touch screen?
Any help would be appreciated.
