Skip to content

Commit 0901d90

Browse files
committed
Merge branch 'mdev' into pixelforge_backport
2 parents 868b2ca + 7994536 commit 0901d90

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

wled00/FX_2Dfcn.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ void WS2812FX::setUpMatrix() {
4848

4949
// WLEDMM check if mapping table is necessary (avoiding heap fragmentation)
5050
//#if defined(WLED_ENABLE_HUB75MATRIX)
51-
bool needLedMap = (loadedLedmap >0); // ledmap loaded
52-
needLedMap |= WLED_FS.exists(F("/2d-gaps.json")); // gapFile found
51+
bool needLedMap = (loadedLedmap >0); // ledmap loaded
5352
needLedMap |= panel.size() > 1; // 2D config: more than one panel
5453
if (panel.size() == 1) {
5554
Panel &p = panel[0];
@@ -58,6 +57,11 @@ void WS2812FX::setUpMatrix() {
5857
needLedMap |= p.bottomStart | p.rightStart; // panel not top left, or not left->light
5958
needLedMap |= (p.xOffset > 0) || (p.yOffset > 0); // panel does not start at (0,0)
6059
}
60+
needLedMap |= (ledMaps >1) && (loadedLedmap >0); // ledmap1...10 loaded
61+
if (!needLedMap) { // only perform file cheking if we must (may cause flicker)
62+
needLedMap |= WLED_FS.exists(F("/2d-gaps.json")); // gapFile found
63+
needLedMap |= WLED_FS.exists(F("/ledmap.json")); // global ledmap found
64+
}
6165
//#else
6266
// bool needLedMap = true; // un-comment to always use ledMaps on non-HUB75 builds
6367
//#endif
@@ -172,6 +176,7 @@ void WS2812FX::setUpMatrix() {
172176
}
173177
}
174178

179+
#if 0 // WLEDMM this test is too early - ledmap will be loaded later
175180
#ifdef WLED_ENABLE_HUB75MATRIX
176181
// softhack007 hack: delete mapping table in case it only contains "identity"
177182
if (customMappingTable != nullptr && customMappingTableSize > 0) {
@@ -188,6 +193,7 @@ void WS2812FX::setUpMatrix() {
188193
}
189194
}
190195
#endif
196+
#endif
191197

192198
#else
193199
isMatrix = false; // no matter what config says

wled00/FX_fcn.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2705,6 +2705,7 @@ bool WS2812FX::deserializeMap(uint8_t n) {
27052705
//DEBUG_PRINTF(" (\"width\": %s) ", fileName)
27062706

27072707
memset(fileName, 0, sizeof(fileName)); // clear old buffer
2708+
f.seek(0); // rewind to start
27082709
f.find("\"height\":");
27092710
f.readBytesUntil('\n', fileName, sizeof(fileName)-1);
27102711
uint16_t maxHeight = atoi(cleanUpName(fileName));
@@ -2722,7 +2723,7 @@ bool WS2812FX::deserializeMap(uint8_t n) {
27222723
#endif
27232724
}
27242725

2725-
USER_PRINTF("deserializeMap %d x %d\n", Segment::maxWidth, Segment::maxHeight);
2726+
DEBUG_PRINTF("deserializeMap %d x %d\n", Segment::maxWidth, Segment::maxHeight);
27262727

27272728
//WLEDMM recreate customMappingTable if more space needed
27282729
if (Segment::maxWidth * Segment::maxHeight > customMappingTableSize) {
@@ -2752,20 +2753,27 @@ bool WS2812FX::deserializeMap(uint8_t n) {
27522753
// WLEDMM reset mapping table before loading
27532754
//memset(customMappingTable, 0xFF, customMappingTableSize * sizeof(uint16_t)); // FFFF = no pixel
27542755
for (unsigned i=0; i<customMappingTableSize; i++) customMappingTable[i]=i; // "neutral" 1:1 mapping
2755-
27562756
//WLEDMM: find the map values
2757-
f.find("\"map\":[");
2757+
f.seek(0); // rewind to start
2758+
f.find("\"map\":");
2759+
f.readBytesUntil('[', fileName, sizeof(fileName)-1); // drop everything until "["
27582760
uint16_t i=0;
2761+
bool endOfArray = false;
27592762
do { //for each element in the array
2760-
int mapi = f.readStringUntil(',').toInt();
2761-
// USER_PRINTF(", %d(%d)", mapi, i);
2763+
String entry = f.readStringUntil(',');
2764+
int mapi = entry.toInt();
2765+
//DEBUG_PRINTF("%c %d(%d)", i>0?',':' ', mapi, i);
27622766
if (i < customMappingSize) customMappingTable[i++] = (uint16_t) (mapi<0 ? 0xFFFFU : mapi); // WLEDMM do not write past array bounds
2763-
} while (f.available() && (i < customMappingSize));
2767+
endOfArray = entry.indexOf("]") >= 0; // if we hit "]", stop reading
2768+
} while (f.available() && (i < customMappingSize) && !endOfArray);
2769+
//DEBUG_PRINTLN("");
27642770

27652771
loadedLedmap = n;
27662772
f.close();
27672773

2768-
USER_PRINTF("Custom ledmap: %d size=%d\n", loadedLedmap, customMappingSize);
2774+
if ((customMappingTable != nullptr) && (customMappingSize>0)) {
2775+
USER_PRINTF(PSTR("Ledmap #%d read. Size=%d (%d x %d); %d items found.\n"), loadedLedmap, customMappingSize, Segment::maxWidth, Segment::maxHeight, i);
2776+
}
27692777
#ifdef WLED_DEBUG_MAPS
27702778
for (uint16_t j=0; j<customMappingSize; j++) { // fixing a minor warning: declaration of 'i' shadows a previous local
27712779
if (!(j%Segment::maxWidth)) DEBUG_PRINTLN();

wled00/wled.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
// version code in format yymmddb (b = daily build)
10-
#define VERSION 2512292
10+
#define VERSION 2512301
1111

1212
// 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.
1313
#define _MoonModules_WLED_

0 commit comments

Comments
 (0)