控制器#

V5 控制器允许用户控制和自定义机器人的行为,或在控制器屏幕上显示消息。

以下是可用模块列表:

数值 - 读取按钮状态和摇杆位置。

操作 – 震动控制器并启用或禁用已配置的控制器功能。

事件——当按钮被按下或操纵杆被移动时运行代码。

屏幕 – 在控制器屏幕上显示文本和数字。

价值观#

控制器被按下?#

控制器是否被按下? 模块返回一个布尔值,指示控制器上的特定按钮当前是否被按下。

  • 正确——控制器上指定的按钮已被按下。

  • 错误——控制器上指定的按钮未被按下。

The front and back side of the V5 Controller with the buttons highlighted in yellow. On the surface of the controller are up, down, left, and right arrow buttons on the left, and X, A, B, Y buttons clockwise from 12 oclock on the right. On the back side of the controller are L1, L2, R1, and R2 on the left and right sides respectively.

<[Controller 1 v] [▲ v] 按下?>

范围

描述

设备

在“设备”窗口中配置要使用的控制器。

按钮

要检查哪个按钮:

  • X
  • B
  • Y
  • A
  • L1
  • L2
  • R1
  • R2

例子

当开始
[Drive forward while X is pressed.]
永久循环
如果 <[Controller 1 v] [X v] 按下?> 那么
驱动 [向前 v]
否则
驱动停止

控制器位置#

控制器位置 模块返回操纵杆沿特定轴移动的距离,范围从 -100 到 100。值为 0 表示操纵杆位于中心位置。

A VEX V5 Controller with the axes around the joysticks labeled. Axis 1 and 2 are around the right joystick, and Axis 3 and 4 are around the left.

([Controller1 v] [1 v] position)

范围

描述

设备

在“设备”窗口中配置要使用的控制器。

要检查哪个轴:

  • 1
  • 2
  • 3
  • 4

例子

当开始
[Drive forward while the left joystick is pushed up.]
永久循环
如果 <([Controller1 v] [3 v] position) [math_greater_than v] [0]> 那么
驱动 [向前 v]
否则
驱动停止

行动#

玩大乱斗#

播放震动模块会在控制器上播放震动模式。

[Controller 1 v] 播放 [Long v] 振动

范围

描述

图案

控制器上的震动模式:

  • 长震动 – 一次较长的震动
  • 短震动 – 一次较短的震动
  • 脉冲震动 – 断断续续的震动模式

设备

在“设备”窗口中配置要使用的控制器。

控制器启用/禁用#

控制器启用/禁用模块用于启用或禁用从“设备”菜单对所有已连接控制器配置的操作。

控制器 [Disable v]

范围

描述

状态

将已连接控制器的状态设置为:

  • 禁用
  • 启用

当开始
[Disable controller configured actions until drive is done.]
控制器 [Disable v]
驱动 [向前 v] (6) [英寸 v] ▶
控制器 [Enable v]

活动#

按下控制器按钮#

当控制器按钮被按下时 模块会在指定的控制器按钮被按下或释放时运行所连接的模块堆栈。

The front and back side of the V5 Controller with the buttons highlighted in yellow. On the surface of the controller are up, down, left, and right arrow buttons on the left, and X, A, B, Y buttons clockwise from 12 oclock on the right. On the back side of the controller are L1, L2, R1, and R2 on the left and right sides respectively..

当 [Controller 1 v] 按键 [▲ v] [pressed v] :: hat events

范围

描述

设备

在“设备”窗口中配置要使用的控制器。

按钮

要检查哪个按钮:

  • X
  • B
  • Y
  • A
  • L1
  • L2
  • R1
  • R2

状态

当连接的积木栈运行时:

  • 按下
  • 释放

例子

当 [Controller 1 v] 按键 [Y v] [pressed v] :: hat events
[Drive forward 50 mm whenever the Y button is pressed]
驱动 [向前 v] [200] [毫米 v] ▶

当控制器轴发生变化时#

当指定的操纵杆轴的值发生变化时,当控制器轴发生变化时模块会运行所连接的模块堆栈。

A VEX V5 Controller with the axes around the joysticks labeled. Axis 1 and 2 are around the right joystick, and Axis 3 and 4 are around the left.

when [Controller1 v] axis [1 v]
changed :: hat events

范围

描述

设备

在“设备”窗口中配置要使用的控制器。

要检查哪个轴:

  • 1
  • 2
  • 3
  • 4

例子

when [Controller1 v] axis [3 v] changed :: hat events
[Move forward when left joystick is up, backwards if down.]
如果 <([Controller1 v] [3 v] position) [math_greater_than v] [0]> 那么
驱动 [向前 v]
否则如果 <([Controller1 v] [3 v] position) [math_less_than v] [0]> 那么
驱动 [反 v]
否则
驱动停止

屏幕#

V5 控制器可访问 3 行 19 列进行打印。

A screenshot of the V5 Controller screen, showing the rows and columns in the printable area. Row 1 Column 1 starts at the upper left corner and row 3, column 19 are in the lower right corner.

将光标置于控制器上#

“设置控制器上的光标”模块会将光标设置到控制器屏幕上的特定行和列。控制器屏幕有 3 行 19 列。

A screenshot of the V5 Controller screen, showing the rows and columns in the printable area. Row 1 Column 1 starts at the upper left corner and row 3, column 19 are in the lower right corner.

在 [Controller 1 v] 设定光标至 [1] 行 [1] 列

范围

描述

光标所在行的第 1 行到第 3 行。

柱子

光标所在列,从 1 到 19。

设备

在“设备”窗口中配置要使用的控制器。

例子

当开始
[Clear the screen to prepare for printing.]
clear [Controller1 v]
在 [Controller 1 v] 设定光标至 [1] 行 [1] 列
在 [Controller 1 v] ▶上打印 [Hello!]

将光标设置到控制器上的下一行#

将光标设置到控制器上的下一行 代码块将光标设置到控制器屏幕上的下一行。

设定 [Controller 1 v] 光标至下一行

范围

描述

设备

在“设备”窗口中配置要使用的控制器。

例子

当开始
[Clear the screen to prepare for printing.]
clear [Controller1 v]
在 [Controller 1 v] 设定光标至 [1] 行 [1] 列
在 [Controller 1 v] ▶上打印 [Row 1]
设定 [Controller 1 v] 光标至下一行
在 [Controller 1 v] ▶上打印 [Row 2]

设置控制器上的打印精度#

设置控制器上的打印精度 块用于设置控制器屏幕上打印数字时显示的小数位数。

将打印精度设置为 [1 v] 到 [Controller 1 v]

范围

描述

精确

打印数字时将显示多少位小数:

  • 1
  • 0.1
  • 0.01
  • 0.001
  • 所有数字

设备

在“设备”窗口中配置要使用的控制器。

例子

当开始
[Display division with two decimals.]
将打印精度设置为 [0.01 v] 到 [Controller 1 v]
在 [Controller 1 v] ▶上打印 ([1] [math_division v] [3])

清除控制器#

清除控制器 代码块会清除控制器的屏幕。

clear [Controller1 v]

范围

描述

设备

在“设备”窗口中配置要使用的控制器。

例子

当开始
[Clear the screen to prepare for printing.]
clear [Controller1 v]
在 [Controller 1 v] 设定光标至 [1] 行 [1] 列
在 [Controller 1 v] ▶上打印 [Hello!]

清除控制器上的行#

清除控制器上的行 模块会清除控制器屏幕上指定的行。

清除 [Controller 1 v] 第 [1] 行

范围

描述

要清除第 1 行到第 3 行中的哪一行?

设备

在“设备”窗口中配置要使用的控制器。

例子

当开始
[Clear only one row on the controller.]
clear [Controller1 v]
在 [Controller 1 v] 设定光标至 [1] 行 [1] 列
在 [Controller 1 v] ▶上打印 [I will go!]
设定 [Controller 1 v] 光标至下一行
在 [Controller 1 v] ▶上打印 [I will stay!]
等待 [2] 秒
清除 [Controller 1 v] 第 [1] 行