animate PWM dimmer brightness LEDs during transitions and with variable brightness #11076
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
I have several Martin Jerry SD-01 dimmers using the PWM Dimmer module. When adjusting dimmer level either using buttons on the device or by remote command, the brightness LEDs instantly update to the target dimmer level regardless of FADE and SPEED setting. I would prefer the brightness LEDs to follow the brightness of the light controlled by the PWM dimmer over the course of any dimmer adjustment. If the turn-on takes 3 seconds from 0% to 100%, then I want the brightness LEDs to animate up over the course of 3 seconds.
This change ensures the brightness LEDs are updated whenever the PWM's output is changed. Additionally, it uses
analogWrite()
to set a brightness of each individual LED, adjusting the brightness of the "topmost" lit status LED to be proportional to the (marginal) dimmer amount for that LED. For example, if the dimmer is set to 30%, the brightness LEDs would be lit as following::If the dimmer is set to 75%, the brightness LEDs would be lit as following:
Note that since the bottom LED is relay-linked, its brightness is not controllable, so there is no visible animation for dimmer levels 0%-20%.
I posted a short video demonstrating the smooth animation on YouTube:
As this is my first contribution to this project, I've done my best to review the contribution guidelines, but I'm not sure (1) how to do more thorough testing and (2) if the approach I've taken to implementation is correct. I think this is a neat feature that SD-01 dimmer owners will appreciate, so I'm happy to make whatever changes are needed to get it merged in.
Checklist:
NOTE: The code change must pass CI tests. Your PR cannot be merged unless tests pass