Skip to content

Conversation

@obar
Copy link

@obar obar commented Dec 5, 2024

This usermod lets you make changes to WLED global brightness in 'steps' that are evenly spaced to the human eye.

It lets the user define how many brightness steps to use (up to 32 by default) and what the maximum brightness should be. It also allows for skipping steps at the beginning and end of the range.

The usermod provides JSON API commands to step up and down in brightness, {"pb":"+"} and {"pb":"-"} respectively. It also provides commands to cycle brightness on a button hold, changing directions after a brief button release or optionally changing directions after reaching an extreme without a button release, {"pb":"/"} and {"pb":"~"} respectively.

This usermod adds API commands for changing the global brightness in
steps that look even to the human eye, but in reality are small steps at
the low end and large steps at the high end. There are commands included
to put brightness controls on a single button, ramping the brightness
while the button is held down.
@DedeHai
Copy link
Collaborator

DedeHai commented Dec 5, 2024

thanks for contributing!
question: how is this different to the setting "use gamma correction for brightness"? It uses the CIE brightness formula.

@obar
Copy link
Author

obar commented Dec 5, 2024

Oh that's interesting. Yeah the 'gamma for brightness' is computing brightness basically the same way as this usermod. I'm struggling to recreate the button functionality I've got here without the usermod though. Is there a way to set lower/upper bound and step size in the API brightness command? Ideally I wouldn't want the gamma-adjusted brightness to go below 60 or above 160 on my setup. It seems with this gamma-adjusted brightness there are many low values which aren't really running.

It could be that my usermod's useful bit is press-and-hold button handling for brightness, with max/min/step size and the brightness cycling variations. Or does that make sense as an API extension and not a usermod?

@DedeHai
Copy link
Collaborator

DedeHai commented Dec 5, 2024

I am not familiar enough with JSON commands to say if it is possible. The press end hold for brightness already exists, you just assign a preset to increase or decrease brightness with a defined step size and assign that to "long press" of the button (which still may have a bug, as discussed on discord). So the only thing missing would be to set upper and lower limits, correct?

@blazoncek
Copy link
Contributor

"bri":"w60~160~5"
Buttons 1 and up, have repeating ability built in.

@obar
Copy link
Author

obar commented Dec 5, 2024

Hmm, I tried exactly that API command in a preset and it doesn't work, from 0_15 branch. It works for you @blazoncek?

@blazoncek
Copy link
Contributor

Looks like it is not working for "bri". You can file a bug report.

@blazoncek
Copy link
Contributor

Similar to #3605

@blazoncek
Copy link
Contributor

I have a generic fix. The API is {"bri":"60~160w~5"}.
The previous example is not valid any way.

@obar
Copy link
Author

obar commented Dec 5, 2024

OK so the API call would be different. There is still a bug though, correct? The different API command only sets the brightness to 60 for me.

I'm not even certain it's a bug as I don't see that brightness behavior documented, and I don't see where that code would be from searching the source. At any rate it would be nice to have that in the API.

blazoncek added a commit to blazoncek/WLED that referenced this pull request Dec 5, 2024
- allow incrementing/decrementing as specified in API
@obar
Copy link
Author

obar commented Dec 6, 2024

I just applied your 52e08d2 commit and tried it out with and without wrapping for brightness. Works perfectly! Between that and the gamma correction for brightness feature, my usermod isn't adding much 😁 Will close the pull request. Thanks!

@obar obar closed this Dec 6, 2024
blazoncek added a commit to blazoncek/WLED that referenced this pull request Dec 7, 2024
- allow incrementing/decrementing as specified in API
netmindz added a commit that referenced this pull request Dec 12, 2024
blazoncek added a commit to blazoncek/WLED that referenced this pull request Dec 12, 2024
- allow incrementing/decrementing as specified in API
netmindz added a commit that referenced this pull request Feb 22, 2025
Pluto1010 pushed a commit to Pluto1010/WLED that referenced this pull request Sep 1, 2025
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