Skip to content
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

Merged
merged 4 commits into from
Dec 5, 2024

Conversation

willmmiles
Copy link
Collaborator

@willmmiles willmmiles commented Dec 1, 2024

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.
Copy link
Collaborator

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

@softhack007
Copy link
Collaborator

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

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

image

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

@softhack007
Copy link
Collaborator

softhack007 commented Dec 2, 2024

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

@@ -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>
Copy link
Collaborator

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

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

Copy link
Collaborator 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.

Copy link
Collaborator

@softhack007 softhack007 left a 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.
@blazoncek
Copy link
Collaborator

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
Collaborator

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

@softhack007 softhack007 merged commit 36e065a into Aircoookie:0_15 Dec 5, 2024
19 checks passed
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