信号塔#
初始化信号塔类#
使用以下构造函数创建信号塔:
The signaltower
constructor creates a signaltower object.
范围 |
描述 |
---|---|
|
SignalTower 连接到的有效 智能端口。 |
// 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.
范围 |
描述 |
---|---|
颜色 |
有效的 signalTowerColorType、colorType 或十六进制代码。 |
状态 |
有效的 signalTowerStateType。 |
**返回:**无。
// 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.
范围 |
描述 |
---|---|
RGB |
代表红色、绿色和蓝色 LED 亮度的十六进制值。 |
yw |
代表黄色和白色 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
范围 |
描述 |
---|---|
ID |
信号塔上其中一个 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.
范围 |
描述 |
---|---|
r |
LED 的亮度值在 0 - 255 范围内。 |
y |
LED 的亮度值在 0 - 255 范围内。 |
克 |
LED 的亮度值在 0 - 255 范围内。 |
b |
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.
范围 |
描述 |
---|---|
r |
用于设置红色 LED 的有效 signalTowerStateType。 |
y |
用于将黄色 LED 设置为有效的 signalTowerStateType。 |
克 |
有效的 signalTowerStateType,用于将 LED 设置为绿色。 |
b |
用于设置蓝色 LED 的有效 signalTowerStateType。 |
西 |
用于设置白色 LED 的有效 signalTowerStateType。 |
**返回:**无
// 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
范围 |
描述 |
---|---|
ID |
您要设置闪烁状态的 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
范围 |
描述 |
---|---|
id0 |
您想要将其闪烁状态设置为开的第一个 LED 的 ID。 |
ID1 |
您想要将其闪烁状态设置为开的第一个 LED 的 ID。 |
ID2 |
您想要将其闪烁状态设置为开的第一个 LED 的 ID。 |
ID3 |
您想要将其闪烁状态设置为开的第一个 LED 的 ID。 |
ID4 |
您想要将其闪烁状态设置为开的第一个 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
范围 |
描述 |
---|---|
id0 |
您想要将闪烁状态设置为关闭的第一个 LED 的 ID。 |
ID1 |
您想要将闪烁状态设置为关闭的第一个 LED 的 ID。 |
ID2 |
您想要将闪烁状态设置为关闭的第一个 LED 的 ID。 |
ID3 |
您想要将闪烁状态设置为关闭的第一个 LED 的 ID。 |
ID4 |
您想要将闪烁状态设置为关闭的第一个 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.