Backlight on PI Touchscreen

Using the FBDEV driver (Immaterial though), has anyone controlled the backlight on the Pi touchscreen (The official one).

You can control it using:

sudo sh -c "echo 80 > /sys/class/backlight/rpi_backlight/brightness"

I was wondering if there is an API out there for this? I suppose I could just write to that file.

Whenever I have to work with sysfs I generally use POSIX file APIs (i.e. open, write). I’m not aware of any better way of interacting with it from C.

Yeah thats what I ended up doing, it worked fine.

My question wasnt really LVGL related, so thanks for answer. It did lead me to an LVGL related thing. I want to dim my touch screen if no one touches it for a while. What I was thinking of doing was setting a variable to time of the last gesture. This might be useful for others, so if you want I can post the code as a PR.

I could be wrong, but wouldn’t lv_disp_get_inactive_time do exactly that?

Oh man… I didnt know about that!!! THANK YOU, Now I can quit reenventing the wheel!

Worked perfectly… Man Im dumb…