Console#
Introduction#
Below is a list of all methods:
Actions – Interact with the Console.
print
– Print text to the Console.new_line
– Move the Console cursor position at the start of the next row down.clear
– Clear all text from the Console.
Mutators – Change the text color in the Console.
set_print_color
– Set the color text will display in for the Console.
Monitor – Monitor a sensor’s or variable’s value during a project in VEXcode’s Monitor tab.
monitor_sensor
– Add a sensor to the Monitor tab.monitor_variable
– Add a predefined variable to the Monitor tab.
Actions#
print#
print
prints values in the console using the current cursor position.
Usage:
console.print(value, precision)
Parameters |
Description |
---|---|
|
The value to print as a string or a number. |
|
Optional. How many decimals will be printed. Default is 0. |
# Build Used: Super Code Base 2.0
def main():
# Display a message in the console
console.print("Hello, robot!")
# Start threads — Do not delete
start_thread(main)
# Build Used: Super Code Base 2.0
def main():
# Print a number with 5 decimals
console.print(math.pi, precision = 5)
# Start threads — Do not delete
start_thread(main)
new_line#
new_line
moves the cursor to the start of the row below the current position in the Console.
Usage:
console.new_line()
Parameters |
Description |
---|---|
This method has no parameters. |
# Build Used: Super Code Base 2.0
def main():
# Print on two lines
console.print("Line 1")
console.new_line()
console.print("Line 2")
# Start threads — Do not delete
start_thread(main)
clear#
clear
clears all text from the Console.
Usage:
console.clear()
Parameters |
Description |
---|---|
This method has no parameters. |
# Build Used: Super Code Base 2.0
def main():
# Clear the console after printing
console.print("This will disappear...")
wait(2, SECONDS)
console.clear()
# Start threads — Do not delete
start_thread(main)
Mutators#
set_print_color#
set_print_color
sets the color used when printing text to the Console.
Usage:
set_print_color(color)
Parameters |
Description |
---|---|
|
The color to print text with:
|
# Build Used: Super Code Base 2.0
def main():
# Print in different colors
console.print("Default text color")
wait(1, SECONDS)
console.set_print_color(RED)
console.print("Red text")
# Start threads — Do not delete
start_thread(main)
Monitor#
monitor_sensor#
monitor_sensor
adds a sensor value to be monitored in the Monitor tab of VEXcode.
Usage:
monitor_sensor(“sensor”)
Parameters |
Description |
---|---|
|
Which sensor to monitor, given as a string:
|
# Build Used: Super Code Base 2.0
def main():
# Monitor the rotation in the Monitor tab
monitor_sensor("drivetrain.get_rotation")
drivetrain.turn_for(RIGHT, 450)
# Start threads — Do not delete
start_thread(main)
monitor_variable#
monitor_variable
adds a predefined variable to be monitored in the Monitor tab of VEXcode.
Usage:
monitor_variable(“variable”)
Parameters |
Description |
---|---|
|
The name of the predefined variable to monitor, given as a string. |
loops = 0
# Build Used: Super Code Base 2.0
def main():
# Monitor the amount of loops
global loops
monitor_variable("loops")
while loops < 12:
drivetrain.turn_for(RIGHT, 90)
drivetrain.drive_for(FORWARD, 150, MM)
loops += 1
# Start threads — Do not delete
start_thread(main)