add read/only pin logic and check
This commit is contained in:
@@ -267,6 +267,29 @@ bool PinManagerClass::isPinOk(byte gpio, bool output) const
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned *PinManagerClass::getReadOnlyPins()
|
||||
{
|
||||
#ifdef READ_ONLY_PINS
|
||||
static unsigned readOnlyPins[] = {READ_ONLY_PINS};
|
||||
#elif
|
||||
static unsigned readOnlyPins[] = 255;
|
||||
#endif
|
||||
return readOnlyPins;
|
||||
}
|
||||
|
||||
bool PinManagerClass::isReadOnlyPin(byte gpio)
|
||||
{
|
||||
const unsigned* pins = PinManagerClass::getReadOnlyPins();
|
||||
const unsigned numPins = sizeof(pins) / sizeof(pins[0]);
|
||||
|
||||
for (unsigned i = 0; i < numPins; i++) {
|
||||
if (pins[i] == gpio) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
PinOwner PinManagerClass::getPinOwner(byte gpio) const
|
||||
{
|
||||
if (!isPinOk(gpio, false)) return PinOwner::None;
|
||||
|
||||
Reference in New Issue
Block a user