@Cavagnis
I'm trying to understand when the GIGA Display Touch takes a sample and how it queues the data. I have a situation where a single touch results in two events in my code and the obvious things haven't worked for me to resolve it yet.
#include "Arduino_GigaDisplayTouch.h"
Arduino_GigaDisplayTouch touchDetector;
void setup() {
Serial.begin(115200);
while (!Serial) {}
if (touchDetector.begin()) {
Serial.println("Touch controller init - OK");
} else {
Serial.println("Touch controller init - FAILED");
while (1) {}
}
}
int taskCounter;
void loop() {
uint8_t contacts;
GDTpoint_t points[5];
contacts = touchDetector.getTouchPoints(points);
if (contacts > 0) {
Serial.print("Contacts: ");
Serial.println(contacts);
for (uint8_t i = 0; i < contacts; i++) {
Serial.print(points[i].x);
Serial.print(" ");
Serial.println(points[i].y);
}
// Do task here triggered by touch
// Why does this run twice for each touch tap???
Serial.print("Doing the task now ");
Serial.println(taskCounter++);
delay(2000);
}
delay(1);
}
Here's the GIGA Display Touch polling Example with very slight modification to show the issue. Run this code on a GIGA with a Display Touch attached, make one quick tap anywhere on the screen and see two task running messages in the Serial Console.
Note how the coordinates for the second task are identical to the first task. And note that those identical coordinates are returned by the touchDetector 2 seconds after the initial touch. So a call to touchDetector can apparently return coordinates from a previous touch, even if no touch is currently occurring.
So it would seem there's some buffering or queuing occurring but I haven't figured out how to characterize it yet. I've tried reading the touchDetector multiple times at the first touch in an attempt to drain any buffering, but I still got the phantom touch when I called touchDetector two seconds later.
And this seems the opposite of the typical approach of ignoring any touches that occur within 250 ms of a prior touch. In this case a phantom touch is being detected 2 seconds after a valid touch. The phantom touch even occurs if I wait 40 seconds to check touchDetector again.
Does anyone have any experience with this or any ideas of how to work around it?