prevent flickering during OTA
I've almost toasted my wiring due to uncontrolled LED flickering during OTA. So here is the fix - it prevents any strip updates when OTA is ongoing.
This commit is contained in:
@@ -1615,6 +1615,8 @@ void WS2812FX::waitUntilIdle(void) {
|
|||||||
|
|
||||||
void WS2812FX::service() {
|
void WS2812FX::service() {
|
||||||
unsigned long nowUp = millis(); // Be aware, millis() rolls over every 49 days // WLEDMM avoid losing precision
|
unsigned long nowUp = millis(); // Be aware, millis() rolls over every 49 days // WLEDMM avoid losing precision
|
||||||
|
if (OTAisRunning) return; // WLEDMM avoid flickering during OTA
|
||||||
|
|
||||||
now = nowUp + timebase;
|
now = nowUp + timebase;
|
||||||
#if defined(ARDUINO_ARCH_ESP32) && defined(WLEDMM_FASTPATH)
|
#if defined(ARDUINO_ARCH_ESP32) && defined(WLEDMM_FASTPATH)
|
||||||
if ((_frametime > 2) && (_frametime < 32) && (nowUp - _lastShow) < (_frametime/2)) return; // WLEDMM experimental - stabilizes frametimes but increases CPU load
|
if ((_frametime > 2) && (_frametime < 32) && (nowUp - _lastShow) < (_frametime/2)) return; // WLEDMM experimental - stabilizes frametimes but increases CPU load
|
||||||
@@ -1776,6 +1778,8 @@ void WS2812FX::estimateCurrentAndLimitBri() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void WS2812FX::show(void) {
|
void WS2812FX::show(void) {
|
||||||
|
if (OTAisRunning) return; // WLEDMM avoid flickering during OTA
|
||||||
|
|
||||||
// avoid race condition, capture _callback value
|
// avoid race condition, capture _callback value
|
||||||
show_callback callback = _callback;
|
show_callback callback = _callback;
|
||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// version code in format yymmddb (b = daily build)
|
// version code in format yymmddb (b = daily build)
|
||||||
#define VERSION 2401290
|
#define VERSION 2402120
|
||||||
|
|
||||||
// WLEDMM - you can check for this define in usermods, to only enabled WLEDMM specific code in the "right" fork. Its not defined in AC WLED.
|
// WLEDMM - you can check for this define in usermods, to only enabled WLEDMM specific code in the "right" fork. Its not defined in AC WLED.
|
||||||
#define _MoonModules_WLED_
|
#define _MoonModules_WLED_
|
||||||
@@ -749,6 +749,7 @@ WLED_GLOBAL volatile bool doInitBusses _INIT(false); // WLEDMM "volatile"
|
|||||||
WLED_GLOBAL volatile bool loadLedmap _INIT(false); // WLEDMM use as bool and use loadedLedmap for Nr
|
WLED_GLOBAL volatile bool loadLedmap _INIT(false); // WLEDMM use as bool and use loadedLedmap for Nr
|
||||||
WLED_GLOBAL volatile uint8_t loadedLedmap _INIT(0); // WLEDMM default 0
|
WLED_GLOBAL volatile uint8_t loadedLedmap _INIT(0); // WLEDMM default 0
|
||||||
WLED_GLOBAL volatile bool suspendStripService _INIT(false); // WLEDMM temporarily prevent running strip.service, when strip or segments are "under update" and inconsistent
|
WLED_GLOBAL volatile bool suspendStripService _INIT(false); // WLEDMM temporarily prevent running strip.service, when strip or segments are "under update" and inconsistent
|
||||||
|
WLED_GLOBAL volatile bool OTAisRunning _INIT(false); // WLEDMM temporarily stop led updates during OTA
|
||||||
#ifndef ESP8266
|
#ifndef ESP8266
|
||||||
WLED_GLOBAL char *ledmapNames[WLED_MAX_LEDMAPS-1] _INIT_N(({nullptr}));
|
WLED_GLOBAL char *ledmapNames[WLED_MAX_LEDMAPS-1] _INIT_N(({nullptr}));
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -336,6 +336,8 @@ void initServer()
|
|||||||
if(!index){
|
if(!index){
|
||||||
DEBUG_PRINTLN(F("OTA Update Start"));
|
DEBUG_PRINTLN(F("OTA Update Start"));
|
||||||
WLED::instance().disableWatchdog();
|
WLED::instance().disableWatchdog();
|
||||||
|
OTAisRunning = true; // WLEDMM flicker fixer
|
||||||
|
strip.fill(BLACK);
|
||||||
usermods.onUpdateBegin(true); // notify usermods that update is about to begin (some may require task de-init)
|
usermods.onUpdateBegin(true); // notify usermods that update is about to begin (some may require task de-init)
|
||||||
lastEditTime = millis(); // make sure PIN does not lock during update
|
lastEditTime = millis(); // make sure PIN does not lock during update
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
@@ -352,6 +354,7 @@ void initServer()
|
|||||||
usermods.onUpdateBegin(false); // notify usermods that update has failed (some may require task init)
|
usermods.onUpdateBegin(false); // notify usermods that update has failed (some may require task init)
|
||||||
WLED::instance().enableWatchdog();
|
WLED::instance().enableWatchdog();
|
||||||
}
|
}
|
||||||
|
OTAisRunning = false; // WLEDMM flicker fixer
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
#else
|
#else
|
||||||
|
|||||||
Reference in New Issue
Block a user