t2:led_set

led_set


led_set — Set LED intensity and duty length

Description


void led_set(<LED_IDENTIFIER>, fix32 intensity, uint32 dutylength);

Set the intensity and duty length values of the LED identified by <LED_IDENTIFIER>.

ATTENTION: The led_set() holds the last state set and should NOT be called on every interaction of main.
Depending on the “Device Lightbar” option in device settings, the led_set() also have effect on the Titan Two lightbar.
DualShock 4 and Titan Two Lightbar RGB Map
LED_1 Blue
LED_2 Red
LED_3 Green
Always set LED_4 to 0.0 when configuring colors using the RGB spectrum.

Parameters


  • <LED_IDENTIFIER>: An valid LED identifier LED_1, LED_2, LED_3 or LED_4. Note: the LED identifier is passed as direct parameter of the led_set() opcode, therefore stack values can't be used.
  • intensity: The LED intensity level in percentage, from 0.00 to 100.00 (%). Pass a negative value to use the “Default LED Intensity” configured by the user in the device settings.
  • dutylength: The total length of the LED blinking duty cycle, expressed in milli-seconds. The duty cycle is 50% on and 50% off, for instance, a dutylenght of 800 will result in blink the LED for 400ms on and 400ms off. Set this parameter to 0 to not blink the LED.
The intensity value is only fully supported by DualShock 4 controllers and for the others controllers this parameter is interpreted as binary value to turn the LED on or off.
The dutylength value is only fully supported by DualShock 3 controllers, for the others controllers this parameter is ignored.

Return Value


No value is returned.

Examples


Example #1 led_set() example

init {
    uint8 protocol;
    port_status(PORT_USB_A, &protocol, NULL);
 
    // If there is an PS3 controller on INPUT-A ...
    if(protocol == PROTOCOL_PS3) {
        // ... blink the player LED_2.
        led_set(LED_1, 0.0, 0);
        led_set(LED_2, 100.0, 400);
        led_set(LED_3, 0.0, 0);
        led_set(LED_4, 0.0, 0);
    }
}

Example #2 led_set() example

void set_rgb(fix32 r, fix32 g, fix32 b) {
    led_set(LED_1, b, 0);
    led_set(LED_2, r, 0);
    led_set(LED_3, g, 0);
    led_set(LED_4, 0.0, 0);
    printf("rgb(%0.2f, %0.2f, %0.2f)", r, g, b);
    return;
}

See Also

t2/led_set.txt · Last modified: 2016/11/29 06:25 by J2Kbr