Post · 1 min read· pp. 59–60

Function Scripts

Purpose

Function scripts are invoked via EdgeTX 'Lua Script' of Special Functions configuration page.

Typical uses of Function scripts are:

  • specialized handling in response to switch position changes
  • customized announcements

Execution & Lifetime

Function script is loded when model is selected.

Script executes until

  • it misbehaves (e.g. run-time error or low memory)
  • One-time Script is running. When One-time script finishes execution, Wigdet Script resumes execution.

!!! warning Function scripts DO NOT HAVE ACCESS TO LCD DISPLAY

File Location

Function scripts are located on the SD card in the folder /SCRIPTS/FUNCTIONS/

!!! warning File name length (without extension) must be 6 characters or less

Interface

Every Function script must include a return statement at the end, defining its interface to EdgeTX.

This statement returns a table with the following fields:

Field

Type

Required

Desctiption

run

function

This function is called periodicaly when switch assiociated the Special Function is ON.

Parameters none

Return values none

Field

Type

Required

Desctiption

init

function

This function is called once when Function script is loaded and executed for the first time

Parameters none

Return Values none

Field

Type

Required

Desctiption

background

function

This function is called periodicaly when switch assiociated the Special Function is OFF

Parameters none

Return Values none

Example