Hi,
I wrote a little programm with some different screens where I use one button to go back to the last screen.
The "back" button is always at the same position. The problem is if I press the "back" button in one screen, it
will go back until the first screen.
I tried many (useless) ways to debounce the touchscreen so that every new screen is displayed only after releasing the touch and wait
for another touch on the back button.
Yesterday I saw the great button library from defragster, but this exceeds my programming skills a lot.
Is there a simple way to do that?
If I don´t use the IRQ it works better but not in that way I would like to have it working.
This is the sample code from the XPT2046 (with irq):
I use the Teensy 3.5.
I believe I am an good electronic engineer but my programming skill in C (Arduino) looks weak and must be improved.
Jens
I wrote a little programm with some different screens where I use one button to go back to the last screen.
The "back" button is always at the same position. The problem is if I press the "back" button in one screen, it
will go back until the first screen.
I tried many (useless) ways to debounce the touchscreen so that every new screen is displayed only after releasing the touch and wait
for another touch on the back button.
Yesterday I saw the great button library from defragster, but this exceeds my programming skills a lot.
Is there a simple way to do that?
If I don´t use the IRQ it works better but not in that way I would like to have it working.
This is the sample code from the XPT2046 (with irq):
I use the Teensy 3.5.
Code:
#include <XPT2046_Touchscreen.h>
#include <SPI.h>
#define CS_PIN 8
// MOSI=11, MISO=12, SCK=13
// The TIRQ interrupt signal must be used for this example.
#define TIRQ_PIN 7
XPT2046_Touchscreen ts(CS_PIN, TIRQ_PIN); // Param 2 - Touch IRQ Pin - interrupt enabled polling
void setup() {
Serial.begin(38400);
ts.begin();
ts.setRotation(1);
while (!Serial && (millis() <= 1000));
}
void loop() {
// tirqTouched() is much faster than touched(). For projects where other SPI chips
// or other time sensitive tasks are added to loop(), using tirqTouched() can greatly
// reduce the delay added to loop() when the screen has not been touched.
if (ts.tirqTouched()) {
if (ts.touched()) {
TS_Point p = ts.getPoint();
Serial.print("Pressure = ");
Serial.print(p.z);
Serial.print(", x = ");
Serial.print(p.x);
Serial.print(", y = ");
Serial.print(p.y);
delay(30);
Serial.println();
}
}
}
I believe I am an good electronic engineer but my programming skill in C (Arduino) looks weak and must be improved.
Jens
Last edited: