Air Manager Instrument Logic API

From Sim Innovations Wiki
Jump to navigation Jump to search

Every instrument has a logic file (logic.lua). This file contains the code to tell the instrument how to behave. A well known scripting language is used, called Lua. This page describes which functions may be used in this logic file. For instance to add a background image, to add text or to communicate with X-Plane.

X-Plane

These functions are used to communicate with X-Plane. X-Plane knows two ways of communicating, datarefs and commands. Datarefs are used for most kind of data, such as airspeed, altitude etc. etc. The other way of communicating is done by sending commands to X-Plane. Commands are event driven, and are mostly used for simulating certain buttons on instruments.

Our YouTube contains videos about subscribing to datarefs, writing datarefs and variable_subscribe and commands.

Function Description Version
xpl_dataref_subscribe(dataref,type,callback_function) Subscribe to specified dataref(s) AM 1.0/AP 3.0 and up
xpl_dataref_write(dataref,type,value,offset,force) Write to a certain X-Plane dataref AM 1.0/AP 3.0 and up
xpl_command(commandref) Send a certain command to X-Plane AM 1.2/AP 3.0 and up
xpl_command_subscribe(commandref, callback_function) Subscribe to certain command in X-Plane AM 3.3/AP 3.3 and up
connected = xpl_connected() Check if we are connected to X-Plane AM 3.6/AP 3.6 and up
variable_subscribe(source,variable_name,type,callback_function) Subscribe to multiple sources (X-Plane, FSX, AM) using one subscription AM 3.0/AP 3.0 and up
request_callback(callback_function) Force an update on a subscription AM 3.5/AP 3.5 and up

Flight Simulator X or Prepar3D

These functions are used to communicate with Flight Simulator X or Prepar3D. Air Manager uses the SimConnect interface. There are two ways of communicating, variables and events. Variables are used for most kind of data, such as airspeed, altitude etc. etc. The other way of communicating is done by sending events to FSX or Prepar3D. Events are mostly used for simulating certain buttons on instruments.

Click here for a screencast video about FSX and Prepar3D functions.

Function Description Version
fsx_variable_subscribe(variable,unit,callback_function) Subscribe to specified variable(s) AM 2.0/AP 3.0 and up
fsx_variable_write(variable,unit, value) Write data to a variable AM 2.0/AP 3.0 and up
fsx_event(event) Trigger a certain FSX or Prepar3D event AM 2.0/AP 3.0 and up
connected = fsx_connected() Check if we are connected to FSX AM 3.6/AP 3.6 and up
connected = p3d_connected() Check if we are connected to Prepar3d AM 3.6/AP 3.6 and up
variable_subscribe(source,variable_name,type,callback_function) Subscribe to multiple sources (X-plane, FSX, AM) using one subscription AM 3.0/AP 3.0 and up
request_callback(callback_function) Force an update on a subscription AM 3.5/AP 3.5 and up

Flight Simulator 2020

These functions are used to communicate with Microsoft Flight Simulator 2020. Air Manager uses the SimConnect interface. There are two ways of communicating, variables and events. Variables are used for most kind of data, such as airspeed, altitude etc. etc. The other way of communicating is done by sending events to the flight simulator. Events are mostly used for simulating certain buttons on instruments.

Function Description Version
fs2020_variable_subscribe(variable,unit,callback_function) Subscribe to specified variable(s) AM 4.0/AP 4.0 and up
fs2020_variable_write(variable,unit, value) Write data to a variable AM 4.0/AP 4.0 and up
fs2020_event(event) Trigger a certain FS2020 event AM 4.0/AP 4.0 and up
connected = fs2020_connected() Check if we are connected to FS2020 AM 4.0/AP 4.0 and up
variable_subscribe(source,variable_name,type,callback_function) Subscribe to multiple sources (X-plane, FSX, AM) using one subscription AM 3.0/AP 3.0 and up
request_callback(callback_function) Force an update on a subscription AM 3.5/AP 3.5 and up

Aerofly FS2

These functions are used to communicate with Aerofly FS2.

Click here for a screencast video about Aerofly FS2 functions.

Function Description Version
fs2_msg_subscribe(msg,type,callback_function) Subscribe to specified message(s) AM 3.4/AP 3.4 and up
fs2_msg_write(msg,flags,type,value) Send a message to FS2 AM 3.4/AP 3.4 and up
connected = fs2_connected() Check if we are connected to FS2 AM 3.6/AP 3.6 and up
variable_subscribe(source,variable_name,type,callback_function) Subscribe to multiple sources (X-plane, FSX, AM) using one subscription AM 3.4/AP 3.4 and up
request_callback(callback_function) Force an update on a subscription AM 3.5/AP 3.5 and up

Inter-instrument communication

These functions are used to communicate between instruments. Communication all goes through the Air Manager flight simulator plugin (X-plane or FSX), so make sure that is running. There are two ways to communicate between instruments. Variables and commands. Variables are state full, there is always has a value behind it. Commands are event based, and won't hold any value.

Click here for a screencast video about inter-instrument communication.

Function Description Version
var_id = si_variable_create(variable,unit,initial_value) Create a new Air Manager variable AM 3.6/AP 3.6 and up
si_variable_subscribe(variable,unit,callback_function) Subscribe to specified Air Manager variable(s) AM 3.6/AP 3.6 and up
si_variable_write(var_id,value) Write to a Air Manager variable AM 3.6/AP 3.6 and up
variable_subscribe(source,variable_name,type,callback_function) Subscribe to multiple sources (X-plane, FSX, AM) using one subscription AM 3.6/AP 3.6 and up
si_command_subscribe(command,callback_function) Subscribe to specified Air Manager command(s) AM 3.6/AP 3.6 and up
si_command(command) Send a Air Manager command AM 3.6/AP 3.6 and up
request_callback(callback_function) Force an update on a subscription AM 3.6/AP 3.6 and up

External data source (Professional version only!)

The Professional version of Air Manager can connect to external data sources. These functions describe how to receive and send data from and to an external source.

Function Description Version
ext_variable_subscribe(source_tag,variable,unit,callback_function) Subscribe to external source variable(s) AM 2.1.2/AP 3.0 Professional and up
ext_variable_write(source_tag,variable,unit, value) Write an external source variable AM 2.1.2/AP 3.0 Professional and up
ext_command(source_tag,event_name) Send a command to the external source AM 2.1.2/AP 3.0 Professional and up
request_callback(callback_function) Force an update on a subscription AM 3.5/AP 3.5 and up

Node

Many objects (like images, text, buttons etc.) are considered nodes, and as such can be used with the functions below.

Click here for a screencast video about nodes.

Function Description Version
move(node_id,x,y,width,height) Move the node to the specified bounds AM 1.3/AP 3.0 and up
visible(node_id,visible) Makes a node visible or invisible AM 1.3/AP 3.0 and up
opacity(node_id,opacity) Change the opacity AM 3.3/AP 3.3 and up
viewport_rect(node_id,x,y,width,height) Only shows the node within a specified rectangle AM 1.3/AP 3.0 and up

Image

These functions are used to add images to your instrument. The order in which you add the images determines the layering. The images you add first are at the back, and every next image is layed on top of the previous. PNG is used as the image format, since it supports transparency.

Click here for a screencast video about the image functions.

Function Description Version
image_id = img_add(filename,x,y,width,height) Add an image to specified bounds AM 1.0/AP 3.0 and up
image_id = img_add_fullscreen(filename) Add an image fullscreen AM 1.0/AP 3.0 and up
rotate(image_id,degrees) Rotate an image to the specified degree AM 3.0/AP 3.0 and up
remove(image_id) Remove the image from the instrument AM 3.5/AP 3.5 and up
move, visible, opacity and viewport_rect Inherited from Node
Function Description Version
running_img_id = running_img_add_ver(filename,x,y,nr_visible_items,item_width,item_height) Adds a vertical running image object AM 1.0/AP 3.0 and up
running_img_id = running_img_add_hor(filename,x,y,nr_visible_items,item_width,item_height) Adds a horizontal running image object AM 1.0/AP 3.0 and up
running_img_id = running_img_add_cir(filename,x,y,nr_visible_items,item_width,item_height,radius) Adds a circular running image object AM 1.0/AP 3.0 and up
running_img_move_carot(running_img_id, position) Set carrot position for a running image object AM 1.0/AP 3.0 and up
move, visible, opacity and viewport_rect Inherited from Node

Text

These functions are used to add text to your instrument.

Click here for a screencast video about the text functions.

Function Description Version
txt_id = txt_add(text,style,x,y,width,height) Add a text box to specified bounds AM 1.0/AP 3.0 and up
txt_set(txt_id,text) Set a new text string AM 1.0/AP 3.0 and up
txt_style(txt_id,style) Change the style of a text box AM 1.0/AP 3.0 and up
rotate(txt_id,degrees) Rotate text to the specified degree AM 3.3/AP 3.3 and up
move, visible, opacity and viewport_rect Inherited from Node
Function Description Version
running_txt_id = running_txt_add_ver(x,y,nr_visible_items,item_width,item_height,value_callback,style) Adds a vertical running text object AM 1.0/AP 3.0 and up
running_txt_id = running_txt_add_hor(x,y,nr_visible_items,item_width,item_height,value_callback,style) Adds a horizontal running text object AM 1.0/AP 3.0 and up
running_txt_id = running_txt_add_cir(x,y,nr_visible_items,item_width,item_height,radius,value_callback,style) Adds a circular running text object AM 1.0/AP 3.0 and up
running_txt_move_carot(running_txt_id, position) Set carrot position for a running text object AM 1.0/AP 3.0 and up
move, visible, opacity and viewport_rect Inherited from Node

Button

These functions let you add buttons to your instruments. Buttons don't have any state, they always pop back to the original position.

Click here for a screencast video about button functions.

Function Description Version
button_id = button_add(img_normal,img_pressed,x,y,width,height,press_callback,release_callback) Add a button to specified bounds AM 1.2/AP 3.0 and up
mouse_setting(button_id,property,value) Sets mouse settings for a button (such as custom cursor images) AM 2.1/AP 3.0 and up
move, visible, opacity and viewport_rect Inherited from Node

Switch

These functions let you add switches to your instrument. Switched are statefull, they can have 2 or more positions.

Click here for a screencast video about button functions.

Function Description Version
switch_id = switch_add(img_pos_0, img_pos_1, img_pos_n,x,y,width,height,click_callback) Add a switch to specified bounds AM 1.2/AP 3.0 and up
switch_set_position(switch_id,position) Set the switch to a certain position AM 3.4/AP 3.4 and up
position = switch_get_position(switch_id) Get the current switch position AM 3.4/AP 3.4 and up
touch_setting(switch_id,property,value) Sets touch settings for a switch AM 2.1/AP 3.0 and up
mouse_setting(switch_id,property,value) Sets mouse settings for a switch (such as custom cursor images) AM 2.1/AP 3.0 and up
move, visible, opacity and viewport_rect Inherited from Node

Dial

These functions let you add a dial to your instrument. Dials can be rotated endlessly, and don't hold any state.

Click here for a screencast video about dial functions.

Function Description Version
dial_id = dial_add(image,x,y,width,height,acceleration,click_callback) Add a dial to specified bounds AM 1.2/AP 3.0 and up
touch_setting(dial_id,property,value) Sets touch settings for a dial AM 2.1/AP 3.0 and up
mouse_setting(dial_id,property,value) Sets mouse settings for a dial (such as custom cursor images) AM 2.1/AP 3.0 and up
move, visible, opacity and viewport_rect Inherited from Node

Slider

These functions let you add a slider to your instrument. You can add an horizontal, vertical or circular slider to your instrument.

Click here for a screencast video about slider functions.

Function Description Version
slider_id = slider_add_hor(image, x, y, width, height, thumb_image, thumb_width, thumb_height, callback) Add a horizontal slider to specified bounds AM 3.0/AP 3.0 and up
slider_id = slider_add_ver(image, x, y, width, height, thumb_image, thumb_width, thumb_height, callback) Add a vertical slider to specified bounds AM 3.0/AP 3.0 and up
slider_id = slider_add_cir(image, x, y, width, height, radius, start_angle, end_angle, thumb_image, thumb_width, thumb_height, callback) Add a circular slider to specified bounds AM 3.0/AP 3.0 and up
slider_set_position(slider_id, position) Set the slider to a certain position AM 3.0/AP 3.0 and up
move, visible, opacity and viewport_rect Inherited from Node

Scroll wheel

These functions let you add a scroll wheel to your instrument. You can add a horizontal or vertical scroll wheel to your instrument.

Click here for a screencast video about scrollwheel functions.

Function Description Version
scrollwheel_id = scrollwheel_add_hor(segment_image, x, y, width, height, segment_width, segment_height, callback) Add a horizontal scroll wheel to specified bounds AM 3.0/AP 3.0 and up
scrollwheel_id = scrollwheel_add_ver(segment_image, x, y, width, height, segment_width, segment_height, callback) Add a vertical scroll wheel to specified bounds AM 3.0/AP 3.0 and up
mouse_setting(scrollwheel_id,property,value) Sets mouse settings for a button (such as custom cursor images) AM 3.1/AP 3.1 and up
touch_setting(scrollwheel_id,property,value) Sets touch settings for a scroll wheel AM 3.1/AP 3.1 and up
move, visible, opacity and viewport_rect Inherited from Node

Map

These functions let you open a moving map to your instrument. OpenStreetMap is used as the source for the map. You also have the ability to overlay NAV data (Airports, VOR, NDB) onto the map.

Click here for a screencast video about the map functions.

Function Description Version
map_id = map_add(x,y,width,height,source,zoom) Add a map to the instrument. AM 1.1/AP 3.0 and up
map_goto(map_id,lat,lon) Go to a certain location on earth, defined by longitude and latitude. AM 1.1/AP 3.0 and up
map_zoom(map_id,zoom) Change the zoom level of a map AM 1.1/AP 3.0 and up
map_baselayer(map_id,source) Change the base layer of a map AM 1.1.2/AP 3.0 and up
move, visible, opacity and viewport_rect Inherited from Node
Function Description Version
layer_id = map_add_nav_canvas_layer(map_id, nav_type, x, y, width, height, draw_callback) Add a canvas layer to the map for a certain NAV source. AM 4.0/AP 4.0 and up
map_nav_canvas_layer_draw(layer_id) Redraw the canvas AM 4.0/AP 4.0 and up
layer_id = map_add_nav_img_layer(map_id, nav_type, filename, x, y, width, height) Add an image layer to the map for a certain NAV source. AM 1.1/AP 3.0 and up
layer_id = map_add_nav_txt_layer(map_id, nav_type, nav_param, style, x, y, width, height) Add a txt layer to the map for a certain NAV source. AM 1.1/AP 3.0 and up
visible(layer_id,visible) Make a layer visible or invisible AM 1.3/AP 3.0 and up

Canvas

The canvas allows to draw shapes like lines, rectangles, circles etc. in your instrument.

The canvas screencast video is divided into part one, part two and part three.

Function Description Version
canvas_id = canvas_add(x, y, width, height, draw_callback) Create a new canvas to draw in. AM 3.3/AP 3.3 and up
canvas_draw(canvas_id, draw_callback) Redraw the canvas AM 3.3/AP 3.3 and up
rotate(canvas_id,degrees) Rotate canvas to the specified degree AM 3.3/AP 3.3 and up
move, visible, opacity and viewport_rect Inherited from Node

Draw callback functions

Function Description Version
_move_to(x, y) Move pen to new location AM 3.3/AP 3.3 and up
_line_to(x, y) Queue line to new location AM 3.3/AP 3.3 and up
_bezier_to(cp1x, cp1y, cp2x, cp2y, x, y) Queue bezier line to new location AM 3.3/AP 3.3 and up
_quad_to(cpx, cpy, x, y) Queue quad line to new location AM 3.3/AP 3.3 and up
_arc_to(cpx, cpy, x, y, radius) Queue arc line to new location AM 3.3/AP 3.3 and up
_arc(cx, cy, start_angle, end_angle, radius, direction) Queue arc AM 3.3/AP 3.3 and up
_rect(x, y, width, height, corner) Queue a rectangle for drawing AM 3.3/AP 3.3 and up
_circle(cx, cy, radius) Queue a circle for drawing AM 3.3/AP 3.3 and up
_ellipse(cx, cy, radius_x, radius_y) Queue a ellipse for drawing AM 3.3/AP 3.3 and up
_triangle(x1, y1, x2, y2, x3, y3) Queue a triangle for drawing AM 3.3/AP 3.3 and up
_stroke(color, stroke_width) Stroke enqueued objects AM 3.3/AP 3.3 and up
_fill(color) Fill enqueued objects AM 3.3/AP 3.3 and up
_fill_img(file_name, x, y, width, height, opacity) Fill enqueued objects with an image AM 3.5/AP 3.5 and up
_fill_gradient_linear(x1, y1, x2, y2, color_1, color_2) Fill enqueued objects with a linear gradient AM 4.0/AP 4.0 and up
_fill_gradient_box(x, y, width, height, corner, feather, color_inner, color_outer) Fill enqueued objects with a boxed gradient AM 4.0/AP 4.0 and up
_fill_gradient_radial(x, y, radial_inner, radial_outer, color_inner, color_outer) Fill enqueued objects with a radial gradient AM 4.0/AP 4.0 and up
_txt(text, style, x, y) Draw text AM 3.5/AP 3.5 and up
_rotate(angle, x, y) Rotate around a certain position AM 3.5/AP 3.5 and up
_translate(x, y) Move content in X and/or Y direction AM 3.5/AP 3.5 and up
_scale(angle, x, y) Scale content AM 3.5/AP 3.5 and up

Group

Groups give you the ability to group together multiple objects (switch, button, image, text, etc etc). This way you can make the whole group visible of invisible with one function call.

Click here for a screencast video about the group functions.

Function Description Version
group_id = group_add(node_id, ...) Create a new group AM 1.2/AP 3.0 and up
group_obj_add(group_id, node_id, ...) Add additional objects to the group AM 2.1/AP 3.0 and up
group_obj_remove(group_id, node_id, ...) Remove objects from the group AM 2.1/AP 3.0 and up
rotate(group_id, degrees) Rotate the group AM 3.4/AP 3.4 and up
move, visible, opacity and viewport_rect Inherited from Node

Instrument

Info These functions can only be used within a panel script, not within an instrument script.

Set of functions to interact with instruments that are part of a panel.

Function Description Version
instrument_id = instrument_get(uuid, offset) Get an instrument from the running panel AM 3.5/AP 3.5 and up
z_order(instrument_id, order) Set the Z order of an instrument AM 3.5/AP 3.5 and up
move, visible, opacity and viewport_rect Inherited from Node

Layer

Info These functions can only be used within a panel script, not within an instrument script.

Set of functions to create and manipulate a layer.

Function Description Version
layer_id = layer_add(z_order, callback) Create a new layer AM 3.5/AP 3.5 and up
z_order(layout_id, order) Set the Z order of a layer AM 3.5/AP 3.5 and up
move, visible, opacity and viewport_rect Inherited from Node

Sound

These functions let you add sound clips to your instrument. Only WAV file format is supported.

Function Description Version
sound_id = sound_add(filename, volume) Loads a new sound AM 1.0/AP 3.0 and up
sound_play(sound_id) Play a sound once AM 1.0/AP 3.0 and up
sound_loop(sound_id) Play a sound forever and ever AM 1.0/AP 3.0 and up
sound_stop(sound_id) Stop playing a sound AM 1.0/AP 3.0 and up

Game controller

These functions let you get events from HID game controller (joystick) devices. Only works on the Windows and Linux platform.

Function Description Version
game_controller_list = game_controller_list() List all attached game controllers AM 4.0/AP 4.0 and up
game_controller_id = game_controller_add(game_controller_name, index, callback) Create a new game controller AM 4.0/AP 4.0 and up

Timer

These functions let you add a timer to your instrument. The timer can call a specific function with a configurable interval, and delay.

Function Description Version
timer_id = timer_start(delay,period,callback_function) Start a timer which will call a function at a given interval AM 2.1/AP 3.0 and up
timer_stop(timer_id) Stop a timer AM 2.1/AP 3.0 and up
running = timer_running(timer_id) Check if a timer is still running AM 2.1/AP 3.0 and up

Persistence

Persistence functions let you save data to the hard drive. This makes it possible to let your instrument 'remember' certain settings or values.

Function Description Version
persist_id = persist_add(key, type, initial_value) Open up a new persistence object AM 2.1/AP 3.0 and up
persist_put(persist_id, value) Put a new value in the persistence object AM 2.1/AP 3.0 and up
value = persist_get(persist_id) Get the value from a persistence object AM 2.1/AP 3.0 and up

User properties

User properties can be used to let the user of the instrument change certain aspects of your instrument. User properties are visible to the instrument user and requires no need knowledge of the lua system.

Function Description Version
user_prop_id = user_prop_add_integer(name, min, max, default_value, description) Create a new integer user property AM 3.0/AP 3.0 and up
user_prop_id = user_prop_add_real(name, min, max, default_value, description) Create a new floating point user property AM 3.0/AP 3.0 and up
user_prop_id = user_prop_add_boolean(name, default_value, description) Create a new boolean user property AM 3.0/AP 3.0 and up
user_prop_id = user_prop_add_string(name, default_value, description) Create a new string user property AM 3.0/AP 3.0 and up
user_prop_id = user_prop_add_enum(name, possible_values, default_value, description) Create a new enumeration (list) user property AM 3.0/AP 3.0 and up
user_prop_id = user_prop_add_percentage(name, min, max, default_value, description) Create a new percentage user property AM 3.7/AP 3.7 and up
user_prop_id = user_prop_add_table(name, column_name, column_type, ..., description) Create a new table user property AM 3.7/AP 3.7 and up
user_prop_id = user_prop_add_hardware_id(name, default_value, description) Create a new hardware ID user property AM 3.0/AP 3.0 and up
value = user_prop_get(user_prop_id) Get the value of a user property AM 3.0/AP 3.0 and up

Navigation data

These functions help you get navigation data from Air Manager.

Function Description Version
nav_get(nav_type, nav_property, value) Get details of a NAV item AM 2.1.1/AP 3.0 and up
nav_get_nearest(nav_type, lat, lon, max_entries) Get the nearest NAV items from a certain latitude and longitude AM 2.1.1/AP 3.0 and up
nav_get_radius(nav_type, lat, lon, distance, max_entries) Get the NAV items within a radius around a certain latitude and longitude AM 2.1.1/AP 3.0 and up

Static data

Add own data (CSV, JSON or text) to your instrument.

Function Description Version
static_data_load(path, callback) Load data from CSV, JSON or txt file AM 3.5/AP 3.5 and up

Hardware

Hardware functions. All sorts of functions aimed to do interact with hardware buttons, dials, LED's etc.

Check the list below for compatible hardware (such as Raspberry Pi and Arduino):
Hardware ID list

Hardware node

All hardware objects (like buttons, switches, character displays etc.) are considered hardware nodes, and as such can be used with the functions below.

Function Description Version
connected = hw_connected(hw_node_id) Determines if the hardware node is connected to the actual hardware AM 3.5/AP 3.5 and up

Button

Function Description Version
hw_button_id = hw_button_add(hw_id, pressed_callback, released_callback) Add a hardware button AM 3.0/AP 3.0 and up
hw_connected Inherited from Hardware node

LED

Function Description Version
hw_led_id = hw_led_add(hw_id, initial_brightness) Add a LED output AM 3.0/AP 3.0 and up
hw_led_set(hw_led_id, brightness) Set the brightness of the LED AM 3.0/AP 3.0 and up
hw_connected Inherited from Hardware node

Switch

Function Description Version
hw_switch_id = hw_switch_add(hw_id_0, hw_id_0, hw_id_n, callback) Add a hardware switch AM 3.0/AP 3.0 and up
position = hw_switch_get_position(hw_switch_id) Get the current switch position AM 3.4/AP 3.4 and up
hw_connected Inherited from Hardware node

Rotary encoder

Function Description Version
hw_dial_id = hw_dial_add(hw_id_a, hw_id_b, callback) Add a rotary encoder AM 3.0/AP 3.0 and up
hw_dial_set_acceleration(hw_dial_id, acceleration) Change the acceleration of a rotary encoder AM 3.5/AP 3.5 and up
hw_connected Inherited from Hardware node

Digital input

Function Description Version
hw_input_id = hw_input_add(hw_id, callback) Add a hardware input AM 3.0/AP 3.0 and up
state = hw_input_read(hw_input_id) Reads the current state of the input AM 3.0/AP 3.0 and up
hw_connected Inherited from Hardware node

Digital output

Function Description Version
hw_output_id = hw_output_add(hw_id, initial_state) Add a hardware output AM 3.0/AP 3.0 and up
hw_output_set(hw_output_id, state) Set the state of a output AM 3.0/AP 3.0 and up
hw_connected Inherited from Hardware node

Analog input

Function Description Version
hw_adc_input_id = hw_adc_input_add(hw_id, callback) Add a hardware ADC input AM 3.0/AP 3.0 and up
state = hw_adc_input_read(hw_adc_input_id) Read the current ADC input value AM 3.0/AP 3.0 and up
hw_connected Inherited from Hardware node

Analog output

Function Description Version
hw_dac_output_id = hw_dac_output_add(hw_id, initial_value) Add a DAC output (analog voltage) AM 3.4/AP 3.4 and up
hw_dac_output_set(hw_dac_output_id, value) Set the state of a DAC output AM 3.4/AP 3.4 and up
hw_connected Inherited from Hardware node

PWM output

Function Description Version
hw_output_pwm_id = hw_output_pwm_add(hw_id, frequency_hz, initial_duty_cycle) Add a PWM hardware output AM 3.0/AP 3.0 and up
hw_output_pwm_duty_cycle(hw_output_pwm_id, duty_cycle) Set the duty cycle of a PWM output AM 3.0/AP 3.0 and up
hw_connected Inherited from Hardware node

Character display

Function Description Version
hw_chr_display_id = hw_chr_display_add(type, nr_displays, hw_id_0, hw_id_1 ...) Add a character display AM 3.4/AP 3.4 and up
hw_chr_display_set_text(hw_chr_display_id, display, line, text) Write text to a character display AM 3.4/AP 3.4 and up
hw_chr_display_set_brightness(hw_chr_display_id, display, brightness) Set brightness for a character display AM 3.4/AP 3.4 and up
hw_connected Inherited from Hardware node

Button array

Function Description Version
hw_button_array_id = hw_button_array_add(nr_rows, nr_columns, hw_id_0, hw_id_1, ..., pressed_callback, released_callback) Add a hardware button array AM 3.5/AP 3.5 and up
hw_connected Inherited from Hardware node

Stepper motor

Function Description Version
hw_stepper_motor_id = hw_stepper_motor_add(type, nr_steps, speed_rpm, hw_id_0, hw_id_1, ...) Add a stepper motor AM 3.5/AP 3.5 and up
hw_stepper_motor_calibrate(hw_stepper_motor_id, position) Calibrate to the current stepper motor position AM 3.5/AP 3.5 and up
hw_stepper_motor_speed(hw_stepper_motor_id, speed_rpm) Set the speed of the stepper motor AM 3.5/AP 3.5 and up
hw_stepper_motor_position(hw_stepper_motor_id, position, direction) Set the desired position of the stepper motor AM 3.5/AP 3.5 and up
hw_connected Inherited from Hardware node

Message port

Function Description Version
hw_message_port_id = hw_message_port_add(hw_id, message_callback) Add a message port AM 3.3/AP 3.3 and up
hw_message_port_send(hw_message_port_id , message_id, payload_type, payload) Send a message to the message port AM 3.3/AP 3.3 and up
hw_connected Inherited from Hardware node

Flight Illusion

With these functions, you can connect to a Flight Illusion gauge or engine cluster from your instrument code.

NOTE : This is still in development, and not yet available.

Function Description Version
fi_gauge_id = fi_gauge_add(address, type) Add a flight illusion gauge. AM 3.7/AP 3.7 and up
fi_gauge_prop_set(fi_gauge_id, prop_name, value) Set a gauge property. E.g. needle position or display text. AM 3.7/AP 3.7 and up
fi_gauge_prop_subscribe(fi_gauge_id, prop_name, callback) Subscribe to a gauge property. E.g. needle position or display text. AM 3.7/AP 3.7 and up
fi_gauge_command(fi_gauge_id, command_name) Send a command to the gauge. E.g. to turn the autopilot off. AM 3.7/AP 3.7 and up
fi_gauge_command_subscribe(fi_gauge_id, command_name, value) Subscribe to a gauge command. E.g. when a button is pressed. AM 3.7/AP 3.7 and up
fi_engine_cluster_id = fi_engine_cluster_add(type) Add a flight illusion engine cluster. AM 3.7/AP 3.7 and up
fi_engine_cluster_prop_set(fi_engine_cluster_id, prop_name, value) Set a engine cluster property. E.g. needle position or display text. AM 3.7/AP 3.7 and up

Helpers

Helper functions. All sorts of functions aimed to do common instruments tasks.

Function Description Version
value = instrument_prop(property) Get different settings from the current instrument like aircraft, type, version, height, width, development, etc etc... AM 2.1/AP 3.0 and up
value = panel_prop(property) Get different settings from the current panel like author, name, layout uuid, height, width, etc etc... AM 3.5/AP 3.5 and up
meta_data = resource_info(filename) Get information of a resource file. This can also be used to check if a resource exists. AM 2.1.1/AP 3.0 and up
value = var_cap(value,min,max) Limits a value to a minimum and maximum value. AM 1.0/AP 3.0 and up
value = var_round(value,decimals) Rounds the value to the given number of decimals. AM 1.0/AP 3.0 and up
value = var_format(value,decimals) Rounds the value to the given number of decimals and always shows that selected amount of decimals. AM 1.0/AP 3.0 and up
x, y = geo_rotate_coordinates(degrees, radius_x, radius_y) Used to get the x and y coordinates from a circle with a certain radius and angle. AM 1.0/AP 3.0 and up
settings = interpolate_settings_from_user_prop(user_prop_table_value) Creates interpolate settings from table user property AM 3.7/AP 3.7 and up
value = interpolate_linear(settings, value) Interpolate a value with given settings AM 3.7/AP 3.7 and up
feature_available = has_feature(name) Check if the current version of Air Manager or Air Panel support a certain feature. AM 3.5/AP 3.5 and up
event_subscribe(callback) Subscribe to global events. E.g., when the instrument or panel is starting, showing or closing. AM 3.6/AP 3.6 and up
shut_down(type) Shut down application or computer AM 3.3/AP 3.3 and up
log(type, message, ...) Write a message to the Air Manager or Air Player log file AM 3.7/AP 3.7 and up