-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?

4
  • 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.
    Commented Jan 20, 2019 at 21:46
  • 1
    have you done any research about disabling the touch panel?
    – jsotola
    Commented Jan 21, 2019 at 3:20
  • @T.M. This is my exact model: link
    – Nimda
    Commented Jan 21, 2019 at 20:22
  • @jsotola Yes. But i didn't a proper way for doing it.
    – Nimda
    Commented Jan 21, 2019 at 20:51

2 Answers 2

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.

2
  • I have searched about it. I think the ID will change every time that rpi boots and how can I solve this?
    – Nimda
    Commented Jan 21, 2019 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. Commented Feb 14, 2022 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.

1
  • 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. Commented Jan 21, 2019 at 8:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.