mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-25 05:31:24 +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.
|
// Read value from virtual pin.
|
||||||
bool IODevice::read(VPIN vpin) {
|
int IODevice::read(VPIN vpin) {
|
||||||
for (IODevice *dev = _firstDevice; dev != 0; dev = dev->_nextDevice) {
|
for (IODevice *dev = _firstDevice; dev != 0; dev = dev->_nextDevice) {
|
||||||
if (dev->owns(vpin))
|
if (dev->owns(vpin))
|
||||||
return dev->_read(vpin);
|
return dev->_read(vpin);
|
||||||
@ -302,7 +302,7 @@ bool IODevice::hasCallback(VPIN vpin) {
|
|||||||
(void)vpin; // Avoid compiler warnings
|
(void)vpin; // Avoid compiler warnings
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool IODevice::read(VPIN vpin) {
|
int IODevice::read(VPIN vpin) {
|
||||||
pinMode(vpin, INPUT_PULLUP);
|
pinMode(vpin, INPUT_PULLUP);
|
||||||
return !digitalRead(vpin); // Return inverted state (5v=0, 0v=1)
|
return !digitalRead(vpin); // Return inverted state (5v=0, 0v=1)
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ public:
|
|||||||
static bool hasCallback(VPIN vpin);
|
static bool hasCallback(VPIN vpin);
|
||||||
|
|
||||||
// read invokes the IODevice instance's _read method.
|
// 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.
|
// loop invokes the IODevice instance's _loop method.
|
||||||
static void loop();
|
static void loop();
|
||||||
|
Loading…
Reference in New Issue
Block a user