18
18
# Create the mission process used for running the current mission
19
19
initthread ()
20
20
# Now that setup has finished, import everything else from MenuLib
21
- from MenuLib import *
21
+ import MenuLib
22
22
23
23
# Calibrate the gyro
24
- calibrate ()
24
+ MenuLib . calibrate ()
25
25
# Calibrate the color sensor
26
- robot .reflectCal ()
26
+ MenuLib . robot .reflectCal ()
27
27
# Initialization has finished, print status message to VS Code output window
28
28
print ("Finished Init" , file = stderr )
29
29
@@ -33,50 +33,50 @@ def left():
33
33
Called when left button pressed; if there is no mission running,
34
34
decrease count and update the display. Otherwise, abort the current mission.
35
35
"""
36
- if not mission .is_alive ():
37
- minusCount ()
38
- display ()
36
+ if not MenuLib . mission .is_alive ():
37
+ MenuLib . minusCount ()
38
+ MenuLib . display ()
39
39
else :
40
- abort ()
40
+ MenuLib . abort ()
41
41
def right ():
42
42
"""
43
43
Called when right button pressed; if there is no mission running,
44
44
increase count and update the display. Otherwise, abort the current mission.
45
45
"""
46
- if not mission .is_alive ():
47
- addCount ()
48
- display ()
46
+ if not MenuLib . mission .is_alive ():
47
+ MenuLib . addCount ()
48
+ MenuLib . display ()
49
49
else :
50
- abort ()
50
+ MenuLib . abort ()
51
51
def down ():
52
52
"""
53
53
Called when bottom button pressed; if there is no mission running,
54
54
recalibrate the gyro. Otherwise, abort the current mission.
55
55
"""
56
- if not mission .is_alive ():
57
- calibrate ()
56
+ if not MenuLib . mission .is_alive ():
57
+ MenuLib . calibrate ()
58
58
else :
59
- abort ()
59
+ MenuLib . abort ()
60
60
def up ():
61
61
"""
62
62
Called when top button pressed; if there is no mission running,
63
63
recalibrate the color sensor. Otherwise, abort the current mission.
64
64
"""
65
- if not mission .is_alive ():
66
- robot .reflectCal ()
65
+ if not MenuLib . mission .is_alive ():
66
+ MenuLib . robot .reflectCal ()
67
67
else :
68
- abort ()
68
+ MenuLib . abort ()
69
69
def enter ():
70
70
"""
71
71
Called when center button pressed; if there is no mission running, launch the selected mission,
72
72
increase count, and update the display. Otherwise, abort the current mission.
73
73
"""
74
- if not mission .is_alive ():
75
- run ()
76
- addCount ()
77
- display ()
74
+ if not MenuLib . mission .is_alive ():
75
+ MenuLib . run ()
76
+ MenuLib . addCount ()
77
+ MenuLib . display ()
78
78
else :
79
- abort ()
79
+ MenuLib . abort ()
80
80
81
81
# Print to the VS Code window that the button functions have been defined
82
82
print ("Functions Defined" , file = stderr )
@@ -95,17 +95,15 @@ def enter():
95
95
96
96
# Start the infinite menu loop
97
97
while True :
98
- # This updates the status and process id of the mission process every loop cycle
99
- from MenuLib import mission
100
98
# Store the list of buttons currently pressed as buttonlist
101
- buttonlist = robot .btn .buttons_pressed
99
+ buttonlist = MenuLib . robot .btn .buttons_pressed
102
100
# Check if there are any buttons pressed; if there is, run the corresponding function
103
101
if buttonlist :
104
102
buttonMap [buttonlist [0 ]]()
105
103
# Increment loopIndex and reset to zero every hundreth loop
106
104
loopIndex = (loopIndex + 1 ) % 100
107
105
# Make sure there is no mission running (to prevent resource conflicts),
108
106
# and if there is none, display the sensor values and update the light color based on the gyro sensor
109
- if not mission .is_alive ():
110
- checkDrift ()
111
- displaySensor ()
107
+ if not MenuLib . mission .is_alive ():
108
+ MenuLib . checkDrift ()
109
+ MenuLib . displaySensor ()
0 commit comments