fix touchscreen

This commit is contained in:
mverch67 2025-06-01 10:04:44 +02:00 committed by Thomas Göttgens
parent 212839bdd3
commit 4f4d55e7c9

View File

@ -8,28 +8,12 @@
CSE_CST328 tsPanel = CSE_CST328(EINK_WIDTH, EINK_HEIGHT, &Wire, CST328_PIN_RST, CST328_PIN_INT);
volatile bool intReceived = false;
void touchISR()
{
// Detach the interrupt to prevent multiple interrupts
detachInterrupt(digitalPinToInterrupt(CST328_PIN_INT));
intReceived = true;
}
bool readTouch(int16_t *x, int16_t *y)
{
if (intReceived) {
intReceived = false;
// Reattach the interrupt for the next touch
attachInterrupt(digitalPinToInterrupt(CST328_PIN_INT), touchISR, FALLING);
// Read the touch point
if (tsPanel.isTouched(0)) {
*x = tsPanel.getPoint(0).x;
*y = tsPanel.getPoint(0).y;
return true;
}
if (tsPanel.getTouches()) {
*x = tsPanel.getPoint(0).x;
*y = tsPanel.getPoint(0).y;
return true;
}
return false;
}
@ -38,7 +22,6 @@ bool readTouch(int16_t *x, int16_t *y)
void lateInitVariant()
{
tsPanel.begin();
attachInterrupt(digitalPinToInterrupt(CST328_PIN_INT), touchISR, FALLING);
touchScreenImpl1 = new TouchScreenImpl1(EINK_WIDTH, EINK_HEIGHT, readTouch);
touchScreenImpl1->init();
}