From 943494385f2a259a46f8d19e13abcdd8ba48a3d7 Mon Sep 17 00:00:00 2001 From: peteGSX Date: Sun, 18 Dec 2022 18:59:16 +1000 Subject: [PATCH] Add digital write --- IO_EXIOExpander.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/IO_EXIOExpander.h b/IO_EXIOExpander.h index 94bd589..90dd06d 100644 --- a/IO_EXIOExpander.h +++ b/IO_EXIOExpander.h @@ -125,6 +125,14 @@ private: return _analogueValues[pin]; } + void _write(VPIN vpin, int value) override { + int pin = vpin - _firstVpin; + _digitalWriteBuffer[0] = EXIOWRD; + _digitalWriteBuffer[1] = pin; + _digitalWriteBuffer[2] = value; + I2CManager.write(_i2cAddress, _digitalWriteBuffer, 3, &_i2crb); + } + void _display() override { DIAG(F("EX-IOExpander I2C:x%x Configured on Vpins:%d-%d %S"), _i2cAddress, _firstVpin, _firstVpin+_nPins-1, _deviceState == DEVSTATE_FAILED ? F("OFFLINE") : F("")); @@ -140,6 +148,7 @@ private: byte * _digitalInBuffer = NULL; byte _analogueInBuffer[2]; byte _analogueOutBuffer[2]; + byte _digitalWriteBuffer[3]; uint16_t * _analogueValues = NULL; uint8_t _currentAPin; // Current analogue pin to read uint8_t _activity; @@ -152,6 +161,7 @@ private: EXIODPUP = 0xE3, // Flag we're sending digital pin pullup configuration EXIOOP = 0xE4, // Flag to say we're operating normally EXIORDAN = 0xE5, // Flag to read an analogue input + EXIOWRD = 0xE6, // Flag for digital write }; };