-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,791
  • 3
  • 16
  • 20
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
  • 27,928
  • 6
  • 53
  • 144
  • I have searched about it. I think the ID will change every time that rpi boots and how can I solve this? – Nimda Jan 21 '19 at 20:52
  • @Nimda It will only change if you keep adding/removing input devices between reboots. If this is the case, you can parse the xinput output and find the ID by name. – Dmitry Grigoryev Feb 14 '22 at 11:05
-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,451
  • 12
  • 15
  • Sorry, but that doesn't answer the question. If you wanted to share your knowledge, better ask&answer your own question than posting an answer which doesn't fit. – Dmitry Grigoryev Jan 21 '19 at 08:54