mirror of
https://github.com/esphome/esphome.git
synced 2025-09-25 06:32:22 +01:00
preen
This commit is contained in:
@@ -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
|
||||||
|
@@ -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);
|
||||||
|
Reference in New Issue
Block a user