-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,478
  • 3
  • 12
  • 20
Nimda
  • 1
  • 1
  • Are you sure that's a feature that's available in software for your device? Which exact model do you have? Can you find a link to a datasheet on it? All those things would improve your question. – T. M. Jan 20 '19 at 21:46
  • 1
    have you done any research about disabling the touch panel? – jsotola Jan 21 '19 at 03:20
  • @T.M. This is my exact model: [link](https://www.waveshare.com/wiki/7inch_HDMI_LCD_(B)) – Nimda Jan 21 '19 at 20:22
  • @jsotola Yes. But i didn't a proper way for doing it. – Nimda Jan 21 '19 at 20:51

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
  • 26,688
  • 4
  • 44
  • 133
  • 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,381
  • 11
  • 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