Merge remote-tracking branch 'origin/ac_main' into mdev

This commit is contained in:
Ewoud
2023-01-02 21:05:03 +01:00
37 changed files with 4740 additions and 4253 deletions

View File

@@ -43,29 +43,35 @@ void WS2812FX::setUpMatrix(bool reset) {
customMappingSize = 0;
}
// important if called from set.cpp, irrelevant if called from cfg.cpp
// fix limits if not a matrix set-up (no finalizeInit() called from set.cpp)
Segment::maxWidth = _length;
Segment::maxHeight = 1;
// isMatrix is set in cfg.cpp or set.cpp
if (isMatrix) {
Segment::maxWidth = hPanels * panelW;
Segment::maxHeight = vPanels * panelH;
uint16_t maxWidth = hPanels * panelW;
uint16_t maxHeight = vPanels * panelH;
// safety check
if (Segment::maxWidth * Segment::maxHeight > MAX_LEDS || Segment::maxWidth == 1 || Segment::maxHeight == 1) {
Segment::maxWidth = _length;
Segment::maxHeight = 1;
if (maxWidth * maxHeight > MAX_LEDS || maxWidth == 1 || maxHeight == 1) {
isMatrix = false;
return;
}
if (reset) { //WLEDMM: add reset option to switch on/off reset of customMappingTable
customMappingSize = Segment::maxWidth * Segment::maxHeight;
customMappingTable = new uint16_t[customMappingSize];
customMappingTable = new uint16_t[maxWidth * maxHeight];
//WLEDMM: init customMappingTable with a 1:1 mapping (for customMappingTable[customMappingTable[x]])
for (uint16_t i=0; i<customMappingSize; i++) {
for (uint16_t i=0; i<maxWidth * maxHeight; i++) {
customMappingTable[i] = i;
}
}
if (customMappingTable != nullptr) {
Segment::maxWidth = maxWidth;
Segment::maxHeight = maxHeight;
customMappingSize = maxWidth * maxHeight;
uint16_t startL; // index in custom mapping array (logical strip)
uint16_t startP; // position of 1st pixel of panel on (virtual) strip
uint16_t x, y, offset;
@@ -102,18 +108,12 @@ void WS2812FX::setUpMatrix(bool reset) {
}
DEBUG_PRINTLN();
#endif
} else {
// memory allocation error
Segment::maxWidth = _length;
Segment::maxHeight = 1;
} else { // memory allocation error
isMatrix = false;
return;
}
} else {
// not a matrix set up
Segment::maxWidth = _length;
Segment::maxHeight = 1;
}
#else
isMatrix = false; // no matter what config says
#endif
}