-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
FEATURE: WLED Power Consumption in JSON API #5261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 6 commits
a80fe6e
949e3a7
c8794ec
59d6190
7b55a15
8a0603e
3b63054
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -133,11 +133,19 @@ | |
| } | ||
| } | ||
| } | ||
| function enPM() | ||
| { | ||
| var en = d.Sf.PM.checked; | ||
| gId('pwrmon').style.display = (en) ? 'inline':'none'; | ||
| gId('pmwarn').style.display = (en && !d.Sf.ABL.checked) ? 'inline':'none'; | ||
| } | ||
| function enABL() | ||
| { | ||
| var en = d.Sf.ABL.checked; | ||
| gId('abl').style.display = (en) ? 'inline':'none'; | ||
| gId('psu2').style.display = (en) ? 'inline':'none'; | ||
| // Change power monitoring warning visibility (hide if ABL is enabled - calculations already running) | ||
| if (d.Sf.PM.checked) gId('pmwarn').style.display = (!en) ? 'inline':'none'; | ||
| if (!en) { | ||
| // limiter disabled | ||
| d.Sf.PPL.checked = false; | ||
|
|
@@ -172,11 +180,10 @@ | |
| // enable and update LED Amps | ||
| function enLA(s,n) | ||
| { | ||
| const abl = d.Sf.ABL.checked; | ||
| const t = parseInt(d.Sf["LT"+n].value); // LED type SELECT | ||
| gId('LAdis'+n).style.display = s.selectedIndex==5 ? "inline" : "none"; // show/hide custom mA field | ||
| if (s.value!=="0") d.Sf["LA"+n].value = s.value; // set value from select object | ||
| d.Sf["LA"+n].min = (!isDig(t) || !abl) ? 0 : 1; // set minimum value for validation | ||
| d.Sf["LA"+n].min = (!isDig(t)) ? 0 : 1; // set minimum value for validation (required for power monitoring) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there is a reason the field is hidden if its not used - to not confuse unexperienced users (which there are a lot of)
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. made it appear only when the abl/power fields are selected |
||
| } | ||
| function setABL() | ||
| { | ||
|
|
@@ -202,6 +209,7 @@ | |
| else sel.value = 0; | ||
| enLA(sel,n); // configure individual limiter | ||
| }); | ||
| enPM(); | ||
| enABL(); | ||
| gId('m1').innerHTML = maxM; | ||
| } | ||
|
|
@@ -287,11 +295,11 @@ | |
| memu += getMem(t, n); // calc memory | ||
| dC += (isDig(t) && !isD2P(t)); | ||
| setPinConfig(n,t); | ||
| gId("abl"+n).style.display = (!abl || !isDig(t)) ? "none" : "inline"; // show/hide individual ABL settings | ||
| gId("dig"+n+"ma").style.display = isDig(t) ? "inline" : "none"; // show mA/LED for digital LEDs (for power monitoring) | ||
| if (change) { // did we change LED type? | ||
| gId("rf"+n).checked = (gId("rf"+n).checked || t == 31); // LEDs require data in off state (mandatory for TM1814) | ||
| if (isAna(t)) d.Sf["LC"+n].value = 1; // for sanity change analog count just to 1 LED | ||
| d.Sf["LA"+n].min = (!isDig(t) || !abl) ? 0 : 1; // set minimum value for LED mA | ||
| d.Sf["LA"+n].min = (!isDig(t)) ? 0 : 1; // set minimum value for LED mA (always required for power monitoring) | ||
| d.Sf["MA"+n].min = (!isDig(t)) ? 0 : 250; // set minimum value for PSU mA | ||
| } | ||
| gId("rf"+n).onclick = mustR(t) ? (()=>{return false}) : (()=>{}); // prevent change change of "Refresh" checkmark when mandatory | ||
|
|
@@ -469,7 +477,7 @@ | |
| <hr class="sml"> | ||
| ${i+1}: | ||
| <select name="LT${s}" onchange="updateTypeDropdowns();UI(true)"></select><br> | ||
| <div id="abl${s}"> | ||
| <div id="dig${s}ma" style="display:none"> | ||
| mA/LED: <select name="LAsel${s}" onchange="enLA(this,'${s}');UI();"> | ||
| <option value="55" selected>55mA (typ. 5V WS281x)</option> | ||
| <option value="35">35mA (eco WS2812)</option> | ||
|
|
@@ -479,8 +487,8 @@ | |
| <option value="0">Custom</option> | ||
| </select><br> | ||
| <div id="LAdis${s}" style="display: none;">max. mA/LED: <input name="LA${s}" type="number" min="1" max="255" oninput="UI()"> mA<br></div> | ||
| <div id="PSU${s}">PSU: <input name="MA${s}" type="number" class="xl" min="250" max="65000" oninput="UI()" value="250"> mA<br></div> | ||
| </div> | ||
| <div id="PSU${s}">PSU: <input name="MA${s}" type="number" class="xl" min="250" max="65000" oninput="UI()" value="250"> mA<br></div> | ||
| <div id="co${s}" style="display:inline">Color Order: | ||
| <select name="CO${s}"> | ||
| <option value="0">GRB</option> | ||
|
|
@@ -695,6 +703,7 @@ | |
| }); | ||
| d.getElementsByName("PR")[0].checked = l.prl | 0; | ||
| d.getElementsByName("MA")[0].value = l.maxpwr; | ||
| if (l.voltage) d.getElementsByName("LV")[0].value = l.voltage; | ||
| d.getElementsByName("ABL")[0].checked = l.maxpwr > 0; | ||
| } | ||
| if(c.hw.com) { | ||
|
|
@@ -868,6 +877,12 @@ <h2>LED & Hardware setup</h2> | |
| <b><span id="psu">?</span></b><br> | ||
| <span id="psu2"><br></span> | ||
| <br> | ||
| Enable power monitoring: <input type="checkbox" name="PM" onchange="enPM()"><br> | ||
| <div id="pwrmon" style="display:none"> | ||
| LED Strip Voltage: <input name="LV" type="number" class="m" step="1" min="1" max="50" value="5" oninput="UI()"> V<br> | ||
| <i>Exposes power in API. Typical: 5V (WS281x), 12V/24V (others)</i><br> | ||
| <i id="pmwarn" class="warn">⚠ CPU intensive, may reduce FPS</i><br> | ||
| </div> | ||
| Enable automatic brightness limiter: <input type="checkbox" name="ABL" onchange="enABL()"><br> | ||
| <div id="abl"> | ||
| <i>Automatically limits brightness to stay close to the limit.<br> | ||
|
|
@@ -880,6 +895,7 @@ <h2>LED & Hardware setup</h2> | |
| <i>Make sure you enter correct value for each LED output.<br> | ||
| If using multiple outputs with only one PSU, distribute its power proportionally amongst outputs.</i><br> | ||
| </div> | ||
| <i class="warn">⚠ CPU intensive, may reduce FPS</i><br> | ||
| <div id="ampwarning" class="warn" style="display: none;"> | ||
| ⚠ Your power supply provides high current.<br> | ||
| To improve the safety of your setup,<br> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -147,6 +147,11 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) | |
| unsigned ablMilliampsMax = request->arg(F("MA")).toInt(); | ||
| BusManager::setMilliampsMax(ablMilliampsMax); | ||
|
|
||
| uint8_t ledVoltage = request->arg(F("LV")).toInt(); | ||
| if (ledVoltage > 0 && ledVoltage <= 50) BusManager::setVoltage(ledVoltage); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why restrict to 50?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could only find 48v leds (UCS2903). So 50V seemed like an appropriate choice.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if there is no technical reason, leave it to the user. there may be 120V strips one day, who knows.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed this check. In html bumped up to 255. |
||
|
|
||
| BusManager::enablePowerMonitoring(request->hasArg(F("PM"))); | ||
|
|
||
| strip.autoSegments = request->hasArg(F("MS")); | ||
| strip.correctWB = request->hasArg(F("CCT")); | ||
| strip.cctFromRgb = request->hasArg(F("CR")); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no need for code duplication, just adjust the logic above:
if (_useABL || _usePowerMonitoring)and
if (_gMilliAmpsMax > 0 && _useABL)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed, but still needed to do this:
because we need to reset _colorSum independently from abl process (it will accumulate over time making wrong calculations)