-
Notifications
You must be signed in to change notification settings - Fork 54
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
Dimming / backlight control on/off #8
Comments
No return on this since nearly one year ? Howerver, I don't know if it is possible to do some dimming. |
There's a method to set the backlight on/off : st7789-python/library/ST7789/__init__.py Line 172 in 5c16bae
Though I've yet to try it, and there appears no current way to adjust the level or dimming of the backlight, but with some code changes, I think it should be possible to set the backlight GPIO pin to PWM mode (https://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/) and change the duty cycle accordingly to vary the brightness. Caveat: I've no idea what impact this would have as far as the current being passed and may fry things?! |
From a quick look at the ST7789 datasheet, it seems there might even be functions to vary brightness that just aren't implemented in the current driver here : https://www.rhydolabz.com/documents/33/ST7789.pdf
|
For all of our display boards, the backlight pin can be PWM'd for brightness control. Any "brightness" registers in the display driver itself will probably do something but since they can't vary the intensity of the backlight they wont have the intended effect. PWM from Python (RPi.GPIO) is... dicey... I haven't tried it for a while, but it wasn't traditionally stable enough for a display backlight. You might see some flicker, which isn't great on a display. Might be worth looking into again to see if the results are acceptable but since Linux is moving toward Libgpio (slow-ish) and the Pi is moving away from traditional register bitbanging (fast) it's probably going to break even more in future anyway. Any other method of PWM is unfortunately outside the scope of this library. The most correct approach is to bring up the pwm-backlight kernel module with the appropriate config. Though since the Pi's PWM slices are often used for analogue audio there are tradeoffs even here. Some instructions on how to do this- pending figuring out how to do it again- might not go amiss in this repository. TLDR: It's complicated. |
I had a look at RPi.GPIO for the PWM details, it's still software based, but an overlay for the device tree to allow hardware PWM (via sysfs - https://jumpnowtek.com/rpi/Using-the-Raspberry-Pi-Hardware-PWM-timers.html) looks straightforward enough and would at least avoid burning user cycles and would hopefully equate to less flicker during garbage collection, etc. |
This is a good example of dimming: https://github.com/pimoroni/pirate-audio/blob/master/examples/backlight-pwm.py |
I use the PWM method but noticed annoying flickering - where does it stem from? How can this be overcome? |
Using I will publish test script using this method later here. |
@Wikinaut - would love to see the example! |
@bjohas Testscript PWM without Audio: Testscript PWM plus Audio: |
Thank you so much! |
Hey!
I'm using pirate audio and it's fun! I have a question, is it possible to allow dimming on this display or turning of backlight completely?
Thanks for letting know!
K
The text was updated successfully, but these errors were encountered: