Official 7" Raspberry Pi Touch Screen FAQ

Can I turn it off/on from Raspbian?
No, not yet! But soon.

Can I control the backlight?
An update to turn the backlight on/off is in the pipeline ( currently
available in cutting-edge firmware ) but brightness control is not
supported.Can I turn it off/on from Raspbian?

Why hasn’t this been updated? You can both turn backlight on/off completely and control brightness gradually by changing files in /sys/class/backlight/rpi_backlight/

I know it has been said that changing backlight brightness wouldn’t even be possible but changing the value in /sys/class/backlight/rpi_backlight/brightness from 255 to 100 certainly changed brightness for me.

Setting /sys/class/backlight/rpi_backlight/bl_power to 1 turns the backlight off, setting it to 0 turns it on.

I simply haven’t had time to look into and verify any changes to the information here.

Fortunately, the best way to get the right information on the internet is to post the wrong information and someone will come and correct you :D Thanks.

Edit: I can’t find anything about brightness control. Where did you learn this?

Hi
Excellent, well done for finding that.
I edited the brightness file and changed the value, when I saved the file, display brightness changed with it.

/sys/class/backlight/rpi_backlight
Is where the file can be found.

If you use nano to edit files then
sudo nano /sys/class/backlight/rpi_backlight/brightness

Will open the file, maximum value seems to be 255
NB don’t make it too low or it may be too dark to see 25 is pretty dark and the value is remembered upon a reboot - so beware if you make it too dark it will stay that way and still be too dark after a reboot!

Regards
David

is this the right way to change these values?
Ideally I would like to dim the display from Python.

Any help gratefully received.
Regards
David

Hi Joerg,

I love the Weather Station / Alarm Clock you’ve put together. Can you provide some additional information about how you did this as I am interested in something very similar.

Thanks

Rob

Writing to /sys/class/backlight/rpi_backlight/brightness is the correct way to change the brightness. Python can write to this file just as it can any other file.

Here’s a quick and dirty library that does just that. Unless you have a remote connection to your Pi, or really know what you’re doing then don’t set the backlight brightness below 20 or turn the power off. It’s not easy to type when you can’t see!

import os

BASE = "/sys/class/backlight/rpi_backlight/"

ON = 0
OFF = 1

def power(state):
    if state in (ON,OFF):
        _power = open(os.path.join(BASE,"bl_power"), "w")
        _power.write(str(state))
        _power.close()
        return
    raise TypeError("Invalid power state")


def brightness(value):
    if value > 0 and value < 256:
        _brightness = open(os.path.join(BASE,"brightness"), "w")
        _brightness.write(str(value))
        _brightness.close()
        return
    raise TypeError("Brightness should be between 0 and 255")

Thank you Gadgetoid,
I plan a slider onscreen to go between 25 and 255 and your code Is mighty helpful.

To avoid having to figure out this from scratch, I had planned a set of files, each containing one of six brightness levels and from within the python software, copy the relevant file to the brightness file to set the matching brightness according to an onscreen slider.
However now I can use your example to do it directly to the file.

In a future version, I may link it to a light sensor too so that it darkens in proportion to the ambient light level. This would be a very useful set of capabilities to be built in. For now, your code is really helpful.

fyi I am building a specialised timepiece, so have added the Piface realtime clock shim, put a case around the Pi - hiding the activity lights to help keep it dark at night - and a nice short USB cable to patch power between the display and the Pi.

I tried the dual USB from Pimoroni, suggested elsewhere, but the plugs are too long and show up outside the frame - finding a right angled one hasn’t been fruitful either.

It’s a shame there isn’t a suitable case or add on pi bow layers for a combined touchscreen and Pi with cables to make it look less like an IT project. i like the flotilla colour best.

Best regards
David

Here are a couple USB cords that should work if you can find them locally:

https://www.amazon.com/gp/product/B00S8GTVIK/ref=oh_aui_detailpage_o08_s00

Sorry about the late response, forgot about it. Found the info on brightness control in some thread on the raspberry pi forums which I found through Google. I can find it now tough, the threads that show up in my browser history only talk about the file that lets you turn it off/on. Obviously the brightness control works though.

Was baffled when there seemed to be no way to control the brightness (I did not check FAQs for that before buying, being able to control brightness of a display just seems like a given).

Turns out it’s possible but for some reason isn’t documented in an official capacity anywhere which is just bizarre. Your FAQ is one of the top hits on Google when it comes to the display so seems like a good place to have the info (also bought display from you).

The only real official docs are the Troubleshooting ones, which I pretty much copied from this thread and should definitely try to update. I don’t think there’s anyone with the time or inclination to write technical documentation at the Pi Foundation- specially not when they can always count on us re-sellers to do it for them. They’re busy folks with plenty of better things to do!

Honestly, what’s detailed above is about as official as it gets, unfortunately I’m also short on time so it doesn’t get updated as frequently as it should!

Yea, not much documentation at all. I even had trouble figuring out if and what for I needed the four jumper cables… Most install guides just say “two jumpers this way” or “four jumpers that way” without really saying why. Bit odd. (Though I think I figured it out in the end, need none, can use two to power Pi from display, can use another two for touch if you don’t have a Pi 2.)

Hey,
I tried as here was mentiones to play with the brightness. I see the value of 255 in /sys/class/backlight/rpi_backlight/brightness . However, when I lower it on like 200 (and save it), nothing happens with the brightness - it is still on 100%.
But what is odd - if I change it to value 110, the brightness goes to zero. Probably for me there is just 0-128 is 0%, 129-255 is 100% and nothing between.

What the hell? Any ideas? :-)

Thanks

Matt

Hi Gadgetoid,
I made the changes & added a check to make sure (as best I can) that its running on a Pi - ideally I’d like to check the display.

however your code isn’t running because its a protected file.
when I changed it by hand - I used sudo

what would you suggest be the right way to do it from a non proved account?
Regards
David

Right now I’d just run the python script as the root user. Not the best solution, but I’m not sure if the following will work:

On this page there’s an example of a udev rules file which should give all users access to backlight controls:

Which would involve running sudo nano /etc/udev/rules.d/backlight-permissions.rules

And pasting in:

SUBSYSTEM=="backlight",RUN+="/bin/chmod 666 /sys/class/backlight/%k/brightness /sys/class/backlight/%k/bl_power"

Hi Gadgetoid,
your suggestion of running just the python script with privs works, and the permission change from FBTFT is also working - after I substituted rpi_backlight for %k - which is the better solution

the python slider is now changing the brightness :)
now I want to start it only if its running on the console when the pi account auto logs in after startup.
at the moment I have my program running from .xsession
so maybe the right way is to run startx when the account logs in - that will only work from the console.
or add a command to check the tty is tty1

that way I can still ssh to make changes when necessary

then stop the display from blanking out - its not helpful for a clock!
thanks for your help
Regards
David

Hi
It’s all working as required. Thanks for the help
Two tasks - bit of masking tape to block the blinking lights on the pi and edimax wifi.

Now only issue is with a Piface RTC.
If anyone has a fix, I would really appreciate it.

Keeps time and works over a reboot.
However on a power off at say 11:31 then leave it off for a couple of hours, when it powers up the time continues from 11:31 rather than 13:31.

Not a "feature " I wanted from an RTC and isn’t useful for a clock - hence I am having to keep it going from wifi NTT

This is for a relative with Alzheimer’s who needs constant reassurance of the day of the week - so it’s very much needed.

Thanks in advance for any help
Regards
David

ntp not NTT of course

A post was split to a new topic: Strange Official Touchscreen Problem

St. Patrick’s day is approaching and I would love a Jade Coupé 3 to match my Jade display frame. Pretty please. :-D

Hi! I got my official 7" touchscreen display and it work very well! Since I need to place an additional glass lens on it, I would like to know if it is possible to increase the touch sensitivity (for example by editing some configuration file, driver, ecc…) Anyone know if it is possible and how?
Thank you!