28 lines
708 B
C++
28 lines
708 B
C++
#ifndef I2CRELAY_H
|
|
#define I2CRELAY_H
|
|
|
|
#include <Arduino.h>
|
|
#include <Wire.h>
|
|
|
|
class I2CRelay {
|
|
public:
|
|
I2CRelay(uint8_t sda = SDA, uint8_t scl = SCL);
|
|
|
|
void begin();
|
|
void scan(Stream &out = Serial);
|
|
void setSlaveAddress(uint8_t oldAddr, uint8_t newAddr, Stream &out = Serial);
|
|
void setSlaveName(uint8_t addr, const char* newName, Stream &out = Serial);
|
|
String requestSlaveInfo(uint8_t addr);
|
|
|
|
// Relay control
|
|
bool setRelay(uint8_t addr, uint8_t relay, bool on);
|
|
bool setAllRelays(uint8_t addr, bool on);
|
|
bool setRelayTimer(uint8_t addr, uint8_t relay, uint32_t ms);
|
|
bool setAllRelaysTimer(uint8_t addr, uint32_t ms);
|
|
|
|
private:
|
|
uint8_t _sda, _scl;
|
|
};
|
|
|
|
#endif
|