mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-23 21:01:25 +01:00
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.
This commit is contained in:
parent
2a79f67308
commit
ec503e7d3e
@ -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)
|
||||
}
|
||||
|
@ -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
|
Loading…
Reference in New Issue
Block a user