-
Notifications
You must be signed in to change notification settings - Fork 0
/
RPI_replay.py
44 lines (32 loc) · 890 Bytes
/
RPI_replay.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import RPi.GPIO as GPIO
import time
import os,sys
led_on = False
cmd='sudo sendiq -s 250000 -f 867.8625e6 -t u8 -i ~/lexus1/lexus_open.iq '
def setupGPIO():
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(18, GPIO.OUT, initial=GPIO.LOW)
GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)
def flashLED(count):
for i in range(count):
GPIO.output(18, GPIO.HIGH)
time.sleep(.2)
GPIO.output(18, GPIO.LOW)
time.sleep(.2)
def switch(ev=None):
os.system(cmd)
flashLED(2)
# sys.exit()
def detectButtonPress():
GPIO.add_event_detect(23, GPIO.FALLING, callback=switch, bouncetime=300)
def waitForEvents():
while True:
time.sleep(1)
def main():
setupGPIO()
flashLED(5)
detectButtonPress()
waitForEvents()
if __name__ == "__main__":
main()