Have at least one button defined

This commit is contained in:
Blaž Kristan 2025-07-04 18:48:36 +02:00 committed by GitHub
parent e670b26cd0
commit 6c3f4a7c33
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -421,7 +421,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
for (size_t s = 0; s < WLED_MAX_BUTTONS && s < numPins; s++) { for (size_t s = 0; s < WLED_MAX_BUTTONS && s < numPins; s++) {
type = defTypes[s < numTypes ? s : numTypes - 1]; // use last known type to set current type if types less than pins type = defTypes[s < numTypes ? s : numTypes - 1]; // use last known type to set current type if types less than pins
if (type == BTN_TYPE_NONE || defPins[s] < 0 || !PinManager::allocatePin(defPins[s], false, PinOwner::Button)) { if (type == BTN_TYPE_NONE || defPins[s] < 0 || !PinManager::allocatePin(defPins[s], false, PinOwner::Button)) {
//buttons.emplace_back(-1, BTN_TYPE_NONE); // add disabled button to vector if (buttons.size() == 0) buttons.emplace_back(-1, BTN_TYPE_NONE); // add disabled button to vector (so we have at least one button defined)
continue; // pin not available or invalid, skip configuring this GPIO continue; // pin not available or invalid, skip configuring this GPIO
} }
if (disablePullUp) { if (disablePullUp) {
@ -1334,4 +1334,4 @@ void serializeConfigSec() {
if (f) serializeJson(root, f); if (f) serializeJson(root, f);
f.close(); f.close();
releaseJSONBufferLock(); releaseJSONBufferLock();
} }