From 1cb3ab82c242fd87a81677b2f8816d206d06578a Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Wed, 10 Aug 2022 20:53:11 +0200 Subject: [PATCH] Reduction of flicering on web access (info) --- wled00/FX_fcn.cpp | 5 +++++ wled00/fcn_declare.h | 1 + wled00/json.cpp | 7 +------ wled00/util.cpp | 11 +++++++++++ wled00/wled.h | 3 ++- 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index a9b93bb2..5e6fcd0f 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -809,6 +809,11 @@ void WS2812FX::finalizeInit(void) seg.resetIfRequired(); } + // for the lack of better place enumerate ledmaps here + // if we do it in json.cpp (serializeInfo()) we are getting flashes on LEDs + // unfortunately this means we do not get updates after uploads + enumerateLedmaps(); + _hasWhiteChannel = _isOffRefreshRequired = false; //if busses failed to load, add default (fresh install, FS issue, ...) diff --git a/wled00/fcn_declare.h b/wled00/fcn_declare.h index 2e771927..d0073f85 100644 --- a/wled00/fcn_declare.h +++ b/wled00/fcn_declare.h @@ -327,6 +327,7 @@ uint8_t extractModeSlider(uint8_t mode, uint8_t slider, char *dest, uint8_t maxL int16_t extractModeDefaults(uint8_t mode, const char *segVar); uint16_t crc16(const unsigned char* data_p, size_t length); um_data_t* simulateSound(uint8_t simulationId); +void enumerateLedmaps(); #ifdef WLED_ADD_EEPROM_SUPPORT //wled_eeprom.cpp diff --git a/wled00/json.cpp b/wled00/json.cpp index 3995dc3e..8d5b7978 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -654,12 +654,7 @@ void serializeInfo(JsonObject root) JsonArray ledmaps = root.createNestedArray(F("maps")); for (size_t i=0; i<10; i++) { - char fileName[16]; - strcpy_P(fileName, PSTR("/ledmap")); - if (i) sprintf(fileName +7, "%d", i); - strcat_P(fileName, PSTR(".json")); - bool isFile = WLED_FS.exists(fileName); - if (isFile || i==0) ledmaps.add(i); + if ((ledMaps>>i) & 0x0001) ledmaps.add(i); } JsonObject wifi_info = root.createNestedObject("wifi"); diff --git a/wled00/util.cpp b/wled00/util.cpp index 107378a8..d2cbc0fb 100644 --- a/wled00/util.cpp +++ b/wled00/util.cpp @@ -503,3 +503,14 @@ um_data_t* simulateSound(uint8_t simulationId) return um_data; } #endif + + +void enumerateLedmaps() { + ledMaps = 1; + for (size_t i=1; i<10; i++) { + char fileName[16]; + sprintf_P(fileName, PSTR("/ledmap%d.json"), i); + bool isFile = WLED_FS.exists(fileName); + if (isFile) ledMaps |= 1 << i; + } +} \ No newline at end of file diff --git a/wled00/wled.h b/wled00/wled.h index d37ad488..d1291ae5 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2208061 +#define VERSION 2208101 //uncomment this if you have a "my_config.h" file you'd like to use //#define WLED_USE_MY_CONFIG @@ -639,6 +639,7 @@ WLED_GLOBAL WS2812FX strip _INIT(WS2812FX()); WLED_GLOBAL BusConfig* busConfigs[WLED_MAX_BUSSES] _INIT({nullptr}); //temporary, to remember values from network callback until after WLED_GLOBAL bool doInitBusses _INIT(false); WLED_GLOBAL int8_t loadLedmap _INIT(-1); +WLED_GLOBAL uint16_t ledMaps _INIT(0); // bitfield representation of available ledmaps // Usermod manager WLED_GLOBAL UsermodManager usermods _INIT(UsermodManager());