Signal Tower#
Introduction#
The signaltower class is used to change lights and detect interactions with the CTE Signal Tower.
Class Constructors#
signaltower(
int32_t index );
Class Destructor#
Destroys the signaltower object and releases associated resources.
virtual ~signaltower();
Parameters#
Parameter |
Type |
Description |
|---|---|---|
|
|
The Smart Port that the Signal Tower is connected to, written as |
Examples#
// Create a signal tower instance in Port 1
signaltower SignalTower = signaltower(PORT1);
Member Functions#
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 - Sets the blink state of an LED on the Signal Tower by the LED’s ID.
setBlinkTime - Sets the blink timing for the LEDs on the Signal Tower.
enableBlink - Enables blinking for multiple LEDs on the Signal Tower by their IDs.
disableBlink - Disables blinking for multiple LEDs on the Signal Tower by their IDs.
pressing - Returns whether the signal tower button is currently being pressed.
pressed - Registers a function to be called when the signal tower button is pressed.
released - Registers a function to be called when the signal tower button is released.
timestamp - Returns the timestamp of the last received status packet from the signal tower.
installed - Returns if the signal tower device is connected or not.
setColor#
Controls the LED colors and states on the signal tower using various input methods.
Available Functions1 — Sets the signal tower to a color using vex::color.
void setColor( vex::color color, signaltower::state state = signaltower::state::on );
2 — Sets LED colors using 32-bit RGB and YW values.
void setColor( uint32_t rgb, uint32_t yw );
3 — Sets individual LED brightness by LED ID.
void setColor( ledId id, uint32_t value );
Parameters4 — Sets brightness levels for all LEDs individually.
void setColor( uint8_t r, uint8_t y, uint8_t g, uint8_t b, uint8_t w );
Parameter |
Type |
Description |
|---|---|---|
|
|
The color to use (red, green, etc.) using |
|
|
The state for the LED:
|
|
|
The brightness of red, green and blue LED using 32-bit value (e.g., red on = |
|
|
The brightness of yellow and white LED using 32-bit value (e.g., yellow on = |
|
|
The index of the LED to control. |
|
|
The brightness of the LED (0 to 255). |
|
|
The brightness of the red LED (0 to 255). |
|
|
The brightness of the yellow LED (0 to 255). |
|
|
The brightness of the green LED (0 to 255). |
|
|
The brightness of the blue LED (0 to 255). |
|
|
The brightness of the white LED (0 to 255). |
This function does not return a value.
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.
Available Functionsvoid setColors(
signaltower::state rs,
signaltower::state ys,
signaltower::state gs,
signaltower::state bs,
signaltower::state ws );
Parameter |
Type |
Description |
|---|---|---|
|
|
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:
|
This function does not return a value.
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.
Available Functionsvoid setBlink(
ledId id,
bool enable );
Parameter |
Type |
Description |
|---|---|---|
|
|
The LED ID:
|
|
|
|
This function does not return a value.
setBlinkTime#
Sets the blink timing for the LEDs on the Signal Tower.
Available Functionsvoid setBlinkTime(
uint32_t onTime,
uint32_t offTime = 0 );
Parameter |
Type |
Description |
|---|---|---|
|
|
The time in milliseconds that the LED should be on when blinking. Max is 2500ms. A value of 0 defaults to 500ms. |
|
|
The time in milliseconds that the LED should be off when blinking. Max is 2500ms. A value of 0 uses the onTime value. Default is 0. |
This function does not return a value.
enableBlink#
Enables blinking for multiple LEDs on the Signal Tower by their IDs.
Available Functionsvoid enableBlink(
ledId id0,
ledId id1 = ledId::none,
ledId id2 = ledId::none,
ledId id3 = ledId::none,
ledId id4 = ledId::none );
Parameter |
Type |
Description |
|---|---|---|
|
|
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
|
This function does not return a value.
disableBlink#
Disables blinking for multiple LEDs on the Signal Tower by their IDs.
Available Functionsvoid disableBlink(
ledId id0,
ledId id1 = ledId::none,
ledId id2 = ledId::none,
ledId id3 = ledId::none,
ledId id4 = ledId::none );
Parameter |
Type |
Description |
|---|---|---|
|
|
The index of the first LED.
|
|
|
The index of the second LED (optional).
|
|
|
The index of the third LED (optional).
|
|
|
The index of the fourth LED (optional).
|
|
|
The index of the fifth LED (optional).
|
This function does not return a value.
pressing#
Returns whether the signal tower button is currently being pressed.
Available Functionsbool pressing();
This function does not have parameters.
Return ValuesReturns a Boolean indicating whether the signal tower button is currently being pressed.
trueif the signal tower button is currently being pressed.falseif the signal tower button is not currently being pressed.
pressed#
Registers a function to be called when the signal tower button is pressed.
Available Functionsvoid pressed( void (* callback)(void) );
Parameter |
Type |
Description |
|---|---|---|
|
|
A function that will be called when the button is pressed. |
This function does not return a value.
Examples// 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");
}
// Run towerButtonPressed when the tower button
// is pressed.
SignalTower.pressed(towerButtonPressed);
released#
Registers a function to be called when the signal tower button is released.
Available Functionsvoid released( void (* callback)(void) );
Parameter |
Type |
Description |
|---|---|---|
|
|
A function that will be called when the button is released. |
This function does not return a value.
Examples// 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");
}
// Run towerButtonReleased when the tower
// button is released.
SignalTower.released(towerButtonReleased);
timestamp#
Returns the timestamp of the last received status packet from the Signal Tower.
Available Functionsuint32_t timestamp();
This function does not have parameters.
Return ValuesReturns the timestamp of the last status packet as a uint32_t in milliseconds since the last status packet was received.
installed#
Returns if the signal tower is connected or not.
Available Functionsbool installed();
This function does not have parameters.
Return ValuesReturns a Boolean indicating whether the signal tower is connected or not.
trueif the signal tower is connected.falseif the signal tower is not connected.