diff --git a/wled00/pin_manager.cpp b/wled00/pin_manager.cpp index 527e4470c..2bd82115f 100644 --- a/wled00/pin_manager.cpp +++ b/wled00/pin_manager.cpp @@ -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; } diff --git a/wled00/pin_manager.h b/wled00/pin_manager.h index b441b89af..a8ddf5f75 100644 --- a/wled00/pin_manager.h +++ b/wled00/pin_manager.h @@ -111,8 +111,7 @@ class PinManagerClass { bool isPinAllocated(byte gpio, PinOwner tag = PinOwner::None) const; // 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; diff --git a/wled00/xml.cpp b/wled00/xml.cpp index dfb3d67df..fce453cfc 100644 --- a/wled00/xml.cpp +++ b/wled00/xml.cpp @@ -191,14 +191,14 @@ 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("];"));