Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

esc-button.py 420B

12345678910111213141516171819202122
  1. #!/usr/bin/env python
  2. from RPi import GPIO
  3. import time
  4. from subprocess import call
  5. GPIO.setmode(GPIO.BCM)
  6. GPIO.setup(3, GPIO.IN)
  7. pressed = False
  8. while True:
  9. current = not GPIO.input(3)
  10. if current and not pressed:
  11. call(["xdotool", "keydown", "Escape"])
  12. pressed = True
  13. elif not current and pressed:
  14. call(["xdotool", "keyup", "Escape"])
  15. pressed = False
  16. time.sleep(0.1)