Controlador#

Introducción#

The controller class represents a VEX IQ Controller connected to the IQ Brain. A controller object can be used to access joystick axis values, read button states, register button or joystick callbacks, and check whether the controller is connected.

El módulo IQ (2.ª generación) puede conectarse a un controlador IQ (2.ª generación) o a un controlador IQ (1.ª generación). Un controlador IQ (1.ª generación) debe tener instalada una radio inteligente azul.

When one or more controllers are configured in the Devices window, VEXcode IQ also provides RemoteControlCodeEnabled. This global variable enables or disables controller actions configured in the Devices menu.

Clases derivadas#

The controller class provides the following derived classes:

  • Axis - Provides access to joystick axis input values and change events.

  • Button - Provides access to button state and button event callbacks.

Constructores#

1 - Crea un controlador utilizando el tipo de controlador principal. Normalmente se utiliza cuando hay un único controlador conectado.

controller();

2 - Crea un controlador para el tipo de controlador especificado. Se utiliza cuando se conectan dos controladores.

controller(
    controllerType id );

Funciones disponibles

controller();

controller(controllerType id);

Parámetro

Tipo

Descripción

id

controllerType

Optional. The controller type to create: primary for the primary controller connected to the Brain or partner for the second controller connected to the Brain.

Notas

Only one primary controller and one partner controller can be created in a single project.

Ejemplo

// Create the primary controller
controller Controller1 = controller();

// Create a partner controller
controller Controller2 = controller(partner);

Incinerador de basuras#

~controlador#

~controller destroys the controller object and releases associated resources.

Función disponible

~controller();

Parámetros#

Parámetro

Tipo

Descripción

id

controllerType

The type of controller being created:

  • primary - The primary controller connected to the Brain.
  • partner - The partner (second) controller connected to the Brain.

Notas#

  • Only one primary and one partner controller may exist in a single project.

Ejemplo#

// Create a controller instance
controller Controller = controller();

Funciones de los miembros#

The controller class includes the following member function:

  • installed - Checks whether the controller is connected to the brain.

instalado#

installed returns whether the controller is connected to the Brain.

Función disponible

bool installed();

Parámetros

Esta función no tiene parámetros.

Valor de retorno

Devuelve un valor booleano.

  • true - The controller is installed/connected.
  • false - The controller is not installed/connected.

Variables globales#

Código de control remoto habilitado#

RemoteControlCodeEnabled enables or disables controller actions configured in the Devices menu. Controller configured actions are enabled by default.

Usage:
RemoteControlCodeEnabled = state;

Valor

Descripción

true

Habilita las acciones configuradas por el controlador.

false

Deshabilita las acciones configuradas por el controlador.

Values
  • true - Controller-configured actions are enabled.
  • false - Controller-configured actions are disabled.
Notes
  • Las acciones configuradas por el controlador están habilitadas de forma predeterminada.

Examples
// Drive forward or backward using the left joystick
RemoteControlCodeEnabled = false;

while (true) {
  if (Controller1.AxisA.position() > 0) {
    Drivetrain.drive(forward);
  }
  else if (Controller1.AxisA.position() < 0) {
    Drivetrain.drive(reverse);
  }
  // Press E Up to use controller configured actions again
  else if (Controller1.ButtonEUp.pressing()) {
    break;
  }
  else {
    Drivetrain.stop();
  }

  wait(20, msec);
}

RemoteControlCodeEnabled = true;