W. H. Heydt
Posts: 10988
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Sleep Mode - and or turn off backlight?

Fri Mar 11, 2016 8:00 pm

I have confirmation from my friend that MCM shipped him a v1.1 unit, so it looks like the supply chain has probably cleared out the v1.0 versions.

W. H. Heydt
Posts: 10988
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Sleep Mode - and or turn off backlight?

Fri Mar 11, 2016 8:01 pm

brporter wrote:Could someone point me to the repo where the backlight interface can be found? I wanted to take a look at how backlight control was implemented for the RPi display.
Check back through this thread. It is--IIRC--just a matter of writing a numerical value to a particular file.

Edit to add...there is a code sample near the top of Page 5.

SebTC
Posts: 9
Joined: Sun Mar 13, 2016 12:01 am

Re: Sleep Mode - and or turn off backlight?

Sun Mar 13, 2016 12:07 am

The backlight control works great with the 1.1v board. Curious about when or how it is possible to completely shut off the touchscreen (over i2c). Bringing the brightness to 0% is not enough power saving for my project, need to completely shut off the screen sometimes.
Too bad switching the power to the screen isn't going to work unless I resend the initialising i2c data to the screen after powering it again. However, an "power off" or deep sleep command over i2c is a nicer solution.

Thank you for your answer.

JimmyN
Posts: 1109
Joined: Wed Mar 18, 2015 7:05 pm
Location: Virginia, USA

Re: Sleep Mode - and or turn off backlight?

Sun Mar 13, 2016 12:30 pm

You can have screen blanking, and you can turn the backlight off, but I don't think there is any way to shut the display controller off completely. The display controller and touchscreen input will still be "on".

SebTC
Posts: 9
Joined: Sun Mar 13, 2016 12:01 am

Re: Sleep Mode - and or turn off backlight?

Sun Mar 13, 2016 1:04 pm

Let's hope one of the developers knows how to reduce current draw. Without the backlight the board is still consuming lot of power. Other option is to disconnect the power from touchscreen, but have to reload initialising data. Is there any code or function to reload this data?

W. H. Heydt
Posts: 10988
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Sleep Mode - and or turn off backlight?

Sun Mar 13, 2016 4:36 pm

SebTC wrote:Let's hope one of the developers knows how to reduce current draw. Without the backlight the board is still consuming lot of power. Other option is to disconnect the power from touchscreen, but have to reload initialising data. Is there any code or function to reload this data?
What are you defining as "a lot of power"? There is a report in this thread that, with a lower level of backlighting, the display and controller draw about 250mA, so 1.25W. What are you doing that that is a troublesome amount of power consumption?

SebTC
Posts: 9
Joined: Sun Mar 13, 2016 12:01 am

Re: Sleep Mode - and or turn off backlight?

Sun Mar 13, 2016 5:10 pm

The Pi runs on a big battery. When a system is powered on, the user can control that system. When off, the Pi communicates with a server every x minutes. I can bring the Pi 3 down to [email protected] without touchscreen/video when Wifi, usb, ethernet,HDMI output and other stuff switched off. ([email protected] battery which is low enough for me). When doing the communication, I just enable the peripheral and disable it afterwards. With a HDMI screen it works great because I can cut off the screen power with a MOSFET and turn it on afterwards. I want to use the Pi screen because of the quality. If it is possible to get the screen in a very low power mode it would be great. Other option is switching the power off with a MOSFET, but after turning it on the system has to initialise the screen again.
Turning the Pi off and on is not really a solution for me and I prefer not to add a second microcontroller :)

User avatar
tonyhansen
Posts: 13
Joined: Sat Jan 03, 2015 6:20 am

Re: Sleep Mode - and or turn off backlight?

Sun Mar 13, 2016 10:04 pm

I'm wondering if the display initialization code can be encapsulated into a command that can be run after turning the power to the display back on.

roli1220
Posts: 1
Joined: Tue Mar 15, 2016 6:06 am

Re: Sleep Mode - and or turn off backlight?

Tue Mar 15, 2016 7:58 am

Hi Karl!
karlkiste wrote:
This is no display sleep mode, it is the kernel screensaver. You can disable it like

setterm -powersave off -powerdown 0 -blank 0

Greets,
Kiste
Are these settings available after reboot, or have they to be set after each reboot?

Greetings from Vienna,
roland

snorlax
Posts: 1
Joined: Mon Apr 18, 2016 7:42 am

Re: Sleep Mode - and or turn off backlight?

Mon Apr 18, 2016 7:46 am

solar3000 wrote:
gsh wrote:That's the easy bit...

echo 80 > /sys/class/backlight/rpi-backlight/brightness
that does not work.
'File not found'
/sys/class/backlight/: no files, just an empty folder
Did you finally get your answer? because I also have an empty "/sys/class/backlight/" folder on my Raspbian brand new install with LCD_show_v5 addon. The LCD screen works well but is always on :cry:

Edit:
I have downloaded the LCD_show_v5.tar file here : http://kedei.net/raspberry/raspberry.html

darthpug
Posts: 1
Joined: Fri May 13, 2016 9:11 pm

Re: Sleep Mode - and or turn off backlight?

Fri May 13, 2016 9:16 pm

snorlax wrote:
solar3000 wrote:
gsh wrote:That's the easy bit...

'File not found'
/sys/class/backlight/: no files, just an empty folder
Did you finally get your answer? because I also have an empty "/sys/class/backlight/" folder on my Raspbian brand new install with LCD_show_v5 addon. The LCD screen works well but is always on :cry:
From what I've read not every screen support backlight control. I have a Waveshare 5" screen and also have the empty /sys/class/backlight directory.

For those that have got the directory, would you mind sharing which LCD screen you have? (I think i need to replace this one since being able to turn off the screen is fairly important to my setup).

User avatar
CarlRJ
Posts: 599
Joined: Thu Feb 20, 2014 4:00 am
Location: San Diego, California

Re: Sleep Mode - and or turn off backlight?

Fri May 13, 2016 11:23 pm

darthpug wrote:From what I've read not every screen support backlight control. I have a Waveshare 5" screen and also have the empty /sys/class/backlight directory.

For those that have got the directory, would you mind sharing which LCD screen you have? (I think i need to replace this one since being able to turn off the screen is fairly important to my setup).
The thread you're posting on is in a sub-forum that is specifically for discussion of the Raspberry Pi Foundation's "Official Touchscreen Display". That display does have backlight control. More specifically, the early ones, with v1.0 of the associated control board, can turn the backlight on and off, while the newer ones, with v1.1 of the control board, can also control the brightness of the backlight.

I think it'd be a more accurate characterization to say that a few specific screens support backlight control (rather than "not every screen supports..."). It is not by any means a universal feature, the display maker has to make specific provision for this. As mentioned above, the "Official Touchscreen Display" supports dimming the backlight, as do some models of Adafruit's PiTFT. I have no idea about the capabilities of other displays. Many of them are driven by the fbtft drivers that Notro originally developed as a separate project (now included in the distribution). If you poke around on the wiki associated with the drivers (https://github.com/notro/fbtft/wiki) you may find information about whether/how your display supports this.

On my Official Touchscreen Display, the backlight directory looks like this:

Code: Select all

$ ls -l /sys/class/backlight/
total 0K
lrwxrwxrwx 1 root root 0 May 13 14:58 rpi_backlight -> ../../devices/platform/rpi_backlight/backlight/rpi_backlight
$
$ ls -l /sys/devices/platform/rpi_backlight/backlight/rpi_backlight/
total 0K
-r--r--r-- 1 root root 4096 May 13 14:59 actual_brightness
-rw-r--r-- 1 root root 4096 May 13 13:49 bl_power
-rw-r--r-- 1 root root 4096 May 13 14:54 brightness
lrwxrwxrwx 1 root root    0 May 13 14:59 device -> ../../../rpi_backlight
-r--r--r-- 1 root root 4096 May 13 14:59 max_brightness
lrwxrwxrwx 1 root root    0 May 13 14:59 subsystem -> ../../../../../class/backlight
-r--r--r-- 1 root root 4096 May 13 14:59 type
-rw-r--r-- 1 root root 4096 May 13 14:59 uevent
$ 
My Adafruit PiTFT (model 1983) doesn't have a backlight directory; the backlight is controlled directly via GPIO, as seen here: https://learn.adafruit.com/adafruit-2-8 ... ht-control

And a minimal interface to the backlight on the Official Touchscreen Display would look something like this:

Code: Select all

#!/bin/sh
BLDIR=/sys/class/backlight/rpi_backlight
case $1 in
off)	echo 1 > $BLDIR/bl_power	;;	# note, 1 NOT 0
on)	echo 0 > $BLDIR/bl_power	;;	# note, 0 NOT 1

[0-9] | [1-9][0-9] | 1[0-9][0-9] | 2[0-4][0-9] | 25[0-5] )	# 0-255
    echo $1 > $BLDIR/brightness
    ;;
show)
    POWER=$(cat $BLDIR/bl_power)
    case $POWER in
    1)	POWER='off'	;;
    0)	POWER='on'	;;
    esac
    BRIGHTNESS=$(cat $BLDIR/brightness)
    echo "backlight is $POWER, brightness is $BRIGHTNESS"
    ;;
*)
    echo "Usage: $0 { off | on | 0-255 | show }" >&2
    exit 1
    ;;
esac
exit 0
FWIW, this shows the backlight capabilities of Adafruit's various PiTFT models:
PiTFT_models_posted.png
PiTFT_models_posted.png (36.58 KiB) Viewed 8085 times

User avatar
jakeh12
Posts: 10
Joined: Wed Jul 31, 2013 7:46 pm
Location: Iowa, USA

Re: Sleep Mode - and or turn off backlight?

Sat May 14, 2016 3:21 pm

I did some current measurements with Raspberry Pi 3 and the V2.0 touchscreen and the current consumption of the display board in "off" state stayed around 90 mA (which is still a lot for "off" mode). Keep in mind the Display board nor the Raspberry Pi computer were not designed for mobile purposes. I made a tablet using the screen and RPi, but the power requirements are just too high even for off, halt, or "sleep" modes. If anybody is planning on using RPi and/or the screen for mobile purposes, I would recommend using a MOSFET and ATtiny to control the power to RPi and the display.

I am including a graph of measured current flows through RPi (Arch Linux, LXDE, idling) and different brightness levels of the screen (power consumption in "off" state of the screen is the same as the one with 0% brightness).
graph_currents.png
graph_currents.png (58.01 KiB) Viewed 8008 times

Also, if you would like to control brightness and power state more "user-friendly", you can use a utility I made:

https://github.com/jakeh12/rpi-backlight
viewtopic.php?f=108&t=146336

User avatar
tonyhansen
Posts: 13
Joined: Sat Jan 03, 2015 6:20 am

Re: Sleep Mode - and or turn off backlight?

Sat May 14, 2016 5:33 pm

Is there any way to tell via software which version of the official screen is in use?

User avatar
jakeh12
Posts: 10
Joined: Wed Jul 31, 2013 7:46 pm
Location: Iowa, USA

Re: Sleep Mode - and or turn off backlight?

Sat May 14, 2016 9:23 pm

tonyhansen wrote:Is there any way to tell via software which version of the official screen is in use?
Not a one that's for sure but if you can control the brightness then it's a V1.1 or V2.0. if you can only control on off states, it's a V1.0. The easiest way is to look for it on the display board pcb.

User avatar
tonyhansen
Posts: 13
Joined: Sat Jan 03, 2015 6:20 am

Re: Sleep Mode - and or turn off backlight?

Sat May 14, 2016 10:54 pm

jakeh12 wrote:
tonyhansen wrote:Is there any way to tell via software which version of the official screen is in use?
Not a one that's for sure but if you can control the brightness then it's a V1.1 or V2.0. if you can only control on off states, it's a V1.0. The easiest way is to look for it on the display board pcb.
Unfortunately, a library and tool developer doesn't have the luxury of "looking at the board". The software they write needs to work as well as it can with all models, and that usually requires: being able to differentiate somehow, and being able to indicate to programs using your tools and libraries what capabilities are available.

For example, a method using a probe might work by reading the current state of the brightness, set it to 10 or 250, seeing if it really got set to 10 or 250 instead of 0 and 255, then setting back to the value originally read. I don't have the later models yet, so can't try things out.

User avatar
jakeh12
Posts: 10
Joined: Wed Jul 31, 2013 7:46 pm
Location: Iowa, USA

Re: Sleep Mode - and or turn off backlight?

Sun May 15, 2016 6:28 pm

tonyhansen wrote: Unfortunately, a library and tool developer doesn't have the luxury of "looking at the board". The software they write needs to work as well as it can with all models, and that usually requires: being able to differentiate somehow, and being able to indicate to programs using your tools and libraries what capabilities are available.

For example, a method using a probe might work by reading the current state of the brightness, set it to 10 or 250, seeing if it really got set to 10 or 250 instead of 0 and 255, then setting back to the value originally read. I don't have the later models yet, so can't try things out.
Thank you for your suggestion! I will add this functionality soon (I am on vacation currently and I do not have a RPi handy to test it).

User avatar
CarlRJ
Posts: 599
Joined: Thu Feb 20, 2014 4:00 am
Location: San Diego, California

Re: Sleep Mode - and or turn off backlight?

Sun May 15, 2016 10:12 pm

jakeh12 wrote:Not a one that's for sure but if you can control the brightness then it's a V1.1 or V2.0. if you can only control on off states, it's a V1.0.
Is the V2.0 conjecture, or has it been announced or spotted in the wild? I'm very curious as to what might be different between V1.1 and V2.0.

opi
Posts: 7
Joined: Tue Sep 01, 2015 12:33 am

Re: Sleep Mode - and or turn off backlight?

Thu Jun 23, 2016 2:39 am

I have a 1.0 board but I keep getting "Permission denied" when trying

Code: Select all

sudo echo 1 > /sys/devices/platform/rpi_backlight/backlight/rpi_backlight/bl_power
Am I misunderstanding that the 1.0 board should be able to do this, or doing something wrong?

User avatar
CarlRJ
Posts: 599
Joined: Thu Feb 20, 2014 4:00 am
Location: San Diego, California

Re: Sleep Mode - and or turn off backlight?

Thu Jun 23, 2016 5:05 am

opi wrote:I have a 1.0 board but I keep getting "Permission denied" when trying

Code: Select all

sudo echo 1 > /sys/devices/platform/rpi_backlight/backlight/rpi_backlight/bl_power
Am I misunderstanding that the 1.0 board should be able to do this, or doing something wrong?
sudo is running the echo command as root, but the redirect to the bl_power file has already happened in your shell (presumably as user "pi") before sudo rever runs - and _you_ don't have permission to open the file for writing. There are a variety of ways around this. One is to put the "echo 1 > longpathto_bl_power" into a file, and then run that file with "sudo sh filename" - then the sudo will happen before the ">", and so the redirect will happen as root, getting past the permission problem. Another method that can work, though I haven't tried it in this situation, is "echo 1 | sudo dd of=longpathto_bl_power" - this way dd is elevated to root permission before it evaluates its output file argument.

JimmyN
Posts: 1109
Joined: Wed Mar 18, 2015 7:05 pm
Location: Virginia, USA

Re: Sleep Mode - and or turn off backlight?

Thu Jun 23, 2016 12:40 pm

opi wrote: Am I misunderstanding that the 1.0 board should be able to do this, or doing something wrong?
It will do that. I have a version 1.0 and added a button to toggle the display on/off when I want. Push to turn on, push to turn off, push to turn on.... It makes turning it on/off pretty easy

This is the Python script I created to do that.

Code: Select all

#!/usr/bin/python
#
#   backlight-toggle.py
#
#   RPF 7" Touchscreen Display
#          Toggles backlight on/off with button press 
#          Uses GPIO5  (BOARD Pin 29)


import RPi.GPIO as gpio
from subprocess import call
import time

gpio.setmode(gpio.BCM)
gpio.setup(5, gpio.IN, pull_up_down = gpio.PUD_UP)

def set_backlight(channel):
    file = open('/sys/devices/platform/rpi_backlight/backlight/rpi_backlight/bl_power','r+')
    current_status = int(file.read(1))
    
    if current_status == 0:
        bl_set = 1
    else:
        bl_set = 0

    bl_update = str(bl_set)
    file.seek(0)
    file.write(bl_update)
    file.close
    
gpio.add_event_detect(5, gpio.FALLING, callback=set_backlight, bouncetime=250)

while 1:
    time.sleep(360)
Then I added it to the users autostart, so the script runs when the desktop starts.

Code: Select all

nano ~/.config/lxsession/LXDE-pi/autostart
And added this line

Code: Select all

@sudo python /home/pi/scripts/backlight-toggle.py
If you didn't want the button you could rework the script so it would change states, and turn it on or off, whenever the script is run manually.

opi
Posts: 7
Joined: Tue Sep 01, 2015 12:33 am

Re: Sleep Mode - and or turn off backlight?

Fri Jun 24, 2016 6:21 am

Ah, of course! I knew that, silly mistake, thanks!

gfxfr
Posts: 9
Joined: Sun Dec 04, 2016 9:04 pm

Re: Sleep Mode - and or turn off backlight?

Tue Dec 06, 2016 6:50 am

Hi, since the last firmware update some days ago I ran into the backlight problem with the official touch dislay.
Some time the screen doesn't wake up when I touch it, and in the dmseg I find :
[31748.504937] rpi-backlight rpi_backlight: Backlight change failed

uname -a : Linux xyz 4.4.34-v7+ #930 SMP Wed Nov 23 15:20:41 GMT 2016 armv7l GNU/Linux

What can I do? Is there a regression in the firmware?

Pierre86
Posts: 5
Joined: Wed Jul 06, 2016 9:09 pm

Re: Sleep Mode - and or turn off backlight?

Sun Dec 11, 2016 8:11 pm

gfxfr wrote:Hi, since the last firmware update some days ago I ran into the backlight problem with the official touch dislay.
Some time the screen doesn't wake up when I touch it, and in the dmseg I find :
[31748.504937] rpi-backlight rpi_backlight: Backlight change failed

uname -a : Linux xyz 4.4.34-v7+ #930 SMP Wed Nov 23 15:20:41 GMT 2016 armv7l GNU/Linux

What can I do? Is there a regression in the firmware?
I confirm, I encounter the same problem since last updates. The behavior is quite erratic : sometimes it arrives quite rapidly, sometimes after several hours.

morphious6
Posts: 17
Joined: Thu Sep 17, 2015 8:21 pm

Re: Sleep Mode - and or turn off backlight?

Mon Dec 12, 2016 5:42 pm

I can confirm there is issues since last update. My screen is White on reboot and cannot shut off the screen using /sys/class/backlight/rpi_backlight/bl_power" Off as allof the symbolick links now seem to be missing from the /sys/ dir......

Raspberry, Please fix this ASAP!!!

Return to “Beginners”