diff --git a/wled00/FX.h b/wled00/FX.h index 4e2a7f6c..03429309 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -648,6 +648,7 @@ class WS2812FX { calcGammaTable(float), trigger(void), setSegment(uint8_t n, uint16_t start, uint16_t stop, uint8_t grouping = 0, uint8_t spacing = 0, uint16_t offset = UINT16_MAX), + restartRuntime(), resetSegments(), makeAutoSegments(), fixInvalidSegments(), diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index b5416d52..60fcfddc 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -606,6 +606,12 @@ void WS2812FX::setSegment(uint8_t n, uint16_t i1, uint16_t i2, uint8_t grouping, _segment_runtimes[n].reset(); } +void WS2812FX::restartRuntime() { + for (uint8_t i = 0; i < MAX_NUM_SEGMENTS; i++) { + _segment_runtimes[i].reset(); + } +} + void WS2812FX::resetSegments() { for (uint8_t i = 0; i < MAX_NUM_SEGMENTS; i++) if (_segments[i].name) delete _segments[i].name; mainSegment = 0; diff --git a/wled00/json.cpp b/wled00/json.cpp index 30506c16..746d6a22 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -320,7 +320,7 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId) byte lowestActive = 99; for (byte s = 0; s < strip.getMaxSegments(); s++) { - WS2812FX::Segment sg = strip.getSegment(s); + WS2812FX::Segment &sg = strip.getSegment(s); if (sg.isActive()) { if (lowestActive == 99) lowestActive = s; @@ -486,7 +486,7 @@ void serializeState(JsonObject root, bool forPreset, bool includeBri, bool segme JsonArray seg = root.createNestedArray("seg"); for (byte s = 0; s < strip.getMaxSegments(); s++) { - WS2812FX::Segment sg = strip.getSegment(s); + WS2812FX::Segment &sg = strip.getSegment(s); if (sg.isActive()) { JsonObject seg0 = seg.createNestedObject(); diff --git a/wled00/wled.cpp b/wled00/wled.cpp index 2a80ccce..dd080d24 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -120,6 +120,7 @@ void WLED::loop() if (lastMqttReconnectAttempt > millis()) { rolloverMillis++; lastMqttReconnectAttempt = 0; + strip.restartRuntime(); } if (millis() - lastMqttReconnectAttempt > 30000) { lastMqttReconnectAttempt = millis();