This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
rpi-backlight- Control Raspberry Pi 7" Screen Backlight with Asus TinkerBoard
#1
Big Grin 
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.

[Image: 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:

Code:
$ 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:


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

Code:
$ 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:
$

GUI

Open a terminal and run rpi-backlight-gui as root.
[Image: gui.png]

Adding a shortcut to the LXDE panel
[Image: panel_result.png]
See docs.

Find it at:
http://github.com/p1r473/rpi-backlight
Reply
#2
Added --toggle command
Reply
#3
Big praise for your job. I wish you (or someone else) to add these bits to the wiki pages.
Light blue words might be a link. Have you try to click on them? Big Grin
Reply
#4
Thanks for the recognition
I will add a screenshot and links to the Github of it working when I hit the 25 post limit
Which wiki are you speaking of?
Reply
#5
This site Wink
Light blue words might be a link. Have you try to click on them? Big Grin
Reply
#6
I've added a link to this thread under the Wiki
Reply
#7
Updated codebase to V2.
No functionality changes, but better code
Reply
#8
Added new toggle option
rpi-backlight -p toggle
rpi-backlight -p toggle -d 1
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)