LED Functions

Function Name

Description

Zen

Plus

Sets the state of the LED on a controller

✔️

✔️

Gets the state of the LED on a controller

✔️

✔️

Blinks a LED a certain number of times

✔️

✔️

Checks if a LED is being blinked by the set_ledx function

✔️

✔️

Reset the LEDs state to what was set by the console

✔️

✔️

Gets ps4 indication bar color

✔️

Sets ps4 indication color

✔️

set_led

set_led sets the state of an LED on the controller. The LEDs range from 0 to 3. Four constants have been created to make it easier to remember which value is assigned to which LED:

Name

Description

Value

LED_1

LED 1 / Xbox 360 Quadrant 1

0

LED_2

LED 2 / Xbox 360 Quadrant 2

1

LED_3

LED 3 / Xbox 360 Quadrant 3

2

LED_4

LED 4 / Xbox 360 Quadrant 4

3

An LED can be set to one of four states using this function which range from 0 to 3, as shown in the table below:

Value

Description

0

LED Off

1

LED On

2

LED Blink Fast

3

LED Blink Slowly

set_led(LED_1, 0);    // turn the LED OFF
set_led(LED_1, 1);    // turn the LED ON
set_led(LED_1, 2);    // make the LED blink fast
set_led(LED_1, 3);    // make the LED blink slowly

🔴 Syntax

set_led( <led_identifier>,<led_state>);

Parameters

<led_identifier> : the LED identifier. <led_state> : the state identifier of the controller LED.

🔵 Returns

None

get_led

get_led returns a value in the form of an int which represents the current state of the chosen LED. The return value from this function informs you of the current state of the selected LED. The function returns a value ranging from 0 ~ 3;

Return Value

Description

0

LED Off

1

LED On

2

LED Blinking Fast

3

LED Blinking Slowly

Example of usage:

main {     
    if(get_led(LED_2) == 1) { // If LED 2 is On        
    // Do Something    
    } 
}

🔴 Syntax

get_led ( <Led_Identifier> );

Parameters

<Led_Identifier> : The identifier of an LED

🔵 Returns

An int ranging from 0 ~ 3 which represents the current state

set_ledx

set_ledx is used to Blink and LED a set amount of times. You can blink an led from 0 to 255 times. 0 sets the LED to on.

Example of usage:

main {    
    if(!get_ledx()) { // If the leds are not blinking...         
        set_led(LED_1, 10);  // Blink LED 1 10 times    
        } 
    }

🔴 Syntax

set_ledx ( <led_identifier> , <no_of_blinks> );

Parameters

<led_identifier> : the identifier of an LED<no_of_blinks> : The number of times to blink the LED

get_ledx

get_ledx checks to see if an LED is currently being blinked by the set_ledx function.

Example of usage:

main {     
    if(get_ledx()) { // If the leds are blinking...       
        // Do Something     
        } 
    }

🔴 Syntax

get_ledx ( );

Parameters

None

🔵 Returns

TRUE is the LEDs are being blinked by the set_ledx function, FALSE if they are not

reset_leds

reset_leds returns control of the LEDs to the console and disables any current LED states which are being set by the Virtual Machine.

Example of usage:

main {     
    if(event_press(XB1_A)) { // If A / Cross is Pressed...         
        reset_leds();  // Reset Leds     
        } 
    }

🔴 Syntax

reset_leds ( );

Parameters

None

Setting DS4 Lightbar

The Dualshock 4 controller has one lightbar instead of four LEDs. The color of the lightbar can be controlled by setting all four led states simultaneously.

get_ps4_lbar

get_ps4_lbar gets the playstation 4 lightbar led state from the console.

get_ps4_lbar(State, Range, Color)

There is 3 Colors: PS4_RED, PS4_GREEN, and PS4_BLUE. They have a range from 0 - 255 ( Lower the number equals less brightness, higher the number equals more brighter ).

Example:


if(get_ps4_lbar(TRUE,255,PS4_GREEN)){  // Will check if the console is sending Green lightbar to controller.

set_ps4_lbar

set_ps4_lbar sets the playstation 4 lightbar led state on the controller and sets the color that will be sent to the controller.

There is 3 Colors: DS4_RED, DS4_GREEN, and DS4_BLUE. They have a range from 0 - 255 ( Lower the number equals less brightness, higher the number equals more brighter ).

Example:

set_ps4_lbar(0,0,255);  //Will set the DS4 lightbar to bright green.

set_ps4_lbar(0,255,0);  //Will set the DS4 lightbar to bright red.

set_ps4_lbar(255,0,0);  //Will set the DS4 lightbar to bright blue.

Example using both:

main{

	if(get_ps4_lbar(TRUE,255,PS4_GREEN)){	//Checks if console sending green to controller.
		set_ps4_lbar(0,225,0) ;		// Sets Contoller lightbar to Red if console sending Green to controller.
		}

Last updated