Touch LED#
Introduction#
The VEX IQ (2nd Gen) Touch LED category offers methods for interacting with the Touch 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.
Below is a list of all available methods:
Actions – Interact with the Touch 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.
Mutators – Change colors, brightness, and settings of the Touch 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 – Return data from the Touch LED.
pressing – Returns whether the Touch LED is being pressed.
installed – Returns whether the Touch LED is connected to the Brain.
Constructors – Manually initialize a Touch LED.
touchled – Create a Touch LED.
Actions#
pressed#
pressed
registers a function to be called when the Touch LED is pressed.
Usage:
TouchLED1.pressed(callback);
Parameters |
Description |
---|---|
|
A function that is previously defined to execute when the Touch LED is pressed. |
// Example coming soon
released#
released
registers a function to be called when the Touch LED is released.
Usage:
TouchLED1.released(callback);
Parameters |
Description |
---|---|
|
A function that is previously defined to execute when the Touch LED is released. |
// 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);
Parameters |
Description |
---|---|
|
A valid color:
|
|
Optional. The brightness at which to set the LED in percent, defaulting to 100. |
|
The hue of the LED. This can also be represented as a Hexcode value. |
|
An integer representing the red value of the LED. |
|
An integer representing the green value of the LED. |
|
An integer representing the blue value of the LED. |
// Example coming soon
off#
off
turns the Touch LED off.
Usage:
TouchLED1.off();
Parameters |
Description |
---|---|
This method has no parameters. |
// Example coming soon
Mutators#
setColor#
setColor
turns the LED of the Touch LED Sensor on to a specific color.
Usage:
TouchLED1.setColor(color);
Parameters |
Description |
---|---|
|
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);
Parameters |
Description |
---|---|
|
The speed the fade will be set to:
|
// Example coming soon
setBrightness#
setBrightness
sets the brightness of the Touch LED.
Usage:
TouchLED1.setBrightness(value);
Parameters |
Description |
---|---|
|
The brightness of the Touch LED to set as a percent. |
// 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);
Parameters |
Description |
---|---|
|
A valid color:
|
|
Optional. The period in seconds the LED will be on in the blinking pattern in seconds, defaulting to 0.25 seconds. |
|
Optional. The period in seconds the LED will be off in the blinking pattern in seconds, defaulting to 0.25 seconds. |
|
The hue of the LED. This can also be represented by a Hexcode value. |
// Example coming soon
Getters#
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()
Parameters |
Description |
---|---|
This method has no parameters. |
// 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()
Parameters |
Description |
---|---|
This method has no parameters. |
// Example coming soon
Constructors#
touchled#
touchled
creates an object of the touchled Class in the specified port.
Usage:
touchled TouchLED1 = touchled(port);
Parameter |
Description |
---|---|
|
Which Smart Port that the Touch LED is connected to as |
// Example coming soon