1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-16 18:22:22 +01:00
This commit is contained in:
J. Nick Koston
2025-06-12 15:45:47 -05:00
parent eae0d90a1e
commit 9b0d01e03f
2 changed files with 4 additions and 4 deletions

View File

@@ -178,7 +178,9 @@ class ESP32TouchBinarySensor : public binary_sensor::BinarySensor {
touch_pad_t get_touch_pad() const { return this->touch_pad_; } touch_pad_t get_touch_pad() const { return this->touch_pad_; }
uint32_t get_threshold() const { return this->threshold_; } uint32_t get_threshold() const { return this->threshold_; }
void set_threshold(uint32_t threshold) { this->threshold_ = threshold; } void set_threshold(uint32_t threshold) { this->threshold_ = threshold; }
#ifdef USE_ESP32_VARIANT_ESP32
uint32_t get_value() const { return this->value_; } uint32_t get_value() const { return this->value_; }
#endif
uint32_t get_wakeup_threshold() const { return this->wakeup_threshold_; } uint32_t get_wakeup_threshold() const { return this->wakeup_threshold_; }
protected: protected:
@@ -186,7 +188,9 @@ class ESP32TouchBinarySensor : public binary_sensor::BinarySensor {
touch_pad_t touch_pad_{TOUCH_PAD_MAX}; touch_pad_t touch_pad_{TOUCH_PAD_MAX};
uint32_t threshold_{0}; uint32_t threshold_{0};
#ifdef USE_ESP32_VARIANT_ESP32
uint32_t value_{0}; uint32_t value_{0};
#endif
bool last_state_{false}; bool last_state_{false};
const uint32_t wakeup_threshold_{0}; const uint32_t wakeup_threshold_{0};
}; };

View File

@@ -270,8 +270,6 @@ void ESP32TouchComponent::loop() {
touch_pad_read_benchmark(child->get_touch_pad(), &value); touch_pad_read_benchmark(child->get_touch_pad(), &value);
} }
child->value_ = value;
// For S2/S3 v2, higher value means touched (opposite of v1) // For S2/S3 v2, higher value means touched (opposite of v1)
bool is_touched = value > child->get_threshold(); bool is_touched = value > child->get_threshold();
child->last_state_ = is_touched; child->last_state_ = is_touched;
@@ -307,8 +305,6 @@ void ESP32TouchComponent::loop() {
touch_pad_read_benchmark(event.pad, &value); touch_pad_read_benchmark(event.pad, &value);
} }
child->value_ = value;
// Update state if changed // Update state if changed
if (child->last_state_ != is_touch_event) { if (child->last_state_ != is_touch_event) {
child->last_state_ = is_touch_event; child->last_state_ = is_touch_event;