信号塔#
初始化信号塔类#
使用以下构造函数创建信号塔:
The signaltower constructor creates a signaltower object.
范围 |
描述 |
|---|---|
|
A valid |
// 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.
类方法#
setColor()#
该方法通过以下方式调用:
The setColor(color, state) method turns one or more LED on the signal tower on or off using predefined colors or a hexcode.
范围 |
描述 |
|---|---|
|
A valid |
状态 |
A valid |
**返回:**无。
// 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.
范围 |
描述 |
|---|---|
|
代表红色、绿色和蓝色 LED 亮度的十六进制值。 |
|
代表黄色和白色 LED 亮度的十六进制值。 |
**返回:**无。
// 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 编号:
红色:0
绿色:1
蓝色:2
白色:3
黄色:4
无:99
范围 |
描述 |
|---|---|
|
信号塔上其中一个 LED 的 ID。 |
|
LED 的亮度值在 0 - 255 范围内。 |
**返回:**无。
// 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.
范围 |
描述 |
|---|---|
|
LED 的亮度值在 0 - 255 范围内。 |
|
LED 的亮度值在 0 - 255 范围内。 |
|
LED 的亮度值在 0 - 255 范围内。 |
|
LED 的亮度值在 0 - 255 范围内。 |
|
LED 的亮度值在 0 - 255 范围内。 |
**返回:**无。
// 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.
范围 |
描述 |
|---|---|
|
A valid |
|
A valid |
|
A valid |
|
A valid |
|
A valid |
**返回:**无
// Turn on all LEDs.
SignalTower.setColors(signaltower::on, signaltower::on, signaltower::on, signaltower::on, signaltower::on);
setBlink()#
The setBlink(id, enable) method sets the blink state of an LED on the Signal Tower by the LED’s id.
LED 编号:
红色:0
绿色:1
蓝色:2
白色:3
黄色:4
无:99
范围 |
描述 |
|---|---|
|
您要设置闪烁状态的 LED 的 ID。 |
|
用于将 LED 设置为闪烁还是不闪烁的布尔值。 |
**返回:**无。
setBlinkTime()#
The setBlinkTime(onTime, offTime) method sets the blink time for the LEDs on the Signal Tower.
范围 |
描述 |
|---|---|
|
LED 闪烁时亮起的持续时间(以毫秒为单位)。最大值为 2500 毫秒。值为 0 时默认为 500 毫秒。 |
|
LED 闪烁时应关闭的时间(以毫秒为单位)。最大值为 2500 毫秒。值为 0 时将使用 onTime 的设置时间。默认值为 0。 |
**返回:**无。
enableBlink()#
The enableBlink(id0, id1, id2, id3, id4) method sets the blink state to on of LEDs on the Signal Tower by the LED’s id.
LED 编号:
红色:0
绿色:1
蓝色:2
白色:3
黄色:4
无:99
范围 |
描述 |
|---|---|
|
您想要将其闪烁状态设置为开的第一个 LED 的 ID。 |
|
您想要将其闪烁状态设置为开的第一个 LED 的 ID。 |
|
您想要将其闪烁状态设置为开的第一个 LED 的 ID。 |
|
您想要将其闪烁状态设置为开的第一个 LED 的 ID。 |
|
您想要将其闪烁状态设置为开的第一个 LED 的 ID。 |
**返回:**无。
disableBlink()#
The disableBlink(id0, id1, id2, id3, id4) method sets the blink state to off of LEDs on the Signal Tower by the LED’s id.
LED 编号:
红色:0
绿色:1
蓝色:2
白色:3
黄色:4
无:99
范围 |
描述 |
|---|---|
|
您想要将闪烁状态设置为关闭的第一个 LED 的 ID。 |
|
您想要将闪烁状态设置为关闭的第一个 LED 的 ID。 |
|
您想要将闪烁状态设置为关闭的第一个 LED 的 ID。 |
|
您想要将闪烁状态设置为关闭的第一个 LED 的 ID。 |
|
您想要将闪烁状态设置为关闭的第一个 LED 的 ID。 |
**返回:**无。
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.
范围 |
描述 |
|---|---|
|
按下按钮时调用的函数 |
**返回:**无。
// 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.
范围 |
描述 |
|---|---|
|
释放按钮时调用的函数 |
**返回:**无。
// 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.
**返回:**最后一个状态包的时间戳,以毫秒为单位的无符号 32 位整数。
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.