Torre de señales#
Introducción#
The signaltower class is used to change lights and detect interactions with the CTE Signal Tower.
Constructores de clases#
signaltower(
int32_t index );
Instructor de clase#
Destroys the signaltower object and releases associated resources.
virtual ~signaltower();
Parámetros#
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
The Smart Port that the Signal Tower is connected to, written as |
Ejemplos#
// Create a signal tower instance in Port 1
signaltower SignalTower = signaltower(PORT1);
Funciones de los miembros#
The signaltower class provides the following member functions:
setColor - Controls the LED colors and states on the Signal Tower using various input methods.
setColors - Sets the state of all LEDs on the Signal Tower individually.
setBlink - Establece el estado de parpadeo de un LED en la torre de señalización mediante la ID del LED.
setBlinkTime - Sets the time between blinks for the LEDs on the Signal Tower.
enableBlink - Habilita el parpadeo de varios LED en la torre de señalización mediante sus identificadores.
disableBlink - Deshabilita el parpadeo de varios LED en la torre de señalización por sus identificadores.
pressing - Returns whether the Signal Tower bumper is currently being pressed.
pressed - Registers a function to be called when the Signal Tower bumper is pressed.
released - Registers a function to be called when the Signal Tower bumper is released.
setColor#
Controls the LED colors and states on the Signal Tower using various input methods. These lights can be used to track where the robot is at in a project or to show when certain conditions are met.
Available Functions1 — Sets the Signal Tower to a color using vex::color.
void setColor( vex::color color, signaltower::state state = signaltower::state::on );
2 — Establece los colores de los LED utilizando valores RGB y YW de 32 bits.
void setColor( uint32_t rgb, uint32_t yw );
3 — Establece el brillo de cada LED individual mediante su ID.
void setColor( ledId id, uint32_t value );
Parameters4 — Establece los niveles de brillo para todos los LED individualmente.
void setColor( uint8_t r, uint8_t y, uint8_t g, uint8_t b, uint8_t w );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
The color to use:
|
|
|
The state for the LED:
|
|
|
The brightness of red, green and blue LED using a 32-bit value (e.g., red on = |
|
|
The brightness of yellow and white LED using a 32-bit value (e.g., yellow on = |
|
|
The index of the LED to control:
|
|
|
The brightness of the LED from 0 to 255, with 0 being off and 255 being the max brightness. |
|
|
The brightness of the red LED from 0 to 255, with 0 being off and 255 being the max brightness. |
|
|
The brightness of the yellow LED from 0 to 255, with 0 being off and 255 being the max brightness. |
|
|
The brightness of the green LED from 0 to 255, with 0 being off and 255 being the max brightness. |
|
|
The brightness of the blue LED from 0 to 255, with 0 being off and 255 being the max brightness. |
|
|
The brightness of the white LED from 0 to 255, with 0 being off and 255 being the max brightness. |
Esta función no devuelve ningún valor.
Examples// Set the Signal Tower to start blinking blue
SignalTower.setColor(vex::color::blue, signaltower::blink);
// Set the red, blue and white LEDs using hex values
SignalTower.setColor(0xFF00FF, 0x00FF);
// Set the green LED to full brightness by ID
SignalTower.setColor(1, 255);
// Set all LEDs to full brightness
SignalTower.setColor(255, 255, 255, 255, 255);
setColors#
Sets the state of all LEDs on the Signal Tower individually. These lights can be used to track where the robot is at in a project or to show when certain conditions are met.
Available Functionsvoid setColors(
signaltower::state rs,
signaltower::state ys,
signaltower::state gs,
signaltower::state bs,
signaltower::state ws );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
The state of the red LED:
|
|
|
The state of the yellow LED:
|
|
|
The state of the green LED:
|
|
|
The state of the blue LED:
|
|
|
The state of the white LED:
|
Esta función no devuelve ningún valor.
Examples// Turn on all LEDs
SignalTower.setColors(signaltower::on, signaltower::on, signaltower::on, signaltower::on, signaltower::on);
setBlink#
Sets the blink state of an LED on the Signal Tower by the LED’s ID. These blinking lights can be used to show when certain conditions are met, such as when the robot is waiting or when attention is needed.
Available Functionsvoid setBlink(
ledId id,
bool enable );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
The LED ID:
|
|
|
|
Esta función no devuelve ningún valor.
setBlinkTime#
Sets the time between blinks for the LEDs on the Signal Tower.
Available Functionsvoid setBlinkTime(
uint32_t onTime,
uint32_t offTime = 0 );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
El tiempo en milisegundos que el LED debe permanecer encendido al parpadear. El máximo es de 2500 ms. Un valor de 0 establece por defecto un tiempo de 500 ms. |
|
|
Tiempo en milisegundos que el LED debe permanecer apagado al parpadear. El máximo es 2500 ms. Un valor de 0 utiliza el valor de onTime. El valor predeterminado es 0. |
Esta función no devuelve ningún valor.
enableBlink#
Permite que varios LED de la torre de señalización parpadeen según sus identificadores.
Available Functionsvoid enableBlink(
ledId id0,
ledId id1 = ledId::none,
ledId id2 = ledId::none,
ledId id3 = ledId::none,
ledId id4 = ledId::none );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
The LED ID:
|
|
|
The index of the second LED (optional). Default is
|
|
|
The index of the third LED (optional). Default is
|
|
|
The index of the fourth LED (optional). Default is
|
|
|
The index of the fifth LED (optional). Default is
|
Esta función no devuelve ningún valor.
disableBlink#
Desactiva el parpadeo de varios LED en la torre de señalización mediante sus identificadores.
Available Functionsvoid disableBlink(
ledId id0,
ledId id1 = ledId::none,
ledId id2 = ledId::none,
ledId id3 = ledId::none,
ledId id4 = ledId::none );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
The index of the first LED.
|
|
|
The index of the second LED (optional). Default is
|
|
|
The index of the third LED (optional). Default is
|
|
|
The index of the fourth LED (optional). Default is
|
|
|
The index of the fifth LED (optional). Default is
|
Esta función no devuelve ningún valor.
pressing#
Returns whether the Signal Tower’s bumper is currently being pressed. This can be used as an emergency stop.
Available Functionsbool pressing();
Esta función no tiene parámetros.
Return ValuesReturns a Boolean indicating whether the Signal Tower’s bumper is currently being pressed.
true— The Signal Tower’s bumper is currently being pressed.false— The Signal Tower’s bumper is not being pressed.
pressed#
Registers a function to be called when the Signal Tower bumper is pressed.
Available Functionsvoid pressed( void (* callback)(void) );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
A pointer to a function that will be called when the bumper is pressed. |
Esta función no devuelve ningún valor.
ExamplesDefine the callback function (outside of
int main())// Display a message when bumper is pressed void towerBumperPressed() { Brain.Screen.print("tower bumper pressed"); }Register the callback inside
int main()int main() { /* vexcodeInit() is only required when using VEXcode. Remove vexcodeInit() if compiling in VS Code. */ vexcodeInit(); // Run towerBumperPressed when the tower bumper // is pressed SignalTower.pressed(towerBumperPressed); }
released#
Registers a function to be called when the Signal Tower bumper is released.
Available Functionsvoid released( void (* callback)(void) );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
A pointer to a function that will be called when the bumper is released. |
Esta función no devuelve ningún valor.
ExamplesDefine the callback function (outside of
int main())// Display a message when bumper is pressed void towerBumperReleased() { Brain.Screen.print("tower bumper pressed"); }Register the callback inside
int main()int main() { /* vexcodeInit() is only required when using VEXcode. Remove vexcodeInit() if compiling in VS Code. */ vexcodeInit(); // Run towerBumperReleased when the tower bumper // is released SignalTower.pressed(towerBumperReleased); }