ESPHome  2022.8.0
gpio_switch.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "esphome/core/hal.h"
6 
7 namespace esphome {
8 namespace gpio {
9 
17 };
18 
19 class GPIOSwitch : public switch_::Switch, public Component {
20  public:
21  void set_pin(GPIOPin *pin) { pin_ = pin; }
22 
23  void set_restore_mode(GPIOSwitchRestoreMode restore_mode);
24 
25  // ========== INTERNAL METHODS ==========
26  // (In most use cases you won't need these)
27  float get_setup_priority() const override;
28 
29  void setup() override;
30  void dump_config() override;
31  void set_interlock(const std::vector<Switch *> &interlock);
32  void set_interlock_wait_time(uint32_t interlock_wait_time) { interlock_wait_time_ = interlock_wait_time; }
33 
34  protected:
35  void write_state(bool state) override;
36 
39  std::vector<Switch *> interlock_;
40  uint32_t interlock_wait_time_{0};
41 };
42 
43 } // namespace gpio
44 } // namespace esphome
Base class for all switches.
Definition: switch.h:33
void dump_config() override
Definition: gpio_switch.cpp:49
void set_interlock_wait_time(uint32_t interlock_wait_time)
Definition: gpio_switch.h:32
void set_pin(GPIOPin *pin)
Definition: gpio_switch.h:21
float get_setup_priority() const override
Definition: gpio_switch.cpp:9
void set_restore_mode(GPIOSwitchRestoreMode restore_mode)
void set_interlock(const std::vector< Switch *> &interlock)
Definition: a4988.cpp:4
void write_state(bool state) override
Definition: gpio_switch.cpp:83
GPIOSwitchRestoreMode restore_mode_
Definition: gpio_switch.h:38
std::vector< Switch * > interlock_
Definition: gpio_switch.h:39
bool state
The current reported state of the binary sensor.
Definition: switch.h:48