diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index 530cae32d..295a84e52 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -119,13 +119,13 @@ class BusDigital : public Bus { public: BusDigital(BusConfig &bc, uint8_t nr) : Bus(bc.type, bc.start) { if (!IS_DIGITAL(bc.type) || !bc.count) return; + if (!pinManager.allocatePin(bc.pins[0])) return; _pins[0] = bc.pins[0]; - if (!pinManager.allocatePin(_pins[0])) return; if (IS_2PIN(bc.type)) { - _pins[1] = bc.pins[1]; - if (!pinManager.allocatePin(_pins[1])) { + if (!pinManager.allocatePin(bc.pins[1])) { cleanup(); return; } + _pins[1] = bc.pins[1]; } reversed = bc.reversed; _skip = bc.skipAmount; //sacrificial pixels @@ -241,10 +241,11 @@ class BusPwm : public Bus { #endif for (uint8_t i = 0; i < numPins; i++) { - _pins[i] = bc.pins[i]; - if (!pinManager.allocatePin(_pins[i])) { + uint8_t currentPin = bc.pins[i]; + if (!pinManager.allocatePin(currentPin)) { deallocatePins(); return; } + _pins[i] = currentPin; // store only after allocatePin() succeeds #ifdef ESP8266 pinMode(_pins[i], OUTPUT); #else diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index d4cce2f37..d054b8b08 100644 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -152,14 +152,20 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { } } else { // new install/missing configuration (button 0 has defaults) - if (fromFS) - for (uint8_t s=1; s