Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. #!/usr/bin/env python2.7
  2. import RPi.GPIO as GPIO
  3. import subprocess
  4. import time
  5. GPIO.setmode(GPIO.BOARD)
  6. subprocess.call(['sudo', 'systemctl', 'stop', 'mmdvmhost.service', 'dmrmmdvmhost.service'])
  7. GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_UP)
  8. GPIO.setup(16, GPIO.IN, pull_up_down=GPIO.PUD_UP)
  9. GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)
  10. GPIO.setup(40, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
  11. def run_DMR(channel):
  12. subprocess.call(['sudo', 'systemctl', 'stop', 'mmdvmhost.service', 'dmrmmdvmhost.service'])
  13. time.sleep(5)
  14. subprocess.call(['sudo', 'systemctl', 'start', 'mmdvmhost.service'])
  15.  
  16. def run_BM(channel):
  17. subprocess.call(['sudo', 'systemctl', 'stop', 'mmdvmhost.service', 'dmrmmdvmhost.service'])
  18. time.sleep(5)
  19. subprocess.call(['sudo', 'systemctl', 'start', 'dmrmmdvmhost.service'])
  20.  
  21. def close_all_mmdvm(channel):
  22. subprocess.call(['sudo', 'systemctl', 'stop', 'mmdvmhost.service', 'dmrmmdvmhost.service'])
  23.  
  24. GPIO.add_event_detect(12, GPIO.FALLING, callback=run_DMR, bouncetime=300)
  25. GPIO.add_event_detect(16, GPIO.FALLING, callback=run_BM, bouncetime=300)
  26. GPIO.add_event_detect(18, GPIO.FALLING, callback=close_all_mmdvm, bouncetime=300)
  27. try:
  28. GPIO.wait_for_edge(40, GPIO.FALLING, bouncetime=300)
  29. except KeyboardInterrupt:
  30. GPIO.cleanup()
  31. GPIO.cleanup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement