Cerebro#

Introducción#

La categoría de detección cerebral VEX IQ (2.ª generación) ofrece métodos para interactuar con los botones del cerebro y la batería conectada.

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

Acciones: interactúa con los botones de VEX IQ (2.ª generación).

  • pressed – Calls a function when the specified button is pressed.

  • released – Calls a function when the specified button is released.

Getters – Devuelven datos de los botones y la batería.

  • capacity – Returns the remaining battery capacity as a percentage.

  • pressing – Returns whether the specified button is being pressed.

  • voltage – Returns the battery voltage in volts.

  • current – Returns the battery current in amps.

Constructores: inicializan manualmente el cerebro.

  • brain – Create a Brain.

Comportamiento#

pressed#

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

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

Botón

Dominio

buttonCheck

Brain.buttonCheck.pressed(callback); — The Check button

buttonLeft

Brain.buttonLeft.pressed(callback); — The Left button

buttonRight

Brain.buttonRight.pressed(callback); — The Right button

Parámetros

Descripción

callback

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

// Display text with this function
void onCheckPressed() {
  Brain.Screen.clearScreen();
  Brain.Screen.print("Button pressed!");
}

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

   // Call the onCheckPressed when Check button is pressed
  Brain.buttonCheck.pressed(onCheckPressed);
}

released#

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

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

Botón

Dominio

buttonCheck

Brain.buttonCheck.released(callback); — The Check button

buttonLeft

Brain.buttonLeft.released(callback); — The Left button

buttonRight

Brain.buttonRight.released(callback); — The Right button

Parámetros

Descripción

callback

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

// Display text with this function
void onCheckReleased() {
  Brain.Screen.clearScreen();
  Brain.Screen.print("Button released!");
}

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

  // Call the onCheckReleased when Check button is released
  Brain.buttonCheck.released(onCheckReleased);
}

Captadores#

capacity#

capacity returns the remaining battery capacity of the Brain as a percentage.

Usage:
Brain.Battery.capacity()

Parámetros

Descripción

Este método no tiene parámetros.

pressing#

pressing returns a Boolean indicating whether a specific button on the Brain is currently being pressed. This method must be called on a specific button object, such as buttonCheck (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 tres objetos de botón disponibles con este método, como se muestra a continuación:

Botón

Dominio

buttonCheck

Brain.buttonCheck.pressing() — The Check button

buttonLeft

Brain.buttonLeft.pressing() — The Left button

buttonRight

Brain.buttonRight.pressing() — The Right button

Parámetros

Descripción

Este método no tiene parámetros.

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

  // Show if Check button is pressed
  while (true) {
    Brain.Screen.clearScreen();
    Brain.Screen.setCursor(1, 1);
    if (Brain.buttonCheck.pressing()) {
      Brain.Screen.print("Pressed");
    } else {
      Brain.Screen.print("Not pressed");
    }
    wait(100, msec);
  }
}

voltage#

voltage returns the Brain’s battery voltage in volts.

Usage:
Brain.Battery.voltage()

Parámetros

Descripción

Este método no tiene parámetros.

current#

current returns the Brain’s battery current in amps.

Usage:
Brain.Battery.current()

Parámetros

Descripción

Este método no tiene parámetros.

Constructores#

brain#

brain creates an object of the brain Class.

Usage:
brain Brain;

Parámetro

Descripción

Este constructor no tiene parámetros.

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

  // Create a new Brain object
  brain MyBrain;
}