ESPHome  2021.9.1
gpio_switch.h
Go to the documentation of this file.
1 #pragma once
2 
5 
6 namespace esphome {
7 namespace gpio {
8 
16 };
17 
18 class GPIOSwitch : public switch_::Switch, public Component {
19  public:
20  void set_pin(GPIOPin *pin) { pin_ = pin; }
21 
22  void set_restore_mode(GPIOSwitchRestoreMode restore_mode);
23 
24  // ========== INTERNAL METHODS ==========
25  // (In most use cases you won't need these)
26  float get_setup_priority() const override;
27 
28  void setup() override;
29  void dump_config() override;
30  void set_interlock(const std::vector<Switch *> &interlock);
31  void set_interlock_wait_time(uint32_t interlock_wait_time) { interlock_wait_time_ = interlock_wait_time; }
32 
33  protected:
34  void write_state(bool state) override;
35 
38  std::vector<Switch *> interlock_;
39  uint32_t interlock_wait_time_{0};
40 };
41 
42 } // namespace gpio
43 } // namespace esphome
Base class for all switches.
Definition: switch.h:29
void dump_config() override
Definition: gpio_switch.cpp:47
void set_interlock_wait_time(uint32_t interlock_wait_time)
Definition: gpio_switch.h:31
void set_pin(GPIOPin *pin)
Definition: gpio_switch.h:20
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)
Library based on https://github.com/miguelbalboa/rfid and adapted to ESPHome by . ...
Definition: a4988.cpp:4
void write_state(bool state) override
Definition: gpio_switch.cpp:81
GPIOSwitchRestoreMode restore_mode_
Definition: gpio_switch.h:37
std::vector< Switch * > interlock_
Definition: gpio_switch.h:38
bool state
The current reported state of the binary sensor.
Definition: switch.h:44
A high-level abstraction class that can expose a pin together with useful options like pinMode...
Definition: esphal.h:69