Skip to content

Commit 34f4905

Browse files
committed
bugfix for 2D Sun Radiation
size of the sun was very small on larger fixtures
1 parent a5b07bc commit 34f4905

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

wled00/FX.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5818,6 +5818,8 @@ uint16_t mode_2DSunradiation(void) { // By: ldirko https://edi
58185818

58195819
const uint16_t cols = SEGMENT.virtualWidth();
58205820
const uint16_t rows = SEGMENT.virtualHeight();
5821+
const int minSize = min(cols, rows); // WLEDMM
5822+
const int magnify = (minSize <= 32) ? 8 : 46; // WLEDMM
58215823

58225824
if (!SEGENV.allocateData(sizeof(byte)*(cols+2)*(rows+2))) return mode_static(); //allocation failed
58235825
byte *bump = reinterpret_cast<byte*>(SEGENV.data);
@@ -5846,10 +5848,10 @@ uint16_t mode_2DSunradiation(void) { // By: ldirko https://edi
58465848
++vlx;
58475849
int8_t nx = bump[x + yindex + 1] - bump[x + yindex - 1];
58485850
int8_t ny = bump[x + yindex + (cols + 2)] - bump[x + yindex - (cols + 2)];
5849-
byte difx = abs8(vlx * 7 - nx);
5850-
byte dify = abs8(vly * 7 - ny);
5851+
byte difx = min(abs(vlx * 7 - nx), 255); // WLEDMM replaced abs8 as it does not work for numbers >127
5852+
byte dify = min(abs(vly * 7 - ny), 255); // WLEDMM
58515853
int temp = difx * difx + dify * dify;
5852-
int col = 255 - temp / 8; //8 its a size of effect
5854+
int col = 255 - temp / magnify; //8 its a size of effect // WLEDMM size adjusts to matrix dimensions
58535855
if (col < 0) col = 0;
58545856
SEGMENT.setPixelColorXY(x, y, HeatColor(col / (3.0f-(float)(SEGMENT.intensity)/128.f)));
58555857
}

0 commit comments

Comments
 (0)