mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-24 13:21:23 +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();
|
||||
|
Loading…
Reference in New Issue
Block a user