Cerebro#

In VEX EXP C++, the Brain is represented by the brain class. You create (or use the default project-provided) Brain object and then access Brain features through its member objects.

Clases derivadas#

The brain class serves as a base class for the following derived classes:

  • Screen — This class provides access to the Brain’s built-in color touchscreen, allowing programs to display text, graphics, and receive touch input.

  • Timer — This class provides high-resolution timing utilities for measuring elapsed time and controlling time-based behavior in programs.

  • Battery — This class allows programs to monitor the Brain’s battery status, including voltage, current, capacity, and temperature.

  • Button — This class allows programs to interact with the Brain’s buttons.

  • ThreeWirePort (triport / 3-Wire Port) — This class provides access to the Brain’s 3-Wire ports for connecting and controlling legacy sensors and devices such as limit switches, potentiometers, and LEDs.

  • SDcard — This class enables reading from and writing to the Brain’s SD card for file storage, data logging, and loading external resources.

Constructores de clases#

brain();

Parámetros#

The brain constructor uses no parameters.

Notas#

  • Only one brain object should be created in a project.

Ejemplo#

// Create the EXP Brain
brain Brain = brain();

Funciones de los miembros#

The brain class includes the following member functions:

  • programStop — Stops the currently running project on the EXP Brain.

  • timer — Returns the current value of the Brain’s internal timer in the specified units.

  • resetTimer — Resets the Brain’s internal timer to zero and restarts timing.

  • setTimer — Sets the Brain’s internal timer to a specified value and time unit.

Before calling any brain member functions, a brain instance must be created, as shown below:

// Create the EXP Brain
brain Brain = brain();

programaDetener#

Detiene el proyecto que se está ejecutando actualmente en el EXP Brain.

Available Functions
void programStop();

Parameters

Esta función no acepta ningún parámetro.

Return Values

Esta función no devuelve ningún valor.

Examples
// Stop the project when the Brain screen is pressed
while (true) {
  if (Brain.Screen.pressing()) {
    Brain.programStop();
  }
  wait(20, msec);
}

minutero#

Devuelve el valor actual del temporizador interno del cerebro en las unidades especificadas.

Available Functions
double timer(
  timeUnits units );

Parameters

Parámetro

Tipo

Descripción

units

timeUnits

The unit of time to return:

  • seconds / sec — seconds
  • msec — milliseconds

Return Values

Returns a double representing the elapsed time since the program started, in the specified units.

Examples
  • El temporizador se inicia automáticamente cuando comienza el proyecto.

  • The timer can be reset with the use of resetTimer .

Examples
// Stop the project after 3 seconds
while (Brain.timer(seconds) < 3) {
  wait(20, msec);
}

Brain.programStop();

reiniciar temporizador#

Reinicia el temporizador interno del cerebro a cero. Después, el temporizador comienza a contar de nuevo inmediatamente desde cero.

Available Functions
void resetTimer();

Parameters

Esta función no acepta ningún parámetro.

Return Values

Esta función no devuelve ningún valor.

Notes
  • El temporizador vuelve a contar inmediatamente después de reiniciarse.

  • Calling resetTimer affects the value returned by subsequent calls to timer.

Examples
// Reset the timer and measure elapsed time
Brain.resetTimer();

while (Brain.timer(sec) < 5) {
  wait(20, msec);
}

// 5 seconds have elapsed since reset
Brain.Screen.print("5 seconds passed");

establecer temporizador#

Configura el temporizador interno del sistema a un valor y una unidad de tiempo específicos.

Available Functions
void setTimer(
  double value,
  timeUnits units );

Parameters

Parámetro

Tipo

Descripción

value

double

The time to set the timer to, based on the timeUnits provided in the units parameter.

units

timeUnits

The unit used to interpret the value parameter:

  • seconds / sec — seconds
  • msec — milliseconds

Return Values

Esta función no devuelve ningún valor.

Notes
  • El temporizador continúa contando hacia adelante después de haber sido configurado.

  • Calling setTimer immediately changes the value returned by timer.

Examples
// Set the timer to start at 10 seconds
Brain.setTimer(10, sec);

// Wait until the timer is at 3 seconds
while (Brain.timer(sec) < 3) {
  wait(20, msec);
}

// 5 seconds have elapsed since setTimer was called
Brain.Screen.print("5 seconds passed");