mirror of
https://github.com/esphome/esphome.git
synced 2025-08-01 16:07:47 +00:00
Fix print
This commit is contained in:
parent
14e6918eb1
commit
140792d8a9
@ -293,10 +293,8 @@ uint32_t ESP32TouchComponent::component_touch_pad_read(touch_pad_t tp) {
|
|||||||
|
|
||||||
void ESP32TouchComponent::loop() {
|
void ESP32TouchComponent::loop() {
|
||||||
const uint32_t now = App.get_loop_component_start_time();
|
const uint32_t now = App.get_loop_component_start_time();
|
||||||
bool should_print = this->setup_mode_ && now - this->setup_mode_last_log_print_ > 250;
|
if (this->current_child_ == 0) {
|
||||||
if (should_print && this->current_child_ == this->children_.size() - 1) {
|
this->should_print_ = this->setup_mode_ && now - this->setup_mode_last_log_print_ > 250;
|
||||||
// Avoid spamming logs
|
|
||||||
this->setup_mode_last_log_print_ = now;
|
|
||||||
}
|
}
|
||||||
if (this->children_.empty()) {
|
if (this->children_.empty()) {
|
||||||
return;
|
return;
|
||||||
@ -310,11 +308,17 @@ void ESP32TouchComponent::loop() {
|
|||||||
child->publish_state(child->value_ > child->get_threshold());
|
child->publish_state(child->value_ > child->get_threshold());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (should_print) {
|
if (this->should_print_) {
|
||||||
ESP_LOGD(TAG, "Touch Pad '%s' (T%" PRIu32 "): %" PRIu32, child->get_name().c_str(),
|
ESP_LOGD(TAG, "Touch Pad '%s' (T%" PRIu32 "): %" PRIu32, child->get_name().c_str(),
|
||||||
(uint32_t) child->get_touch_pad(), child->value_);
|
(uint32_t) child->get_touch_pad(), child->value_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this->should_print_ && this->current_child_ == this->children_.size() - 1) {
|
||||||
|
// Avoid spamming logs
|
||||||
|
this->setup_mode_last_log_print_ = now;
|
||||||
|
this->should_print_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
this->current_child_ = (this->current_child_ + 1) % this->children_.size();
|
this->current_child_ = (this->current_child_ + 1) % this->children_.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,6 +75,7 @@ class ESP32TouchComponent : public Component {
|
|||||||
std::vector<ESP32TouchBinarySensor *> children_;
|
std::vector<ESP32TouchBinarySensor *> children_;
|
||||||
uint8_t current_child_{0};
|
uint8_t current_child_{0};
|
||||||
bool setup_mode_{false};
|
bool setup_mode_{false};
|
||||||
|
bool should_print_{false};
|
||||||
uint32_t setup_mode_last_log_print_{0};
|
uint32_t setup_mode_last_log_print_{0};
|
||||||
// common parameters
|
// common parameters
|
||||||
uint16_t sleep_cycle_{4095};
|
uint16_t sleep_cycle_{4095};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user