LED táctil#
Introducción#
El LED táctil VEX IQ funciona como luz y botón. Puede brillar en diferentes colores para proporcionar información, como indicar que el robot está listo, mostrar el modo seleccionado o coincidir con un color detectado por otro sensor. Además, detecta cuando se toca, lo que permite iniciar o modificar el comportamiento del robot con un simple toque.
Constructor de clases#
touchled(
int32_t index );
Instructor de clase#
Destroys the touchled object and releases associated resources.
virtual ~touchled();
Parámetros#
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
The Smart Port that the Touch LED is connected to, written as |
Ejemplo#
// Create a touchled instance in Port 1
touchled TouchLED1 = touchled(PORT1);
Funciones de los miembros#
The touchled class includes the following member functions:
pressing– Returns whether the Touch LED is being pressed.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.pressed– Registers a function to be called when the Touch LED is pressed.released– Registers a function to be called when the Touch LED is released.on– Turns the Touch LED on.off– Turns the Touch LED off.setBlink– Alternate the Touch LED on and off indefinitely.installed– Returns whether the Touch LED is connected to the Brain.
Before calling any touchled member functions, a touchled instance must be created, as shown below:
/* This constructor is required when using VS Code.
Touch LED configuration is generated automatically
in VEXcode using the Device Menu. Replace the values
as needed. */
// Create a Touch LED instance in Port 1
touchled TouchLED1 = touchled(PORT1);
pressing#
Devuelve el valor si se está pulsando el TouchLED.
Available Functionsbool pressing();
Esta función no acepta ningún parámetro.
Return ValuesReturns an bool indicating whether the Touch LED is being pressed.
-
true— The Touch LED is being pressed. -
false— The Touch LED is not being pressed.
setColor#
Configura el LED del sensor táctil LED para que se encienda en un color específico.
Available Functions1 — Sets the Touch LED to a color using
vex::color.void setColor( vex::color color );
Parameters2 — Sets LED colors using a
colorType.void setColor( colorType color );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
A valid color:
|
|
|
Un color personalizado válido. |
Esta función no devuelve ningún valor.
setFade#
Configura el ajuste de desvanecimiento del sensor LED táctil. El sensor LED táctil cambiará a nuevos colores utilizando el tipo de desvanecimiento.
Available Functionsvoid setFade(
fadeType speed );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
The speed the fade will be set to:
|
Esta función no devuelve ningún valor.
setBrightness#
Ajusta el brillo del LED táctil.
Available Functionsvoid setBrightness(
uint32_t value );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
El brillo del LED táctil se puede configurar como un porcentaje. |
Esta función no devuelve ningún valor.
pressed#
Registra una función que se llamará cuando se presione el LED táctil.
Available Functionsvoid pressed( void (* callback)(void) );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
Un puntero a una función que se llamará cuando se presione el LED táctil. La función no debe recibir parámetros y debe devolver void. |
Esta función no devuelve ningún valor.
ExamplesDefine the callback function (outside of
int main())// Display a message when LED is pressed void LEDPressed() { Brain.Screen.print("LED pressed"); }Register the callback inside
int main()int main() { /* vexcodeInit() is only required when using VEXcode. Remove vexcodeInit() if compiling in VS Code. */ vexcodeInit(); // Run LEDPressed when the value of the Touch LED is pressed. TouchLED1.pressed(LEDPressed); }
released#
Registra una función que se llamará cuando se suelte el LED táctil.
Available Functionsvoid released( void (* callback)(void) );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
Un puntero a una función que se llamará cuando se suelte el LED táctil. La función no debe recibir parámetros y debe devolver void. |
Esta función no devuelve ningún valor.
ExamplesDefine the callback function (outside of
int main())// Display a message when LED is released void LEDReleased() { Brain.Screen.print("LED released"); }Register the callback inside
int main()int main() { /* vexcodeInit() is only required when using VEXcode. Remove vexcodeInit() if compiling in VS Code. */ vexcodeInit(); // Run LEDReleased when the value of the Touch LED is released. TouchLED1.released(LEDReleased); }
on#
Enciende el LED del sensor TouchLED utilizando colores y un brillo preestablecido.
Available Functions1 — Establece un color para el LED usando vex::color.
void on( vex::color color, uint32_t brightness = 100 );
2 — Establece el color del LED usando el tono.
void on( uint32_t hue, uint32_t brightness = 100);
Parameters3 — Establece el color del LED mediante valores RGB.
void on( uint8_t red, uint8_t green, uint8_t blue, uint32_t brightness = 100);
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
A valid color:
|
|
|
Opcional. El nivel de brillo al que se ajustará el LED en porcentaje; el valor predeterminado es 100. |
|
|
El tono del LED. Esto también se puede representar como un valor de código hexadecimal (0x000000). |
|
|
Un número entero que representa el valor rojo del LED. |
|
|
Un número entero que representa el valor verde del LED. |
|
|
Un número entero que representa el valor azul del LED. |
Esta función no devuelve ningún valor.
off#
Apaga el LED táctil.
Available Functionsvoid off( void );
Esta función no requiere ningún parámetro.
Return ValuesEsta función no devuelve ningún valor.
setBlink#
El LED táctil parpadea repetidamente en un patrón de encendido y apagado.
Available Functions1 — Establece un color para el LED usando vex::color.
void on( vex::color color, double onTime = 0.25, double offTime = 0.25 );
2 — Establece el color del LED usando el tono.
void on( uint32_t hue, double onTime = 0.25, double offTime = 0.25 );
Parameters3 — Establece el color del LED mediante valores RGB.
void setColor( colorType color, double onTime = 0.25, double offTime = 0.25 );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
A valid color:
|
|
|
Opcional. El tiempo en segundos que el LED permanecerá encendido en el patrón de parpadeo, con un valor predeterminado de 0,25 segundos. |
|
|
Opcional. El tiempo en segundos que el LED permanecerá apagado en el patrón de parpadeo, con un valor predeterminado de 0,25 segundos. |
|
|
El tono del LED. Esto también se puede representar mediante un valor hexadecimal. |
|
|
Un color personalizado válido. |
Esta función no devuelve ningún valor.
Notes - Calling [off](#off) will not stop the blinking behavior. To stop the blinking behavior, set the LED brightness to 0 with [setBrightness](#setbrightness).
installed#
Indica si el LED táctil está conectado.
Available Functionsbool installed();
Esta función no requiere ningún parámetro.
Return ValuesDevuelve un valor booleano que indica si el LED táctil está conectado:
-
true— The sensor is connected and responding. -
false— The sensor is not connected or not detected.