As far as I can tell, M5 is using the exact same technique for ther lobo-derived micropython fork. Their display class actually has a brightness method that uses PWM on the light pin.
I just checked the schematics, applying a PWM signal from pin 32 will dim the backlight leds. The circuit seems to be designed to be used that way.
One thing though: I found that when soft resetting the M5Stack, one has small issues with PWM. I actually have to do this:
backlightPwm = PWM(Pin(32))
backlightPwm.init(duty=128) # or any other duty
It seems that (like many other hardware things) PWM persists across soft-resets and the simple creation of a PWM object is insufficient to restart/reset the pulsation. This is quite logical, since a soft reset only resets microPython (and very few other ancilary items, like lvgl’s ILI9341). Thus the
init sequence. Since this seems to work, I did not investigate further…