-
Notifications
You must be signed in to change notification settings - Fork 0
/
control.py
58 lines (44 loc) · 1.35 KB
/
control.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import pifacedigitalio
import monte_carlo
import block_drawer
DEBUG = True
START_BUTTON_INDEX = 0
RESET_BUTTON_INDEX = 1
CLEAR_BUTTON_INDEX = 2
def start(event):
if DEBUG:
print('DEBUG:FAKE:Starting Monte Carlo')
else:
monte_carlo.start_monte_carlo()
on_finish()
def reset(event):
if DEBUG:
print('DEBUG:FAKE:Resetting Block Drawer')
else:
# Turns off the finale relay and restores the minecraft world
pifacedigital.relays[0].turn_off()
block_drawer.restore_checkpoint()
def clear(event):
if DEBUG:
print('DEBUG:FAKE:Clearing Block Drawer')
else:
block_drawer.clear()
def on_finish():
if DEBUG:
print('Finished')
else:
# Runs after pi has been calculated
pifacedigital.relays[0].turn_on()
if __name__ == '__main__':
pifacedigital = pifacedigitalio.PiFaceDigital()
listener = pifacedigitalio.InputEventListener(chip=pifacedigital)
listener.register(START_BUTTON_INDEX,
pifacedigitalio.IODIR_FALLING_EDGE,
start)
listener.register(RESET_BUTTON_INDEX,
pifacedigitalio.IODIR_FALLING_EDGE,
reset)
listener.register(CLEAR_BUTTON_INDEX,
pifacedigitalio.IODIR_FALLING_EDGE,
clear)
listener.activate()