Difference between revisions of "Hw output add"

From Sim Innovations Wiki
Jump to navigation Jump to search
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Description ==
== Description ==


'''hw_output_id = hw_output_add(name, initial_state)''' (from AM/AP 3.5)
  '''hw_output_id = hw_output_add(hw_id, initial_state)'''
  '''hw_output_id = hw_output_add(hw_id, initial_state)'''


'''hw_output_add''' is used to add a hardware output to your instrument.
'''hw_output_add''' is used to add a hardware output to your instrument.


== Return value ==  
== Named ==
{{tip| Available from AM/AP 3.5.}}
 
Give your hardware objects a name (.e.g. 'Power button' or 'Strobe LED').<br/>
Air Manager will present the user with a view where the assignment of pins can be done.
 
=== Arguments ===
 
'''hw_output_id = hw_output_add(name, initial_state)'''
 
{| class="wikitable"
|-
! # !! Argument !! Type !! Description
|-
| 1 || '''name''' || ''String'' || A functional name to define the output.
|-
| 2 || '''initial_state''' || ''Boolean'' || The initial state of the output. When true, the pin will be driven high, otherwise low.
|-
|}
 
=== Return value ===  


{| class="wikitable"
{| class="wikitable"
Line 11: Line 32:
! Argument !! Type !! Description
! Argument !! Type !! Description
|-
|-
| '''hw_output_id''' || ''String'' || This value can be used for further reference. Functions such as [[hw_output_set]] can use this hw_output_id. Its good practice to store this hw_output_id in your logic code.
| '''hw_output_id''' || ''ID'' || This value can be used for further reference. Functions such as [[hw_output_set]] can use this hw_output_id. Its good practice to store this hw_output_id in your logic code.
|}
|}


== Arguments ==
=== Example ===


<source lang="lua">
-- Create a new output
outp_id = hw_output_add("My output", true)
-- Nah, rather have the output low
hw_output_set(outp_id, false)
</source >
== Hardware Id's ==
{{warning| 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_output_id = hw_output_add(hw_id, initial_state)'''


{| class="wikitable"
{| class="wikitable"
Line 21: Line 60:
! # !! Argument !! Type !! Description
! # !! Argument !! Type !! Description
|-
|-
| 1 || '''hw_id''' || ''String'' || The is the reference to the output. You can choose to bind to an existing Hardware ID ([[Hardware_id_list]]), or define your own Hardware ID, which you can dynamicly couple to an external type of hardware, such as the Teensy or Arduino.
| 1 || '''hw_id''' || ''String'' || The is the reference to the output. You can choose to bind to an existing Hardware ID ([[Hardware_id_list]]).
|-
|-
| 2 || '''initial_state''' || ''Boolean'' || The initial state of the output. When true, the pin will be driven high, otherwise low.
| 2 || '''initial_state''' || ''Boolean'' || The initial state of the output. When true, the pin will be driven high, otherwise low.
Line 27: Line 66:
|}
|}


== Example ==
=== Return value ===
 
{| class="wikitable"
|-
! Argument !! Type !! Description
|-
| '''hw_output_id''' || ''ID'' || This value can be used for further reference. Functions such as [[hw_output_set]] can use this hw_output_id. Its good practice to store this hw_output_id in your logic code.
|}
 
=== Example ===


<source lang="lua">
<source lang="lua">
Line 34: Line 82:


-- Nah, rather have the output low
-- Nah, rather have the output low
hw_output_write(outp_id, false)
hw_output_set(outp_id, false)
 
</source >
</source >

Latest revision as of 19:29, 11 October 2018

Description

hw_output_id = hw_output_add(name, initial_state) (from AM/AP 3.5)
hw_output_id = hw_output_add(hw_id, initial_state)

hw_output_add is used to add a hardware output to your instrument.

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_output_id = hw_output_add(name, initial_state)

# Argument Type Description
1 name String A functional name to define the output.
2 initial_state Boolean The initial state of the output. When true, the pin will be driven high, otherwise low.

Return value

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

Example

-- Create a new output
outp_id = hw_output_add("My output", true)

-- Nah, rather have the output low
hw_output_set(outp_id, false)

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_output_id = hw_output_add(hw_id, initial_state)

# Argument Type Description
1 hw_id String The is the reference to the output. You can choose to bind to an existing Hardware ID (Hardware_id_list).
2 initial_state Boolean The initial state of the output. When true, the pin will be driven high, otherwise low.

Return value

Argument Type Description
hw_output_id ID This value can be used for further reference. Functions such as hw_output_set can use this hw_output_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 drive the output high
outp_id = hw_output_add("RPI_V2_P1_38", true)

-- Nah, rather have the output low
hw_output_set(outp_id, false)