Merge remote-tracking branch 'origin/ac_main' into mdev
This commit is contained in:
@@ -29,8 +29,8 @@
|
||||
// setUpMatrix() - constructs ledmap array from matrix of panels with WxH pixels
|
||||
// this converts physical (possibly irregular) LED arrangement into well defined
|
||||
// array of logical pixels: fist entry corresponds to left-topmost logical pixel
|
||||
// followed by horizontal pixels, when matrixWidth logical pixels are added they
|
||||
// are followed by next row (down) of matrixWidth pixels (and so forth)
|
||||
// followed by horizontal pixels, when Segment::maxWidth logical pixels are added they
|
||||
// are followed by next row (down) of Segment::maxWidth pixels (and so forth)
|
||||
// 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
|
||||
@@ -43,20 +43,21 @@ void WS2812FX::setUpMatrix(bool reset) {
|
||||
customMappingSize = 0;
|
||||
}
|
||||
|
||||
// isMatrix is set in cfg.cpp or set.cpp
|
||||
if (isMatrix) {
|
||||
matrixWidth = hPanels * panelW;
|
||||
matrixHeight = vPanels * panelH;
|
||||
Segment::maxWidth = hPanels * panelW;
|
||||
Segment::maxHeight = vPanels * panelH;
|
||||
|
||||
// safety check
|
||||
if (matrixWidth * matrixHeight > MAX_LEDS) {
|
||||
matrixWidth = _length;
|
||||
matrixHeight = 1;
|
||||
if (Segment::maxWidth * Segment::maxHeight > MAX_LEDS || Segment::maxWidth == 1 || Segment::maxHeight == 1) {
|
||||
Segment::maxWidth = _length;
|
||||
Segment::maxHeight = 1;
|
||||
isMatrix = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (reset) { //WLEDMM: add reset option to switch on/off reset of customMappingTable
|
||||
customMappingSize = matrixWidth * matrixHeight;
|
||||
customMappingSize = Segment::maxWidth * Segment::maxHeight;
|
||||
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++) {
|
||||
@@ -77,7 +78,7 @@ void WS2812FX::setUpMatrix(bool reset) {
|
||||
x = (matrix.vertical ? matrix.bottomStart : matrix.rightStart) ? h - i - 1 : i;
|
||||
x = matrix.serpentine && j%2 ? h - x - 1 : x;
|
||||
|
||||
startL = (matrix.vertical ? y : x) * panelW + (matrix.vertical ? x : y) * matrixWidth * panelH; // logical index (top-left corner)
|
||||
startL = (matrix.vertical ? y : x) * panelW + (matrix.vertical ? x : y) * Segment::maxWidth * panelH; // logical index (top-left corner)
|
||||
startP = p * panelW * panelH; // physical index (top-left corner)
|
||||
|
||||
uint8_t H = panel[h*j + i].vertical ? panelW : panelH;
|
||||
@@ -87,7 +88,7 @@ void WS2812FX::setUpMatrix(bool reset) {
|
||||
y = (panel[h*j + i].vertical ? panel[h*j + i].rightStart : panel[h*j + i].bottomStart) ? H - l - 1 : l;
|
||||
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;
|
||||
offset = (panel[h*j + i].vertical ? y : x) + (panel[h*j + i].vertical ? x : y) * Segment::maxWidth;
|
||||
customMappingTable[customMappingTable[startL + offset]] = startP + q; //WLEDMM: allow for 2 transitions if reset = false (ledmap and logical to physical)
|
||||
}
|
||||
}
|
||||
@@ -96,22 +97,22 @@ void WS2812FX::setUpMatrix(bool reset) {
|
||||
#ifdef WLED_DEBUG
|
||||
DEBUG_PRINT(F("Matrix ledmap:"));
|
||||
for (uint16_t i=0; i<customMappingSize; i++) {
|
||||
if (!(i%matrixWidth)) DEBUG_PRINTLN();
|
||||
if (!(i%Segment::maxWidth)) DEBUG_PRINTLN();
|
||||
DEBUG_PRINTF("%4d,", customMappingTable[i]);
|
||||
}
|
||||
DEBUG_PRINTLN();
|
||||
#endif
|
||||
} else {
|
||||
// memory allocation error
|
||||
matrixWidth = _length;
|
||||
matrixHeight = 1;
|
||||
Segment::maxWidth = _length;
|
||||
Segment::maxHeight = 1;
|
||||
isMatrix = false;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// not a matrix set up
|
||||
matrixWidth = _length;
|
||||
matrixHeight = 1;
|
||||
Segment::maxWidth = _length;
|
||||
Segment::maxHeight = 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -121,7 +122,7 @@ void IRAM_ATTR_YN WS2812FX::setPixelColorXY(int x, int y, uint32_t col) //WLEDMM
|
||||
{
|
||||
#ifndef WLED_DISABLE_2D
|
||||
if (!isMatrix) return; // not a matrix set-up
|
||||
uint16_t index = y * matrixWidth + x;
|
||||
uint16_t index = y * Segment::maxWidth + x;
|
||||
if (index >= customMappingSize) return; // customMappingSize is always W * H of matrix in 2D setup
|
||||
#else
|
||||
uint16_t index = x;
|
||||
@@ -134,7 +135,7 @@ void IRAM_ATTR_YN WS2812FX::setPixelColorXY(int x, int y, uint32_t col) //WLEDMM
|
||||
// returns RGBW values of pixel
|
||||
uint32_t WS2812FX::getPixelColorXY(uint16_t x, uint16_t y) {
|
||||
#ifndef WLED_DISABLE_2D
|
||||
uint16_t index = (y * matrixWidth + x);
|
||||
uint16_t index = (y * Segment::maxWidth + x);
|
||||
if (index >= customMappingSize) return 0; // customMappingSize is always W * H of matrix in 2D setup
|
||||
#else
|
||||
uint16_t index = x;
|
||||
@@ -159,7 +160,7 @@ uint16_t IRAM_ATTR_YN Segment::XY(uint16_t x, uint16_t y) { //WLEDMM: IRAM_ATTR
|
||||
|
||||
void IRAM_ATTR_YN Segment::setPixelColorXY(int x, int y, uint32_t col) //WLEDMM: IRAM_ATTR conditionaly
|
||||
{
|
||||
if (!strip.isMatrix) return; // not a matrix set-up
|
||||
if (Segment::maxHeight==1) return; // not a matrix set-up
|
||||
if (x >= virtualWidth() || y >= virtualHeight() || x<0 || y<0) return; // if pixel would fall out of virtual segment just exit
|
||||
|
||||
if (leds) leds[XY(x,y)] = col;
|
||||
@@ -206,7 +207,7 @@ void IRAM_ATTR_YN Segment::setPixelColorXY(int x, int y, uint32_t col) //WLEDMM:
|
||||
// anti-aliased version of setPixelColorXY()
|
||||
void Segment::setPixelColorXY(float x, float y, uint32_t col, bool aa)
|
||||
{
|
||||
if (!strip.isMatrix) return; // not a matrix set-up
|
||||
if (Segment::maxHeight==1) return; // not a matrix set-up
|
||||
if (x<0.0f || x>1.0f || y<0.0f || y>1.0f) return; // not normalized
|
||||
|
||||
const uint16_t cols = virtualWidth();
|
||||
|
||||
Reference in New Issue
Block a user