Add support for default ledmap.json + peek with ledmap if default panel

Thx to @Troy#2642
This commit is contained in:
Ewoud
2023-02-13 19:09:02 +01:00
parent 0d0f6b5e30
commit 9ba9a61af5
5 changed files with 767 additions and 760 deletions

View File

@@ -80,7 +80,7 @@ void WS2812FX::setUpMatrix(bool reset) {
customMappingSize = Segment::maxWidth * Segment::maxHeight;
uint16_t *customMappingTableCombi = nullptr; //WLEDMM: Idea @Troy#2642
if (loadedLedmap > 0)
if (loadedLedmap >= 0) //WLEDMM: @Troy#2642 : include ledmap = 0 as default ledmap
customMappingTableCombi = new uint16_t[customMappingSize];
uint16_t x, y, pix=0; //pixel
@@ -94,7 +94,7 @@ void WS2812FX::setUpMatrix(bool reset) {
x = (p.vertical?p.bottomStart:p.rightStart) ? h-i-1 : i;
x = p.serpentine && j%2 ? h-x-1 : x;
uint16_t index = (p.yOffset + (p.vertical?x:y)) * Segment::maxWidth + p.xOffset + (p.vertical?y:x);
if (loadedLedmap > 0) {
if (loadedLedmap >= 0) { //WLEDMM: @Troy#2642 : include ledmap = 0 as default ledmap
if (index < customMappingSizeLedmap) {
if (customMappingTable[index] < customMappingSize)
customMappingTableCombi[customMappingTable[index]] = pix; //WLEDMM: allow for 2 transitions if reset = false (ledmap and logical to physical)
@@ -108,7 +108,7 @@ void WS2812FX::setUpMatrix(bool reset) {
}
}
if (loadedLedmap > 0) {
if (loadedLedmap >= 0) { //WLEDMM: @Troy#2642 : include ledmap = 0 as default ledmap
for (size_t i = 0; i < customMappingSize; i++) {
customMappingTable[i] = customMappingTableCombi[i];
}

View File

@@ -1990,8 +1990,8 @@ void WS2812FX::deserializeMap(uint8_t n) {
if (!requestJSONBufferLock(7)) return;
DEBUG_PRINT(F("Reading LED map from "));
DEBUG_PRINTLN(fileName);
USER_PRINT(F("Reading LED map from ")); //WLEDMM use USER_PRINT
USER_PRINTLN(fileName);
if (!readObjectFromFile(fileName, nullptr, &doc)) {
releaseJSONBufferLock();

View File

@@ -1305,10 +1305,12 @@ function drawSegments() {
}
//draw the ledmap
if (ledmapNr>0 && ctx) {
if (ledmapNr>=0 && ctx) { //WLEDMM: @Troy#2642 : include ledmap = 0 as default ledmap
// console.log("Before fetch ledmap ", lastinfo.ledmap);
var fileName;
if (ledmapNr<10)
if (ledmapNr==0)
fileName = "ledmap.json"; //0 is ledmap.json, not ledmap0.json
else if (ledmapNr<10)
fileName = "ledmap"+ledmapNr+".json";
else
fileName = ledmapFileNames[ledmapNr-10];

File diff suppressed because it is too large Load Diff

View File

@@ -170,7 +170,12 @@ bool sendLiveLedsWs(uint32_t wsClient)
for (uint16_t i = 0; pos < bufSize -2; i += n)
{
uint32_t c = strip.getPixelColor(i);
//WLEDMM: include ledmap in peek if default panel
uint32_t c;
if (strip.panel.size()==1 && !strip.panel[0].vertical && !strip.panel[0].bottomStart && !strip.panel[0].rightStart) // one default panel
c = busses.getPixelColor(i);
else
c = strip.getPixelColor(i);
buffer[pos++] = qadd8(W(c), R(c)); //R, add white channel to RGB channels as a simple RGBW -> RGB map
buffer[pos++] = qadd8(W(c), G(c)); //G
buffer[pos++] = qadd8(W(c), B(c)); //B