ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
m5stack_4relay.h
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4
8
9#ifdef USE_SWITCH
11#endif
12
14
15class M5Stack4Relay : public Component, public i2c::I2CDevice {
16 public:
17 void setup() override;
18 void dump_config() override;
19
21 bool set_relay(uint8_t channel, bool on);
22
23#ifdef USE_SWITCH
24 void register_switch(uint8_t channel, switch_::Switch *sw) { this->switches_[channel] = sw; }
25#endif
26
27 protected:
28 uint8_t relays_{0};
29#ifdef USE_SWITCH
30 std::array<switch_::Switch *, 4> switches_{};
31#endif
32};
33
34} // namespace esphome::m5stack_4relay
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:144
std::array< switch_::Switch *, 4 > switches_
void register_switch(uint8_t channel, switch_::Switch *sw)
bool set_relay(uint8_t channel, bool on)
Switch relay channel (0-3) on or off; returns false when the write failed.
Base class for all switches.
Definition switch.h:43