8000 Experimental new menu system · WesleyJ-128/FLL_Python_Codebase@26b27a9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 26b27a9

Browse files
committed
Experimental new menu system
1 parent b5cc464 commit 26b27a9

File tree

1 file changed

+55
-56
lines changed

1 file changed

+55
-56
lines changed

FLLMaster/Main.py

Lines changed: 55 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -9,62 +9,61 @@
99
calibrate()
1010
robot.reflectCal()
1111

12-
def left(state):
13-
if state:
14-
if not mission.is_alive():
15-
minusCount()
16-
display()
17-
else:
18-
abort()
19-
minusCount()
20-
display()
21-
def right(state):
22-
if state:
23-
if not mission.is_alive():
24-
addCount()
25-
display()
26-
else:
27-
abort()
28-
minusCount()
29-
display()
30-
def down(state):
31-
if state:
32-
if not mission.is_alive():
33-
calibrate()
34-
else:
35-
abort()
36-
minusCount()
37-
display()
38-
def up(state):
39-
if state:
40-
if not mission.is_alive():
41-
robot.reflectCal()
42-
else:
43-
abort()
44-
minusCount()
45-
display()
46-
def enter(state):
47-
if state:
48-
if not mission.is_alive():
49-
run()
50-
addCount()
51-
display()
52-
else:
53-
abort()
54-
minusCount()
55-
display()
56-
def backspace(state):
57-
pass
12+
def left():
13+
robot.btn.wait_for_released('left, right, up, down, enter')
14+
if not mission.is_alive():
15+
minusCount()
16+
display()
17+
else:
18+
abort()
19+
minusCount()
20+
display()
21+
def right():
22+
robot.btn.wait_for_released('left, right, up, down, enter')
23+
if not mission.is_alive():
24+
addCount()
25+
display()
26+
else:
27+
abort()
28+
minusCount()
29+
display()
30+
def down():
31+
robot.btn.wait_for_released('left, right, up, down, enter')
32+
if not mission.is_alive():
33+
calibrate()
34+
else:
35+
abort()
36+
minusCount()
37+
display()
38+
def up():
39+
robot.btn.wait_for_released('left, right, up, down, enter')
40+
if not mission.is_alive():
41+
robot.reflectCal()
42+
else:
43+
abort()
44+
minusCount()
45+
display()
46+
def enter():
47+
robot.btn.wait_for_released('left, right, up, down, enter')
48+
if not mission.is_alive():
49+
run()
50+
addCount()
51+
display()
52+
else:
53+
abort()
54+
minusCount()
55+
display()
5856

59-
robot.btn.on_left = left
60-
robot.btn.on_right = right
61-
robot.btn.on_up = up
62-
robot.btn.on_down = down
63-
robot.btn.on_enter = enter
64-
robot.btn.on_backspace = backspace
57+
buttonMap = {
58+
'left': left(),
59+
'right': right(),
60+
'enter': enter(),
61+
'up': up(),
62+
'down': down()
63+
}
6564

66-
while True:
67-
robot.btn.process()
68-
loopIndex = (loopIndex + 1) % 100
65+
while True:
66+
buttonMap[robot.btn.buttons_pressed]()
67+
checkDrift()
6968
displaySensor()
70-
checkDrift()
69+
loopIndex = (loopIndex + 1) % 100

0 commit comments

Comments
 (0)
0