Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python2.7
- import RPi.GPIO as GPIO
- import subprocess
- import time
- GPIO.setmode(GPIO.BOARD)
- subprocess.call(['sudo', 'systemctl', 'stop', 'mmdvmhost.service', 'dmrmmdvmhost.service'])
- GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_UP)
- GPIO.setup(16, GPIO.IN, pull_up_down=GPIO.PUD_UP)
- GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)
- GPIO.setup(40, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
- def run_DMR(channel):
- subprocess.call(['sudo', 'systemctl', 'stop', 'mmdvmhost.service', 'dmrmmdvmhost.service'])
- time.sleep(5)
- subprocess.call(['sudo', 'systemctl', 'start', 'mmdvmhost.service'])
- def run_BM(channel):
- subprocess.call(['sudo', 'systemctl', 'stop', 'mmdvmhost.service', 'dmrmmdvmhost.service'])
- time.sleep(5)
- subprocess.call(['sudo', 'systemctl', 'start', 'dmrmmdvmhost.service'])
- def close_all_mmdvm(channel):
- subprocess.call(['sudo', 'systemctl', 'stop', 'mmdvmhost.service', 'dmrmmdvmhost.service'])
- GPIO.add_event_detect(12, GPIO.FALLING, callback=run_DMR, bouncetime=300)
- GPIO.add_event_detect(16, GPIO.FALLING, callback=run_BM, bouncetime=300)
- GPIO.add_event_detect(18, GPIO.FALLING, callback=close_all_mmdvm, bouncetime=300)
- try:
- GPIO.wait_for_edge(40, GPIO.FALLING, bouncetime=300)
- except KeyboardInterrupt:
- GPIO.cleanup()
- GPIO.cleanup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement