File SwitchWithCover2Pos.h
File List > Firmware > Libraries > PanelGroup > Inputs > SwitchWithCover2Pos > SwitchWithCover2Pos.h
Go to the documentation of this file
#pragma once
#ifdef ARDUINO_ARCH_STM32
#include <Inputs/Switch2Pos/Switch2Pos.h> // family base (InputBase, PinRef via PanelGroup.h)
namespace OpenSkyhawk {
class SwitchWithCover2Pos : public Switch2Pos {
public:
static constexpr uint16_t COVER_DELAY_MS = 200;
SwitchWithCover2Pos(uint16_t switchId, uint16_t coverId, PinRef pin, bool reverse = false);
void poll() override;
#ifdef SWITCHWITHCOVER_TEST
uint8_t state() const { return (uint8_t)_state; }
uint8_t target() const { return (uint8_t)_target; }
#endif
protected:
void emit(bool active, bool init) override;
private:
enum class Cover : uint8_t { OFF_CLOSED = 0, OFF_OPEN = 1, ON_OPEN = 2 };
void step();
void sendCover(bool open);
void sendSwitch(bool on);
uint16_t _coverId;
Cover _state;
Cover _target;
uint32_t _lastStepMs;
};
} // namespace OpenSkyhawk
#endif // ARDUINO_ARCH_STM32