#

位置()#

position(units) 命令获取操纵杆轴在 -100 到 100 范围内的位置。

目的

描述



报告哪个轴的位置:

  • Axis1 - 右操纵杆的左侧和右侧。3
  • Axis2 - 右操纵杆的上下。5</li><li>Axis3 - 左操纵杆的上下。7
  • Axis4` - 左操纵杆的左侧和右侧。

**返回:**表示操纵杆轴位置的整数。

// Get the position of the current axis.
int axis = Controller.Axis1.position();

// Print the position of the current controller axis to the
// Brain's screen.
Brain.Screen.print(axis);

已更改()#

changed(callback) 命令注册一个函数,当轴值改变时调用。

范围

描述

打回来

当轴值改变时调用的函数

**返回:**无。

// Define the axisChanged function with a void return type,
// showing it doesn't return a value.
void axisChanged() {
  // The Brain will print that the controller axis changed
  // on the Brain's screen.
  Brain.Screen.print("controller axis changed");
}

int main() {
  // Initializing Robot Configuration. DO NOT REMOVE!
  vexcodeInit();

  // Run axisChanged when the value of the controller axis changes.
  Controller.Axis3.changed(axisChanged);
}