diff --git a/wled00/FX_2Dfcn.cpp b/wled00/FX_2Dfcn.cpp index a5507f23..1e7505cb 100644 --- a/wled00/FX_2Dfcn.cpp +++ b/wled00/FX_2Dfcn.cpp @@ -48,8 +48,7 @@ void WS2812FX::setUpMatrix() { // WLEDMM check if mapping table is necessary (avoiding heap fragmentation) //#if defined(WLED_ENABLE_HUB75MATRIX) - bool needLedMap = (loadedLedmap >0); // ledmap loaded - needLedMap |= WLED_FS.exists(F("/2d-gaps.json")); // gapFile found + bool needLedMap = (loadedLedmap >0); // ledmap loaded needLedMap |= panel.size() > 1; // 2D config: more than one panel if (panel.size() == 1) { Panel &p = panel[0]; @@ -58,6 +57,11 @@ void WS2812FX::setUpMatrix() { needLedMap |= p.bottomStart | p.rightStart; // panel not top left, or not left->light needLedMap |= (p.xOffset > 0) || (p.yOffset > 0); // panel does not start at (0,0) } + needLedMap |= (ledMaps >1) && (loadedLedmap >0); // ledmap1...10 loaded + if (!needLedMap) { // only perform file cheking if we must (may cause flicker) + needLedMap |= WLED_FS.exists(F("/2d-gaps.json")); // gapFile found + needLedMap |= WLED_FS.exists(F("/ledmap.json")); // global ledmap found + } //#else // bool needLedMap = true; // un-comment to always use ledMaps on non-HUB75 builds //#endif @@ -172,6 +176,7 @@ void WS2812FX::setUpMatrix() { } } +#if 0 // WLEDMM this test is too early - ledmap will be loaded later #ifdef WLED_ENABLE_HUB75MATRIX // softhack007 hack: delete mapping table in case it only contains "identity" if (customMappingTable != nullptr && customMappingTableSize > 0) { @@ -188,6 +193,7 @@ void WS2812FX::setUpMatrix() { } } #endif +#endif #else isMatrix = false; // no matter what config says diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index b95f20c1..2af3cb9e 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -2705,6 +2705,7 @@ bool WS2812FX::deserializeMap(uint8_t n) { //DEBUG_PRINTF(" (\"width\": %s) ", fileName) memset(fileName, 0, sizeof(fileName)); // clear old buffer + f.seek(0); // rewind to start f.find("\"height\":"); f.readBytesUntil('\n', fileName, sizeof(fileName)-1); uint16_t maxHeight = atoi(cleanUpName(fileName)); @@ -2722,7 +2723,7 @@ bool WS2812FX::deserializeMap(uint8_t n) { #endif } - USER_PRINTF("deserializeMap %d x %d\n", Segment::maxWidth, Segment::maxHeight); + DEBUG_PRINTF("deserializeMap %d x %d\n", Segment::maxWidth, Segment::maxHeight); //WLEDMM recreate customMappingTable if more space needed if (Segment::maxWidth * Segment::maxHeight > customMappingTableSize) { @@ -2752,20 +2753,27 @@ bool WS2812FX::deserializeMap(uint8_t n) { // WLEDMM reset mapping table before loading //memset(customMappingTable, 0xFF, customMappingTableSize * sizeof(uint16_t)); // FFFF = no pixel for (unsigned i=0; i0?',':' ', mapi, i); if (i < customMappingSize) customMappingTable[i++] = (uint16_t) (mapi<0 ? 0xFFFFU : mapi); // WLEDMM do not write past array bounds - } while (f.available() && (i < customMappingSize)); + endOfArray = entry.indexOf("]") >= 0; // if we hit "]", stop reading + } while (f.available() && (i < customMappingSize) && !endOfArray); + //DEBUG_PRINTLN(""); loadedLedmap = n; f.close(); - USER_PRINTF("Custom ledmap: %d size=%d\n", loadedLedmap, customMappingSize); + if ((customMappingTable != nullptr) && (customMappingSize>0)) { + USER_PRINTF(PSTR("Ledmap #%d read. Size=%d (%d x %d); %d items found.\n"), loadedLedmap, customMappingSize, Segment::maxWidth, Segment::maxHeight, i); + } #ifdef WLED_DEBUG_MAPS for (uint16_t j=0; j