控制器#

介绍#

The Controller category includes blocks for detecting and responding to input from the VEX IQ (2nd gen) Controller. These blocks allow your robot to react to button presses, monitor joystick positions, and control how input mappings are applied during a project.

Below is a list of all blocks:

控制器按钮按下了吗?#

**控制器按钮是否被按下?**块返回一个整数,指示是否按下了特定的控制器按钮。

  • 0 — The controller button is not being pressed.

  • 1 — The controller button is being pressed.

settings
<Controller [E ▲ v] 按下了?>

参数

描述

按钮

按钮按下/释放状态检测:

  • E ▲
  • E ▼
  • F ▲
  • F ▼
  • L ▲
  • L ▼
  • R ▲
  • R ▼
  • L3
  • R3

例子

当开始
[Move forward when the R ▲ button is pressed.]
永久循环
如果 <Controller [R ▲ v] 按下了?> 那么
驱动 [向前 v]
否则
驱动停止

控制器轴位置#

控制器轴位置块以 -100 到 100 之间的整数返回操纵杆沿指定轴的位置。

settings
(Controller [A v] 位移)

参数

描述

要检查变化的轴:

  • A
  • B
  • C
  • D

例子

当开始
[Turn depending on the position of the right joystick.]
永久循环
如果 <(Controller [C v] 位移) [math_less_than v] [0]> 那么
[左 v] 转
否则如果 <(Controller [C v] 位移) [math_greater_than v] [0]> 那么
[右 v] 转
否则
驱动停止

控制器启用/禁用#

The controller enable/disable block enables or disables controller configured actions from the Devices menu.

控制器 [Disable v]

参数

描述

状态

将控制器设置为什么状态:

  • 禁用
  • 启用

例子

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

当控制器按钮#

当按下或释放按钮时,当控制器按钮块会激活附加的块堆栈。

settings
当Controller按键 [E ▲ v] [pressed v]

参数

描述

按钮

按钮按下/释放状态检测:

  • E ▲
  • E ▼
  • F ▲
  • F ▼
  • L ▲
  • L ▼
  • R ▲
  • R ▼
  • L3
  • R3

按钮状态

指定当按钮按下时是否触发附加的块堆栈:

例子

当Controller按键 [R ▲ v] [pressed v]
[Turn when a button is pressed.]
[右 v] 转 (90) 度 ▶

当控制器轴改变时#

当轴发生变化时,当控制器轴发生变化时块会激活附加的块堆栈。

settings
当Controller [A v] 轴改变

参数

描述

要检查变化的轴:

  • A
  • B
  • C
  • D

例子

当Controller [D v] 轴改变
[Move forward when right joystick is moved.]
驱动 [向前 v] (200) [毫米 v] ▶