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