-1

I am using an Raspberry Pi 3b and a 7 inch hdmi waveshare touchscreen that connects to rpi with a hdmi cable and a micro usb cable.

I want to program a push button from GPIO pins to make the screen on/off when the button is pressed.

I can turn the backlight off with vcgencmd display_power 0 command but the touch is still working and when the screen turns on again I can see that the touches that I have made is applied.

How can I turn off touch like the backlight in this screen?

MatsK
  • 2,882
  • 3
  • 17
  • 22
Nimda
  • 1
  • 1

2 Answers2

0

Find out what xinput ID your touchscreen has, then disable it with

xinput set-prop $ID "Device Enabled" 0

Note: a proper standby (halting CPU/RAM, not just the screen backlight) is not possible on the Pi, at least with stock kernel/drivers.

Dmitry Grigoryev
  • 28,277
  • 6
  • 54
  • 147
-1

I'm not sure about disabling touch, but for the button press action, that's easy with gpiozero:

from gpiozero import Button
from subprocess import check_call
from signal import pause

def screen_off(btn):
    check_call(['vcgencmd', 'display_power', '0'])
    btn.when_held = screen_on  # swap actions

def screen_on(btn):
    check_call(['vcgencmd', 'display_power', '1'])
    btn.when_held = screen_off  # swap actions

shutdown_btn = Button(17, hold_time=2)
shutdown_btn.when_held = screen_off

pause()

Alternatively you could use when_pressed or when_released, or even use two combined.

See a similar example and see Button docs.

ben_nuttall
  • 2,471
  • 14
  • 15