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,29 +8,13 @@
CSE_CST328 tsPanel = CSE_CST328(EINK_WIDTH, EINK_HEIGHT, &Wire, CST328_PIN_RST, CST328_PIN_INT); 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) bool readTouch(int16_t *x, int16_t *y)
{ {
if (intReceived) { if (tsPanel.getTouches()) {
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; *x = tsPanel.getPoint(0).x;
*y = tsPanel.getPoint(0).y; *y = tsPanel.getPoint(0).y;
return true; return true;
} }
}
return false; return false;
} }
@ -38,7 +22,6 @@ bool readTouch(int16_t *x, int16_t *y)
void lateInitVariant() void lateInitVariant()
{ {
tsPanel.begin(); tsPanel.begin();
attachInterrupt(digitalPinToInterrupt(CST328_PIN_INT), touchISR, FALLING);
touchScreenImpl1 = new TouchScreenImpl1(EINK_WIDTH, EINK_HEIGHT, readTouch); touchScreenImpl1 = new TouchScreenImpl1(EINK_WIDTH, EINK_HEIGHT, readTouch);
touchScreenImpl1->init(); touchScreenImpl1->init();
} }