Skip to content

settings_leds: Initialize current limiter field - #4336

Merged
softhack007 merged 4 commits into
wled:0_15from
willmmiles:4280-limiter-not-saving
Dec 5, 2024
Merged

softhack007 merged 4 commits into
wled:0_15from
willmmiles:4280-limiter-not-saving

Conversation

@willmmiles

@willmmiles willmmiles commented Dec 1, 2024 •

Copy link
Copy Markdown
Member

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!

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 blazoncek left a comment

Copy link
Copy Markdown
Contributor

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.

@softhack007

Copy link
Copy Markdown
Member

@willmmiles unfortunately this is not working with my example cfg.json.
I'll do some more tests to find out what's happening.

@softhack007

Copy link
Copy Markdown
Member

@willmmiles i'm getting this error in MSEdge dev tools:

image

I think the div ID is called "psu" (lower) not "PSU" (upper)

@softhack007

softhack007 commented Dec 2, 2024 •

Copy link
Copy Markdown
Member

@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 🤦

Comment thread wled00/data/settings_leds.htm Outdated
<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>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

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.

@softhack007 softhack007 left a comment •

Copy link
Copy Markdown
Member

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.
@blazoncek

Copy link
Copy Markdown
Contributor
enLA(d.Sf["LAsel"+s],s); // update LED mA

is needed just before // disable inappropriate LED types in addLEDs().

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.
@softhack007

Copy link
Copy Markdown
Member

Last update works in my test, too. PR is ready to merge 👍

@softhack007
softhack007 merged commit 36e065a into wled:0_15 Dec 5, 2024
aenertia pushed a commit to aenertia/WLED that referenced this pull request Aug 18, 2026
settings_leds: always initialize current limiter field (partly solves wled#4280 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants