Hi , someone can explain me how to set screen lightness on my raspberry touchscreen ?
I’m using a rpi 3 model b and I have installed raspbian
-
- Posts: 7
- Joined: Tue May 08, 2018 5:50 pm
- DougieLawson
- Posts: 40568
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
- Contact: Website Twitter
Re: Raspberry pi 7”touchscreen brightness
Assuming this is the official RPF 7" touch screen and not a V1.0 model. There's a virtual filesystem
/sys/class/backlight/rpi_backlight
In there you've got
A root user can write to the brightness file.
sudo sh -c 'echo "128" > /sys/class/backlight/rpi_backlight/brightness'
Values run from 0 (dark) to 255 (full brightness).
/sys/class/backlight/rpi_backlight
In there you've got
Code: Select all
pi@Challenger:/sys/class/backlight/rpi_backlight $ ls -la
total 0
drwxr-xr-x 3 root root 0 May 19 09:17 .
drwxr-xr-x 3 root root 0 May 19 09:17 ..
-r--r--r-- 1 root root 4096 May 21 18:46 actual_brightness
-rw-r--r-- 1 root root 4096 May 21 18:46 bl_power
-rw-r--r-- 1 root root 4096 May 19 09:17 brightness
lrwxrwxrwx 1 root root 0 May 21 18:46 device -> ../../../rpi_backlight
-r--r--r-- 1 root root 4096 May 19 09:17 max_brightness
drwxr-xr-x 2 root root 0 May 21 18:45 power
lrwxrwxrwx 1 root root 0 May 19 09:17 subsystem -> ../../../../../class/backlight
-r--r--r-- 1 root root 4096 May 19 09:17 type
-rw-r--r-- 1 root root 4096 May 19 09:17 uevent
pi@Challenger:/sys/class/backlight/rpi_backlight $
sudo sh -c 'echo "128" > /sys/class/backlight/rpi_backlight/brightness'
Values run from 0 (dark) to 255 (full brightness).
Any language using left-hand whitespace for syntax is ridiculous
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
-
- Posts: 7
- Joined: Tue May 08, 2018 5:50 pm
Re: Raspberry pi 7”touchscreen brightness
I tried to set 255 but the brightness still low , but it changes When I set different values .
Yes , it is the official display
Yes , it is the official display
-
- Posts: 3
- Joined: Sun Jul 22, 2018 2:19 am
- Location: Australia
- Contact: Website
Re: Raspberry pi 7”touchscreen brightness
I'm no guru on this subject, but ........
My lab test shows maximum brightness around 200, whereas 255 is actually slightly dimmer than 200.
This finding also corresponds with measured current consumption which is around 85mA higher at the 200 setting than the 255 setting.
Re: Raspberry pi 7”touchscreen brightness
I've coded a little Python program that calls Linus Groh's module (he does all the good stuff like error trapping).
It requires three files as given below,
1) The python program, called brightness.py
2) The desktop file brightness.desktop, so that it can appear as an application icon,
3) Readme.txt to tell you how to use the files.
Copy the code for each of the above files into Leafpad and save all three in /home/pi/Programs/Brightness using the filenames indicated, above. It is important that the files are in the correct subdirectory. If you have changed your user name, then replace the name 'pi' with your user name in the above path and in the brightness.desktop file.
Then read the Readme.txt file for instructions for adding the program to the Applications Launcher and to the panel..
It requires three files as given below,
1) The python program, called brightness.py
Code: Select all
# brightness.py Version 0.1
# Copyright (C) 2019 Roy Leith
# This program is distributed under the terms of the GNU General Public License V3
import rpi_backlight as bl
from Tkinter import *
def maxbl ():
maxb = bl.get_max_brightness()
return maxb
def statusquo ():
value = bl.get_actual_brightness()
return value / ratio
def setb (val):
bl.set_brightness (int(int(val) * ratio))
master = Tk()
master.title('Brightness')
master.option_add('*font', ('verdana', 10, 'bold'))
maxv = maxbl ()
ratio = float(maxv) / 100
maxvalue = int(maxv / ratio)
Rvalue = statusquo()
brivar = IntVar()
brivar.set(Rvalue)
brightness = Scale(master, from_=maxvalue, to=10, orient=VERTICAL, length=200, width=10,
tickinterval=20, variable=brivar, command= setb,)
brightness.grid(row=0, column=0, sticky='NE')
mainloop()
Code: Select all
[Desktop Entry]
Name=Brightness
Comment=Brightness Control
TryExec=python
Exec=python /home/pi/Programs/Brightness/brightness.py
Icon=/usr/share/icons/Adwaita/96x96/status/display-brightness-symbolic.symbolic.png
Terminal=false
Type=Application
Categories=GTK;Utility
Code: Select all
How to add Brightness to your Raspberry Pi Official 7" touch display.
You will need to install two Python modules.
The first is Linus Groh's rpi-backlight module released under the MIT License.
pip install rpi_backlight
Second is tkinter,
sudo apt-get install python3-tk
You will need to give your user permission to use the system files.
sudo leafpad /etc/udev/rules.d/backlight-permissions.rules
Insert the line::
SUBSYSTEM=="backlight",RUN+="/bin/chmod 666 /sys/class/backlight/%k/brightness /sys/class/backlight/%k/bl_power"
Place the files, brightness.py, brightness.desktop and this
Readme.txt file in a folder called,
/home/pi/Programs/Brightness
If you have changed your user name, then replace the name 'pi'
in the above path and in the brightness.desktop file.
Please note that the file brightness.desktop will appear as the file
Brightness, with a 'sun' icon.
Run the File Manager with root permissions,
sudo pcmanfm
and copy the file brightness.desktop to the folder,
/usr/share/raspi-ui-overrides/applications
When you open the Applications Menu you will find the Brightness icon
in the 'Accessories' catagory. Add it to the Panel by adding an
'Application Launcher' Panel Item and editing it to use Brightness.
Then read the Readme.txt file for instructions for adding the program to the Applications Launcher and to the panel..
Re: Raspberry pi 7”touchscreen brightness
Hello, thank you for your work, for a newbie like me it seems incredible. I followed all thei nstructions but when I try to change the level of brightness in the app, it close instantly. Do you know an how I can solve that problem ?
Re: Raspberry pi 7”touchscreen brightness
Your permissions are probably incorrect
BTW, this tool is useful: https://github.com/linusg/rpi-backlight