Difference between revisions of "Hw led add"

From Sim Innovations Wiki
Jump to navigation Jump to search
 
(6 intermediate revisions by the same user not shown)
Line 6: Line 6:
'''hw_led_add''' is used to add a LED output to your instrument.
'''hw_led_add''' is used to add a LED output to your instrument.


== Return value ==


{| class="wikitable"
{{tip| Use [[hw_output_add]] instead if you don't need to control the brightness of your LED, since it is more efficient. }}
|-
! 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.
|}


== Named ==
== Named ==
Line 31: Line 25:
| 1 || '''name''' || ''String'' || A functional name to define the LED.
| 1 || '''name''' || ''String'' || A functional name to define the LED.
|-
|-
| 2 || '''initial_brightness''' || ''Number'' || The initial state of the LED. Ranges from 1.0 (full brightness) to 0.0 (off).
| 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 ===
 
{| class="wikitable"
|-
! 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.
|}
|}


Line 61: Line 64:
| 1 || '''name''' || ''String'' || The is the reference to the LED output. You can choose to bind to an existing Hardware ID ([[Hardware_id_list]]).
| 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'' || The initial state of the LED. Ranges from 1.0 (full brightness) to 0.0 (off).
| 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 ===
{| class="wikitable"
|-
! 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.
|}
|}



Latest revision as of 13:50, 17 March 2019

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, since it is more efficient.

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)