Controlador#

Introducción#

El Brain IQ (2.ª generación) se puede conectar a un mando IQ (2.ª generación) o a un mando IQ (1.ª generación). Ambos mandos cuentan con dos joysticks analógicos y varios botones que el Brain puede usar para detectar movimientos y pulsaciones.

For the examples below, the configured controller will be named controller and will be used in all subsequent examples throughout this API documentation when referring to Controller class methods.

A continuación se muestra una lista de todos los métodos disponibles:

Acciones: activa o desactiva las acciones programadas por el controlador.

Getters: leen los estados de los botones y las posiciones del joystick.

  • .pressing – Devuelve si se está presionando el botón especificado.

  • .position – Devuelve la posición del eje especificado del joystick.

Devolución de llamada: ejecuta el código cuando los botones o joysticks cambian de estado.

  • .pressed – Llama a una función cuando se presiona el botón especificado.

  • .released – Llama a una función cuando se suelta el botón especificado.

  • .changed – Llama a una función cuando cambia el eje del joystick.

Constructores: inicializan y configuran manualmente el controlador.

Comportamiento#

remote_control_code_enabled#

remote_control_code_enabled is a variable that can be set to a boolean that enables or disables Controller configured actions from the Devices menu. The Controller is enabled by default. It can be set to either of the following:

  • True — Enable Controller configured actions.

  • False — Disable Controller configured actions.

Usage: remote_control_code_enabled = False

# Example coming soon!

Captadores#

.pressing#

.pressing returns an integer indicating whether a specific button on the controller is currently being pressed. This method must be called on a specific button object, such as buttonEDown (see full list of button objects below).

  • 1 - The specified button is being pressed.

  • 0 - The specified button is not being pressed.

Uso:
Se puede usar uno de los cinco objetos de botón disponibles con este método, como se muestra a continuación:

Botón

Dominio

buttonEDown

controller.buttonEDown.pressing() — The E Down button

buttonEUp

controller.buttonEUp.pressing() — The E Up button

buttonFDown

controller.buttonFDown.pressing() — The F Down button

buttonFUp

controller.buttonFUp.pressing() — The F Up button

buttonL3

controller.buttonL3.pressing() — The Left Joystick button - IQ (2nd gen) Controller only

buttonLDown

controller.buttonLDown.pressing() — The L Down button

buttonLUp

controller.buttonLUp.pressing() — The L Up button

buttonR3

controller.buttonR3.pressing() — The Right Joystick button - IQ (2nd gen) Controller only

buttonRDown

controller.buttonRDown.pressing() — The R Down button

buttonRUp

controller.buttonRUp.pressing() — The R Up button

Parámetros

Descripción

Este método no tiene parámetros.

# Example coming soon

.position#

.position returns the position of the joystick’s specified axis as an integer from –100 to 100, representing a percentage. This method must be called on a specific axis object, such as axisA (see full list of axis objects below).

Uso:

Se puede utilizar uno de los cuatro ejes disponibles con este método, como se muestra a continuación:

Eje

Dominio

axisA

controller.axisA.position() — The Left Joystick’s vertical axis

axisB

controller.axisB.position() — The Left Joystick’s horizontal axis

axisC

controller.axisC.position() — The Right Joystick’s horizontal axis

axisD

controller.axisD.position() — The Right Joystick’s vertical axis

Parámetros

Descripción

Este método no tiene parámetros.

# Example coming soon

Llamar de vuelta#

.pressed#

.pressed registers a function to be called when a specific button on the controller is pressed. This method must be called on a specific button object, such as buttonEDown – (see full list of button objects below).

Uso:
Uno de los objetos de botón disponibles se puede utilizar con este método, como se muestra a continuación:

Botón

Dominio

buttonEDown

controller.buttonEDown.pressed(callback, arg) — The E Down button

buttonEUp

controller.buttonEUp.pressed(callback, arg) — The E Up button

buttonFDown

controller.buttonFDown.pressed(callback, arg) — The F Down button

buttonFUp

controller.buttonFUp.pressed(callback, arg) — The F Up button

buttonL3

controller.buttonL3.pressed(callback, arg) — The Left Joystick button - IQ (2nd gen) only

buttonLDown

controller.buttonLDown.pressed(callback, arg) — The L Down button

buttonLUp

controller.buttonLUp.pressed(callback, arg) — The L Up button

buttonR3

controller.buttonR3.pressed(callback, arg) — The Right Joystick button - IQ (2nd gen) only

buttonRDown

controller.buttonRDown.pressed(callback, arg) — The R Down button

buttonRUp

controller.buttonRUp.pressed(callback, arg) — The R Up button

Parámetros

Descripción

llamar de vuelta

Una función que se define previamente para ejecutarse cuando se presiona el botón especificado.

arg

Opcional. Una tupla que contiene argumentos para la función de devolución de llamada. Funciones con parámetros para más información.

# Example coming soon

.released#

.released registers a function to be called when a specific button on the controller is released. This method must be called on a specific button object, such as buttonEDown – (see full list of button objects below).

Uso:
Uno de los objetos de botón disponibles se puede utilizar con este método, como se muestra a continuación:

Botón

Dominio

buttonEDown

controller.buttonEDown.released(callback, arg) — The E Down button

buttonEUp

controller.buttonEUp.released(callback, arg) — The E Up button

buttonFDown

controller.buttonFDown.released(callback, arg) — The F Down button

buttonFUp

controller.buttonFUp.released(callback, arg) — The F Up button

buttonL3

controller.buttonL3.released(callback, arg) — The Left Joystick button - IQ (2nd gen) Controller only

buttonLDown

controller.buttonLDown.released(callback, arg) — The L Down button

buttonLUp

controller.buttonLUp.released(callback, arg) — The L Up button

buttonR3

controller.buttonR3.released(callback, arg) — The Right Joystick button - IQ (2nd gen) Controller only

buttonRDown

controller.buttonRDown.released(callback, arg) — The R Down button

buttonRUp

controller.buttonRUp.released(callback, arg) — The R Up button

Parámetros

Descripción

llamar de vuelta

Una función que se define previamente para ejecutarse cuando se suelta el botón especificado.

arg

Opcional. Una tupla que contiene argumentos para la función de devolución de llamada. Funciones con parámetros para más información.

# Example coming soon

.changed#

.changed registers a function to be called when the joystick’s position changes. This method must be called on a specific axis object, such as axisA (see full list of axis objects below).

Uso:
Se puede utilizar uno de los cuatro ejes disponibles con este método, como se muestra a continuación:

Eje

Dominio

axisA

controller.axisA.changed(callback, arg) — The Left Joystick’s vertical axis

axisB

controller.axisB.changed(callback, arg) — The Left Joystick’s horizontal axis

axisC

controller.axisC.changed(callback, arg) — The Right Joystick’s horizontal axis

axisD

controller.axisD.changed(callback, arg) — The Right Joystick’s vertical axis

Parámetros

Descripción

llamar de vuelta

Una función que se define previamente para ejecutarse cuando cambia el valor del eje.

arg

Opcional. Una tupla que contiene los argumentos que se pasarán a la función de devolución de llamada. Consulte Funciones con parámetros para obtener más información.

# Function to display an emoji when the joystick is moved
def move_joystick():
    robot.screen.show_emoji(CONFUSED)

# Run the function when the joystick is moved up or down
controller.axis1.changed(move_joystick)

Constructores#

Constructors are used to manually create Controller objects, which are necessary for configuring a controller outside of VEXcode.

Controller#

Controller creates a controller.

Usage:
Controller()

Parámetros

Descripción

Este constructor no tiene parámetros.

# Example coming soon