remove getReadOnlyPins() function

This commit is contained in:
PaoloTK 2024-09-03 17:29:38 +02:00
parent 9bb979f2e8
commit d79d5dbadd
3 changed files with 16 additions and 26 deletions

View File

@ -267,26 +267,17 @@ bool PinManagerClass::isPinOk(byte gpio, bool output) const
return false;
}
unsigned *PinManagerClass::getReadOnlyPins()
{
#ifdef READ_ONLY_PINS
static unsigned readOnlyPins[] = {READ_ONLY_PINS};
#else
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]);
#ifdef READ_ONLY_PINS
const unsigned pins[] = {READ_ONLY_PINS};
const unsigned numPins = ((sizeof pins) / (sizeof pins[0]));
for (unsigned i = 0; i < numPins; i++) {
if (pins[i] == gpio) {
return true;
}
if (gpio <= WLED_NUM_PINS) {
for (unsigned i = 0; i < numPins; i++) if (gpio == pins[i]) return true;
}
#endif
return false;
}

View File

@ -112,7 +112,6 @@ class PinManagerClass {
// will return false for reserved pins
bool isPinOk(byte gpio, bool output = true) const;
static unsigned* getReadOnlyPins();
static bool isReadOnlyPin(byte gpio);
PinOwner getPinOwner(byte gpio) const;

View File

@ -191,13 +191,13 @@ void appendGPIOinfo() {
// add info for read-only GPIO
oappend(SET_F("d.ro_gpio=["));
const unsigned* readOnlyPins = pinManager.getReadOnlyPins();
const unsigned numReadOnlyPins = (sizeof *readOnlyPins) / (sizeof readOnlyPins[0]);
for (unsigned i = 0; i < numReadOnlyPins; i++) {
// Ignore 255
if (readOnlyPins[i] <= WLED_NUM_PINS) {
oappendi(readOnlyPins[i]);
if (i != numReadOnlyPins) oappend(SET_F(","));
bool firstPin = true;
for (unsigned i = 0; i < WLED_NUM_PINS; i++) {
if (pinManager.isReadOnlyPin(i)) {
// No comma before the first pin
if (!firstPin) oappend(SET_F(","));
oappendi(i);
firstPin = false;
}
}
oappend(SET_F("];"));