From 34f4905e0b941c22f631d33dac95cd1f87987f71 Mon Sep 17 00:00:00 2001 From: Frank Date: Thu, 18 Apr 2024 23:23:52 +0200 Subject: [PATCH] bugfix for 2D Sun Radiation size of the sun was very small on larger fixtures --- wled00/FX.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index f241a457..075a2ba9 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -5818,6 +5818,8 @@ uint16_t mode_2DSunradiation(void) { // By: ldirko https://edi const uint16_t cols = SEGMENT.virtualWidth(); const uint16_t rows = SEGMENT.virtualHeight(); + const int minSize = min(cols, rows); // WLEDMM + const int magnify = (minSize <= 32) ? 8 : 46; // WLEDMM if (!SEGENV.allocateData(sizeof(byte)*(cols+2)*(rows+2))) return mode_static(); //allocation failed byte *bump = reinterpret_cast(SEGENV.data); @@ -5846,10 +5848,10 @@ uint16_t mode_2DSunradiation(void) { // By: ldirko https://edi ++vlx; int8_t nx = bump[x + yindex + 1] - bump[x + yindex - 1]; int8_t ny = bump[x + yindex + (cols + 2)] - bump[x + yindex - (cols + 2)]; - byte difx = abs8(vlx * 7 - nx); - byte dify = abs8(vly * 7 - ny); + byte difx = min(abs(vlx * 7 - nx), 255); // WLEDMM replaced abs8 as it does not work for numbers >127 + byte dify = min(abs(vly * 7 - ny), 255); // WLEDMM int temp = difx * difx + dify * dify; - int col = 255 - temp / 8; //8 its a size of effect + int col = 255 - temp / magnify; //8 its a size of effect // WLEDMM size adjusts to matrix dimensions if (col < 0) col = 0; SEGMENT.setPixelColorXY(x, y, HeatColor(col / (3.0f-(float)(SEGMENT.intensity)/128.f))); }