updated files
This commit is contained in:
1 parent
1f9edb14b4
commit
4264de514d
6 files changed
+11
-61
No files matched your search
+5
-5
@@ -4,24 +4,24 @@
|
||||
#include "I2CMasterUtils.h"
|
||||
#include "I2CCommands.h"
|
||||
|
||||
RelayI2CMaster::RelayI2CMaster(uint8_t slaveAddress) : _slaveAddress(slaveAddress) {}
|
||||
I2CRelay::I2CRelay(uint8_t slaveAddress) : _slaveAddress(slaveAddress) {}
|
||||
|
||||
void RelayI2CMaster::setAddress(uint8_t newAddress) {
|
||||
void I2CRelay::setAddress(uint8_t newAddress) {
|
||||
_slaveAddress = newAddress;
|
||||
}
|
||||
|
||||
void RelayI2CMaster::begin() {
|
||||
void I2CRelay::begin() {
|
||||
Wire.begin();
|
||||
}
|
||||
|
||||
void RelayI2CMaster::setRelay(uint8_t relayIndex, bool state) {
|
||||
void I2CRelay::setRelay(uint8_t relayIndex, bool state) {
|
||||
Wire.beginTransmission(_slaveAddress);
|
||||
Wire.write(relayIndex);
|
||||
Wire.write(state ? 1 : 0);
|
||||
Wire.endTransmission();
|
||||
}
|
||||
|
||||
uint8_t RelayI2CMaster::scanDevices(uint8_t* foundAddresses, uint8_t maxDevices) {
|
||||
uint8_t I2CRelay::scanDevices(uint8_t* foundAddresses, uint8_t maxDevices) {
|
||||
uint8_t count = 0;
|
||||
for(uint8_t addr = 1; addr < 127; addr++) {
|
||||
Wire.beginTransmission(addr);
|
||||
|
||||
+4
-4
@@ -1,12 +1,12 @@
|
||||
#ifndef RELAY_I2C_MASTER_H
|
||||
#define RELAY_I2C_MASTER_H
|
||||
#ifndef I2CRelay_H
|
||||
#define I2CRelay_H
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
|
||||
class RelayI2CMaster {
|
||||
class I2CRelay {
|
||||
public:
|
||||
RelayI2CMaster(uint8_t slaveAddress);
|
||||
I2CRelay(uint8_t slaveAddress);
|
||||
void begin();
|
||||
void setRelay(uint8_t relayIndex, bool state);
|
||||
uint8_t scanDevices(uint8_t* foundAddresses, uint8_t maxDevices);
|
||||
|
||||
Reference in new issue
Block a user