-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame_1.10.py
44 lines (33 loc) · 967 Bytes
/
game_1.10.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 subprocess
import RPi.GPIO as GPIO
import time
Models = 'Matrix'
arguements = ['/opt/fpp/src/fppmm', '-m', 'a' , '-o', 'on']
fill_trigger = 23
start_trigger = 27
end = 26
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(fill_trigger, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(end, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(start_trigger, GPIO.IN, pull_up_down=GPIO.PUD_UP)
counter = 0
def race_start(channel):
global counter
counter = 0
for i in range(1, 30):
arguements[2] = Models + str(i)
subprocess.run(arguements)
def fill(channel):
global counter
arguements[2] = Models + str(counter)
arguements[4] = 'off'
subprocess.run(arguements)
counter += 1
GPIO.add_event_detect(start_trigger, GPIO.RISING, callback=race_start, bouncetime=200)
GPIO.add_event_detect(fill_trigger, GPIO.RISING, callback=fill, bouncetime=200)
try:
GPIO.wait_for_edge(end, GPIO.RISING)
except KeyboardInterrupt:
GPIO.cleanup()
GPIO.cleanup()