Skip to content

Commit f15ee08

Browse files
committed
Fixed comments in Main.py to use docstrings
Added a "how to use" section to README.md
1 parent 98e89c3 commit f15ee08

File tree

2 files changed

+40
-12
lines changed

2 files changed

+40
-12
lines changed

FLLMaster/Main.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/usr/bin/env python3
22

3+
# This is the program that should be run during use; it creates the interactive menu.
4+
# It is also the only executable file other than test.py, which is only for testing things.
5+
36
# Initialize loopIndex variable, used in displaySensor()
47
loopIndex = 0
58

@@ -26,38 +29,48 @@
2629

2730
# Define the functions for button presses
2831
def left():
29-
# Make sure there is no mission process running; if it is not, decrease count and update the display
30-
# Otherwise, abort the current mission
32+
"""
33+
Called when left button pressed; if there is no mission running,
34+
decrease count and update the display. Otherwise, abort the current mission.
35+
"""
3136
if not mission.is_alive():
3237
minusCount()
3338
display()
3439
else:
3540
abort()
3641
def right():
37-
# Make sure there is no mission process running; if it is not, increase count and update the display
38-
# Otherwise, abort the current mission
42+
"""
43+
Called when right button pressed; if there is no mission running,
44+
increase count and update the display. Otherwise, abort the current mission.
45+
"""
3946
if not mission.is_alive():
4047
addCount()
4148
display()
4249
else:
4350
abort()
4451
def down():
45-
# Make sure there is no mission process running; if it is not, recalibrate the gyro
46-
# Otherwise, abort the current mission
52+
"""
53+
Called when bottom button pressed; if there is no mission running,
54+
recalibrate the gyro. Otherwise, abort the current mission.
55+
"""
4756
if not mission.is_alive():
4857
calibrate()
4958
else:
5059
abort()
5160
def up():
52-
# Make sure there is no mission process running; if it is not, recalibrate the color sensor
53-
# Otherwise, abort the current mission
61+
"""
62+
Called when top button pressed; if there is no mission running,
63+
recalibrate the color sensor. Otherwise, abort the current mission.
64+
"""
5465
if not mission.is_alive():
5566
robot.reflectCal()
5667
else:
5768
abort()
5869
def enter():
59-
# Make sure there is no mission process running; if it is not, run the current mission, increase count, and update the display
60-
# Otherwise, abort the current mission
70+
"""
71+
Called when center button pressed; if there is no mission running, launch the selected mission,
72+
increase count, and update the display. Otherwise, abort the current mission.
73+
"""
6174
if not mission.is_alive():
6275
run()
6376
addCount()

README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,17 @@
1-
# FLL_Python_Codebase
2-
Driving libraries and a master program designed for FLL-legal robots. Uses a robot.cfg file for robot parameters, and uses the ev3dev2 python library and brick firmware.
1+
# FLL_Python_Codebase
2+
Driving libraries and a master program designed for FLL-legal robots. Uses a robot.cfg file for robot parameters, and uses the ev3dev2 python library and brick firmware.
3+
4+
# Use:
5+
The file ``Main.py`` is the only executable file other than ``test.py``, and is the program that creates the menu. This program takes a while to start, so it should be started well before any timers. On startup, the robot will eventually emit the normal beep (A4) signalling that the config file has been read and some menu systems have been initialized. It will then emit a low-pitched beep (different from any other beep) and turn the lights yellow. This is standard procedure for recalibrating the gyro (inside this program, anyway), and the robot should be absolutely still from the first low-pitched beep to the second normal beep. After the second normal beep, the robot will start the color sensor calibration routine, emitting a high-pitched beep. This signals that the color sensor should be placed on the white surface. After pressing the center button, the robot will emit a normal beep signalling that the white surface has been stored. The robot will then emit a low-pitched beep. Again, place the robot on the black surface and press the center button. The robot will emit a normal beep, and the complete setup is done.
6+
7+
The screen will then show the name of the current mission across the top; and the current gyro and color sensor values (angle and RLI towards the bottom in the center. The lights will also likely begin flickering between red and green. The color of the light is determined by the rate reported by the gyro sensor; if it is within 1 degree/second of zero, the light will turn green. If the gyro reports that it is moving any faster than that, the light will turn red. Therefore, if the robot is not being manipulated and is not running a mission, the light should be green most of the time. If it is not, the gyro is likely drifting and needs to be recalibrated.
8+
9+
Button functions:
10+
*The center button runs the nission whose name is currently being displayed on the screen. It also advances to the next
11+
mission afterward.
12+
*The left button changes the selection to the previous mission, looping around to the last when pressing left on the first
13+
mission.
14+
*The right button works the same way as the left, but moving foward instead of back
15+
*The bottom button recalibrates the gyro
16+
*The top button recalibrates the color sensor
17+
When a mission is running, all buttons lose their normal functioon, and will abort the current mission.

0 commit comments

Comments
 (0)