-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
settings_leds: Initialize current limiter field #4336
settings_leds: Initialize current limiter field #4336
Conversation
When adding a new bus, the numeric current limit field was not being initialized; this was causing it to save 0 when saved instead of the default 55mA value.
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.
Another option, I think, is to set min
value to 0 or call enLA()
after new bus is added.
Otherwise looks good as in case limiter isn't enabled this field is not used.
@willmmiles unfortunately this is not working with my example cfg.json. |
@willmmiles i'm getting this error in MSEdge dev tools: I think the div ID is called "psu" (lower) not "PSU" (upper) |
nevermind ... my error. I've accidentally deleted a quote when manually applying your patch 🤦 |
wled00/data/settings_leds.htm
Outdated
@@ -422,7 +422,7 @@ | |||
<option value="15">15mA (seed/fairy pixels)</option> | |||
<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="LAdis${s}" style="display: none;">max. mA/LED: <input name="LA${s}" type="number" min="1" max="255" oninput="UI()" value=55> mA<br></div> |
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.
might be better to put the value in quotes? like value="55"
it might also be possible to use the JS var laprev
WLED/wled00/data/settings_leds.htm
Line 9 in 99427c2
var laprev=55,maxB=1,maxD=1,maxA=1,maxV=0,maxM=4000,maxPB=2048,maxL=1664,maxCO=5,maxLbquot=0; //maximum bytes for LED allocation: 4kB for 8266, 32kB for 32 |
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.
might be better to put the value in quotes? like value="55"
I should've looked that up; I'd assumed a numeric field required a numeric value, but you're right - it should be quoted.
it might also be possible to use the JS var laprev
Oooh, good catch! This variable is never used - perhaps the intent was to make the next new bus inherit the values from the previous one, which is a reasonable default. I'm inclined to remove it for now - that's beyond my level of JS skill, especially given the upcoming release - but leave an issue entry for the duplication behaviour for the future.
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.
My testcase works now (after fixing my own stupid mistake when manually patching settings_leds.htm)
Remove a couple of leftover variables from previous revisions.
enLA(d.Sf["LAsel"+s],s); // update LED mA is needed just before This will fill whatever is selected as a default LED mA. |
Supersedes previous approach; this should use less space and be more robust to future changes.
Last update works in my test, too. PR is ready to merge 👍 |
When adding a new bus, the numeric current limit field was not being initialized; this was causing it to send an empty value (interpreted as 0) when saved if the current limiter drop-down was never touched.
This is a fix for one of the issues reported in #4280.
While this fix technically works, I'm not really satisfied with it -- it replicates the initialization value, so it has to be kept in sync with
LAsel
should that ever change. I couldn't see an easy alternative, though. Suggestions welcome!