Reinstate ledmap on 2D

FX.h / FX_2Dfcn.cpp: 
- setUpMatrix with reset option (create 1:1 matrix) and customMappingTable[customMappingTable[x]] 

FX_fcn.cpp: 
- deserializeMap: also for 2D, use setUpMatrix
This commit is contained in:
Ewoud
2022-11-22 10:00:53 +01:00
parent b0b78a9959
commit f1088a6ed7
5 changed files with 212 additions and 193 deletions

View File

@@ -34,12 +34,14 @@
// note: matrix may be comprised of multiple panels each with different orientation
// but ledmap takes care of that. ledmap is constructed upon initialization
// so matrix should disable regular ledmap processing
void WS2812FX::setUpMatrix() {
void WS2812FX::setUpMatrix(bool reset) {
#ifndef WLED_DISABLE_2D
// erase old ledmap, just in case.
if (customMappingTable != nullptr) delete[] customMappingTable;
customMappingTable = nullptr;
customMappingSize = 0;
if (reset) { //WLEDMM: add reset option to switch on/off reset of customMappingTable
if (customMappingTable != nullptr) delete[] customMappingTable;
customMappingTable = nullptr;
customMappingSize = 0;
}
if (isMatrix) {
matrixWidth = hPanels * panelW;
@@ -53,8 +55,14 @@ void WS2812FX::setUpMatrix() {
return;
}
customMappingSize = matrixWidth * matrixHeight;
customMappingTable = new uint16_t[customMappingSize];
if (reset) { //WLEDMM: add reset option to switch on/off reset of customMappingTable
customMappingSize = matrixWidth * matrixHeight;
customMappingTable = new uint16_t[customMappingSize];
//WLEDMM: init customMappingTable with a 1:1 mapping (for customMappingTable[customMappingTable[x]])
for (uint16_t i=0; i<customMappingSize; i++) {
customMappingTable[i] = i;
}
}
if (customMappingTable != nullptr) {
uint16_t startL; // index in custom mapping array (logical strip)
@@ -80,7 +88,7 @@ void WS2812FX::setUpMatrix() {
x = (panel[h*j + i].vertical ? panel[h*j + i].bottomStart : panel[h*j + i].rightStart) ? W - k - 1 : k;
x = (panel[h*j + i].serpentine && l%2) ? (W - x - 1) : x;
offset = (panel[h*j + i].vertical ? y : x) + (panel[h*j + i].vertical ? x : y) * matrixWidth;
customMappingTable[startL + offset] = startP + q;
customMappingTable[customMappingTable[startL + offset]] = startP + q; //WLEDMM: allow for 2 transitions if reset = false (ledmap and logical to physical)
}
}
}