触摸LED#
介绍#
VEX IQ(第二代)触摸 LED 类别提供了与触摸 LED 交互的方法。
For the examples below, the configured Touch LED will be named TouchLED1
and will be used in all subsequent examples throughout this API documentation when referring to touchled
class methods.
以下是所有可用方法的列表:
操作——与触摸 LED 交互。
pressed
– Calls a function when the Touch LED is pressed.released
– Calls a function when the Bumper Switch is released.on
– Turns the Touch LED on.off
– Turns the Touch LED off.
改变器——改变触摸 LED 的颜色、亮度和设置。
setColor
– Sets the color of the Touch LED.setFade
– Sets how fast colors will fade to one another.setBrightness
– Sets the brightness of the Touch LED.setBlink
– Alternate the Touch LED on and off indefinitely.
Getters – 从触摸 LED 返回数据。
pressing
– Returns whether the Touch LED is being pressed.installed
– Returns whether the Touch LED is connected to the Brain.
构造函数 – 手动初始化触摸 LED。
touchled
– Create a Touch LED.
行动#
pressed#
pressed
registers a function to be called when the Touch LED is pressed.
Usage:
TouchLED1.pressed(callback);
参数 |
描述 |
---|---|
|
先前定义的 函数 在按下触摸 LED 时执行。 |
// Example coming soon
released#
released
registers a function to be called when the Touch LED is released.
Usage:
TouchLED1.released(callback);
参数 |
描述 |
---|---|
|
先前定义的在释放触摸 LED 时执行的功能。 |
// Example coming soon
on#
on
method turns the LED of the TouchLED Sensor on using predefined colors and a set brightness.
Default Usage:
TouchLED1.on(color, brightness);
Overload Usages:
TouchLED1.on(hue, brightness);
TouchLED1.on(r, g, b, brightness);
参数 |
描述 |
---|---|
|
A valid color:
|
|
可选。LED 亮度的百分比,默认为 100。 |
|
LED 的色调。这也可以表示为十六进制代码值。 |
|
表示 LED 红色值的整数。 |
|
表示 LED 绿色值的整数。 |
|
表示 LED 蓝色值的整数。 |
// Example coming soon
off#
off
turns the Touch LED off.
Usage:
TouchLED1.off();
参数 |
描述 |
---|---|
该方法没有参数。 |
// Example coming soon
修改器#
setColor#
setColor
turns the LED of the Touch LED Sensor on to a specific color.
Usage:
TouchLED1.setColor(color);
参数 |
描述 |
---|---|
|
A valid color:
|
// Example coming soon
setFade#
setFade
changes the fade setting of the Touch LED Sensor. The Touch LED Sensor will change to new colors using the fade type.
Usage:
TouchLED1.setFade(speed);
参数 |
描述 |
---|---|
|
The speed the fade will be set to:
|
// Example coming soon
setBrightness#
setBrightness
sets the brightness of the Touch LED.
Usage:
TouchLED1.setBrightness(value);
参数 |
描述 |
---|---|
|
触摸 LED 的亮度设置为百分比。 |
// Example coming soon
setBlink#
setBlink
repeatedly blinks the TouchLED in an on and off pattern.
Note: Calling off
will not stop the blinking behavior. To stop the blinking behavior, set the LED brightness to 0 with setBrightness
.
Default Usage:
TouchLED1.setBlink(color, ontime, offtime);
Overload Usages:
TouchLED1.setBlink(hue, ontime, offtime);
参数 |
描述 |
---|---|
|
A valid color:
|
|
可选。LED 闪烁的持续时间(以秒为单位),默认为 0.25 秒。 |
|
可选。LED 闪烁熄灭的时长(以秒为单位),默认为 0.25 秒。 |
|
LED 的色调。也可以用十六进制代码值表示。 |
// Example coming soon
吸气剂#
pressing#
pressing
returns a Boolean indicating whether the Touch LED Sensor is currently being pressed.
1
– The Touch LED is currently bring pressed.0
– The Touch LED is not currently being pressed.
Usage:
TouchLED1.pressing()
参数 |
描述 |
---|---|
该方法没有参数。 |
// Example coming soon
installed#
installed
returns a Boolean indicating whether the Touch LED is currently connected to the Brain.
1
– The TouchLED is connected to the Brain.0
– The TouchLED is not connected to the Brain.
Usage:
TouchLED1.installed()
参数 |
描述 |
---|---|
该方法没有参数。 |
// Example coming soon
构造函数#
touchled#
touchled
creates an object of the touchled Class in the specified port.
Usage:
touchled TouchLED1 = touchled(port);
范围 |
描述 |
---|---|
|
Which Smart Port that the Touch LED is connected to as |
// Example coming soon