tocado#

Inicializando la clase touchled#

The touchled constructor creates a touchled object in the specified Smart Port.

Este constructor utiliza un parámetro:

Parámetro

Descripción

port

Un Puerto inteligente válido al que está conectado el sensor TouchLED.

// Construct the Brain.
brain Brain;
// Construct a TouchLED Sensor "touch" with the
// TouchLED class.
touchled touch = touchled(PORT1);

This touch object will be used in all subsequent examples throughout this API documentation when referring to touchled class methods.

Métodos de clase#

pressing()#

The pressing() method returns whether the TouchLED Sensor is currently being pressed.

Returns: true if the TouchLED Sensor is currently being pressed. false if it is not.

on()#

Este método se llama de las siguientes maneras:

The on(color, brightness) method turns the LED of the TouchLED Sensor on using predefined colors.

Parámetros

Descripción

color

Un colorType válido.

brillo

El brillo con el que se debe configurar el LED.

Devoluciones: Ninguna.

The on(hue, brightness) method turns the LED of the TouchLED Sensor on using hue values.

Parámetros

Descripción

matiz

El tono del LED. También se puede representar como un valor hexadecimal.

brillo

El brillo con el que se debe configurar el LED.

Devoluciones: Ninguna.

The on(r, g, b, brightness) method turns the LED of the TouchLED Sensor on using RGB values.

Parámetros

Descripción

o

Un entero de 8 bits sin signo que representa el valor rojo del LED.

gramo

Un entero de 8 bits sin signo que representa el valor verde del LED.

b

Un entero de 8 bits sin signo que representa el valor azul del LED.

brillo

El brillo con el que se debe configurar el LED.

Devoluciones: Ninguna.

off()#

The off() method turns the LED of the TouchLED Sensor off.

Devoluciones: Ninguna.

setFade()#

The setFade(setting) method changes the fade setting of the TouchLED Sensor . The TouchLED Sensor will change to new colors using the fade type.

Parámetros

Descripción

configuración

Un fadeType válido.

Devoluciones: Ninguna.

setColor()#

The setColor(value) method turns the LED of the TouchLED Sensor on. This method has similar functionality to the on() method but this method will use the previous brightness level instead of a specified value.

Parámetros

Descripción

valor

Un colorType válido.

Devoluciones: Ninguna.

setBrightness()#

The setBrightness(value) method changes the brightness of the TouchLED Sensor. The TouchLED Sensor will be turned on using the previously used color but with a different brightness.

Parámetros

Descripción

valor

Brillo en el rango de 0 - 255.

Devoluciones: Ninguna.

pressed()#

The pressed(callback) method registers a function to be called when the TouchLED Sensor is pressed.

Parámetros

Descripción

llamar de vuelta

Una función que se llamará cuando se presione el sensor TouchLED.

Devoluciones: Ninguna.

// Define the touchLEDPressed function with a void return type,
// showing it doesn't return a value.
void touchLEDPressed() {
  // The Brain will print that the TouchLED Sensor was pressed on the
  // Brain's screen.
  Brain.Screen.print("TouchLED Sensor pressed");
}

int main() {
  // Initializing Robot Configuration. DO NOT REMOVE!
  vexcodeInit();

  // Run touchLEDPressed when the value of the TouchLED Sensor
  // is pressed.
  touch.pressed(touchLEDPressed);
}

released()#

The released(callback) method registers a function to be called when the TouchLED Sensor is released.

Parámetros

Descripción

llamar de vuelta

Una función que se llamará cuando se suelte el sensor TouchLED.

Devoluciones: Ninguna.

// Define the touchLEDReleased function with a void return type,
// showing it doesn't return a value.
void touchLEDReleased() {
  // The Brain will print that the TouchLED Sesor was released 
  // on the Brain's screen.
  Brain.Screen.print("TouchLED Sensor released");
}

int main() {
  // Initializing Robot Configuration. DO NOT REMOVE!
  vexcodeInit();

  // Run touchLEDReleased when the value of the TouchLED Sensor 
  // is released.
  touch.released(touchLEDReleased);
}

timestamp()#

The timestamp() method requests the timestamp of the last received status packet from the Touch LED Sensor.

Devuelve: Marca de tiempo del último paquete de estado como un entero de 32 bits sin signo en milisegundos.

installed()#

The installed() method returns if the TouchLED Sensor is connected to the Brain.

Returns: true if the TouchLED Sensor is connected to the Brain. false if it is not.