I’m currently playing around with the brightness of the display with presto.set_backlight(0.0 to 1.0). (by the way: the function should be renamed to set_brightness to avoid confusion with the neopixel backlight feature)
I noticed that the difference in brightness between 1.0 and 0.1 is not very big and below 0.1 the backlight suddenly turns off completely (you can’t see anything on the display anymore).
Since the backlight PMIC (AP3031) is controlled by PWM, I wonder why it should not be possible to control the brightness in finer steps between 0.1 and 0.0 to avoid the sudden shutoff and make the display as dark as possible but still readable (for night operation).
I tried to understand the AP3031 datasheet regarding the behavior of the CTRL pin, but I don’t get it.
Is there a hardware limitation for PWM dimming? Or can something be optimized here via software?
I don’t have a presto, but with other displays I had to do two things: configure the PWM to use a somewhat lower frequency. And secondly use gamma-correction for the brightness control. I don’t know if the first is possible without hacking the presto software, but the second is simple. You will find many suitable gamma correction methods if you google around.
I tried that yesterday.
I created a fork of the firmware and completely deactivated the backlight control in it.
Then I defined the GPIO pin as a PWM output via MicroPython and tested various values for frequency and duty cycle. However, the result was always the same. Below a certain value, the brightness does not decrease, but the lighting switches off completely. So it doesn’t seem to be the fault of the software, but is related to the AP3031.
I think I have solved the problem. It seems that the PWM frequency of the CTRL pin must be very low (below 1000 Hz). I have achieved the best results with around 100 Hz.
I have created a corresponding patch for the firmware:
Sounds reasonable. The datasheet documents two different behaviors, one below 1kHz, one above 1kHz. It could very well be that the extra large capacitor (twice the recommended size) just levels out the effects of the high-frequency of the PWM signal.