HASwitchPlate / openHASP

HomeAutomation Switchplate based on lvgl for ESP32
https://www.openhasp.com
MIT License
695 stars 179 forks source link

On ESP32 fade the backlight #626

Closed presslab-us closed 7 months ago

presslab-us commented 8 months ago

This creates a smooth but fast backlight transition, fading to the new level in 200 milliseconds. Tested on sunton-8048s050c_16MB.

fvanroie commented 7 months ago

I've been testing this feature, but it doesn't seem to work on my ESP32. I had to disable the fade parameter for my backlight to work properly.

I need to send multiple commands for the backlight to dim or power on/off to the set level, which is quite confusing. It seems to be related that the fade cannot be set when another fade is already in progress. This leads to an unpredictable state.

More testing and a fix is needed for this to be enabled by default in the firmware.

presslab-us commented 7 months ago

I've been testing this feature, but it doesn't seem to work on my ESP32. I had to disable the fade parameter for my backlight to work properly.

What display are you testing with?

I need to send multiple commands for the backlight to dim or power on/off to the set level, which is quite confusing.

I'm not sure what you mean, is this something that your particular hardware needs? So you are sending multiple backlight commands in quick succession?

It seems to be related that the fade cannot be set when another fade is already in progress. This leads to an unpredictable state.

I read that the ESP32 hardware does not support cancelling a fade while in progress. But also I read that setting the level to the end-level of the fade in progress will end the fade; maybe this is not working correctly.

Another option is to have a callback for when the fade is complete, which could check if the requested backlight level has changed in the mean time. Maybe this is a more robust approach.

presslab-us commented 7 months ago

The branch below has the changes with the callback. I tested this with a really slow fade time and sent multiple backlight commands. Once the in progress fade completed it then started the latest fade command. I believe it should handle any number of successive commands. If it works for you I could do another pull request? https://github.com/presslab-us/openHASP/tree/backlight_fade_cb

fvanroie commented 7 months ago

Yes, please do a new Pull request. I will test it.