Skip to content

LED Settings UI "Custom bus start indices:" and output "Start:" options always revert to defaults if ABL is disabled #3632

@RussellAult

Description

@RussellAult

What happened?

If ABL is disabled, the "Custom bus start indices:" and output "Start:" options in the LED Settings UI revert to their defaults every time the /settings/leds page is loaded (including after hitting the "Save" button)

To Reproduce Bug

  1. Navigate to /settings/leds in a web browser
  2. Uncheck the box beside "Enable automatic brightness limiter:"
  3. Set output 1 "Length:" to 1
  4. Create a second output
  5. Check the box beside "Custom bus start indices:"; the "Start:" entry for each output becomes enabled
  6. Set output 2 "Start:" to 100
  7. Hit the "Save" button; notice that the check the box beside "Custom bus start indices:" has reset to unchecked, the "Start:" entry for each output is disabled, and the output 2 "Start:" value has reset itself to 1 (i.e. the defaults)
  8. Navigate to /settings/sec in a web browser
  9. Hit the "Backup configuration" button; notice in cfg.json that the second {} in the {"hw":{"led":{"ins":[]}}} array has "start":100 (i.e. the settings have been stored correctly)

Expected Behavior

The "Custom bus start indices:" and output "Start:" options in the Settings UI reflect the start settings stored in the configuration

Install Method

Binary from WLED.me

What version of WLED?

WLED 0.14.1-b2 (build 2312290)

Which microcontroller/board are you seeing the problem on?

ESP32

Relevant log/trace output

No response

Anything else?

If I'm understanding this correctly, the issue is that the checkSi() function is using the start and length values displayed on the page (instead of the values actually stored in the configuration) to determine whether or not customStarts should be true. Because customStarts is initially declared as false, anything calling the UI() function before checkSi() has had a chance to run will result in the start values being recalculate (which, in turn, will result in checkSi() finding no "custom starts", since the data its checking has now been overwritten).

As it so happens, setting "Enable automatic brightness limiter:" to false does exactly this: the setABL() function (called just before checkSi() during the load event) calls the enABL() function if ABL is disabled, and enABL() in turn calls UI(), causing the start values to be recalculated before checkSi() has had a chance to run.

In theory the solution could be as simple as reversing the order of https://github.com/Aircoookie/WLED/blob/e8b3c66c215665f68e1706e50a71a0e64dd461fb/wled00/data/settings_leds.htm#L29-L30
...but given that declaring customStarts as false creates the potential for data loss, I'd suggest a more robust solution would be to modify https://github.com/Aircoookie/WLED/blob/e8b3c66c215665f68e1706e50a71a0e64dd461fb/wled00/data/settings_leds.htm#L13
so that customStarts=true, and then letting checkSi() establish the setting default of false after it's had the opportunity to run (which it's actually already doing). In theory, declaring customStarts to true should ensure that nothing will cause the start values to be recalculated before checkSi() has had a chance to run regardless of load event execution order.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugfixed in sourceThis issue is unsolved in the latest release but fixed in master

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions