SignalTower#

Signal Tower commands can only be used with the CTE Signal Tower.

Initializing the SignalTower Class#

A Signal Tower is created by using the following constructor:

SignalTower(port)

This constructor use one parameter:

Parameter

Description

port

A valid Smart Port that the SignalTower is connected to.

# Construct a Signal Tower "signaltower_1" with the
# SignalTower class.
signaltower_1 = SignalTower(Ports.Port1)

This signaltower_1 object will be used in all subsequent examples throughout this API documentation when referring to SignalTower class methods.

Class Methods#

set_color()#

The set_color(color, state) method is used to set the Signal Tower’s color and state indefinitely, or until the method is used again.

Parameter

Description

color

A valid SignalTowerColorType.

state

A valid SignalTowerColorType.

Returns: None

# Set the Signal Tower to start blinking the blue LED.
signaltower_1.set_color(signal_tower.BLUE, signal_tower.BLINK)

set_colors()#

The set_colors(r, y, g, b, w) method turns all LEDs on the Signal Tower on or off.

Parameter

Description

r

A valid SignalTowerColorType to set the red LED to.

y

A valid SignalTowerColorType to set the yellow LED to.

g

A valid SignalTowerColorType to set the green LED to.

b

A valid SignalTowerColorType to set the blue LED to.

w

A valid SignalTowerColorType to set the white LED to.

Returns: None

# Turn on all LEDs.
signaltower_1.set_color(signal_tower.ON, signal_tower.ON, signal_tower.ON, signal_tower.ON, signal_tower.ON)

# Turn on just the red LED.
signaltower_1.set_color(signal_tower.ON, signal_tower.OFF, signal_tower.OFF, signal_tower.OFF, signal_tower.OFF)

pressing()#

The pressing() method returns whether the Signal Tower’s button is currently being pressed.

Returns: True if the Signal Tower’s button is currently being pressed. False if it is not.

pressed()#

The pressed(callback, arg) method registers a function to be called when the Signal Tower’s button is pressed.

Parameter

Description

callback

A function that will be called when the button is pressed

arg

Optional. A tuple that is used to pass arguments to the callback function

Returns: An instance of the Event class.

# Define a function tower_button_pressed().
def tower_button_pressed():
    # Print that the Signal Tower's button was pressed to
    # the Brain's screen.
    brain.screen.print("button pressed")

# Run tower_button_pressed when the Signal Tower's button 
# is pressed.
signaltower_1.pressed(tower_button_pressed)

released()#

The released(callback, arg) method registers a function to be called when the Signal Tower’s button is released.

Parameter

Description

callback

A function that will be called when the button is released

arg

Optional. A tuple that is used to pass arguments to the callback function

Returns: An instance of the Event class

# Define a function tower_button_released().
def tower_button_released():
    # Print that the Signal Tower's button was released
    # to the Brain's screen.
    brain.screen.print("button released")

# Run tower_button_released when the Signal Tower's button
# is released.
signaltower_1.released(tower_button_released)

installed()#

The installed() method checks for device connection.

Returns: True if the device is connected. False if it is not.

timestamp()#

The timestamp() method returns the timestamp of the last received status packet from the Signal Tower.

Returns: The timestamp of the last received status packet in milliseconds.