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,6 +1410,8 @@ void WS2812FX::enumerateLedmaps() {
if (ledmapNames[i-1]) strlcpy(ledmapNames[i-1], tmp, 33); if (ledmapNames[i-1]) strlcpy(ledmapNames[i-1], tmp, 33);
} }
USER_PRINTF("enumerateLedmaps %s \"%s\"", fileName, name);
if (isMatrix) {
//WLEDMM calc ledmapMaxSize (TroyHack) //WLEDMM calc ledmapMaxSize (TroyHack)
char dim[34] = { '\0' }; char dim[34] = { '\0' };
f.find("\"width\":"); f.find("\"width\":");
@@ -1421,7 +1423,14 @@ void WS2812FX::enumerateLedmaps() {
uint16_t maxHeight = atoi(cleanUpName(dim)); uint16_t maxHeight = atoi(cleanUpName(dim));
ledmapMaxSize = MAX(ledmapMaxSize, maxWidth * maxHeight); 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,6 +2213,7 @@ 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);
if (isMatrix) {
//WLEDMM: read width and height //WLEDMM: read width and height
f.find("\"width\":"); f.find("\"width\":");
f.readBytesUntil('\n', fileName, sizeof(fileName)); //hack: use fileName as we have this allocated already f.readBytesUntil('\n', fileName, sizeof(fileName)); //hack: use fileName as we have this allocated already
@@ -2213,14 +2223,17 @@ bool WS2812FX::deserializeMap(uint8_t n) {
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 //WLEDMM: support ledmap file properties width and height: if found change segment
if (maxWidth * maxHeight > 0) { if (maxWidth * maxHeight > 0) {
Segment::maxWidth = maxWidth; Segment::maxWidth = maxWidth;
Segment::maxHeight = maxHeight; Segment::maxHeight = maxHeight;
resetSegments(true); //WLEDMM not makeAutoSegments() as we only want to change bounds 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) {
@@ -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\":[");