1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-25 06:32:22 +01:00
This commit is contained in:
J. Nick Koston
2025-06-12 17:14:00 -05:00
parent a0c81ffd7a
commit 86be1f56d0
2 changed files with 8 additions and 2 deletions

View File

@@ -249,7 +249,10 @@ void IRAM_ATTR ESP32TouchComponent::touch_isr_handler(void *arg) {
continue; continue;
} }
// For original ESP32, lower value means touched // IMPORTANT: ESP32 v1 touch detection logic - INVERTED compared to v2!
// ESP32 v1: Touch is detected when capacitance INCREASES, causing the measured value to DECREASE
// Therefore: touched = (value < threshold)
// This is opposite to ESP32-S2/S3 v2 where touched = (value > threshold)
bool is_touched = value < child->get_threshold(); bool is_touched = value < child->get_threshold();
// Always send the current state - the main loop will filter for changes // Always send the current state - the main loop will filter for changes

View File

@@ -250,7 +250,10 @@ void ESP32TouchComponent::loop() {
touch_pad_read_benchmark(child->get_touch_pad(), &value); touch_pad_read_benchmark(child->get_touch_pad(), &value);
} }
// For S2/S3 v2, higher value means touched (opposite of v1) // IMPORTANT: ESP32-S2/S3 v2 touch detection logic - INVERTED compared to v1!
// ESP32-S2/S3 v2: Touch is detected when capacitance INCREASES, causing the measured value to INCREASE
// Therefore: touched = (value > threshold)
// This is opposite to original ESP32 v1 where touched = (value < threshold)
bool is_touched = value > child->get_threshold(); bool is_touched = value > child->get_threshold();
child->last_state_ = is_touched; child->last_state_ = is_touched;
child->publish_state(is_touched); child->publish_state(is_touched);