From 11c56387827ec96830efd1a56fff187b4f78bdca Mon Sep 17 00:00:00 2001 From: pmantoine Date: Wed, 18 Sep 2024 12:03:22 +1000 Subject: [PATCH] Add IO_PCA9554.h to IODevice.h --- IODevice.h | 1 + IO_PCA9554.h | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/IODevice.h b/IODevice.h index 6c70f5f..69b1bd1 100644 --- a/IODevice.h +++ b/IODevice.h @@ -544,6 +544,7 @@ protected: #include "IO_PCF8574.h" #include "IO_PCF8575.h" #include "IO_PCA9555.h" +#include "IO_PCA9554.h" #include "IO_duinoNodes.h" #include "IO_EXIOExpander.h" #include "IO_trainbrains.h" diff --git a/IO_PCA9554.h b/IO_PCA9554.h index 417c5d2..55fc3b2 100644 --- a/IO_PCA9554.h +++ b/IO_PCA9554.h @@ -40,8 +40,10 @@ private: PCA9554(VPIN vpin, uint8_t nPins, I2CAddress I2CAddress, int interruptPin=-1) : GPIOBase((FSH *)F("PCA9554"), vpin, nPins, I2CAddress, interruptPin) { - if (nPins > 8) + if (nPins > 8) { DIAG(F("PCA9554 nPins %d larger than allowed!")); + nPins = 8; + } requestBlock.setRequestParams(_I2CAddress, inputBuffer, sizeof(inputBuffer), outputBuffer, sizeof(outputBuffer)); outputBuffer[0] = REG_INPUT_P0; @@ -81,8 +83,12 @@ private: } // This function is invoked when an I/O operation on the requestBlock completes. void _processCompletion(uint8_t status) override { - if (status == I2C_STATUS_OK) - _portInputState = inputBuffer[0]; + if (status == I2C_STATUS_OK) + { + if (_portInputState != (inputBuffer[0] | _portMode)) + DIAG(F("PCA9554 inputs changed, value now %x"), inputBuffer[0]); + _portInputState = inputBuffer[0] | _portMode; + } else _portInputState = 0xff; }