Is there a way to adjust the brightness of the official touchscreen display? I couldn't find a definite answer. I'm running the latest release of Raspbian Jessie.
The driver for the screen provides an interface through
/sys/. To turn the screen on you can use the command:
echo 0 > /sys/class/backlight/rpi_backlight/bl_power
and to turn it off:
echo 1 > /sys/class/backlight/rpi_backlight/bl_power
the brightness can be adjusted using:
echo n > /sys/class/backlight/rpi_backlight/brightness
n is some value between 0 and 255.
I've made a Python package for this: github.com/linusg/rpi-backlight. Now you don't need to implement this yourself anymore.
(GIF is outdated because API was changed quite a bit in v2, sorry... Below example is correct 🙂)
Works basically like the above, example:
>>> from rpi_backlight import Backlight >>> >>> backlight = Backlight() >>> backlight.brightness 100 >>> backlight.brightness = 50 >>> backlight.brightness 50 >>> >>> with backlight.fade(duration=1): ... backlight.brightness = 0 ... >>> backlight.fade_duration = 0.5 >>> # subsequent `backlight.brightness = x` will fade 500ms >>> >>> backlight.power True >>> backlight.power = False >>> backlight.power False >>>
It has a GUI, a CLI and a simple Python API :)