From bafd043aae7a6d9ad12f59623df617abaa462972 Mon Sep 17 00:00:00 2001 From: Max Hedge Date: Mon, 13 Jan 2020 17:09:20 +0000 Subject: [PATCH 1/6] Add WS2815 brightness limiter. Uses "magic value" of 255mA. --- wled00/FX_fcn.cpp | 24 ++++++++++++++++++++---- wled00/data/settings_leds.htm | Bin 16312 -> 16730 bytes wled00/html_settings.h | 3 ++- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 3081c2be..e5d237df 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -201,10 +201,17 @@ void WS2812FX::show(void) { //each LED can draw up 195075 "power units" (approx. 53mA) //one PU is the power it takes to have 1 channel 1 step brighter per brightness step //so A=2,R=255,G=0,B=0 would use 510 PU per LED (1mA is about 3700 PU) - - if (ablMilliampsMax > 149 && milliampsPerLed > 0) //0 mA per LED and too low numbers turn off calculation + bool useWackyWS2815PowerModel = false; + byte actualMilliampsPerLed = milliampsPerLed; + + if(milliampsPerLed == 255) { + useWackyWS2815PowerModel = true; + actualMilliampsPerLed = 12; // from testing an actual strip + } + + if (ablMilliampsMax > 149 && actualMilliampsPerLed > 0) //0 mA per LED and too low numbers turn off calculation { - uint32_t puPerMilliamp = 195075 / milliampsPerLed; + uint32_t puPerMilliamp = 195075 / actualMilliampsPerLed; uint32_t powerBudget = (ablMilliampsMax - MA_FOR_ESP) * puPerMilliamp; //100mA for ESP power if (powerBudget > puPerMilliamp * _length) //each LED uses about 1mA in standby, exclude that from power budget { @@ -219,9 +226,18 @@ void WS2812FX::show(void) { for (uint16_t i = 0; i < _length; i++) //sum up the usage of each LED { RgbwColor c = bus->GetPixelColorRgbw(i); - powerSum += (c.R + c.G + c.B + c.W); + + if(useWackyWS2815PowerModel) + { + powerSum += (max(max(max(c.R,c.G),c.B),c.W)) * 3; + } + else + { + powerSum += (c.R + c.G + c.B + c.W); + } } + if (_rgbwMode) //RGBW led total output with white LEDs enabled is still 50mA, so each channel uses less { powerSum *= 3; diff --git a/wled00/data/settings_leds.htm b/wled00/data/settings_leds.htm index 450512b0270776388ca3f5133829d469be188177..e0ebfb0f56f7ad4a0280fbedb2fab1861d831705 100644 GIT binary patch delta 332 zcmdl{f2)acLk1@^Cj;l?a?U`0AkC1>kjPNXkjkLIU^KarQ=idj^LkE37H&?UfC2+A z0~b)KAgiXOErTsc34;ZKpsfW5GZR6(E;Qs0A+GO25&yeyPr`S zBv1y_QUs(kfx_Vo!9e8}KuxBTJ^2k;!3IyR<+qnqU{C`>1qMY7b-Vdzf?XagplOa_ z3Q&hV5Gx^@4CI3x6$TbpV6b9P*jz0zU25_J1D46p3=}3iX&XS@{&DKXfg8K40+ YBA3CDL347Uf%xPFT6&uoXiJCy0B9FGk^lez delta 80 zcmccB#JHn=Lk8#M6&zBN%Q)SDw7_N+t{cpg_p$LzuHX@vEXJz0c@|$E LED Settings -