Enumeration support.

This commit is contained in:
Blaž Kristan 2024-11-09 11:33:10 +01:00
parent 9fa53ccf05
commit ba5ec57e4d
2 changed files with 3 additions and 2 deletions

View File

@ -1823,7 +1823,6 @@ bool WS2812FX::deserializeMap(uint8_t n) {
StaticJsonDocument<64> filter; StaticJsonDocument<64> filter;
filter[F("width")] = true; filter[F("width")] = true;
filter[F("height")] = true; filter[F("height")] = true;
filter[F("name")] = true;
if (!readObjectFromFile(fileName, nullptr, pDoc, &filter)) { if (!readObjectFromFile(fileName, nullptr, pDoc, &filter)) {
DEBUG_PRINT(F("ERROR Invalid ledmap in ")); DEBUG_PRINTLN(fileName); DEBUG_PRINT(F("ERROR Invalid ledmap in ")); DEBUG_PRINTLN(fileName);
releaseJSONBufferLock(); releaseJSONBufferLock();

View File

@ -493,6 +493,8 @@ um_data_t* simulateSound(uint8_t simulationId)
static const char s_ledmap_tmpl[] PROGMEM = "ledmap%d.json"; static const char s_ledmap_tmpl[] PROGMEM = "ledmap%d.json";
// enumerate all ledmapX.json files on FS and extract ledmap names if existing // enumerate all ledmapX.json files on FS and extract ledmap names if existing
void enumerateLedmaps() { void enumerateLedmaps() {
StaticJsonDocument<64> filter;
filter["n"] = true;
ledMaps = 1; ledMaps = 1;
for (size_t i=1; i<WLED_MAX_LEDMAPS; i++) { for (size_t i=1; i<WLED_MAX_LEDMAPS; i++) {
char fileName[33] = "/"; char fileName[33] = "/";
@ -511,7 +513,7 @@ void enumerateLedmaps() {
#ifndef ESP8266 #ifndef ESP8266
if (requestJSONBufferLock(21)) { if (requestJSONBufferLock(21)) {
if (readObjectFromFile(fileName, nullptr, pDoc)) { if (readObjectFromFile(fileName, nullptr, pDoc, &filter)) {
size_t len = 0; size_t len = 0;
JsonObject root = pDoc->as<JsonObject>(); JsonObject root = pDoc->as<JsonObject>();
if (!root["n"].isNull()) { if (!root["n"].isNull()) {