diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 32fda7cb..12eb67c9 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -1505,15 +1505,15 @@ void WS2812FX::service() { void IRAM_ATTR WS2812FX::setPixelColor(int i, uint32_t col) { - if (i >= _length) return; if (i < customMappingSize) i = customMappingTable[i]; + if (i >= _length) return; //WLEDMM: check after mapping busses.setPixelColor(i, col); } uint32_t WS2812FX::getPixelColor(uint16_t i) { - if (i >= _length) return 0; if (i < customMappingSize) i = customMappingTable[i]; + if (i >= _length) return 0; //WLEDMM: check after mapping return busses.getPixelColor(i); } @@ -2040,13 +2040,14 @@ bool WS2812FX::deserializeMap(uint8_t n) { } if (!isFile) { - //WLEDMM: disable temporary!!! // erase custom mapping if selecting nonexistent ledmap.json (n==0) - // if (!isMatrix && !n && customMappingTable != nullptr) { - // customMappingSize = 0; - // delete[] customMappingTable; - // customMappingTable = nullptr; - // } + //WLEDM: doubt this is necessary as return false causes setupMatrix to deal with this + if (!isMatrix && !n && customMappingTable != nullptr) { + customMappingSize = 0; + delete[] customMappingTable; + customMappingTable = nullptr; + loadedLedmap = 0; //WLEDMM + } return false; } @@ -2070,41 +2071,29 @@ bool WS2812FX::deserializeMap(uint8_t n) { JsonArray map = doc[F("map")]; if (!map.isNull() && map.size()) { // not an empty map - if (doc[F("physical")]) { - //WLEDMM: support ledmap file properties width and height - if (doc[F("width")]>0 && doc[F("height")]>0) { - panels = 1; - panel.clear(); - panel.reserve(1U); // pre-allocate memory for panels - Panel p; - p.bottomStart = p.rightStart = p.vertical = p.serpentine = false; - p.xOffset = p.yOffset = 0; - p.width = doc[F("width")]; - p.height = doc[F("height")]; - strip.panel.push_back(p); + //WLEDMM: support ledmap file properties width and height + if (doc[F("width")]>0 && doc[F("height")]>0) { + panels = 1; + panel.clear(); + panel.reserve(1U); // pre-allocate memory for panels + Panel p; + p.bottomStart = p.rightStart = p.vertical = p.serpentine = false; + p.xOffset = p.yOffset = 0; + p.width = doc[F("width")]; + p.height = doc[F("height")]; + strip.panel.push_back(p); - Segment::maxWidth = p.width; - Segment::maxHeight = p.height; + Segment::maxWidth = p.width; + Segment::maxHeight = p.height; - makeAutoSegments(); - } + makeAutoSegments(); } customMappingSize = map.size(); customMappingTable = new uint16_t[customMappingSize]; - // if (!doc[F("physical")]) { - for (uint16_t i=0; i=0 mappings to customMappingTable - // for (uint16_t i=0; i=0) - // customMappingTable[map[i].as()] = i; - // } - + for (uint16_t i=0; i=0 && ctx) { //WLEDMM: @Troy#2642 : include ledmap = 0 as default ledmap - // console.log("Before fetch ledmap ", lastinfo.ledmap); var fileName; if (ledmapNr==0) fileName = "ledmap.json"; //0 is ledmap.json, not ledmap0.json @@ -1331,7 +1331,7 @@ function drawSegmentView() { else fileName = ledmapFileNames[ledmapNr-10]; - fetchAndExecute((loc?`http://${locip}`:'.') + "/", fileName , function(text) { + fetchAndExecute((loc?`http://${locip}`:'.') + "/", fileName , function(text) { var ledmapJson = JSON.parse(text); var counter = 0; var noMap = []; @@ -1339,13 +1339,9 @@ function drawSegmentView() { var colorArray = ["yellow", "green", "magenta", "orange"]; var customMappingTable = []; - if (!ledmapJson["physical"]) { - customMappingTable = ledmapJson["map"]; - } else { - for (let i=0;i=0) customMappingTable[ledmapJson["map"][i]] = i; - } + for (let i=0;i=0) customMappingTable[ledmapJson["map"][i]] = i; for (let i=0;i