调整官方触摸屏的亮度


Answers:


21

屏幕驱动程序通过提供接口/sys/。要打开屏幕,可以使用以下命令:

echo 0 > /sys/class/backlight/rpi_backlight/bl_power

并关闭它:

echo 1 > /sys/class/backlight/rpi_backlight/bl_power

亮度可以使用以下方法调节:

echo n > /sys/class/backlight/rpi_backlight/brightness

其中n是介于0到255之间的某个值。


1
只是很小的错字... rpi-backlight应该是rpi_backlight以获得亮度
Luc Eeckelaert

2
请注意,“亮度”设置仅适用于v1.1 LCD硬件。上V1.0,控制是二进制的,<128“关”,> = 128是“导通”看到raspberrypi.stackexchange.com/questions/49822/...
戴夫劳伦斯

1
如果你得到“许可被拒绝”的错误,请尝试使用sudo bash -c "echo 0 > /sys/class/backlight/rpi_backlight/bl_power"(从raspberrypi.org/forums/viewtopic.php?p=848197#p848197
MasterScrat

如果文件夹rpi_backlight或文件bl_power不存在怎么办?openplotter就是这种情况,所以这些都
不起作用

7

我为此做了一个Python包:github.com/linusg/rpi-backlight。现在,您不再需要自己实现此功能。

例

(GIF已过时,因为在v2中对API进行了相当多的更改,对不起...下面的示例是正确的🙂)

基本上像上面的例子一样工作:

>>> 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
>>>

它具有一个GUI,一个CLI和一个简单的Python API :)

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.