Jump to content
Pirate

rpi-backlight- Control Raspberry Pi 7" Screen Backlight with Asus TinkerBoard

Recommended Posts

Hi all,
I have modified the Github Python Project "rpi-backlight" to work with the Asus Tinkerboard
 
A Python module for controlling power and brightness of the official Raspberry Pi 7" touch display.
 
example.gif
Features
Change the display brightness smoothly or abrupt
Set the display power on or off
Toggle the display power on and off
Get the current brightness
Get the maximum brightness
Get the display power state (on/off)
Command line interface
Graphical user interface
 
Requirements
 
A TinkerBoard including a correctly assembled 7" touch display v1.1 or higher (look on the display's circuit board to see its version) running a Linux-based OS
Python 3.5+
Optional: TinkerBoard: gir1.2-gtk-3.0 for the GUI install
 
Installation
Clone this repository and install by:
 
$ sudo apt-get install gir1.2-gtk-3.0
$ git clone http://github.com/p1r473/rpi-backlight.git
$ cd rpi-backlight
$ sudo python3 setup.py install

Usage
 

API

Example in a Python shell:
 
>>> 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
>>>

NOTE: Code using set_ functions of this library has to be run as root, e.g. sudo python file.py , if the permissions for changing the backlight were not changed as described in the installation section!

CLI
Open a terminal and run rpi-backlight as root:
 
$ rpi-backlight -b 100
$ rpi-backlight --set-brightness 20 --duration 1.5
$ rpi-backlight --get-brightness
20
$ rpi-backlight --get-power
on
$ rpi-backlight -p off
$ rpi-backlight --get-power
off
$ rpi-backlight --set-power off :emulator:
$ rpi-backlight -p toggle
$ rpi-backlight -p toggle -d 1
 
GUI
 
Open a terminal and run rpi-backlight-gui as root.
gui.png
 
Adding a shortcut to the LXDE panel
panel_result.png
See docs.
 
Find it at:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...