From 0cc07ed1dff8afd1d9727bb911bf9e3b957698ed Mon Sep 17 00:00:00 2001 From: peteGSX Date: Mon, 13 Mar 2023 05:29:22 +1000 Subject: [PATCH] Starting on driver feedback --- IO_EXIOExpander.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/IO_EXIOExpander.h b/IO_EXIOExpander.h index 0296c93..da01ae7 100644 --- a/IO_EXIOExpander.h +++ b/IO_EXIOExpander.h @@ -156,10 +156,15 @@ private: void _loop(unsigned long currentMicros) override { (void)currentMicros; // remove warning if (_deviceState == DEVSTATE_FAILED) return; - _command1Buffer[0] = EXIORDD; - I2CManager.read(_i2cAddress, _digitalInputStates, _digitalPinBytes, _command1Buffer, 1, &_i2crb); - _command1Buffer[0] = EXIORDAN; - I2CManager.read(_i2cAddress, _analogueInputStates, _analoguePinBytes, _command1Buffer, 1, &_i2crb); + if (_i2crb.isBusy()) return; + if (_commandFlag) { + _command1Buffer[0] = EXIORDD; + I2CManager.read(_i2cAddress, _digitalInputStates, _digitalPinBytes, _command1Buffer, 1, &_i2crb); + } else { + _command1Buffer[0] = EXIORDAN; + I2CManager.read(_i2cAddress, _analogueInputStates, _analoguePinBytes, _command1Buffer, 1, &_i2crb); + } + _commandFlag = !_commandFlag; } // Obtain the correct analogue input value @@ -243,6 +248,7 @@ private: byte _servoBuffer[7]; uint8_t* _analoguePinMap; I2CRB _i2crb; + bool _commandFlag = 0; // EX-IOExpander protocol flags enum {