0

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?

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

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

xinput set-prop $ID "Device Enabled" 0
  • 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 at 20:52
-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.

  • 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 at 8:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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