Controlador#
Introducción#
The controller class represents a VEX V5 Controller connected to the V5 Brain. A controller object can be used to access joystick axis values, read button states, register button or joystick callbacks, make the Controller rumble, write to the Controller screen, and check whether the Controller is connected.
VEX V5 es compatible con el controlador EXP. Consulte la API del controlador EXP para obtener más información.
When one or more Controllers are configured in the Devices window, VEXcode V5 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:
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 |
|---|---|---|
|
|
Optional. The Controller type to create: |
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 |
|---|---|---|
|
|
The type of controller being created:
|
Notas#
Only one
primaryand onepartnercontroller may exist in a single project.
Ejemplo#
// Create a V5 controller instance
controller Controller = controller();
Funciones de los miembros#
The controller class includes the following member functions:
rumble- Rumbles the controller using a pattern.installed- Checks whether the controller is connected to the brain.
retumbar#
rumble makes the Controller vibrate using a pattern. In the pattern string, dots are short vibrations, dashes are long vibrations, and spaces are pauses.
Función disponible
void rumble(const char *str);
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
Una cadena formada por puntos, guiones y espacios que representan el patrón de vibración. |
Valor de retorno
Esta función no devuelve ningún valor.
Ejemplo
// Rumble with a short-short-long pattern
Controller1.rumble("..-");
Adquiridor#
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 |
|---|---|
|
Habilita las acciones configuradas por el controlador. |
|
Deshabilita las acciones configuradas por el controlador. |
true- Controller-configured actions are enabled.false- Controller-configured actions are disabled.
Las acciones configuradas por el controlador están habilitadas de forma predeterminada.
// Drive forward or backward using the left joystick
RemoteControlCodeEnabled = false;
while (true) {
if (Controller1.Axis3.position() > 0) {
Drivetrain.drive(forward);
}
else if (Controller1.Axis3.position() < 0) {
Drivetrain.drive(reverse);
}
// Press A to use Controller configured actions again
else if (Controller1.ButtonA.pressing()) {
break;
}
else {
Drivetrain.stop();
}
wait(20, msec);
}
RemoteControlCodeEnabled = true;