脑#
初始化 Brain 类#
要在项目中使用 Brain 方法,请首先按如下方式初始化它:
# Create a new object "brain" with the Brain class.
brain = Brain()
This brain object will be used in all subsequent examples throughout this API documentation when referring to Brain class methods.
类方法#
外观方法#
打印()#
The print(text, sep, precision) method prints text on the screen using the current cursor position.
参数 |
描述 |
|---|---|
|
要打印的文本。 |
|
Optional. A string to inset between values. This must be written as a keyword argument ( |
|
Optional. The number of decimal places to display when printing simple numbers. This must be written as a keyword argument( |
**返回:**无。
# Print the number 1 on the Brain's screen at current
# cursor position.
brain.print(1)
# Print the numbers 1, 2, 3 and 4 on the Brain's screen at
# current cursor position separated by a '-'.
brain.print(1, 2, 3, 4, sep='-')
换行()#
The new_line() method moves the cursor to a new line.
**返回:**无。
清除()#
The clear(color) method clears the Print Console.
**返回:**无。
# Print VEXcode on the Print Console.
brain.print("VEXcode")
# Clear the Print Console after 2 seconds.
wait(2, SECONDS)
brain.clear()
设置打印颜色()#
The set_print_color(color) method sets the text color to be printed in the Print Console.
参数 |
描述 |
|---|---|
|
A valid |
**返回:**无。
# Set pen color red using a hex value.
brain.set_print_color(0xFF0000)
传感方法#
timer_reset()#
The timer_reset() method resets the timer’s value.
**返回:**无。
timer_time()#
The timer_time(units) method returns the elapsed time.
参数 |
描述 |
|---|---|
|
A valid |
**返回:**指定单位的经过时间。