Merge branch 'ledmap1D' into mdev

This commit is contained in:
Ewoud
2023-06-15 13:21:57 +02:00
2 changed files with 41 additions and 26 deletions

View File

@@ -63,6 +63,8 @@ void WS2812FX::setUpMatrix() {
return; return;
} }
USER_PRINTF("setUpMatrix %d x %d\n", Segment::maxWidth, Segment::maxHeight);
//WLEDMM recreate customMappingTable if more space needed //WLEDMM recreate customMappingTable if more space needed
if (Segment::maxWidth * Segment::maxHeight > customMappingTableSize) { if (Segment::maxWidth * Segment::maxHeight > customMappingTableSize) {
uint32_t size = MAX(ledmapMaxSize, Segment::maxWidth * Segment::maxHeight);//TroyHack uint32_t size = MAX(ledmapMaxSize, Segment::maxWidth * Segment::maxHeight);//TroyHack

View File

@@ -1410,18 +1410,27 @@ void WS2812FX::enumerateLedmaps() {
if (ledmapNames[i-1]) strlcpy(ledmapNames[i-1], tmp, 33); if (ledmapNames[i-1]) strlcpy(ledmapNames[i-1], tmp, 33);
} }
//WLEDMM calc ledmapMaxSize (TroyHack) USER_PRINTF("enumerateLedmaps %s \"%s\"", fileName, name);
char dim[34] = { '\0' }; if (isMatrix) {
f.find("\"width\":"); //WLEDMM calc ledmapMaxSize (TroyHack)
f.readBytesUntil('\n', dim, sizeof(dim)-1); //hack: use fileName as we have this allocated already char dim[34] = { '\0' };
uint16_t maxWidth = atoi(cleanUpName(dim)); f.find("\"width\":");
f.find("\"height\":"); f.readBytesUntil('\n', dim, sizeof(dim)-1); //hack: use fileName as we have this allocated already
memset(dim, 0, sizeof(dim)); // clear buffer before reading uint16_t maxWidth = atoi(cleanUpName(dim));
f.readBytesUntil('\n', dim, sizeof(dim)-1); f.find("\"height\":");
uint16_t maxHeight = atoi(cleanUpName(dim)); memset(dim, 0, sizeof(dim)); // clear buffer before reading
ledmapMaxSize = MAX(ledmapMaxSize, maxWidth * maxHeight); f.readBytesUntil('\n', dim, sizeof(dim)-1);
uint16_t maxHeight = atoi(cleanUpName(dim));
ledmapMaxSize = MAX(ledmapMaxSize, maxWidth * maxHeight);
USER_PRINTF("enumerateLedmaps %s \"%s\" (%dx%d -> %d)\n", fileName, name, maxWidth, maxHeight, ledmapMaxSize); if (maxWidth*maxHeight>0) {
USER_PRINTF(" (%dx%d -> %d)\n", maxWidth, maxHeight, ledmapMaxSize);
} else {
USER_PRINTLN();
}
}
else
USER_PRINTLN();
} }
f.close(); f.close();
USER_FLUSH(); USER_FLUSH();
@@ -2204,24 +2213,28 @@ bool WS2812FX::deserializeMap(uint8_t n) {
USER_PRINT(F("Reading LED map from ")); //WLEDMM use USER_PRINT USER_PRINT(F("Reading LED map from ")); //WLEDMM use USER_PRINT
USER_PRINTLN(fileName); USER_PRINTLN(fileName);
//WLEDMM: read width and height if (isMatrix) {
f.find("\"width\":"); //WLEDMM: read width and height
f.readBytesUntil('\n', fileName, sizeof(fileName)); //hack: use fileName as we have this allocated already f.find("\"width\":");
uint16_t maxWidth = atoi(fileName); f.readBytesUntil('\n', fileName, sizeof(fileName)); //hack: use fileName as we have this allocated already
uint16_t maxWidth = atoi(fileName);
f.find("\"height\":"); f.find("\"height\":");
f.readBytesUntil('\n', fileName, sizeof(fileName)); f.readBytesUntil('\n', fileName, sizeof(fileName));
uint16_t maxHeight = atoi(fileName); uint16_t maxHeight = atoi(fileName);
USER_PRINTF("deserializeMap %d x %d\n", maxWidth, maxHeight); //WLEDMM: support ledmap file properties width and height: if found change segment
if (maxWidth * maxHeight > 0) {
//WLEDMM: support ledmap file properties width and height: if found change segment Segment::maxWidth = maxWidth;
if (maxWidth * maxHeight > 0) { Segment::maxHeight = maxHeight;
Segment::maxWidth = maxWidth; resetSegments(true); //WLEDMM not makeAutoSegments() as we only want to change bounds
Segment::maxHeight = maxHeight; }
resetSegments(true); //WLEDMM not makeAutoSegments() as we only want to change bounds else
setUpMatrix(); //reset segment sizes to panels
} }
USER_PRINTF("deserializeMap %d x %d\n", Segment::maxWidth, Segment::maxHeight);
//WLEDMM recreate customMappingTable if more space needed //WLEDMM recreate customMappingTable if more space needed
if (Segment::maxWidth * Segment::maxHeight > customMappingTableSize) { if (Segment::maxWidth * Segment::maxHeight > customMappingTableSize) {
uint32_t size = MAX(ledmapMaxSize, Segment::maxWidth * Segment::maxHeight);//TroyHack uint32_t size = MAX(ledmapMaxSize, Segment::maxWidth * Segment::maxHeight);//TroyHack
@@ -2232,7 +2245,7 @@ bool WS2812FX::deserializeMap(uint8_t n) {
} }
if (customMappingTable != nullptr) { if (customMappingTable != nullptr) {
customMappingSize = maxWidth * maxHeight; customMappingSize = Segment::maxWidth * Segment::maxHeight;
//WLEDMM: find the map values //WLEDMM: find the map values
f.find("\"map\":["); f.find("\"map\":[");