From 9b36bdcf46e2c2ec5fd01cc9cc9f02080e40651b Mon Sep 17 00:00:00 2001 From: peteGSX Date: Thu, 12 Jan 2023 08:10:41 +1000 Subject: [PATCH] Logic and diag message done --- IO_EXIOExpander.h | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/IO_EXIOExpander.h b/IO_EXIOExpander.h index d00e97c..1e20fac 100644 --- a/IO_EXIOExpander.h +++ b/IO_EXIOExpander.h @@ -105,7 +105,7 @@ private: if (configType != CONFIGURE_INPUT) return false; if (paramCount != 1) return false; if (vpin >= _firstVpin + _numDigitalPins) { - DIAG(F("Vpin %d is an analogue pin, cannot use as a digital pin"), vpin); + DIAG(F("EX-IOExpander ERROR: Vpin %d is an analogue pin, cannot use as a digital pin"), vpin); return false; } bool pullup = params[0]; @@ -117,11 +117,16 @@ private: return true; } - int _readAnalogue(VPIN vpin) override { + // We only use this to detect incorrect use of analogue pins + int _configureAnalogIn(VPIN vpin) override { if (vpin < _firstVpin + _numDigitalPins) { - DIAG(F("Vpin %d is a digital pin, cannot use as an analogue pin"), vpin); - return false; + DIAG(F("EX-IOExpander ERROR: Vpin %d is a digital pin, cannot use as an analogue pin"), vpin); } + return false; + } + + int _readAnalogue(VPIN vpin) override { + if (vpin < _firstVpin + _numDigitalPins) return false; int pin = vpin - _firstVpin; _analogueOutBuffer[0] = EXIORDAN; _analogueOutBuffer[1] = pin; @@ -130,10 +135,7 @@ private: } int _read(VPIN vpin) override { - if (vpin >= _firstVpin + _numDigitalPins) { - DIAG(F("Vpin %d is an analogue pin, cannot use as a digital pin"), vpin); - return false; - } + if (vpin >= _firstVpin + _numDigitalPins) return false; int pin = vpin - _firstVpin; _digitalOutBuffer[0] = EXIORDD; _digitalOutBuffer[1] = pin; @@ -143,10 +145,7 @@ private: } void _write(VPIN vpin, int value) override { - if (vpin >= _firstVpin + _numDigitalPins) { - DIAG(F("Vpin %d is an analogue pin, cannot use as a digital pin"), vpin); - return; - } + if (vpin >= _firstVpin + _numDigitalPins) return; int pin = vpin - _firstVpin; _digitalOutBuffer[0] = EXIOWRD; _digitalOutBuffer[1] = pin;