signaltower#

Initializing the signaltower Class#

A Signal Tower is created by using the following constructor:

The signaltower constructor creates a signaltower object.

Parameter

Description

port

A valid Smart Port that the SignalTower is connected to.

// 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.

Class Methods#

setColor()#

This method is called in the following ways:

The setColor(color, state) method turns one or more LED on the signal tower on or off using predefined colors or a hexcode.

Parameter

Description

color

A valid SignalTowerColorType, ColorType, or hexcode.

state

A valid SignalTowerStateType.

Returns: None.

// 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.

Parameter

Description

rgb

A hexcode value representing the brightness of the red, green, and blue LEDs.

yw

A hexcode value representing the brightness of the yellow and white LEDs.

Returns: None.

// 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.

LED id’s:

  • red: 0

  • green: 1

  • blue: 2

  • white: 3

  • yellow: 4

  • none: 99

Parameter

Description

id

The id for one of the LEDs on the Signal Tower.

value

The value of brightness of the LED in the range 0 - 255.

Returns: None.

// 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.

Parameter

Description

r

The value of brightness of the LED in the range 0 - 255.

y

The value of brightness of the LED in the range 0 - 255.

g

The value of brightness of the LED in the range 0 - 255.

b

The value of brightness of the LED in the range 0 - 255.

w

The value of brightness of the LED in the range 0 - 255.

Returns: None.

// 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.

Parameter

Description

r

A valid SignalTowerStateType to set the red LED to.

y

A valid SignalTowerStateType to set the yellow LED to.

g

A valid SignalTowerStateType to set the green LED to.

b

A valid SignalTowerStateType to set the blue LED to.

w

A valid SignalTowerStateType to set the white LED to.

Returns: None

// Turn on all LEDs.
SignalTower.setColors(signaltower::on, signaltower::on, signaltower::on, signaltower::on, signaltower::on);

setBlinkTime()#

The setBlinkTime(onTime, offTime) method sets the blink time for the LEDs on the Signal Tower.

Parameter

Description

onTime

The time in milliseconds that the LED should be on for when blinking. The max is 2500 milliseconds. A value of 0 default to 500 milliseconds.

offTime

The time in milliseconds that the LED should be off for when blinking. The max is 2500 milliseconds. A value of 0 will use the time set for onTime. The default is 0.

Returns: None.

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.

Parameter

Description

callback

A function that will be called when the button is pressed

Returns: None.

// 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.

Parameter

Description

callback

A function that will be called when the button is released

Returns: None.

// 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.

Returns: Timestamp of the last status packet as an unsigned 32-bit integer in milliseconds.

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.