Eje#

posición()#

El comando position(units) obtiene la posición del eje del joystick en una escala de -100 a 100.

Objeto

Descripción



eje

De qué eje informar la posición:

  • Eje1 - Izquierda y derecha del joystick derecho.
  • Eje2 - Arriba y abajo del joystick derecho.
  • Eje3 - Arriba y abajo del joystick izquierdo.
  • Eje4 - Izquierda y derecha del joystick izquierdo.

Devuelve: Un entero que representa la posición del eje del joystick.

// 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);

cambió()#

El comando changed(callback) registra una función que se llamará cuando cambie el valor del eje.

Parámetro

Descripción

llamar de vuelta

Una función que se llamará cuando cambie el valor del eje

Devoluciones: Ninguna.

// 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);
}