DigitalIO driver with dynamic channel count
This commit is contained in:
52
src/digitalIO.h
Normal file
52
src/digitalIO.h
Normal file
@@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
|
||||
#include <DebugLog.h>
|
||||
#include <Arduino.h>
|
||||
#include <remoteIO.h>
|
||||
#include <TCA9554PWR_Driver.h>
|
||||
|
||||
#define ON true
|
||||
#define OFF false
|
||||
|
||||
class digitalIO
|
||||
{
|
||||
|
||||
private:
|
||||
enum localInputs
|
||||
{
|
||||
DI1 = 4, // gpio for local inputs starts at 4 as per manufacturer documentation
|
||||
DI2,
|
||||
DI3,
|
||||
DI4,
|
||||
DI5,
|
||||
DI6,
|
||||
DI7,
|
||||
DI8,
|
||||
DI_MAX
|
||||
};
|
||||
|
||||
const uint8_t maxRetries = 5;
|
||||
|
||||
public:
|
||||
digitalIO(drivers::I2C &i2c, drivers::MODBUS &bus, std::vector<uint8_t> remotes);
|
||||
~digitalIO();
|
||||
|
||||
void digitalIOWrite(const uint8_t ch, const bool value);
|
||||
const bool digitalIORead(const uint8_t ch);
|
||||
void reset();
|
||||
|
||||
const uint8_t getOutNum();
|
||||
const uint8_t getInNum();
|
||||
|
||||
private:
|
||||
void digitalWriteLocal(const uint8_t ch, const bool value);
|
||||
void digitalWriteRemote(const uint8_t ch, const bool value);
|
||||
|
||||
const bool digitalReadLocal(const uint8_t ch);
|
||||
const bool digitalReadRemote(const uint8_t ch);
|
||||
|
||||
private:
|
||||
std::vector<uint8_t> m_remoteAddrs;
|
||||
drivers::TCA9554PWR m_localOuts;
|
||||
std::vector<remoteIO> m_remotes;
|
||||
};
|
||||
Reference in New Issue
Block a user