From 82e01f7b17d456bf5e7d7d16a6dd90166d78c981 Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Mon, 17 Jul 2023 16:15:17 +0200 Subject: [PATCH] Fixed ABL calculation. --- wled00/FX_fcn.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 3518e223..5f6fa79f 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -1208,10 +1208,10 @@ uint8_t WS2812FX::estimateCurrentAndLimitBri() { uint8_t newBri = _brightness; if (powerSum * _brightness / 255 > powerBudget) { //scale brightness down to stay in current limit - float scale = (float)powerBudget / (float)powerSum; + float scale = (float)(powerBudget * 255) / (float)(powerSum * _brightness); uint16_t scaleI = scale * 255; uint8_t scaleB = (scaleI > 255) ? 255 : scaleI; - newBri = scale8(_brightness, scaleB); + newBri = scale8(_brightness, scaleB) + 1; } currentMilliamps = (powerSum * newBri) / 255; currentMilliamps += MA_FOR_ESP; //add power of ESP back to estimate