PiTFT auto-off

Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Locked
KyleBoyer
 
Posts: 9
Joined: Fri Feb 20, 2015 12:58 pm

PiTFT auto-off

Post by KyleBoyer »

I noticed that my Pi's screen will automatically go all black/blank. I was wondering if there was some way, when this happens, to turn the blacklight off on the PiTFT. I know using: sudo sh -c "echo '0' > /sys/class/gpio/gpio508/value" will turn the screen off, however I want it to do so when the OS blanks the screen, and then to turn back on when the screen would normally resume.

A similar case is found here: http://www.raspberrypi.org/forums/viewt ... 3&p=485352

User avatar
Bel_Z_Bub
 
Posts: 263
Joined: Wed Jun 04, 2014 1:58 pm

Re: PiTFT auto-off

Post by Bel_Z_Bub »

I would disable the default screensaver you talk about, and then make a script in e.g C or python that starts at startup and runs in the background that turns the backlight off after a certain period, and turns it back on when you press a button or touch the screen.

KyleBoyer
 
Posts: 9
Joined: Fri Feb 20, 2015 12:58 pm

Re: PiTFT auto-off

Post by KyleBoyer »

Bel_Z_Bub wrote:I would disable the default screensaver you talk about, and then make a script in e.g C or python that starts at startup and runs in the background that turns the backlight off after a certain period, and turns it back on when you press a button or touch the screen.
I'm not sure how I would go about tis to be honest. Could you provide more guidance?

User avatar
Bel_Z_Bub
 
Posts: 263
Joined: Wed Jun 04, 2014 1:58 pm

Re: PiTFT auto-off

Post by Bel_Z_Bub »

I guess I could make a little script, probably more people want this.

can you give me more details on how you use the piTFT, what do you run on it, do you use a mouse and/or a keyboard. do you have the buttons soldered, and if so do you have the power button setup? and if so what button. etc etc

KyleBoyer
 
Posts: 9
Joined: Fri Feb 20, 2015 12:58 pm

Re: PiTFT auto-off

Post by KyleBoyer »

Bel_Z_Bub wrote:I guess I could make a little script, probably more people want this.

can you give me more details on how you use the piTFT, what do you run on it, do you use a mouse and/or a keyboard. do you have the buttons soldered, and if so do you have the power button setup? and if so what button. etc etc
I used this tutorial: https://learn.adafruit.com/adafruit-pit ... spberry-pi
Inside there is a raspbian image that I just installed. I do not use a mouse(as of right now). Occasionally I have a keyboard in use. My main use of this script would be to turn off the screen when the system screen blanks* out. Then when the system un-blanks out it should turn back on the screen. No buttons soldered.

*blanking out refers to when the system turns the screen black(I think it is related to the screensaver). The BLANK_TIME can be found in: /etc/kbd/config

User avatar
Bel_Z_Bub
 
Posts: 263
Joined: Wed Jun 04, 2014 1:58 pm

Re: PiTFT auto-off

Post by Bel_Z_Bub »

I understand what you mean, but what I tried to say was I do not know a way of connecting the two together. I can make a script that turns of the backlight after a period of no activity on keyboard, mouse and touchscreen which will look the same as the blankout with backlight off. you could leave the default blank on as well and set it to the same time as the script, but you cant garantee the same behaviour of the two as they arent connected. e.g when you run a game emulator the raspbian blank out wont kick in, but the script of the backlight will unless you specifically program it to stay on.

KyleBoyer
 
Posts: 9
Joined: Fri Feb 20, 2015 12:58 pm

Re: PiTFT auto-off

Post by KyleBoyer »

Bel_Z_Bub wrote:I understand what you mean, but what I tried to say was I do not know a way of connecting the two together. I can make a script that turns of the backlight after a period of no activity on keyboard, mouse and touchscreen which will look the same as the blankout with backlight off. you could leave the default blank on as well and set it to the same time as the script, but you cant garantee the same behaviour of the two as they arent connected. e.g when you run a game emulator the raspbian blank out wont kick in, but the script of the backlight will unless you specifically program it to stay on.
Well I suppose you could code it one of two ways:
1. Have a script get an image of the screen, see if all the pixels are the same(black), and no windows are open, then call the command to turn off the backlight.
2. "make a script that turns of the backlight after a period of no activity on keyboard, mouse and touchscreen" but that period of time is read from the config file I posted above.

User avatar
Bel_Z_Bub
 
Posts: 263
Joined: Wed Jun 04, 2014 1:58 pm

Re: PiTFT auto-off

Post by Bel_Z_Bub »

I dont think you understand what I mean, and if it would read the time from the config file or if you would set it manually is just a finishing touch it would not connect the two together other than they have the same time. also sometimes a keyboard sometimes not, means I would have to monitor if a keyboard is connected or not as well. etc etc. it would be easier if you had a purpose.

I mean running x on it is fun because its possible but lets face it you arent going to use it as such, its just too small

example. I have one pi setup as a webserver. it has a python program running with an analog looking clock and some VU looking meters for CPU, temperature, ram and storage monitoring. when people are connected it wil show them as well. since this is the only thing the piTFT is showing, I programmed the screensaver in the program itself, in this case nothing is rendered on the screen, so its black,no calculation are made and the backlight is off. instead of a timeout I use a button or my remote control. but I can set it to a timeout as well. if people connect and the light is off, it will also go on.

Another pi is my rechargable cupcade. the same C code that is handling the buttons is also handling that when its not connected to USB it will turn off the piTFT's backlight, the piglow, the headlight and the amplifier after 5 minutes of inactivity. and will go back on as soon as you touch a button or the joystick. it also shuts down the backlight if it powers down the pi if the battery goes low.

in both cases the BLANK_TIME is set to 0.

KyleBoyer
 
Posts: 9
Joined: Fri Feb 20, 2015 12:58 pm

Re: PiTFT auto-off

Post by KyleBoyer »

Bel_Z_Bub wrote:I dont think you understand what I mean, and if it would read the time from the config file or if you would set it manually is just a finishing touch it would not connect the two together other than they have the same time. also sometimes a keyboard sometimes not, means I would have to monitor if a keyboard is connected or not as well. etc etc. it would be easier if you had a purpose.

I mean running x on it is fun because its possible but lets face it you arent going to use it as such, its just too small

example. I have one pi setup as a webserver. it has a python program running with an analog looking clock and some VU looking meters for CPU, temperature, ram and storage monitoring. when people are connected it wil show them as well. since this is the only thing the piTFT is showing, I programmed the screensaver in the program itself, in this case nothing is rendered on the screen, so its black,no calculation are made and the backlight is off. instead of a timeout I use a button or my remote control. but I can set it to a timeout as well. if people connect and the light is off, it will also go on.

Another pi is my rechargable cupcade. the same C code that is handling the buttons is also handling that when its not connected to USB it will turn off the piTFT's backlight, the piglow, the headlight and the amplifier after 5 minutes of inactivity. and will go back on as soon as you touch a button or the joystick. it also shuts down the backlight if it powers down the pi if the battery goes low.

in both cases the BLANK_TIME is set to 0.
No, I do understand what you mean. Can't you write this program to listen for a keyboard event, then in that case, if the screen is off, turn it on. If there is a touch event, do the same. I believe the touch event would be very closely related to a mouse move as the cursor is still being moved when touched. Essentially, the program would do this:

Read the BLANK_TIME from that config file.
Listen for keyboard presses/mouse movements, if there are none after the timeout set from the config file, turn off the screen. If the screen is off, still listen for these events, if one, or multiple occur, turn the screen back on.

User avatar
Bel_Z_Bub
 
Posts: 263
Joined: Wed Jun 04, 2014 1:58 pm

Re: PiTFT auto-off

Post by Bel_Z_Bub »

ok I'll give it a shot after I have thought about it a little longer, and if it works I can't guarantee it won't interfere with any future software you will run.

KyleBoyer
 
Posts: 9
Joined: Fri Feb 20, 2015 12:58 pm

Re: PiTFT auto-off

Post by KyleBoyer »

Bel_Z_Bub wrote:ok I'll give it a shot after I have thought about it a little longer, and if it works I can't guarantee it won't interfere with any future software you will run.
Any status update on this?

User avatar
intensivex
 
Posts: 16
Joined: Sun Mar 29, 2015 1:48 pm

Re: PiTFT auto-off

Post by intensivex »

Would someone be kind enough, maybe Adafruit support, maybe fellow piTFT owners, to supply us with a working image based on an adafruit-base OS install and the piTFT (product 1983)?

I've gotten the screen to work (do not run apt-get update blindly! it will screw up any potential to get the screen working!), but I could not get the touch functions to work at all.

Someone with a working, "fresh" image with the piTFT (product 1983) touch functions working would be a tremendous help.

I've tried following every line of every tutorial including this :

https://learn.adafruit.com/adafruit-pit ... -calibrate

... and scoured the web for other examples, all to no avail.

If someone has a working image of the piTFT with touch and gestures working, please help!

An Ideal config would be working piTFT, with working Touch/Gesture, and the backlight turning off and on as the screen goes blank.

Thanks in advance!

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: PiTFT auto-off

Post by adafruit_support_mike »

You mean like the one linked from the tutorial?

https://learn.adafruit.com/adafruit-2-8 ... sy-install

Locked
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/

Return to “Adafruit Raspberry Pi® accessories”