mirror of
https://github.com/esphome/esphome.git
synced 2025-09-19 11:42:20 +01:00
cleanup
This commit is contained in:
@@ -290,14 +290,24 @@ void ESP32TouchComponent::loop() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle active/inactive events
|
// Skip if not an active/inactive event
|
||||||
if (event.intr_mask & (TOUCH_PAD_INTR_MASK_ACTIVE | TOUCH_PAD_INTR_MASK_INACTIVE)) {
|
if (!(event.intr_mask & (TOUCH_PAD_INTR_MASK_ACTIVE | TOUCH_PAD_INTR_MASK_INACTIVE))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
bool is_touch_event = (event.intr_mask & TOUCH_PAD_INTR_MASK_ACTIVE) != 0;
|
bool is_touch_event = (event.intr_mask & TOUCH_PAD_INTR_MASK_ACTIVE) != 0;
|
||||||
|
|
||||||
// Find the child for the pad that triggered the interrupt
|
// Find the child for the pad that triggered the interrupt
|
||||||
for (auto *child : this->children_) {
|
for (auto *child : this->children_) {
|
||||||
if (child->get_touch_pad() == event.pad) {
|
if (child->get_touch_pad() != event.pad) {
|
||||||
if (child->last_state_ != is_touch_event) {
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skip if state hasn't changed
|
||||||
|
if (child->last_state_ == is_touch_event) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Read current value
|
// Read current value
|
||||||
uint32_t value = 0;
|
uint32_t value = 0;
|
||||||
if (this->filter_configured_()) {
|
if (this->filter_configured_()) {
|
||||||
@@ -310,12 +320,9 @@ void ESP32TouchComponent::loop() {
|
|||||||
child->publish_state(is_touch_event);
|
child->publish_state(is_touch_event);
|
||||||
ESP_LOGD(TAG, "Touch Pad '%s' %s (value: %d, threshold: %d)", child->get_name().c_str(),
|
ESP_LOGD(TAG, "Touch Pad '%s' %s (value: %d, threshold: %d)", child->get_name().c_str(),
|
||||||
is_touch_event ? "touched" : "released", value, child->get_threshold());
|
is_touch_event ? "touched" : "released", value, child->get_threshold());
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// In setup mode, periodically log all pad values
|
// In setup mode, periodically log all pad values
|
||||||
|
Reference in New Issue
Block a user