You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using a 3.95" TFT board which has a XPT2046 touch controller, and this library to work with it. If I try to use it with an interrupt like
XPT2046_Touchscreen ts(CS_PIN, TIRQ_PIN);
after enough poking at the screen at a random time it breaks and keeps repeating the last successfully read values. More about this below.
Also: using the touched() function in the main loop is bad practice as it does a full reading making the SPI bus glow red with all the unnecessary readings to determine from the value of Z if there was a touch whereas we have an interrupt for that (if configured to use).
Which don't work by the way.
After enough poking at my screen at a random occassion Z reading falls below the threshold and isrWake is set false at
if (z < Z_THRESHOLD_INT) { // if ( !touched ) {
if (255 != tirqPin)
{
isrWake = false;
Serial.println("isrWake -> FALSE");
}
}
I can confirm this behaviour in my setup (ESP8266 with XPT2046 touchscreen). It happens if you poke very fast on the screen.
The attached patch (in two variants, with and without debugging output over serial) fixes the problem for me.
Note that I moved the setting of isrWake to immediately after it has been used, so I close the time window for any races between ISR and the setting to false.
I am using a 3.95" TFT board which has a XPT2046 touch controller, and this library to work with it. If I try to use it with an interrupt like
XPT2046_Touchscreen ts(CS_PIN, TIRQ_PIN);
after enough poking at the screen at a random time it breaks and keeps repeating the last successfully read values. More about this below.
Also: using the touched() function in the main loop is bad practice as it does a full reading making the SPI bus glow red with all the unnecessary readings to determine from the value of Z if there was a touch whereas we have an interrupt for that (if configured to use).
Which don't work by the way.
After enough poking at my screen at a random occassion Z reading falls below the threshold and isrWake is set false at
if (z < Z_THRESHOLD_INT) { // if ( !touched ) {
if (255 != tirqPin)
{
isrWake = false;
Serial.println("isrWake -> FALSE");
}
}
and never recovers, because
{
XPT2046_Touchscreen *o = isrPinptr;
o->isrWake = true;
}
where it would be restored, never actually runs, effectively breaking the code at
if (!isrWake) return;
in the data update() function.
My method is to use the lib without an interrupt:
XPT2046_Touchscreen ts(CS_PIN, 255);
instead make my own ISR detecting the TS-IRQ low level and do a reading by then. Yet it's a workaround, not a solution.
Forgive me if I wasn't clear or overlooked something, I'm not a programmer. Thanks :)
The text was updated successfully, but these errors were encountered: