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

animate PWM dimmer brightness LEDs during transitions and with variable brightness #11076

Merged
merged 1 commit into from
Feb 21, 2021

Conversation

nohat
Copy link

@nohat nohat commented Feb 21, 2021

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::

            led4 [  0%]  (dimmer levels 81-100)
            led3 [  0%]  (dimmer levels 61-80)
            led2 [  0%]  (dimmer levels 41-60)
            led1 [ 50%]  (dimmer levels 21-40)
relay_linked_led [100%]  (dimmer levels 0–20)

If the dimmer is set to 75%, the brightness LEDs would be lit as following:

            led4 [  0%]  (dimmer levels 81-100)
            led3 [ 75%]  (dimmer levels 61-80)
            led2 [100%]  (dimmer levels 41-60)
            led1 [100%]  (dimmer levels 21-40)
relay_linked_led [100%]  (dimmer levels 0–20)

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:
Watch the video

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:

  • The pull request is done against the latest development branch
  • Only relevant files were touched
  • Only one feature/fix was added per PR and the code change compiles without warnings
  • The code change is tested and works on Tasmota core ESP8266 V.2.7.4.9
  • The code change is tested and works on Tasmota core ESP32 V.1.0.5-rc6
  • I accept the CLA.

NOTE: The code change must pass CI tests. Your PR cannot be merged unless tests pass

@nohat nohat marked this pull request as ready for review February 21, 2021 19:33
@s-hadinger
Copy link
Collaborator

@arendst I don't have this device, but the change looks good to me.

Thanks @nohat

@arendst arendst merged commit 73e2e4f into arendst:development Feb 21, 2021
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