add read/only pin logic and check

This commit is contained in:
PaoloTK
2024-09-01 21:31:19 +02:00
parent 6655e2664e
commit fcc344ba99
5 changed files with 63 additions and 22 deletions

View File

@@ -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;