1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-29 22:24:26 +00:00
This commit is contained in:
J. Nick Koston
2025-06-12 16:33:15 -05:00
parent f7afcb3b24
commit a18374e1ad
2 changed files with 5 additions and 3 deletions

View File

@@ -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};

View File

@@ -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);