mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-05-22 05:43:28 +02:00
8e75980ebd
* Cleanup dashboard JS * Add vscode * Save start_mark/end_mark * Updates * Updates * Remove need for cv.nameable It's a bit hacky but removes so much bloat from integrations * Add enum helper * Document APIs, and Improvements * Fixes * Fixes * Update PULL_REQUEST_TEMPLATE.md * Updates * Updates * Updates
40 lines
950 B
C++
40 lines
950 B
C++
#pragma once
|
|
|
|
#include "esphome/core/component.h"
|
|
#include "esphome/components/switch/switch.h"
|
|
|
|
namespace esphome {
|
|
namespace gpio {
|
|
|
|
enum GPIOSwitchRestoreMode {
|
|
GPIO_SWITCH_RESTORE_DEFAULT_OFF,
|
|
GPIO_SWITCH_RESTORE_DEFAULT_ON,
|
|
GPIO_SWITCH_ALWAYS_OFF,
|
|
GPIO_SWITCH_ALWAYS_ON,
|
|
};
|
|
|
|
class GPIOSwitch : public switch_::Switch, public Component {
|
|
public:
|
|
void set_pin(GPIOPin *pin) { pin_ = pin; }
|
|
|
|
void set_restore_mode(GPIOSwitchRestoreMode restore_mode);
|
|
|
|
// ========== INTERNAL METHODS ==========
|
|
// (In most use cases you won't need these)
|
|
float get_setup_priority() const override;
|
|
|
|
void setup() override;
|
|
void dump_config() override;
|
|
void set_interlock(const std::vector<Switch *> &interlock);
|
|
|
|
protected:
|
|
void write_state(bool state) override;
|
|
|
|
GPIOPin *pin_;
|
|
GPIOSwitchRestoreMode restore_mode_{GPIO_SWITCH_RESTORE_DEFAULT_OFF};
|
|
std::vector<Switch *> interlock_;
|
|
};
|
|
|
|
} // namespace gpio
|
|
} // namespace esphome
|