From ec503e7d3ee21101e0bf2567e65aca846a5ce64d Mon Sep 17 00:00:00 2001 From: Neil McKechnie Date: Thu, 12 Aug 2021 12:01:10 +0100 Subject: [PATCH] Make IODevice::read function return type consistent with underlying _read calls. IODevice::read() now returns int, instead of bool. This is consistent with the IODevice::_read() return and also allows for future devices that return a non-boolean value. --- IODevice.cpp | 4 ++-- IODevice.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/IODevice.cpp b/IODevice.cpp index 0f833e8..d49eedc 100644 --- a/IODevice.cpp +++ b/IODevice.cpp @@ -261,7 +261,7 @@ bool IODevice::owns(VPIN id) { // } // Read value from virtual pin. -bool IODevice::read(VPIN vpin) { +int IODevice::read(VPIN vpin) { for (IODevice *dev = _firstDevice; dev != 0; dev = dev->_nextDevice) { if (dev->owns(vpin)) return dev->_read(vpin); @@ -302,7 +302,7 @@ bool IODevice::hasCallback(VPIN vpin) { (void)vpin; // Avoid compiler warnings return false; } -bool IODevice::read(VPIN vpin) { +int IODevice::read(VPIN vpin) { pinMode(vpin, INPUT_PULLUP); return !digitalRead(vpin); // Return inverted state (5v=0, 0v=1) } diff --git a/IODevice.h b/IODevice.h index eda76ab..ca16285 100644 --- a/IODevice.h +++ b/IODevice.h @@ -102,7 +102,7 @@ public: static bool hasCallback(VPIN vpin); // read invokes the IODevice instance's _read method. - static bool read(VPIN vpin); + static int read(VPIN vpin); // loop invokes the IODevice instance's _loop method. static void loop(); @@ -348,4 +348,4 @@ private: // #include "IO_MCP23017.h" // #include "IO_PCF8574.h" -#endif // iodevice_h +#endif // iodevice_h \ No newline at end of file