torre de señales#
Inicializando la clase signaltower#
Una torre de señales se crea utilizando el siguiente constructor:
The signaltower constructor creates a signaltower object.
Parámetro |
Descripción |
|---|---|
|
A valid |
// Construct a Signal Tower "SignalTower" with the
// signaltower class.
signaltower SignalTower = signaltower(PORT1);
This SignalTower object will be used in all subsequent examples throughout this API documentation when referring to signaltower class methods.
Métodos de clase#
setColor()#
Este método se llama de las siguientes maneras:
The setColor(color, state) method turns one or more LED on the signal tower on or off using predefined colors or a hexcode.
Parámetro |
Descripción |
|---|---|
|
A valid |
estado |
A valid |
Devoluciones: Ninguna.
// Set the Signal Tower to start blinking blue.
SignalTower.setColor(signaltower::blue, signaltower::blink);
The setColor(rgb, yx) method turns one or more LED on the signal tower on or off using 32 bit values.
Parámetro |
Descripción |
|---|---|
|
Un valor de código hexadecimal que representa el brillo de los LED rojo, verde y azul. |
|
Un valor de código hexadecimal que representa el brillo de los LED amarillo y blanco. |
Devoluciones: Ninguna.
// Set the red, blue and white LEDs to on.
// 0xFF00FF sets the red and blue LEDs on
SignalTower.setColor(0xFF00FF, 0x00FF);
The setColor(id, value) method turns an LED on the signal tower on or off based on the id of the LED.
Identificadores de LED:
rojo: 0
verde: 1
azul: 2
blanco: 3
amarillo: 4
ninguno: 99
Parámetro |
Descripción |
|---|---|
|
El identificador de uno de los LED de la torre de señales. |
|
El valor del brillo del LED en el rango 0 - 255. |
Devoluciones: Ninguna.
// Set the green LEDs to on.
SignalTower.setColor(1, 255);
The setColor(r, y, g, b, w) method sets the brightness levels for each LED on the signal tower.
Parámetro |
Descripción |
|---|---|
|
El valor del brillo del LED en el rango 0 - 255. |
|
El valor del brillo del LED en el rango 0 - 255. |
|
El valor del brillo del LED en el rango 0 - 255. |
|
El valor del brillo del LED en el rango 0 - 255. |
|
El valor del brillo del LED en el rango 0 - 255. |
Devoluciones: Ninguna.
// Set all LEDs to on.
SignalTower.setColor(255, 255, 255, 255, 255);
setColors()#
The setColors(r, y, g, b, w) method turns all LEDs on the signal tower on or off.
Parámetro |
Descripción |
|---|---|
|
A valid |
|
A valid |
|
A valid |
|
A valid |
|
A valid |
Devoluciones: Ninguna
// Turn on all LEDs.
SignalTower.setColors(signaltower::on, signaltower::on, signaltower::on, signaltower::on, signaltower::on);
setBlink()#
The setBlink(id, enable) method sets the blink state of an LED on the Signal Tower by the LED’s id.
Identificadores de LED:
rojo: 0
verde: 1
azul: 2
blanco: 3
amarillo: 4
ninguno: 99
Parámetro |
Descripción |
|---|---|
|
El ID del LED cuyo estado de parpadeo desea establecer. |
|
Un valor booleano para configurar el LED para que parpadee o no. |
Devoluciones: Ninguna.
setBlinkTime()#
The setBlinkTime(onTime, offTime) method sets the blink time for the LEDs on the Signal Tower.
Parámetro |
Descripción |
|---|---|
|
El tiempo en milisegundos que el LED debe estar encendido al parpadear. El máximo es de 2500 milisegundos. Un valor de 0 es 500 milisegundos por defecto. |
|
El tiempo en milisegundos que el LED debe estar apagado al parpadear. El máximo es de 2500 milisegundos. Un valor de 0 utilizará el tiempo establecido para onTime. El valor predeterminado es 0. |
Devoluciones: Ninguna.
enableBlink()#
The enableBlink(id0, id1, id2, id3, id4) method sets the blink state to on of LEDs on the Signal Tower by the LED’s id.
Identificadores de LED:
rojo: 0
verde: 1
azul: 2
blanco: 3
amarillo: 4
ninguno: 99
Parámetro |
Descripción |
|---|---|
|
El ID del primer LED en el que desea establecer el estado intermitente. |
|
El ID del primer LED en el que desea establecer el estado intermitente. |
|
El ID del primer LED en el que desea establecer el estado intermitente. |
|
El ID del primer LED en el que desea establecer el estado intermitente. |
|
El ID del primer LED en el que desea establecer el estado intermitente. |
Devoluciones: Ninguna.
disableBlink()#
The disableBlink(id0, id1, id2, id3, id4) method sets the blink state to off of LEDs on the Signal Tower by the LED’s id.
Identificadores de LED:
rojo: 0
verde: 1
azul: 2
blanco: 3
amarillo: 4
ninguno: 99
Parámetro |
Descripción |
|---|---|
|
El ID del primer LED para el cual desea establecer el estado de parpadeo en apagado. |
|
El ID del primer LED para el cual desea establecer el estado de parpadeo en apagado. |
|
El ID del primer LED para el cual desea establecer el estado de parpadeo en apagado. |
|
El ID del primer LED para el cual desea establecer el estado de parpadeo en apagado. |
|
El ID del primer LED para el cual desea establecer el estado de parpadeo en apagado. |
Devoluciones: Ninguna.
pressing()#
The pressing() method returns whether the signal tower button is currently being pressed.
Returns: true if the signal tower button is currently being pressed. false if it is not.
pressed()#
The pressed(callback) method registers a function to be called when the signal tower button is pressed.
Parámetro |
Descripción |
|---|---|
|
Una función que se llamará cuando se presione el botón |
Devoluciones: Ninguna.
// Define the towerButtonPressed function with a void
// return type, showing it doesn't return a value.
void towerButtonPressed() {
// The Brain will print that the tower button was
// pressed on the Brain's screen.
Brain.Screen.print("tower button pressed");
}
int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
// Run towerButtonPressed when the tower button
// is pressed.
SignalTower.pressed(towerButtonPressed);
}
released()#
The released(callback) method registers a function to be called when the signal tower button is released.
Parámetro |
Descripción |
|---|---|
|
Una función que se llamará cuando se suelte el botón |
Devoluciones: Ninguna.
// Define the towerButtonReleased function with a void
// return type, showing it doesn't return a value.
void towerButtonReleased() {
// The Brain will print that the tower button was
// released on the Brain's screen.
Brain.Screen.print("tower button released");
}
int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
// Run towerButtonReleased when the tower
// button is released.
SignalTower.released(towerButtonReleased);
}
timestamp()#
The timestamp() method requests the timestamp of the last received status packet from the Signal Tower.
Devuelve: Marca de tiempo del último paquete de estado como un entero de 32 bits sin signo en milisegundos.
installed()#
The installed() method returns if the signal tower is connected or not.
Returns: true if the device is connected. false if it is not.