mirror of
https://github.com/esphome/esphome.git
synced 2026-06-24 15:28:53 +00:00
[gpio] Use constexpr uint32_t timer ID for interlock timeout (#15010)
This commit is contained in:
@@ -5,6 +5,7 @@ namespace esphome {
|
||||
namespace gpio {
|
||||
|
||||
static const char *const TAG = "switch.gpio";
|
||||
static constexpr uint32_t INTERLOCK_TIMEOUT_ID = 0;
|
||||
|
||||
float GPIOSwitch::get_setup_priority() const { return setup_priority::HARDWARE; }
|
||||
void GPIOSwitch::setup() {
|
||||
@@ -51,7 +52,7 @@ void GPIOSwitch::write_state(bool state) {
|
||||
}
|
||||
}
|
||||
if (found && this->interlock_wait_time_ != 0) {
|
||||
this->set_timeout("interlock", this->interlock_wait_time_, [this, state] {
|
||||
this->set_timeout(INTERLOCK_TIMEOUT_ID, this->interlock_wait_time_, [this, state] {
|
||||
// Don't write directly, call the function again
|
||||
// (some other switch may have changed state while we were waiting)
|
||||
this->write_state(state);
|
||||
@@ -61,7 +62,7 @@ void GPIOSwitch::write_state(bool state) {
|
||||
} else if (this->interlock_wait_time_ != 0) {
|
||||
// If we are switched off during the interlock wait time, cancel any pending
|
||||
// re-activations
|
||||
this->cancel_timeout("interlock");
|
||||
this->cancel_timeout(INTERLOCK_TIMEOUT_ID);
|
||||
}
|
||||
|
||||
this->pin_->digital_write(state);
|
||||
|
||||
Reference in New Issue
Block a user