ESPHome  2024.10.2
gpio_switch.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "esphome/core/hal.h"
6 
7 #include <vector>
8 
9 namespace esphome {
10 namespace gpio {
11 
12 class GPIOSwitch : public switch_::Switch, public Component {
13  public:
14  void set_pin(GPIOPin *pin) { pin_ = pin; }
15 
16  // ========== INTERNAL METHODS ==========
17  // (In most use cases you won't need these)
18  float get_setup_priority() const override;
19 
20  void setup() override;
21  void dump_config() override;
22  void set_interlock(const std::vector<Switch *> &interlock);
23  void set_interlock_wait_time(uint32_t interlock_wait_time) { interlock_wait_time_ = interlock_wait_time; }
24 
25  protected:
26  void write_state(bool state) override;
27 
29  std::vector<Switch *> interlock_;
30  uint32_t interlock_wait_time_{0};
31 };
32 
33 } // namespace gpio
34 } // namespace esphome
Base class for all switches.
Definition: switch.h:39
void dump_config() override
Definition: gpio_switch.cpp:29
void set_interlock_wait_time(uint32_t interlock_wait_time)
Definition: gpio_switch.h:23
void set_pin(GPIOPin *pin)
Definition: gpio_switch.h:14
float get_setup_priority() const override
Definition: gpio_switch.cpp:9
void set_interlock(const std::vector< Switch *> &interlock)
Definition: gpio_switch.cpp:72
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
void write_state(bool state) override
Definition: gpio_switch.cpp:41
std::vector< Switch * > interlock_
Definition: gpio_switch.h:29
bool state
The current reported state of the binary sensor.
Definition: switch.h:53