Skip to content

Commit 2022558

Browse files
committed
fix errors when width>255 or height>255
some effects still don't work when x y dimensions do not fit into 8bit
1 parent df9b1a4 commit 2022558

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

wled00/FX.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8421,7 +8421,7 @@ uint16_t mode_2Doctopus() {
84218421

84228422
const uint16_t cols = SEGMENT.virtualWidth();
84238423
const uint16_t rows = SEGMENT.virtualHeight();
8424-
const uint8_t mapp = 180 / MAX(cols,rows);
8424+
const uint16_t mapp = max(1, 180 / MAX(cols,rows)); // WLEDMM make sure this value is not 0
84258425

84268426
typedef struct {
84278427
uint8_t angle;
@@ -8458,8 +8458,8 @@ uint16_t mode_2Doctopus() {
84588458
SEGENV.aux1 = rows;
84598459
*offsX = SEGMENT.custom1;
84608460
*offsY = SEGMENT.custom2;
8461-
const uint8_t C_X = cols / 2 + (SEGMENT.custom1 - 128)*cols/255;
8462-
const uint8_t C_Y = rows / 2 + (SEGMENT.custom2 - 128)*rows/255;
8461+
const uint16_t C_X = cols / 2 + (SEGMENT.custom1 - 128)*cols/255;
8462+
const uint16_t C_Y = rows / 2 + (SEGMENT.custom2 - 128)*rows/255;
84638463
for (int x = xStart; x < xEnd; x++) {
84648464
for (int y = yStart; y < yEnd; y++) {
84658465
rMap[XY(x, y)].angle = int(40.7436f * atan2f((y - C_Y), (x - C_X))); // avoid 128*atan2()/PI

wled00/FX.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,8 @@ typedef struct Segment {
390390
bool check2 : 1; // checkmark 2
391391
bool check3 : 1; // checkmark 3
392392
};
393-
uint8_t startY; // start Y coodrinate 2D (top); there should be no more than 255 rows
394-
uint8_t stopY; // stop Y coordinate 2D (bottom); there should be no more than 255 rows
393+
uint16_t startY; // start Y coodrinate 2D (top); there should be no more than 255 rows, but we cannot be sure.
394+
uint16_t stopY; // stop Y coordinate 2D (bottom); there should be no more than 255 rows, but we cannot be sure.
395395
char *name = nullptr; // WLEDMM initialize to nullptr
396396

397397
// runtime data
@@ -1017,10 +1017,10 @@ class WS2812FX { // 96 bytes
10171017
} panelO; //panelOrientation
10181018

10191019
typedef struct panel_t {
1020-
uint8_t xOffset; // x offset relative to the top left of matrix in LEDs. WLEDMM 8 bits/256 is enough
1021-
uint8_t yOffset; // y offset relative to the top left of matrix in LEDs. WLEDMM 8 bits/256 is enough
1022-
uint8_t width; // width of the panel
1023-
uint8_t height; // height of the panel
1020+
uint16_t xOffset; // x offset relative to the top left of matrix in LEDs.
1021+
uint16_t yOffset; // y offset relative to the top left of matrix in LEDs.
1022+
uint16_t width; // width of the panel
1023+
uint16_t height; // height of the panel
10241024
union {
10251025
uint8_t options;
10261026
struct {

wled00/FX_2Dfcn.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,11 @@ void WS2812FX::setUpMatrix() {
129129
}
130130

131131
if (needLedMap && customMappingTable != nullptr) { // softhack007
132-
uint16_t x, y, pix=0; //pixel
132+
uint_fast16_t x, y, pix=0; //pixel
133133
for (size_t pan = 0; pan < panel.size(); pan++) {
134134
Panel &p = panel[pan];
135-
uint16_t h = p.vertical ? p.height : p.width;
136-
uint16_t v = p.vertical ? p.width : p.height;
135+
uint_fast16_t h = p.vertical ? p.height : p.width;
136+
uint_fast16_t v = p.vertical ? p.width : p.height;
137137
for (size_t j = 0; j < v; j++){
138138
for(size_t i = 0; i < h; i++) {
139139
y = (p.vertical?p.rightStart:p.bottomStart) ? v-j-1 : j;

wled00/data/settings_2D.htm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@
111111
<option value="1">Vertical</option>
112112
</select><br>
113113
Serpentine: <input id="P${i}S" name="P${i}S" type="checkbox" onclick="draw()"><br>
114-
Dimensions (WxH): <input id="P${i}W" name="P${i}W" type="number" min="1" max="255" value="${pw}" oninput="draw()"> x <input id="P${i}H" name="P${i}H" type="number" min="1" max="255" value="${ph}" oninput="draw()"><br>
115-
Offset X:<input id="P${i}X" name="P${i}X" type="number" min="0" max="255" value="0" oninput="draw()">
116-
Y:<input id="P${i}Y" name="P${i}Y" type="number" min="0" max="255" value="0" oninput="draw()"><br><i>(offset from top-left corner in # LEDs)</i>
114+
Dimensions (WxH): <input id="P${i}W" name="P${i}W" type="number" min="1" max="1023" value="${pw}" oninput="draw()"> x <input id="P${i}H" name="P${i}H" type="number" min="1" max="1023" value="${ph}" oninput="draw()"><br>
115+
Offset X:<input id="P${i}X" name="P${i}X" type="number" min="0" max="1023" value="0" oninput="draw()">
116+
Y:<input id="P${i}Y" name="P${i}Y" type="number" min="0" max="1023" value="0" oninput="draw()"><br><i>(offset from top-left corner in # LEDs)</i>
117117
</div>`;
118118
p.insertAdjacentHTML("beforeend", b);
119119
}
@@ -401,7 +401,7 @@ <h3 id="title">Matrix Setup</h3>
401401
<h3 id="title">Matrix Generator <button type="button" id="expGen" onclick="expand(this,gId('mxGen'));">&gt;</button></h3>
402402
</div>
403403
<div id="mxGen" style="display:none;">
404-
Panel dimensions (WxH): <input name="PW" type="number" min="1" max="255" value="8" oninput="fieldChange()"> x <input name="PH" type="number" min="1" max="255" value="8" oninput="fieldChange()"><br>
404+
Panel dimensions (WxH): <input name="PW" type="number" min="1" max="1023" value="8" oninput="fieldChange()"> x <input name="PH" type="number" min="1" max="1023" value="8" oninput="fieldChange()"><br>
405405
Horizontal panels: <input name="MPH" type="number" min="1" max="8" value="1" oninput="fieldChange()">
406406
Vertical panels: <input name="MPV" type="number" min="1" max="8" value="1" oninput="fieldChange()"><br>
407407
<div id="blockPanelOrientation">

wled00/wled.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99

1010
// version code in format yymmddb (b = daily build)
11-
#define VERSION 2411080
11+
#define VERSION 2411130
1212

1313
// WLEDMM - you can check for this define in usermods, to only enabled WLEDMM specific code in the "right" fork. Its not defined in AC WLED.
1414
#define _MoonModules_WLED_

0 commit comments

Comments
 (0)