Torre de señales#
Introducción#
The Signal Tower is a device that uses colored lights to show the robot’s status. It also has a built-in bumper switch that can detect when it is pressed.
For the examples below, the configured Signal Tower will be named signal_tower_1 and will be used in all subsequent examples throughout this API documentation when referring to SignalTower class methods.
A continuación se muestra una lista de todos los métodos disponibles:
Configuradores: Configure los colores y patrones de las luces de la torre de señalización.
set_color– Sets the pattern for one or all Signal Tower LEDs.set_colors– Sets the state of each Signal Tower LED.
Obtenedores: lean el estado del parachoques de la torre de señalización.
pressing– Returns whether the Signal Tower bumper is currently pressed.
Funciones de devolución de llamada: Ejecuta el código cuando cambia el estado del parachoques de la torre de señalización.
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.
Constructores: Inicialicen y configuren manualmente la torre de señales.
SignalTower– Create a Signal Tower.
Colocadores#
set_color#
set_color sets the light pattern of one or all LEDs on the Signal Tower. These lights can be used to track where the robot is at in a project or to show when certain conditions are met.
Usage:
signal_tower_1.set_color(value, state)
Parámetro |
Descripción |
|---|---|
valor |
The color light to control:
|
estado |
The light pattern to apply:
|
# Set the Signal Tower to start blinking the blue LED
signal_tower_1.set_color(SignalTower.BLUE, signal_tower.BLINK)
set_colors#
set_colors sets the state of each Signal Tower LED. These lights can be used to track where the robot is at in a project or to show when certain conditions are met.
Usage:
signal_tower_1.set_colors(r, y, g, b, w)
Parámetro |
Descripción |
|---|---|
r |
The state for the red light:
|
y |
The state for the yellow light:
|
gramo |
The state for the green light:
|
b |
The state for the blue light:
|
w |
The state for the white light:
|
# Turn on all LEDs
signal_tower_1.set_colors(SignalTower.ON, SignalTower.ON, SignalTower.ON, SignalTower.ON, SignalTower.ON)
# Turn on just the red LED
signal_tower_1.set_colors(SignalTower.ON, SignalTower.OFF, SignalTower.OFF, SignalTower.OFF, SignalTower.OFF)
Getters#
pressing#
pressing returns a Boolean indicating whether the Signal Tower’s bumper is currently being pressed. This can be used as an emergency stop.
True— The Signal Tower’s bumper is currently being pressed.False— The Signal Tower’s bumper is not being pressed.
Usage:
signal_tower_1.pressing()
Devoluciones de llamada#
pressed#
pressed registers a function to be called when the Signal Tower’s bumper is pressed.
This method returns an instance of the Event class.
Usage:
signal_tower_1.pressed(callback, arg)
Parámetros |
Descripción |
|---|---|
|
Una función definida previamente que se ejecuta cuando se presiona el parachoques de la Torre de Señalización. |
|
Optional. A tuple containing arguments to pass to the callback function. See Functions with Parameters for more information. |
# 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.
signal_tower_1.pressed(tower_button_pressed)
released#
released registers a function to be called when the Signal Tower’s bumper is released.
This method returns an instance of the Event class.
Usage:
signal_tower_1.released(callback, arg)
Parámetros |
Descripción |
|---|---|
|
Una función definida previamente que se ejecuta cuando se suelta el parachoques de la torre de señalización. |
|
Optional. A tuple containing arguments to pass to the callback function. See Functions with Parameters for more information. |
# 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.
signal_tower_1.released(tower_button_released)
Constructores#
SignalTower#
SignalTower creates a Signal Tower.
SignalTower(smartport)
Parámetro |
Descripción |
|---|---|
|
The Smart Port that the Signal Tower is connected to, written as |
# Construct a Signal Tower "signal_tower_1" with the
# SignalTower class
signal_tower_1 = SignalTower(Ports.PORT1)