Console#

Introduction#

VEXcode VR features a Monitor tab that allows the tracking of variables and sensors, as well as printing text to the console.

Below is a list of all methods:

Print – 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.

  • set_print_color – Set the color text will display in for the Console.

  • clear – Clear all text from the Console.

Monitor – Monitor a sensor’s or variable’s value during a project in VEXcode’s Monitor tab.

Print#

print#

print prints values in the console using the current cursor position.

Usage:
brain.print(value, precision)

Parameters

Description

value

The value to print as a string or a number.

precision

Optional. How many decimals will be printed. Default is 0.

def main():
    # Display a message in the console
    brain.print("Hello, robot!")

# VR threads — Do not delete
vr_thread(main)

def main():
    # Print a number with 5 decimals
    brain.print(math.pi, precision = 5)

# VR threads — Do not delete
vr_thread(main)

new_line#

new_line moves the cursor to the start of the row below the current position in the Console.

Usage:
brain.new_line()

Parameters

Description

This method has no parameters.

def main():
    # Print on two lines
    brain.print("Line 1")
    brain.new_line()
    brain.print("Line 2")

# VR threads — Do not delete
vr_thread(main)

set_print_color#

set_print_color sets the color used when printing text to the Console.

Usage:
brain.set_print_color(color)

Parameters

Description

color

The color to print text with:

  • BLACK
  • BLUE
  • GREEN
  • RED
def main():
    # Print in different colors
    brain.print("Default text color")
    wait(1, SECONDS)
    brain.set_print_color(RED)
    brain.print("Red text")

# VR threads — Do not delete
vr_thread(main)

clear#

clear clears all text from the Console.

Usage:
brain.clear()

Parameters

Description

This method has no parameters.

def main():
    # Clear the console after printing
    brain.print("This will disappear...")
    wait(2, SECONDS)
    brain.clear()

# VR threads — Do not delete
vr_thread(main)

Monitor#

monitor_variable#

monitor_variable adds a predefined variable or variables to be monitored in the Monitor tab of VEXcode. Variables must be global for monitor_variable to successfully monitor variables.

Usage:
monitor_variable(“variable1”, “variable2”, …)

Parameters

Description

variable

The name of the predefined variable to monitor, given as a string.

def main():
    # Monitor the amount of loops
    global loops
    monitor_variable("loops")

    # Drive in a square 3 times
    for loops in range(12):
        drivetrain.turn_for(RIGHT, 90, DEGREES)
        drivetrain.drive_for(FORWARD, 150, MM)


# VR threads — Do not delete
vr_thread(main)

actions = 0

def main():
    # Monitor the amount of loops and actions
    global loops, actions
    monitor_variable("loops", "actions")

    # Drive in a square 3 times
    for loops in range(12):
        drivetrain.turn_for(RIGHT, 90, DEGREES)
        drivetrain.drive_for(FORWARD, 150, MM)
        actions = actions + 2


# VR threads — Do not delete
vr_thread(main)

monitor_sensor#

monitor_sensor adds a sensor value or values to be monitored in the Monitor tab of VEXcode. If a sensor can return data in different units, the Monitor tab will display the returned data in each available unit.

Usage:
monitor_sensor(“sensor1_id”, “sensor2_id”, …)

Parameters

Description

sensor

Which sensor to monitor, given as a string. This can be any sensor method that returns a value (“drivetrain.rotation”).

def main():
    # Monitor the distance in MM and inches
    monitor_sensor("front_distance.get_distance")
    drivetrain.drive_for(FORWARD, 400, MM)

# VR threads — Do not delete
vr_thread(main)

def main():
    # Monitor the rotation in the Monitor tab
    monitor_sensor("drivetrain.rotation", "drivetrain.heading")
    drivetrain.turn_for(RIGHT, 450, DEGREES)

# VR threads — Do not delete
vr_thread(main)