安慰#

介绍#

VEXcode GO 控制台显示在 VEXcode 的监视器窗口中。它允许您实时显示文本、接收输入、监视变量和传感器,以及格式化打印数据。

以下是所有方法的列表:

操作 — 与控制台交互。

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

Getter – 读取用户输入。

  • input – Returns the most recent user input as a string.

修改器 — 更改控制台中的文本颜色。

监控 — 在 VEXcode 的“监控”选项卡中,监控项目期间传感器或变量的值。

行动#

print#

print 使用当前光标位置在控制台中打印值。

用法:
console.print(value, precision)

参数

描述

value

要打印为字符串或数字的值。

precision

可选。指定打印的小数位数。默认值为 0。

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

# Start threads — Do not delete
start_thread(main)

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.

用法:
console.new_line()

参数

描述

该方法没有参数。

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.

用法:
console.clear()

参数

描述

该方法没有参数。

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)

input#

input returns the most recent user input from the Console as a string.

Usage:
input()

参数

描述

该方法没有参数。

# Message the robot a name for the robot to greet
answer = input("What's your name?")
console.print("Hi, " + answer + "! My name is GO.")

修改器#

set_print_color#

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

用法:
set_print_color(color)

参数

描述

color

The color to print text with:

  • BLACK
  • BLUE
  • GREEN
  • RED

def main():
    # Print in different colors
    console.print("Default text color")
    console.new_line()
    console.set_print_color(RED)
    console.print("Red text color")

# Start threads — Do not delete
start_thread(main)

监视器#

monitor_sensor#

monitor_sensor 在 VEXcode 的 Monitor 选项卡中添加要监控的传感器值。

用法:
monitor_sensor(“sensor”)

参数

描述

sensor

要监控哪个传感器,以字符串形式给出:

  • 计时器
    • timer.time
  • 传动系统
    • 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.get_position
    • motor.get_velocity
    • motor.get_current
    • motor.is_stopped
    • motor.is_moving
    • inertial.get_rotation
    • inertial.get_heading
    • inertial.get_yaw
    • inertial.get_pitch
    • inertial.get_accelerationX
    • inertial.get_accelerationY
    • inertial.get_accelerationZ
  • 保险杠
    • bumper.is_pressed
  • 眼睛
    • 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)

# Build Used: Super Code Base 2.0
def main():
    # Monitor the rotation in the Monitor tab
    monitor_sensor("drivetrain.get_rotation", "drivetrain.get_heading")
    drivetrain.turn_for(RIGHT, 450)

# Start threads — Do not delete
start_thread(main)

monitor_variable#

monitor_variable 在 VEXcode 的 Monitor 选项卡中添加一个要监控的预定义变量。

用法:
monitor_variable(“variable”)

参数

描述

variable

要监视的预定义变量的名称,以字符串形式给出。

# Build Used: Super Code Base 2.0
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)


# Start threads — Do not delete
start_thread(main)

actions = 0

# Build Used: Super Code Base 2.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

# Start threads — Do not delete
start_thread(main)