From fdc4ec8a5784ebc39c7b9b029b28456aef1da8b2 Mon Sep 17 00:00:00 2001 From: Ben Winslow Date: Sun, 27 Apr 2025 22:29:47 -0400 Subject: [PATCH] [touchscreen] Clear interrupt flag before reading touch data. (#8632) --- esphome/components/touchscreen/touchscreen.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/esphome/components/touchscreen/touchscreen.cpp b/esphome/components/touchscreen/touchscreen.cpp index 11207908fa..dcf3209752 100644 --- a/esphome/components/touchscreen/touchscreen.cpp +++ b/esphome/components/touchscreen/touchscreen.cpp @@ -50,13 +50,15 @@ void Touchscreen::loop() { tp.second.x_prev = tp.second.x; tp.second.y_prev = tp.second.y; } + // The interrupt flag must be reset BEFORE calling update_touches, otherwise we might miss an interrupt that was + // triggered while we were reading touch data. + this->store_.touched = false; this->update_touches(); if (this->skip_update_) { for (auto &tp : this->touches_) { tp.second.state &= ~STATE_RELEASING; } } else { - this->store_.touched = false; this->defer([this]() { this->send_touches_(); }); if (this->touch_timeout_ > 0) { // Simulate a touch after touch_timeout_> ms. This will reset any existing timeout operation.