74 lines
1.9 KiB
C++
74 lines
1.9 KiB
C++
#pragma once
|
|
|
|
#define DEBUGLOG_DEFAULT_LOG_LEVEL_INFO
|
|
|
|
#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 c_maxRetries = 5;
|
|
|
|
public:
|
|
digitalIO(drivers::I2C &i2c, drivers::MODBUS &bus, std::vector<uint8_t> remotes);
|
|
~digitalIO();
|
|
|
|
void digitalOutWrite(const uint8_t ch, const bool value);
|
|
void digitalOutWritePort(const std::vector<bool> &values);
|
|
const bool digitalOutRead(const uint8_t ch);
|
|
const std::vector<bool> digitalOutReadPort();
|
|
|
|
const bool digitalInRead(const uint8_t ch);
|
|
const std::vector<bool> digitalInReadPort();
|
|
|
|
void reset();
|
|
|
|
const uint8_t getOutNum();
|
|
const uint8_t getInNum();
|
|
|
|
private:
|
|
const uint8_t getLocalInNum();
|
|
const uint8_t getLocalOutNum();
|
|
const uint8_t getRemoteInNum();
|
|
const uint8_t getRemoteOutNum();
|
|
|
|
void writeLocal(const uint8_t ch, const bool value);
|
|
void writeLocalPort(const std::vector<bool> &values);
|
|
void writeRemote(const uint8_t ch, const bool value);
|
|
void writeRemotePort(const std::vector<bool> &values);
|
|
|
|
const bool readLocalIn(const uint8_t ch);
|
|
const bool readLocalOut(const uint8_t ch);
|
|
const std::vector<bool> readLocalInPort();
|
|
const std::vector<bool> readLocalOutPort();
|
|
const bool readRemoteIn(const uint8_t ch);
|
|
const bool readRemoteOut(const uint8_t ch);
|
|
const std::vector<bool> readRemoteInPort();
|
|
const std::vector<bool> readRemoteOutPort();
|
|
|
|
private:
|
|
std::vector<uint8_t> m_remoteAddrs;
|
|
drivers::TCA9554PWR m_localOuts;
|
|
std::vector<remoteIO> m_remotes;
|
|
}; |