3

I have a raspberry pi model B rev 2, with the Adafruit PiTFT 2.8" w/ touchscreen. I'm running the standard raspbian install, after following the instructions on this page.

What I want to do is set up the pi such that when the console blanks from inactivity (the blanking that's inactivity time is set with setterm -blank VALUE) it also disables the backlight of the PiTFT as described here, and when the console awakes due to kbd/mouse input the backlight is re-enabled.

I would also like a way to make a touchscreen press a method apart from kbd/mouse that will trigger the wake up, or if not that then a physical GPIO button.

Steve Robillard
  • 34,988
  • 18
  • 106
  • 110
crh23
  • 33
  • 4

1 Answers1

1

Gathering from the code on github you could edit the drivers/tty/vt/vt.c file. The function you are concerned with is the one that contains the boolean blank_timer_expired. enter image description here

To turn the backlight off through software you could follow this tutorial by adding sudo sh -c "echo 'out' > /sys/class/gpio/gpio508/direction"(see tutorial for full setup). This would be put in the if clause above right after do_blank_screen(0). This would make the screen turn off at the same time that it blanks out. To turn it back on you would put the line sudo sh -c "echo '1' > /sys/class/gpio/gpio508/value" in the function above in the file right after unblank_screen();.

enter image description here

This would ensure that whatever triggers the screen to turn back on from blanking, will also turn the backlight on and whatever triggers the screen to blank will also trigger backlight to turn off. I believe this would include touching the screen.

NULL
  • 2,240
  • 8
  • 28
  • 49