Touch LED#
Introduction#
The Touch LED is a capacitive touch button that can display colors at varying brightness levels and transition speeds, and can detect when it is pressed.
For the examples below, the configured Touch LED will be named touchled_1
and will be used in all subsequent examples throughout this API documentation when referring to Touchled
class methods.
Below is a list of all methods:
Actions – Interact with the Touch LED.
pressed – Calls a function when the Touch LED is pressed.
released – Calls a function when the Touch LED is released.
on – Turns the Touch LED on.
off – Turns the Touch LED off.
toggle – Turns the Touch LED on or off.
Mutators – Change colors, brightness, and settings of the Touch LED.
set_color – Sets the color of the Touch LED.
set_fade – Sets how fast colors will fade to one another.
set_brightness – Sets the brightness of the Touch LED.
set_blink – 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 and configure the Touch LED.
TouchLED – Create a Touch LED.
Actions#
pressed#
pressed
registers a function to be called when the Touch LED is pressed.
Usage:
touchled_1.pressed(callback, arg)
Parameters |
Description |
---|---|
|
A function that is previously defined to execute when the Touch LED is being pressed. |
|
Optional. A tuple containing arguments to pass to the callback function. See Functions with Parameters for more information. |
# Example coming soon
released#
released
registers a function to be called when the Touch LED is released.
Usage:
touchled_1.released(callback, arg)
Parameters |
Description |
---|---|
|
A function that is previously defined to execute when the Touch LED is released. |
|
Optional. A tuple containing arguments to pass to the callback function. See Functions with Parameters for more information. |
# Example coming soon
on#
on
turns the Touch LED on by setting its brightness to 100%.
Usage:
touchled_1.on(value)
Parameters |
Description |
---|---|
|
Optional. Sets the LED’s color to:
|
# Example coming soon
off#
off
turns the Touch LED off by setting its brightness to 0%.
Usage:
touchled_1.off()
Parameters |
Description |
---|---|
This method has no parameters. |
# Example coming soon
toggle#
toggle
turns the Touch LED on or off. If the LED is currently on, toggle
sets its brightness to 0%, turning it off. If the LED is off, toggle
sets its brightness to 100%, turning it on.
Usage:
touchled_1.toggle()
Parameters |
Description |
---|---|
This method has no parameters. |
# Example coming soon
Mutators#
set_color#
set_color
sets the color of the Touch LED. If the Touch LED is not already on when this method is used, it will set the brightness to 100% to turn the Touch LED on.
Usage:
touchled_1.set_color(color)
Parameters |
Description |
---|---|
|
Optional. Sets the LED’s color to:
set_color will turn the Touch LED on with the previously set color.You can also specify a custom color. |
# Example coming soon
set_fade#
set_fade
changes the color fade setting for the Touch LED.
Usage:
touchled_1.set_fade(type)
Parameters |
Description |
---|---|
|
How fast a color will fade from one to the next:
|
# Example coming soon
set_brightness#
set_brightness
sets the brightness of the Touch LED.
Usage:
touchled_1.set_brightness(brightness)
Parameters |
Description |
---|---|
|
The brightness of the Touch LED to set as a percent. |
# Example coming soon
set_blink#
set_blink
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 set_brightness
.
Usage:
set_blink(color, ontime, offtime)
Parameters |
Description |
---|---|
|
Sets the Touch LED’s color to:
|
|
The period in seconds the LED will be on in the blinking pattern in seconds, defaulting to 0.25 seconds. |
|
The period in seconds the LED will be off in the blinking pattern in seconds, defaulting to 0.25 seconds. |
# Example coming soon
Getters#
pressing#
.pressing
returns an integer indicating whether the Touch LED is currently being pressed.
1
- The TouchLED is being pressed.0
- The TouchLED is not being pressed.
Usage:
touchled_1.pressing()
Parameters |
Description |
---|---|
This method has no parameters. |
# Example coming soon
installed#
installed
returns a Boolean indicating whether the Touch LED is connected to the Brain.
True
- The Touch LED is connected to the Brain.False
- The Touch LED is not connected to the Brain.
Usage:
touchled_1.installed()
Parameters |
Description |
---|---|
This method has no parameters. |
# Example coming soon
Constructors#
Constructors are used to manually create TouchLED
objects, which are necessary for configuring a Touch LED outside of VEXcode.
TouchLED#
TouchLED
creates a Touch LED.
Usage:
touchled_1 = TouchLED(port)
Parameter |
Description |
---|---|
|
Which Smart Port that the Touch LED is connected to as |
# Example coming soon