Consola#

Introducción#

A continuación se muestra una lista de todos los métodos:

Acciones – Interactuar con la consola.

  • 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.

Mutadores: cambian el color del texto en la consola.

Monitor: monitoree el valor de un sensor o una variable durante un proyecto en la pestaña Monitor de VEXcode.

Comportamiento#

print#

print imprime valores en la consola utilizando la posición actual del cursor.

Uso:
console.print(value, precision)

Parámetros

Descripción

value

El valor a imprimir como una cadena o un número.

precision

Opcional. Cuántos decimales se imprimirán. El valor predeterminado es 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 mueve el cursor al inicio de la fila debajo de la posición actual en la Consola.

Uso:
console.new_line()

Parámetros

Descripción

Este método no tiene parámetros.

# 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 borra todo el texto de la consola.

Uso:
console.clear()

Parámetros

Descripción

Este método no tiene parámetros.

# 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)

Mutadores#

set_print_color#

set_print_color establece el color utilizado al imprimir texto en la consola.

Uso:
set_print_color(color)

Parámetros

Descripción

color

El color con el que se imprimirá el texto:

  • BLACK
  • BLUE
  • GREEN
  • RED
# 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 agrega un valor de sensor para ser monitoreado en la pestaña Monitor de VEXcode.

Uso:
monitor_sensor(“sensor”)

Parámetros

Descripción

sensor

Qué sensor monitorear, dado como una cadena:

  • Temporizador
    • timer.time
  • Transmisión
    • drivetrain.get_heading
    • drivetrain.get_rotation
    • drivetrain.get_velocity
    • drivetrain.get_yaw
    • drivetrain.get_roll
    • drivetrain.get_pitch
    • drivetrain.get_crashed
    • drivetrain.is_stopped
  • Motor
    • motor.get_position
    • motor.get_velocity
    • motor.get_current
    • motor.is_stopped
    • motor.is_moving
  • Inercial
    • inertial.get_rotation
    • inertial.get_heading
    • inertial.get_yaw
    • inertial.get_roll
    • inertial.get_pitch
    • inertial.get_accelerationX
    • inertial.get_accelerationY
    • inertial.get_accelerationZ
  • Parachoques
    • bumper.is_pressed
  • Ojo
    • eye.get_color
    • eye.get_hue
    • eye.get_brightness
    • eye.is_object_detected
    • eye.is_color_detected

# 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 agrega una variable predefinida para ser monitoreada en la pestaña Monitor de VEXcode.

Uso:
monitor_variable(“variable”)

Parámetros

Descripción

variable

El nombre de la variable predefinida a monitorear, dado como una cadena.

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)