Repository navigation
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.
blazoncek
left a comment
There was a problem hiding this comment.
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 🤦 |
| <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.
might be better to put the value in quotes? like value="55"
it might also be possible to use the JS var laprev
There was a problem hiding this comment.
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.
Remove a couple of leftover variables from previous revisions.
enLA(d.Sf["LAsel"+s],s); // update LED mAis 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 👍 |
settings_leds: always initialize current limiter field (partly solves wled#4280 )

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
LAselshould that ever change. I couldn't see an easy alternative, though. Suggestions welcome!