Hw led add

From Sim Innovations Wiki
Revision as of 13:49, 17 March 2019 by Admin (talk | contribs)
Jump to navigation Jump to search

Description

hw_led_id = hw_led_add(name, initial_brightness) (from AM/AP 3.5)
hw_led_id = hw_led_add(hw_id, initial_brightness)

hw_led_add is used to add a LED output to your instrument.

Info Use hw_output_add instead if you don't need to control the brightness of your LED.


Named

Info Available from AM/AP 3.5.

Give your hardware objects a name (.e.g. 'Power button' or 'Strobe LED').
Air Manager will present the user with a view where the assignment of pins can be done.

Arguments

hw_led_id = hw_led_add(name, initial_brightness)
# Argument Type Description
1 name String A functional name to define the LED.
2 initial_brightness Number/Bool The initial state of the LED. Ranges from 1.0 or true (full brightness) to 0.0 or false (off).

Return value

Argument Type Description
hw_led_id ID This value can be used for further reference. Functions such as hw_led_set can use this hw_led_id. Its good practice to store this hw_output_id in your logic code.

Example

-- Create a new LED, and turn the LED to full brightness
led_id = hw_led_add("Battery power", 1.0)

-- Nah, rather have the LED set to 50% brightness
hw_led_set(led_id, 0.5)

Hardware Id's

Info Hardware Id's are not preferred, try to use named hardware instead.

Define the used pin(s) right away. This is not preferred, since changing of pin assignment can only be done by changing the instrument/panel lua script.

Arguments

hw_led_id = hw_led_add(hw_id, initial_brightness)
# Argument Type Description
1 name String The is the reference to the LED output. You can choose to bind to an existing Hardware ID (Hardware_id_list).
2 initial_brightness Number/Bool The initial state of the LED. Ranges from 1.0 or true (full brightness) to 0.0 or false (off).

Return value

Argument Type Description
hw_led_id ID This value can be used for further reference. Functions such as hw_led_set can use this hw_led_id. Its good practice to store this hw_output_id in your logic code.

Example

-- Bind to Raspberry Pi 2, Header P1, Pin 38, and turn the LED to full brightness
led_id = hw_led_add("RPI_V2_P1_38", 1.0)

-- Nah, rather have the LED set to 50% brightness
hw_led_set(led_id, 0.5)