Prevent undefind FX behaviour on millis() rollover

This commit is contained in:
Blaz Kristan 2021-12-20 16:43:47 +01:00
parent cd95abb2a1
commit 8bd716c056
3 changed files with 8 additions and 0 deletions

View File

@ -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(),

View File

@ -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;

View File

@ -193,6 +193,7 @@ void WLED::loop()
if (lastMqttReconnectAttempt > millis()) {
rolloverMillis++;
lastMqttReconnectAttempt = 0;
strip.restartRuntime();
}
if (millis() - lastMqttReconnectAttempt > 30000) {
lastMqttReconnectAttempt = millis();