From a18374e1ad595dd0cbfdcaf13b5f9dcf660d9f17 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 12 Jun 2025 16:33:15 -0500 Subject: [PATCH] cleanup --- esphome/components/esp32_touch/esp32_touch.h | 2 ++ esphome/components/esp32_touch/esp32_touch_v1.cpp | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/esphome/components/esp32_touch/esp32_touch.h b/esphome/components/esp32_touch/esp32_touch.h index 3c512e2de6..af516efc5d 100644 --- a/esphome/components/esp32_touch/esp32_touch.h +++ b/esphome/components/esp32_touch/esp32_touch.h @@ -80,6 +80,8 @@ class ESP32TouchComponent : public Component { #ifdef USE_ESP32_VARIANT_ESP32 // ESP32 v1 specific + static constexpr uint32_t MINIMUM_RELEASE_TIME_MS = 100; + static void touch_isr_handler(void *arg); QueueHandle_t touch_queue_{nullptr}; diff --git a/esphome/components/esp32_touch/esp32_touch_v1.cpp b/esphome/components/esp32_touch/esp32_touch_v1.cpp index 16fe677f22..774ff0b0bf 100644 --- a/esphome/components/esp32_touch/esp32_touch_v1.cpp +++ b/esphome/components/esp32_touch/esp32_touch_v1.cpp @@ -74,11 +74,11 @@ void ESP32TouchComponent::setup() { // Calculate release timeout based on sleep cycle // Design note: ESP32 v1 hardware limitation - interrupts only fire on touch (not release) // We must use timeout-based detection for release events - // Formula: 3 sleep cycles converted to ms, with 100ms minimum + // Formula: 3 sleep cycles converted to ms, with MINIMUM_RELEASE_TIME_MS minimum uint32_t rtc_freq = rtc_clk_slow_freq_get_hz(); this->release_timeout_ms_ = (this->sleep_cycle_ * 1000 * 3) / (rtc_freq * 2); - if (this->release_timeout_ms_ < 100) { - this->release_timeout_ms_ = 100; + if (this->release_timeout_ms_ < MINIMUM_RELEASE_TIME_MS) { + this->release_timeout_ms_ = MINIMUM_RELEASE_TIME_MS; } this->release_check_interval_ms_ = std::min(this->release_timeout_ms_ / 4, (uint32_t) 50);