display_driver_framework.py: reduce backlight PWM frequency#531
display_driver_framework.py: reduce backlight PWM frequency#531ThomasFarstrike wants to merge 1 commit intolvgl-micropython:mainfrom
Conversation
The 38kHz frequency for the display backlight was causing issues on QEMU because QEMU had trouble accurately timing that high of a frequency, causing it to "miss" some of the signal, causing it to never go fully 100% bright. As the human eye's refresh rate is far lower, and the LilyGo example code I checked uses just 1kHz, I figured 3.8kHz would still be plenty fast. Presumably, a lower PWM output speed is also good for EMF radiation and power consumption, so why not :-)
|
What is visible and what can be "seen" are 2 different things. Visible is what you process after you brain has done some filtering. what is seen is what is actually seen by the human eye. peoples brains are different and they have different "filters" so to say that there is a hard limit to what is visible is not possible. This is the reason why I set it as high as as it is set. Most MCU's are able to handle that high of a frequency. higher is better to reduce the number of potential visual impacts. QEMU is an emulator and not a piece of hardware. To handle that issue you would need to either monkey patch the driver code or you can simply subclass the display driver and override the methods/functions needed in order to set the PWM frequency to whatever it is you want. This is the reason as to why I wrote the display drivers in Python code was for the sole purpose of allowing users to make adjustments to the drivers as needed without having to write a completely new driver. as an example... import st7789
import machine
class ST7789(st7789.ST7789):
def __init__(self, *args, **kwargs):
st7789.ST7789.__init__(self, *args, **kwargs)
pin = machine.Pin(BACKLIGHT_PIN, machine.Pin.OUT)
self._backlight_pin = machine.PWM(pin, freq=...)
|
|
Oh, I see! I don't mind subclassing the display driver, but just to let you know I did ponder why it was set to 38kHz, indeed assuming that higher was better. But from what I found, such as in the IEEE 1789 standard page 44, 1kHz is a minimal, 2-3kHz is noticeable, above 3kHz is pretty much imperceptible and 4kHz is a very good value to use for this. There might be other disadvantages to going overkill on this frequency, from EMF rating, to power consumption, to people spending time troubleshooting their emulator's brightness instead of writing actual code (haha!) so I would still recommend bringing the default down to ~4kHz and letting user subclass if they want to increase it instead. But that's up to you, of course :-D Thank you in any case for taking the time! |
|
I am sure it was something that I came across at some point in time when working with a display. it was in a datasheet or it was done in an example for a display. What I can tell you is that walking into a home depot lighting area just about gives me a seizure because of of the LED lights that are flickering at a very high rate of speed. I have to hunt to buy incandescent light bulbs since they are not allowed to be sold anymore. It's really annoying..... |
|
I think those (cheap) home depot lights might be flickering at the power grid's frequency, so 60Hz - a far cry from the 3800 Hz proposed here :-D Anyway, I'll close this pull request for now, feel free to re-open if you disagree! |
The 38kHz frequency for the display backlight was causing issues on QEMU because QEMU had trouble accurately timing that high of a frequency, causing it to "miss" some of the signal, causing it to never go fully 100% bright.
As the human eye's refresh rate is far lower, and the LilyGo example code I checked uses just 1kHz, I figured 3.8kHz would still be plenty fast.
Presumably, a lower PWM output speed is also good for EMF radiation and power consumption, so why not :-)