8000 Removed unessecary import within main loop · WesleyJ-128/FLL_Python_Codebase@d8d2e91 · GitHub
[go: up one dir, main page]

Skip to content

Commit d8d2e91

Browse files
committed
Removed unessecary import within main loop
1 parent 54003e4 commit d8d2e91

File tree

1 file changed

+26
-28
lines changed

1 file changed

+26
-28
lines changed

FLLMaster/Main.py

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
# Create the mission process used for running the current mission
1919
initthread()
2020
# Now that setup has finished, import everything else from MenuLib
21-
from MenuLib import *
21+
import MenuLib
2222

2323
# Calibrate the gyro
24-
calibrate()
24+
MenuLib.calibrate()
2525
# Calibrate the color sensor
26-
robot.reflectCal()
26+
MenuLib.robot.reflectCal()
2727
# Initialization has finished, print status message to VS Code output window
2828
print("Finished Init", file=stderr)
2929

@@ -33,50 +33,50 @@ def left():
3333
Called when left button pressed; if there is no mission running,
3434
decrease count and update the display. Otherwise, abort the current mission.
3535
"""
36-
if not mission.is_alive():
37-
minusCount()
38-
display()
36+
if not MenuLib.mission.is_alive():
37+
MenuLib.minusCount()
38+
MenuLib.display()
3939
else:
40-
abort()
40+
MenuLib.abort()
4141
def right():
4242
"""
4343
Called when right button pressed; if there is no mission running,
4444
increase count and update the display. Otherwise, abort the current mission.
4545
"""
46-
if not mission.is_alive():
47-
addCount()
48-
display()
46+
if not MenuLib.mission.is_alive():
47+
MenuLib.addCount()
48+
MenuLib.display()
4949
else:
50-
abort()
50+
MenuLib.abort()
5151
def down():
5252
"""
5353
Called when bottom button pressed; if there is no mission running,
5454
recalibrate the gyro. Otherwise, abort the current mission.
5555
"""
56-
if not mission.is_alive():
57-
calibrate()
56+
if not MenuLib.mission.is_alive():
57+
MenuLib.calibrate()
5858
else:
59-
abort()
59+
MenuLib.abort()
6060
def up():
6161
"""
6262
Called when top button pressed; if there is no mission running,
6363
recalibrate the color sensor. Otherwise, abort the current mission.
6464
"""
65-
if not mission.is_alive():
66-
robot.reflectCal()
65+
if not MenuLib.mission.is_alive():
66+
MenuLib.robot.reflectCal()
6767
else:
68-
abort()
68+
MenuLib.abort()
6969
def enter():
7070
"""
7171
Called when center button pressed; if there is no mission running, launch the selected mission,
7272
increase count, and update the display. Otherwise, abort the current mission.
7373
"""
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()
7878
else:
79-
abort()
79+
MenuLib.abort()
8080

8181
# Print to the VS Code window that the button functions have been defined
8282
print("Functions Defined", file=stderr)
@@ -95,17 +95,15 @@ def enter():
9595

9696
# Start the infinite menu loop
9797
while True:
98-
# This updates the status and process id of the mission process every loop cycle
99-
from MenuLib import mission
10098
# Store the list of buttons currently pressed as buttonlist
101-
buttonlist = robot.btn.buttons_pressed
99+
buttonlist = MenuLib.robot.btn.buttons_pressed
102100
# Check if there are any buttons pressed; if there is, run the corresponding function
103101
if buttonlist:
104102
buttonMap[buttonlist[0]]()
105103
# Increment loopIndex and reset to zero every hundreth loop
106104
loopIndex = (loopIndex + 1) % 100
107105
# Make sure there is no mission running (to prevent resource conflicts),
108106
# 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

Comments
 (0)
0