├── .gitignore
├── part_iii_-_opentx_lua_api_reference
├── constants
│ └── README.md
├── lcd-functions-less-than-greater-than-luadoc-begin-lcd
│ ├── README.md
│ ├── resetbacklighttimeout.md
│ ├── refresh.md
│ ├── getcolor.md
│ ├── getlastleftpos.md
│ ├── clear.md
│ ├── getlastpos.md
│ ├── drawsource.md
│ ├── getlastrightpos.md
│ ├── drawpixmap.md
│ ├── drawswitch.md
│ ├── drawfilledrectangle.md
│ ├── drawchannel.md
│ ├── drawscreentitle.md
│ ├── drawrectangle.md
│ ├── drawgauge.md
│ ├── drawline.md
│ ├── drawpoint.md
│ ├── drawbitmap.md
│ ├── drawtimer.md
│ ├── rgb.md
│ ├── drawnumber.md
│ ├── drawcombobox.md
│ ├── rgb2.md
│ ├── drawtext.md
│ ├── setcolor.md
│ └── lcd_functions-overview.md
├── bitmap-functions-less-than-greater-than-luadoc-begin-bitmap
│ ├── README.md
│ ├── getsize.md
│ └── open.md
├── model-functions-less-than-greater-than-luadoc-begin-model
│ ├── README.md
│ ├── deleteinputs.md
│ ├── deletemixes.md
│ ├── defaultinputs.md
│ ├── deleteflightmodes.md
│ ├── resettimer.md
│ ├── resetsensor.md
│ ├── getinfo.md
│ ├── getinputscount.md
│ ├── deleteinput.md
│ ├── deletemix.md
│ ├── getmixescount.md
│ ├── setflightmode.md
│ ├── setswashring.md
│ ├── setinfo.md
│ ├── settimer.md
│ ├── setoutput.md
│ ├── insertmix.md
│ ├── insertinput.md
│ ├── setmodule.md
│ ├── setcustomfunction.md
│ ├── getswashring.md
│ ├── getglobalvariable.md
│ ├── setlogicalswitch.md
│ ├── setglobalvariable.md
│ ├── getlogicalswitch.md
│ ├── getoutput.md
│ ├── getsensor.md
│ ├── gettimer.md
│ ├── getflightmode.md
│ ├── getcurve.md
│ ├── getcustomfunction.md
│ ├── getinput.md
│ ├── setcurve.md
│ ├── getmodule.md
│ └── getmix.md
├── general-functions-less-than-greater-than-luadoc-begin-general
│ ├── README.md
│ ├── flushaudio.md
│ ├── getavailablememory.md
│ ├── chdir.md
│ ├── setserialbaudrate.md
│ ├── getusage.md
│ ├── serialwrite.md
│ ├── getrotencspeed.md
│ ├── grey.md
│ ├── killevents.md
│ ├── getrtctime.md
│ ├── defaultstick.md
│ ├── getrssi.md
│ ├── multibuffer.md
│ ├── ghosttelemetrypop.md
│ ├── defaultchannel.md
│ ├── crossfiretelemetrypop.md
│ ├── playfile.md
│ ├── playduration.md
│ ├── getglobaltimer.md
│ ├── gettime.md
│ ├── playhaptic.md
│ ├── getdatetime.md
│ ├── popupwarning.md
│ ├── getflightmode.md
│ ├── getras.md
│ ├── ghosttelemetrypush.md
│ ├── resetglobaltimer.md
│ ├── crossfiretelemetrypush.md
│ ├── sporttelemetrypop.md
│ ├── popupconfirmation.md
│ ├── playnumber.md
│ ├── sporttelemetrypush.md
│ ├── serialread.md
│ ├── accesstelemetrypush.md
│ ├── gettxgps.md
│ ├── popupinput.md
│ ├── getgeneralsettings.md
│ ├── playtone.md
│ ├── settelemetryvalue.md
│ ├── getversion.md
│ └── getfieldinfo.md
└── README.md
├── cover.jpg
├── part_vii_-_appendix.md
├── cover_small.jpg
├── introduction.md
├── part_vii_-_appendix
├── README.md
└── units.md
├── part_ii_-_opentx_lua_api_programming_guide
├── included_lua_libraries
│ ├── io-library
│ │ ├── README.md
│ │ ├── io.close.md
│ │ ├── io.open.md
│ │ ├── io.read.md
│ │ ├── io.seek.md
│ │ └── io.write.md
│ └── README.md
├── README.md
├── init_function_syntax.md
├── return_statement_syntax.md
├── output_table_syntax.md
├── run_function_syntax.md
└── input_table_syntax.md
├── theme_scripts.md
├── wizard.md
├── RadioSpecialFunctions.png
├── .gitbook
└── assets
│ ├── count-dn.png
│ ├── count-up.png
│ ├── shocount.png
│ ├── btn_donate_LG.gif
│ ├── clear-example1.png
│ ├── clear-example2.png
│ ├── companion-settings.png
│ ├── drawGauge-example.png
│ ├── drawLine-example.png
│ ├── drawNumber-example.png
│ ├── drawPixmap-example.png
│ ├── drawPoint-example.png
│ ├── drawSource-example.png
│ ├── drawSwitch-example.png
│ ├── drawText-example.png
│ ├── drawTimer-example.png
│ ├── getValue-example.png
│ ├── drawChannel-example.png
│ ├── drawCombobox-example.png
│ ├── getDateTime-example.png
│ ├── getFieldInfo-example.png
│ ├── RadioSpecialFunctions.png
│ ├── drawRectangle-example.png
│ ├── drawScreenTitle-example.png
│ ├── CompanionSpecialFunctions.png
│ ├── setGlobalVariable-example.png
│ ├── drawFilledRectangle-example.png
│ └── getGeneralSettings-example.png
├── introduction
├── README.md
├── getting_started.md
└── acknowledgments.md
├── part_i_-_script_type_overview
├── wizard.md
├── theme_scripts.md
├── README.md
└── one-time_scripts.md
├── part_vi_-_advanced_topics.md
├── part_i_-_script_type_overview.md
├── part_vi_-_advanced_topics
├── README.md
└── optimization_tricks.md
├── part_iii_-_opentx_lua_api_reference.md
├── part_ii_-_opentx_lua_api_programming_guide.md
├── model
├── deleteMixes.md
├── deleteInputs.md
├── defaultInputs.md
├── deleteFlightModes.md
├── resetTimer.md
├── resetSensor.md
├── getInfo.md
├── getInputsCount.md
├── deleteInput.md
├── setFlightMode.md
├── deleteMix.md
├── getMixesCount.md
├── setInfo.md
├── setTimer.md
├── setOutput.md
├── insertMix.md
├── insertInput.md
├── setModule.md
├── setCustomFunction.md
├── getGlobalVariable.md
├── setLogicalSwitch.md
├── setGlobalVariable.md
├── getLogicalSwitch.md
├── getOutput.md
├── getSensor.md
├── getTimer.md
├── getFlightMode.md
├── getCurve.md
├── getCustomFunction.md
├── getInput.md
├── getModule.md
├── getMix.md
└── setCurve.md
├── lcd
├── resetBacklightTimeout.md
├── refresh.md
├── getColor.md
├── getLastLeftPos.md
├── clear.md
├── getLastPos.md
├── drawSource.md
├── getLastRightPos.md
├── drawPixmap.md
├── drawSwitch.md
├── drawFilledRectangle.md
├── drawChannel.md
├── drawScreenTitle.md
├── drawRectangle.md
├── drawGauge.md
├── drawLine.md
├── drawPoint.md
├── drawBitmap.md
├── drawTimer.md
├── RGB.md
├── drawNumber.md
├── drawCombobox.md
├── drawText.md
├── setColor.md
└── lcd_functions-overview.md
├── general
├── chdir.md
├── getUsage.md
├── serialWrite.md
├── getRotEncSpeed.md
├── GREY.md
├── killEvents.md
├── getRtcTime.md
├── defaultStick.md
├── getRSSI.md
├── multiBuffer.md
├── defaultChannel.md
├── crossfireTelemetryPop.md
├── playFile.md
├── playDuration.md
├── getGlobalTimer.md
├── getTime.md
├── playHaptic.md
├── popupWarning.md
├── getDateTime.md
├── getFlightMode.md
├── getRAS.md
├── resetGlobalTimer.md
├── crossfireTelemetryPush.md
├── sportTelemetryPop.md
├── popupConfirmation.md
├── playNumber.md
├── sportTelemetryPush.md
├── serialRead.md
├── accessTelemetryPush.md
├── getTxGPS.md
├── popupInput.md
├── getGeneralSettings.md
├── playTone.md
├── setTelemetryValue.md
├── getVersion.md
└── getFieldInfo.md
├── init_function_syntax.md
├── part_iv_-_converting_opentx_20_scripts.md
├── part_iv_-_converting_opentx_20_scripts
├── README.md
├── known_issues.md
├── handling_lipo_sensor_data.md
└── handling_gps_sensor_data.md
├── Bitmap
├── getSize.md
└── open.md
├── included_lua_libraries.md
├── return_statement_syntax.md
├── getting_started.md
├── output_table_syntax.md
├── acknowledgments.md
├── README.md
├── known_issues.md
├── one-time_scripts.md
├── handling_lipo_sensor_data.md
├── optimization_tricks.md
├── run_function_syntax.md
├── part_v_-_converting_opentx_21_scripts.md
├── handling_gps_sensor_data.md
├── input_table_syntax.md
├── appendix
└── units.md
└── telemetry.md
/.gitignore:
--------------------------------------------------------------------------------
1 | /_book/
2 | /node_modules/
3 | /book.pdf
4 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/constants/README.md:
--------------------------------------------------------------------------------
1 | # Constants
2 |
3 |
--------------------------------------------------------------------------------
/cover.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentx/lua-reference-guide/HEAD/cover.jpg
--------------------------------------------------------------------------------
/part_vii_-_appendix.md:
--------------------------------------------------------------------------------
1 | # Part VII - Appendix
2 |
3 | Various additional documents
--------------------------------------------------------------------------------
/cover_small.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentx/lua-reference-guide/HEAD/cover_small.jpg
--------------------------------------------------------------------------------
/introduction.md:
--------------------------------------------------------------------------------
1 | # Introduction
2 |
3 | This section includes Acknowledgments and Getting Started.
--------------------------------------------------------------------------------
/part_vii_-_appendix/README.md:
--------------------------------------------------------------------------------
1 | # Part VII - Appendix
2 |
3 | Various additional documents
4 |
5 |
--------------------------------------------------------------------------------
/part_ii_-_opentx_lua_api_programming_guide/included_lua_libraries/io-library/README.md:
--------------------------------------------------------------------------------
1 | # io Library
2 |
3 |
--------------------------------------------------------------------------------
/theme_scripts.md:
--------------------------------------------------------------------------------
1 | # Theme Scripts
2 |
3 | TODO: describe how theme scripts work on Horus type transmitters.
--------------------------------------------------------------------------------
/wizard.md:
--------------------------------------------------------------------------------
1 | # Wizard
2 |
3 |
4 | TODO: Need to determine status of wizard in 2.2
5 |
--------------------------------------------------------------------------------
/RadioSpecialFunctions.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentx/lua-reference-guide/HEAD/RadioSpecialFunctions.png
--------------------------------------------------------------------------------
/part_ii_-_opentx_lua_api_programming_guide/included_lua_libraries/io-library/io.close.md:
--------------------------------------------------------------------------------
1 | # io.close\(\)
2 |
3 |
--------------------------------------------------------------------------------
/part_ii_-_opentx_lua_api_programming_guide/included_lua_libraries/io-library/io.open.md:
--------------------------------------------------------------------------------
1 | # io.open\(\)
2 |
3 |
--------------------------------------------------------------------------------
/part_ii_-_opentx_lua_api_programming_guide/included_lua_libraries/io-library/io.read.md:
--------------------------------------------------------------------------------
1 | # io.read\(\)
2 |
3 |
--------------------------------------------------------------------------------
/part_ii_-_opentx_lua_api_programming_guide/included_lua_libraries/io-library/io.seek.md:
--------------------------------------------------------------------------------
1 | # io.seek\(\)
2 |
3 |
--------------------------------------------------------------------------------
/part_ii_-_opentx_lua_api_programming_guide/included_lua_libraries/io-library/io.write.md:
--------------------------------------------------------------------------------
1 | # io.write\(\)
2 |
3 |
--------------------------------------------------------------------------------
/.gitbook/assets/count-dn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentx/lua-reference-guide/HEAD/.gitbook/assets/count-dn.png
--------------------------------------------------------------------------------
/.gitbook/assets/count-up.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentx/lua-reference-guide/HEAD/.gitbook/assets/count-up.png
--------------------------------------------------------------------------------
/.gitbook/assets/shocount.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentx/lua-reference-guide/HEAD/.gitbook/assets/shocount.png
--------------------------------------------------------------------------------
/introduction/README.md:
--------------------------------------------------------------------------------
1 | # Introduction
2 |
3 | This section includes Acknowledgments and Getting Started.
4 |
5 |
--------------------------------------------------------------------------------
/part_i_-_script_type_overview/wizard.md:
--------------------------------------------------------------------------------
1 | # Wizard Script
2 |
3 | TODO: Need to determine status of wizard in 2.2
4 |
5 |
--------------------------------------------------------------------------------
/.gitbook/assets/btn_donate_LG.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentx/lua-reference-guide/HEAD/.gitbook/assets/btn_donate_LG.gif
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/lcd-functions-less-than-greater-than-luadoc-begin-lcd/README.md:
--------------------------------------------------------------------------------
1 | # Lcd Functions
2 |
3 |
--------------------------------------------------------------------------------
/.gitbook/assets/clear-example1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentx/lua-reference-guide/HEAD/.gitbook/assets/clear-example1.png
--------------------------------------------------------------------------------
/.gitbook/assets/clear-example2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentx/lua-reference-guide/HEAD/.gitbook/assets/clear-example2.png
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/bitmap-functions-less-than-greater-than-luadoc-begin-bitmap/README.md:
--------------------------------------------------------------------------------
1 | # Bitmap Functions
2 |
3 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/README.md:
--------------------------------------------------------------------------------
1 | # Model Functions
2 |
3 |
--------------------------------------------------------------------------------
/.gitbook/assets/companion-settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentx/lua-reference-guide/HEAD/.gitbook/assets/companion-settings.png
--------------------------------------------------------------------------------
/.gitbook/assets/drawGauge-example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentx/lua-reference-guide/HEAD/.gitbook/assets/drawGauge-example.png
--------------------------------------------------------------------------------
/.gitbook/assets/drawLine-example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentx/lua-reference-guide/HEAD/.gitbook/assets/drawLine-example.png
--------------------------------------------------------------------------------
/.gitbook/assets/drawNumber-example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentx/lua-reference-guide/HEAD/.gitbook/assets/drawNumber-example.png
--------------------------------------------------------------------------------
/.gitbook/assets/drawPixmap-example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentx/lua-reference-guide/HEAD/.gitbook/assets/drawPixmap-example.png
--------------------------------------------------------------------------------
/.gitbook/assets/drawPoint-example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentx/lua-reference-guide/HEAD/.gitbook/assets/drawPoint-example.png
--------------------------------------------------------------------------------
/.gitbook/assets/drawSource-example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentx/lua-reference-guide/HEAD/.gitbook/assets/drawSource-example.png
--------------------------------------------------------------------------------
/.gitbook/assets/drawSwitch-example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentx/lua-reference-guide/HEAD/.gitbook/assets/drawSwitch-example.png
--------------------------------------------------------------------------------
/.gitbook/assets/drawText-example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentx/lua-reference-guide/HEAD/.gitbook/assets/drawText-example.png
--------------------------------------------------------------------------------
/.gitbook/assets/drawTimer-example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentx/lua-reference-guide/HEAD/.gitbook/assets/drawTimer-example.png
--------------------------------------------------------------------------------
/.gitbook/assets/getValue-example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentx/lua-reference-guide/HEAD/.gitbook/assets/getValue-example.png
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/README.md:
--------------------------------------------------------------------------------
1 | # General Functions
2 |
3 |
--------------------------------------------------------------------------------
/.gitbook/assets/drawChannel-example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentx/lua-reference-guide/HEAD/.gitbook/assets/drawChannel-example.png
--------------------------------------------------------------------------------
/.gitbook/assets/drawCombobox-example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentx/lua-reference-guide/HEAD/.gitbook/assets/drawCombobox-example.png
--------------------------------------------------------------------------------
/.gitbook/assets/getDateTime-example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentx/lua-reference-guide/HEAD/.gitbook/assets/getDateTime-example.png
--------------------------------------------------------------------------------
/.gitbook/assets/getFieldInfo-example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentx/lua-reference-guide/HEAD/.gitbook/assets/getFieldInfo-example.png
--------------------------------------------------------------------------------
/.gitbook/assets/RadioSpecialFunctions.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentx/lua-reference-guide/HEAD/.gitbook/assets/RadioSpecialFunctions.png
--------------------------------------------------------------------------------
/.gitbook/assets/drawRectangle-example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentx/lua-reference-guide/HEAD/.gitbook/assets/drawRectangle-example.png
--------------------------------------------------------------------------------
/.gitbook/assets/drawScreenTitle-example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentx/lua-reference-guide/HEAD/.gitbook/assets/drawScreenTitle-example.png
--------------------------------------------------------------------------------
/part_i_-_script_type_overview/theme_scripts.md:
--------------------------------------------------------------------------------
1 | # Theme Scripts
2 |
3 | TODO: describe how theme scripts work on Horus type transmitters.
4 |
5 |
--------------------------------------------------------------------------------
/part_vi_-_advanced_topics.md:
--------------------------------------------------------------------------------
1 | # Part VI - Advanced Topics
2 |
3 | The advanced topics section covers file i/o, data sharing, and debugging techniques
--------------------------------------------------------------------------------
/.gitbook/assets/CompanionSpecialFunctions.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentx/lua-reference-guide/HEAD/.gitbook/assets/CompanionSpecialFunctions.png
--------------------------------------------------------------------------------
/.gitbook/assets/setGlobalVariable-example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentx/lua-reference-guide/HEAD/.gitbook/assets/setGlobalVariable-example.png
--------------------------------------------------------------------------------
/.gitbook/assets/drawFilledRectangle-example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentx/lua-reference-guide/HEAD/.gitbook/assets/drawFilledRectangle-example.png
--------------------------------------------------------------------------------
/.gitbook/assets/getGeneralSettings-example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentx/lua-reference-guide/HEAD/.gitbook/assets/getGeneralSettings-example.png
--------------------------------------------------------------------------------
/part_i_-_script_type_overview.md:
--------------------------------------------------------------------------------
1 | # Part I - Script Type Overview
2 |
3 | This section introduces the types of Lua scripts supported by OpenTX and how they may be used.
--------------------------------------------------------------------------------
/part_vi_-_advanced_topics/README.md:
--------------------------------------------------------------------------------
1 | # Part VI - Advanced Topics
2 |
3 | The advanced topics section covers file i/o, data sharing, and debugging techniques
4 |
5 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference.md:
--------------------------------------------------------------------------------
1 | # Part III - OpenTX Lua API Reference
2 |
3 | This section describes the Lua libraries, functions and constants that are provided by OpenTX.
--------------------------------------------------------------------------------
/part_i_-_script_type_overview/README.md:
--------------------------------------------------------------------------------
1 | # Part I - Script Type Overview
2 |
3 | This section introduces the types of Lua scripts supported by OpenTX and how they may be used.
4 |
5 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/README.md:
--------------------------------------------------------------------------------
1 | # Part III - OpenTX Lua API Reference
2 |
3 | This section describes the Lua libraries, functions and constants that are provided by OpenTX.
4 |
5 |
--------------------------------------------------------------------------------
/part_ii_-_opentx_lua_api_programming_guide.md:
--------------------------------------------------------------------------------
1 | # Part II - OpenTX Lua API Programming Guide
2 | This section provides more specifics on the OpenTX Lua implementation. Here you will find syntax rules for interface tables and functions.
--------------------------------------------------------------------------------
/part_ii_-_opentx_lua_api_programming_guide/README.md:
--------------------------------------------------------------------------------
1 | # Part II - OpenTX Lua API Programming Guide
2 |
3 | This section provides more specifics on the OpenTX Lua implementation. Here you will find syntax rules for interface tables and functions.
4 |
5 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/flushaudio.md:
--------------------------------------------------------------------------------
1 | # flushAudio()
2 |
3 |
4 |
5 | flushes audio queue
6 |
7 | @status experimental
8 |
9 |
10 | ## Parameters
11 |
12 | none
13 |
14 | ## Return value
15 |
16 | none
17 |
18 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/deleteinputs.md:
--------------------------------------------------------------------------------
1 | # model.deleteInputs()
2 |
3 |
4 |
5 | Delete all Inputs
6 |
7 | @status current Introduced in 2.0.0
8 |
9 |
10 | ## Parameters
11 |
12 | none
13 |
14 | ## Return value
15 |
16 | none
17 |
18 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/deletemixes.md:
--------------------------------------------------------------------------------
1 | # model.deleteMixes()
2 |
3 |
4 |
5 | Remove all mixers
6 |
7 | @status current Introduced in 2.0.0
8 |
9 |
10 | ## Parameters
11 |
12 | none
13 |
14 | ## Return value
15 |
16 | none
17 |
18 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/defaultinputs.md:
--------------------------------------------------------------------------------
1 | # model.defaultInputs()
2 |
3 |
4 |
5 | Set all inputs to defaults
6 |
7 | @status current Introduced in 2.0.0
8 |
9 |
10 | ## Parameters
11 |
12 | none
13 |
14 | ## Return value
15 |
16 | none
17 |
18 |
--------------------------------------------------------------------------------
/model/deleteMixes.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## model.deleteMixes()
4 |
5 |
6 |
7 | Remove all mixers
8 |
9 | @status current Introduced in 2.0.0
10 |
11 |
12 | #### Parameters
13 |
14 | none
15 |
16 | #### Return value
17 |
18 | none
19 |
20 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/deleteflightmodes.md:
--------------------------------------------------------------------------------
1 | # model.deleteFlightModes()
2 |
3 |
4 |
5 | Clear all flightModes
6 |
7 | @status current Introduced in 2.3.10
8 |
9 |
10 | ## Parameters
11 |
12 | none
13 |
14 | ## Return value
15 |
16 | none
17 |
18 |
--------------------------------------------------------------------------------
/model/deleteInputs.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## model.deleteInputs()
4 |
5 |
6 |
7 | Delete all Inputs
8 |
9 | @status current Introduced in 2.0.0
10 |
11 |
12 | #### Parameters
13 |
14 | none
15 |
16 | #### Return value
17 |
18 | none
19 |
20 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/lcd-functions-less-than-greater-than-luadoc-begin-lcd/resetbacklighttimeout.md:
--------------------------------------------------------------------------------
1 | # lcd.resetBacklightTimeout()
2 |
3 |
4 |
5 | Reset the backlight timeout
6 |
7 | @status current Introduced in 2.3.6
8 |
9 |
10 | ## Parameters
11 |
12 | none
13 |
14 | ## Return value
15 |
16 | none
17 |
18 |
--------------------------------------------------------------------------------
/model/defaultInputs.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## model.defaultInputs()
4 |
5 |
6 |
7 | Set all inputs to defaults
8 |
9 | @status current Introduced in 2.0.0
10 |
11 |
12 | #### Parameters
13 |
14 | none
15 |
16 | #### Return value
17 |
18 | none
19 |
20 |
--------------------------------------------------------------------------------
/model/deleteFlightModes.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## model.deleteFlightModes()
4 |
5 |
6 |
7 | Clear all flightModes
8 |
9 | @status current Introduced in 2.3.10
10 |
11 |
12 | #### Parameters
13 |
14 | none
15 |
16 | #### Return value
17 |
18 | none
19 |
20 |
--------------------------------------------------------------------------------
/lcd/resetBacklightTimeout.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## lcd.resetBacklightTimeout()
4 |
5 |
6 |
7 | Reset the backlight timeout
8 |
9 | @status current Introduced in 2.3.6
10 |
11 |
12 | #### Parameters
13 |
14 | none
15 |
16 | #### Return value
17 |
18 | none
19 |
20 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/getavailablememory.md:
--------------------------------------------------------------------------------
1 | # getAvailableMemory()
2 |
3 |
4 |
5 | Get available memory remaining in the Heap for Lua.
6 |
7 |
8 | ## Parameters
9 |
10 | none
11 |
12 | ## Return value
13 |
14 | * `usage` (number) a value returned in b
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/chdir.md:
--------------------------------------------------------------------------------
1 | # chdir(directory)
2 |
3 |
4 |
5 | Change the working directory
6 |
7 | @status current Introduced in 2.3.0
8 |
9 |
10 |
11 | ## Parameters
12 |
13 | * `directory` (string) New working directory
14 |
15 |
16 |
17 | ## Return value
18 |
19 | none
20 |
21 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/resettimer.md:
--------------------------------------------------------------------------------
1 | # model.resetTimer(timer)
2 |
3 |
4 |
5 | Reset model timer to a startup value
6 |
7 | @status current Introduced in TODO
8 |
9 |
10 | ## Parameters
11 |
12 | * `timer` (number) timer index (0 for Timer 1)
13 |
14 |
15 |
16 | ## Return value
17 |
18 | none
19 |
20 |
--------------------------------------------------------------------------------
/general/chdir.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## chdir(directory)
4 |
5 |
6 |
7 | Change the working directory
8 |
9 | @status current Introduced in 2.3.0
10 |
11 |
12 |
13 | #### Parameters
14 |
15 | * `directory` (string) New working directory
16 |
17 |
18 |
19 | #### Return value
20 |
21 | none
22 |
23 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/setserialbaudrate.md:
--------------------------------------------------------------------------------
1 | # setSerialBaudrate(baudrate)
2 | @param baudrate Desired baurate
3 |
4 |
5 |
6 | Set baudrate for serial port(s) affected to LUA
7 |
8 | @status current Introduced in 2.3.12
9 |
10 |
11 | ## Parameters
12 |
13 | none
14 |
15 | ## Return value
16 |
17 | none
18 |
19 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/lcd-functions-less-than-greater-than-luadoc-begin-lcd/refresh.md:
--------------------------------------------------------------------------------
1 | # lcd.refresh()
2 |
3 |
4 |
5 | Refresh the LCD screen
6 |
7 | @status current Introduced in 2.2.0
8 |
9 |
10 | ## Parameters
11 |
12 | none
13 |
14 | ## Return value
15 |
16 | none
17 |
18 | ### Notice
19 | This function only works in stand-alone and telemetry scripts.
20 |
21 |
22 |
--------------------------------------------------------------------------------
/model/resetTimer.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## model.resetTimer(timer)
4 |
5 |
6 |
7 | Reset model timer to a startup value
8 |
9 | @status current Introduced in TODO
10 |
11 |
12 | #### Parameters
13 |
14 | * `timer` (number) timer index (0 for Timer 1)
15 |
16 |
17 |
18 | #### Return value
19 |
20 | none
21 |
22 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/resetsensor.md:
--------------------------------------------------------------------------------
1 | # model.resetSensor(sensor)
2 |
3 |
4 |
5 | Reset Telemetry Sensor parameters
6 |
7 | @status current Introduced in 2.3.11
8 |
9 |
10 | ## Parameters
11 |
12 | * `sensor` (unsigned number) sensor number (use 0 for sensor 1)
13 |
14 |
15 |
16 | ## Return value
17 |
18 | * `nil`
19 |
20 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/lcd-functions-less-than-greater-than-luadoc-begin-lcd/getcolor.md:
--------------------------------------------------------------------------------
1 | # lcd.getColor(area)
2 |
3 |
4 |
5 | Get the color for specific area : see lcd.setColor for area list
6 |
7 | @status current Introduced in 2.3.11
8 |
9 |
10 | ## Parameters
11 |
12 | none
13 |
14 | ## Return value
15 |
16 | none
17 |
18 | ### Notice
19 | Only available on Colorlcd radios
20 |
21 |
22 |
--------------------------------------------------------------------------------
/lcd/refresh.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## lcd.refresh()
4 |
5 |
6 |
7 | Refresh the LCD screen
8 |
9 | @status current Introduced in 2.2.0
10 |
11 |
12 | #### Parameters
13 |
14 | none
15 |
16 | #### Return value
17 |
18 | none
19 |
20 | ##### Notice
21 | This function only works in stand-alone and telemetry scripts.
22 |
23 |
24 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/getusage.md:
--------------------------------------------------------------------------------
1 | # getUsage()
2 |
3 |
4 |
5 | Get percent of already used Lua instructions in current script execution cycle.
6 |
7 | @status current Introduced in 2.2.1
8 |
9 |
10 | ## Parameters
11 |
12 | none
13 |
14 | ## Return value
15 |
16 | * `usage` (number) a value from 0 to 100 (percent)
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/model/resetSensor.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## model.resetSensor(sensor)
4 |
5 |
6 |
7 | Reset Telemetry Sensor parameters
8 |
9 | @status current Introduced in 2.3.11
10 |
11 |
12 | #### Parameters
13 |
14 | * `sensor` (unsigned number) sensor number (use 0 for sensor 1)
15 |
16 |
17 |
18 | #### Return value
19 |
20 | * `nil`
21 |
22 |
--------------------------------------------------------------------------------
/general/getUsage.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## getUsage()
4 |
5 |
6 |
7 | Get percent of already used Lua instructions in current script execution cycle.
8 |
9 | @status current Introduced in 2.2.1
10 |
11 |
12 | #### Parameters
13 |
14 | none
15 |
16 | #### Return value
17 |
18 | * `usage` (number) a value from 0 to 100 (percent)
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/lcd/getColor.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## lcd.getColor(area)
4 |
5 |
6 |
7 | Get the color for specific area : see lcd.setColor for area list
8 |
9 | @status current Introduced in 2.3.11
10 |
11 |
12 | #### Parameters
13 |
14 | none
15 |
16 | #### Return value
17 |
18 | none
19 |
20 | ##### Notice
21 | Only available on Colorlcd radios
22 |
23 |
24 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/serialwrite.md:
--------------------------------------------------------------------------------
1 | # serialWrite(str)
2 | @param str (string) String to be written to the serial port.
3 |
4 |
5 |
6 | Writes a string to the serial port. The string is allowed to contain any character, including 0.
7 |
8 | @status current Introduced in 2.3.10
9 |
10 |
11 | ## Parameters
12 |
13 | none
14 |
15 | ## Return value
16 |
17 | none
18 |
19 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/getinfo.md:
--------------------------------------------------------------------------------
1 | # model.getInfo()
2 |
3 |
4 |
5 | Get current Model information
6 |
7 | @status current Introduced in 2.0.6, changed in 2.2.0
8 |
9 |
10 | ## Parameters
11 |
12 | none
13 |
14 | ## Return value
15 |
16 | * `table` model information:
17 | * `name` (string) model name
18 | * `bitmap` (string) bitmap name (not present on X7)
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/getrotencspeed.md:
--------------------------------------------------------------------------------
1 | # getRotEncSpeed()
2 |
3 |
4 |
5 | Return rotary encoder current speed
6 |
7 | @status current Introduced in 2.3.10
8 |
9 |
10 | ## Parameters
11 |
12 | none
13 |
14 | ## Return value
15 |
16 | * `number` in list: ROTENC_LOWSPEED, ROTENC_MIDSPEED, ROTENC_HIGHSPEED
17 | return 0 on radio without rotary encoder
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/lcd-functions-less-than-greater-than-luadoc-begin-lcd/getlastleftpos.md:
--------------------------------------------------------------------------------
1 | # lcd.getLastLeftPos()
2 |
3 |
4 |
5 | Returns the leftmost x position from previous drawtext or drawNumber output
6 |
7 | @status current Introduced in 2.2.0
8 |
9 |
10 | ## Parameters
11 |
12 | none
13 |
14 | ## Return value
15 |
16 | * `number` (integer) x position
17 |
18 |
19 |
20 | ### Notice
21 | Only available on Taranis
22 |
23 |
24 |
--------------------------------------------------------------------------------
/general/serialWrite.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## serialWrite(str)
4 | @param str (string) String to be written to the serial port.
5 |
6 |
7 |
8 | Writes a string to the serial port. The string is allowed to contain any character, including 0.
9 |
10 | @status current Introduced in 2.3.10
11 |
12 |
13 | #### Parameters
14 |
15 | none
16 |
17 | #### Return value
18 |
19 | none
20 |
21 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/grey.md:
--------------------------------------------------------------------------------
1 | # GREY()
2 |
3 |
4 |
5 | Returns gray value which can be used in LCD functions
6 |
7 | @status current Introduced in 2.0.13
8 |
9 |
10 | ## Parameters
11 |
12 | none
13 |
14 | ## Return value
15 |
16 | * `(number)` a value that represents amount of *greyness* (from 0 to 15)
17 |
18 |
19 |
20 | ### Notice
21 | Only available on Taranis
22 |
23 |
24 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/getinputscount.md:
--------------------------------------------------------------------------------
1 | # model.getInputsCount(input)
2 |
3 |
4 |
5 | Return number of lines for given input
6 |
7 | @status current Introduced in 2.0.0
8 |
9 |
10 | ## Parameters
11 |
12 | * `input` (unsigned number) input number (use 0 for Input1)
13 |
14 |
15 |
16 | ## Return value
17 |
18 | * `number` number of configured lines for given input
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/init_function_syntax.md:
--------------------------------------------------------------------------------
1 | # Init Function Syntax
2 |
3 | If defined, *init* function is called right after the script is loaded from SD card and begins execution. Init is called only once before the run function is called for the first time.
4 |
5 | ```lua
6 | local function ()
7 | -- code here runs only once when the model is loaded
8 | end
9 | ```
10 |
11 | * #####Input Parameters:
12 | none
13 |
14 | * #####Return values:
15 | none
16 |
17 |
18 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/deleteinput.md:
--------------------------------------------------------------------------------
1 | # model.deleteInput(input, line)
2 |
3 |
4 |
5 | Delete line from specified input
6 |
7 | @status current Introduced in 2.0.0
8 |
9 |
10 | ## Parameters
11 |
12 | * `input` (unsigned number) input number (use 0 for Input1)
13 |
14 | * `line` (unsigned number) input line (use 0 for first line)
15 |
16 |
17 |
18 | ## Return value
19 |
20 | none
21 |
22 |
--------------------------------------------------------------------------------
/general/getRotEncSpeed.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## getRotEncSpeed()
4 |
5 |
6 |
7 | Return rotary encoder current speed
8 |
9 | @status current Introduced in 2.3.10
10 |
11 |
12 | #### Parameters
13 |
14 | none
15 |
16 | #### Return value
17 |
18 | * `number` in list: ROTENC_LOWSPEED, ROTENC_MIDSPEED, ROTENC_HIGHSPEED
19 | return 0 on radio without rotary encoder
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/model/getInfo.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## model.getInfo()
4 |
5 |
6 |
7 | Get current Model information
8 |
9 | @status current Introduced in 2.0.6, changed in 2.2.0
10 |
11 |
12 | #### Parameters
13 |
14 | none
15 |
16 | #### Return value
17 |
18 | * `table` model information:
19 | * `name` (string) model name
20 | * `bitmap` (string) bitmap name (not present on X7)
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/general/GREY.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## GREY()
4 |
5 |
6 |
7 | Returns gray value which can be used in LCD functions
8 |
9 | @status current Introduced in 2.0.13
10 |
11 |
12 | #### Parameters
13 |
14 | none
15 |
16 | #### Return value
17 |
18 | * `(number)` a value that represents amount of *greyness* (from 0 to 15)
19 |
20 |
21 |
22 | ##### Notice
23 | Only available on Taranis
24 |
25 |
26 |
--------------------------------------------------------------------------------
/lcd/getLastLeftPos.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## lcd.getLastLeftPos()
4 |
5 |
6 |
7 | Returns the leftmost x position from previous drawtext or drawNumber output
8 |
9 | @status current Introduced in 2.2.0
10 |
11 |
12 | #### Parameters
13 |
14 | none
15 |
16 | #### Return value
17 |
18 | * `number` (integer) x position
19 |
20 |
21 |
22 | ##### Notice
23 | Only available on Taranis
24 |
25 |
26 |
--------------------------------------------------------------------------------
/model/getInputsCount.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## model.getInputsCount(input)
4 |
5 |
6 |
7 | Return number of lines for given input
8 |
9 | @status current Introduced in 2.0.0
10 |
11 |
12 | #### Parameters
13 |
14 | * `input` (unsigned number) input number (use 0 for Input1)
15 |
16 |
17 |
18 | #### Return value
19 |
20 | * `number` number of configured lines for given input
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/killevents.md:
--------------------------------------------------------------------------------
1 | # killEvents(key)
2 |
3 |
4 |
5 | Stops key state machine. See [Key Events](../key_events.md) for the detailed description.
6 |
7 | @status current Introduced in 2.0.0
8 |
9 |
10 |
11 | ## Parameters
12 |
13 | * `key` (number) key to be killed, can also include event type (only the key part is used)
14 |
15 |
16 |
17 | ## Return value
18 |
19 | none
20 |
21 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/deletemix.md:
--------------------------------------------------------------------------------
1 | # model.deleteMix(channel, line)
2 |
3 |
4 |
5 | Delete mixer line from specified Channel
6 |
7 | @status current Introduced in 2.0.0
8 |
9 |
10 | ## Parameters
11 |
12 | * `channel` (unsigned number) channel number (use 0 for CH1)
13 |
14 | * `line` (unsigned number) mix number (use 0 for first line(mix))
15 |
16 |
17 |
18 | ## Return value
19 |
20 | none
21 |
22 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/getmixescount.md:
--------------------------------------------------------------------------------
1 | # model.getMixesCount(channel)
2 |
3 |
4 |
5 | Get the number of Mixer lines that the specified Channel has
6 |
7 | @status current Introduced in 2.0.0
8 |
9 |
10 | ## Parameters
11 |
12 | * `channel` (unsigned number) channel number (use 0 for CH1)
13 |
14 |
15 |
16 | ## Return value
17 |
18 | * `number` number of mixes for requested channel
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/setflightmode.md:
--------------------------------------------------------------------------------
1 | # model.setFlightMode(index, params)
2 |
3 |
4 |
5 | Set Flight mode parameters
6 |
7 | @status current Introduced in 2.3.10
8 |
9 |
10 | ## Parameters
11 |
12 | * `index` (unsigned number) flight mode number (use 0 for FM0)
13 |
14 | * `params` see model.getFlightMode return format for table format.
15 |
16 |
17 |
18 | ## Return value
19 |
20 | none
21 |
22 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/lcd-functions-less-than-greater-than-luadoc-begin-lcd/clear.md:
--------------------------------------------------------------------------------
1 | # lcd.clear([color])
2 |
3 |
4 |
5 | Clear the LCD screen
6 |
7 | @status current Introduced in 2.0.0, `color` parameter introduced in 2.2.0 RC12
8 |
9 |
10 | ## Parameters
11 |
12 | * `color` (optional, only on color screens)
13 |
14 |
15 |
16 | ## Return value
17 |
18 | none
19 |
20 | ### Notice
21 | This function only works in stand-alone and telemetry scripts.
22 |
23 |
24 |
--------------------------------------------------------------------------------
/model/deleteInput.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## model.deleteInput(input, line)
4 |
5 |
6 |
7 | Delete line from specified input
8 |
9 | @status current Introduced in 2.0.0
10 |
11 |
12 | #### Parameters
13 |
14 | * `input` (unsigned number) input number (use 0 for Input1)
15 |
16 | * `line` (unsigned number) input line (use 0 for first line)
17 |
18 |
19 |
20 | #### Return value
21 |
22 | none
23 |
24 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/getrtctime.md:
--------------------------------------------------------------------------------
1 | # getRtcTime()
2 |
3 |
4 |
5 | Return current RTC system date as unix timstamp (in seconds since 1. Jan 1970)
6 |
7 | Please note the RTC timestamp is kept internally as a 32bit integer, which will overflow
8 | in 2038.
9 |
10 |
11 | ## Parameters
12 |
13 | none
14 |
15 | ## Return value
16 |
17 | * `number` Number of seconds elapsed since 1. Jan 1970
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/general/killEvents.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## killEvents(key)
4 |
5 |
6 |
7 | Stops key state machine. See [Key Events](../key_events.md) for the detailed description.
8 |
9 | @status current Introduced in 2.0.0
10 |
11 |
12 |
13 | #### Parameters
14 |
15 | * `key` (number) key to be killed, can also include event type (only the key part is used)
16 |
17 |
18 |
19 | #### Return value
20 |
21 | none
22 |
23 |
--------------------------------------------------------------------------------
/model/setFlightMode.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## model.setFlightMode(index, params)
4 |
5 |
6 |
7 | Set Flight mode parameters
8 |
9 | @status current Introduced in 2.3.10
10 |
11 |
12 | #### Parameters
13 |
14 | * `index` (unsigned number) flight mode number (use 0 for FM0)
15 |
16 | * `params` see model.getFlightMode return format for table format.
17 |
18 |
19 |
20 | #### Return value
21 |
22 | none
23 |
24 |
--------------------------------------------------------------------------------
/part_iv_-_converting_opentx_20_scripts.md:
--------------------------------------------------------------------------------
1 | # Part IV - Converting OpenTX 2.0 Scripts
2 |
3 | The handling of telemetry data is significantly improved in OpenTX 2.1. However, in order to support the additional flexibility of having multiple sensors of the same type, many Lua scripts referencing GPS and Lipo sensor data will require revision.
4 |
5 | This section also covers some of the requirements for scripts that are necessary for them to function properly under both OpenTX 2.1 and OpenTX 2.0.
6 |
7 |
--------------------------------------------------------------------------------
/model/deleteMix.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## model.deleteMix(channel, line)
4 |
5 |
6 |
7 | Delete mixer line from specified Channel
8 |
9 | @status current Introduced in 2.0.0
10 |
11 |
12 | #### Parameters
13 |
14 | * `channel` (unsigned number) channel number (use 0 for CH1)
15 |
16 | * `line` (unsigned number) mix number (use 0 for first line(mix))
17 |
18 |
19 |
20 | #### Return value
21 |
22 | none
23 |
24 |
--------------------------------------------------------------------------------
/model/getMixesCount.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## model.getMixesCount(channel)
4 |
5 |
6 |
7 | Get the number of Mixer lines that the specified Channel has
8 |
9 | @status current Introduced in 2.0.0
10 |
11 |
12 | #### Parameters
13 |
14 | * `channel` (unsigned number) channel number (use 0 for CH1)
15 |
16 |
17 |
18 | #### Return value
19 |
20 | * `number` number of mixes for requested channel
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/defaultstick.md:
--------------------------------------------------------------------------------
1 | # defaultStick(channel)
2 |
3 |
4 |
5 | Get stick that is assigned to a channel. See Default Channel Order in General Settings.
6 |
7 | @status current Introduced in 2.0.0
8 |
9 |
10 | ## Parameters
11 |
12 | * `channel` (number) channel number (0 means CH1)
13 |
14 |
15 |
16 | ## Return value
17 |
18 | * `number` Stick assigned to this channel (from 0 to 3)
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/part_iv_-_converting_opentx_20_scripts/README.md:
--------------------------------------------------------------------------------
1 | # Part IV - Converting OpenTX 2.0 Scripts
2 |
3 | The handling of telemetry data is significantly improved in OpenTX 2.1. However, in order to support the additional flexibility of having multiple sensors of the same type, many Lua scripts referencing GPS and Lipo sensor data will require revision.
4 |
5 | This section also covers some of the requirements for scripts that are necessary for them to function properly under both OpenTX 2.1 and OpenTX 2.0.
6 |
7 |
--------------------------------------------------------------------------------
/general/getRtcTime.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## getRtcTime()
4 |
5 |
6 |
7 | Return current RTC system date as unix timstamp (in seconds since 1. Jan 1970)
8 |
9 | Please note the RTC timestamp is kept internally as a 32bit integer, which will overflow
10 | in 2038.
11 |
12 |
13 | #### Parameters
14 |
15 | none
16 |
17 | #### Return value
18 |
19 | * `number` Number of seconds elapsed since 1. Jan 1970
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/getrssi.md:
--------------------------------------------------------------------------------
1 | # getRSSI()
2 |
3 |
4 |
5 | Get RSSI value as well as low and critical RSSI alarm levels (in dB)
6 |
7 | @status current Introduced in 2.2.0
8 |
9 |
10 | ## Parameters
11 |
12 | none
13 |
14 | ## Return value
15 |
16 | * `rssi` RSSI value (0 if no link)
17 |
18 | * `alarm_low` Configured low RSSI alarm level
19 |
20 | * `alarm_crit` Configured critical RSSI alarm level
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/setswashring.md:
--------------------------------------------------------------------------------
1 | # model.setSwashRing(params)
2 | Set heli swash parameters
3 |
4 |
5 |
6 | @status current Introduced in 2.3.15
7 |
8 |
9 | ## Parameters
10 |
11 | * `value` (table) swash ring parameters, see model.getSwashRing() for table format
12 |
13 |
14 |
15 | ## Return value
16 |
17 | none
18 |
19 | ### Notice
20 | If a parameter is missing, then that parameter remains unchanged.
21 |
22 |
23 |
--------------------------------------------------------------------------------
/lcd/clear.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## lcd.clear([color])
4 |
5 |
6 |
7 | Clear the LCD screen
8 |
9 | @status current Introduced in 2.0.0, `color` parameter introduced in 2.2.0 RC12
10 |
11 |
12 | #### Parameters
13 |
14 | * `color` (optional, only on color screens)
15 |
16 |
17 |
18 | #### Return value
19 |
20 | none
21 |
22 | ##### Notice
23 | This function only works in stand-alone and telemetry scripts.
24 |
25 |
26 |
--------------------------------------------------------------------------------
/general/defaultStick.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## defaultStick(channel)
4 |
5 |
6 |
7 | Get stick that is assigned to a channel. See Default Channel Order in General Settings.
8 |
9 | @status current Introduced in 2.0.0
10 |
11 |
12 | #### Parameters
13 |
14 | * `channel` (number) channel number (0 means CH1)
15 |
16 |
17 |
18 | #### Return value
19 |
20 | * `number` Stick assigned to this channel (from 0 to 3)
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/multibuffer.md:
--------------------------------------------------------------------------------
1 | # multiBuffer(address[,value])
2 |
3 |
4 |
5 | This function reads/writes the Multi protocol buffer to interact with a protocol².
6 |
7 | @status current Introduced in 2.3.2
8 |
9 |
10 | ## Parameters
11 |
12 | * `address` to read/write in the buffer
13 | @param (optional): value to write in the buffer
14 |
15 |
16 |
17 | ## Return value
18 |
19 | * `buffer` value (number)
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/lcd-functions-less-than-greater-than-luadoc-begin-lcd/getlastpos.md:
--------------------------------------------------------------------------------
1 | # lcd.getLastPos()
2 |
3 |
4 |
5 | Returns the rightmost x position from previous output
6 |
7 | @status current Introduced in 2.0.0
8 |
9 |
10 | ## Parameters
11 |
12 | none
13 |
14 | ## Return value
15 |
16 | * `number` (integer) x position
17 |
18 |
19 |
20 | ### Notice
21 | Only available on Taranis
22 |
23 |
24 | For added clarity, it is recommended to use lcd.getLastRightPos()
25 |
26 |
27 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/setinfo.md:
--------------------------------------------------------------------------------
1 | # model.setInfo(value)
2 |
3 |
4 |
5 | Set the current Model information
6 |
7 | @status current Introduced in 2.0.6, changed in TODO
8 |
9 |
10 | ## Parameters
11 |
12 | * `value` model information data, see model.getInfo()
13 |
14 |
15 |
16 | ## Return value
17 |
18 | none
19 |
20 | ### Notice
21 | If a parameter is missing from the value, then
22 | that parameter remains unchanged.
23 |
24 |
25 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/ghosttelemetrypop.md:
--------------------------------------------------------------------------------
1 | # ghostTelemetryPop()
2 | Pops a received Ghost Telemetry packet from the queue.
3 | @retval nil queue does not contain any (or enough) bytes to form a whole packet
4 | @retval multiple returns 2 values:
5 | * type (number)
6 | * packet (table) data bytes
7 | @status current Introduced in 2.3.15
8 |
9 |
10 |
11 |
12 | ## Parameters
13 |
14 | none
15 |
16 | ## Return value
17 |
18 | none
19 |
20 |
--------------------------------------------------------------------------------
/general/getRSSI.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## getRSSI()
4 |
5 |
6 |
7 | Get RSSI value as well as low and critical RSSI alarm levels (in dB)
8 |
9 | @status current Introduced in 2.2.0
10 |
11 |
12 | #### Parameters
13 |
14 | none
15 |
16 | #### Return value
17 |
18 | * `rssi` RSSI value (0 if no link)
19 |
20 | * `alarm_low` Configured low RSSI alarm level
21 |
22 | * `alarm_crit` Configured critical RSSI alarm level
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/part_ii_-_opentx_lua_api_programming_guide/init_function_syntax.md:
--------------------------------------------------------------------------------
1 | # Init Function Syntax
2 |
3 | If defined, _init_ function is called right after the script is loaded from SD card and begins execution. Init is called only once before the run function is called for the first time.
4 |
5 | ```lua
6 | local function ()
7 | -- code here runs only once when the model is loaded
8 | end
9 | ```
10 |
11 | * **Input Parameters:**
12 |
13 | none
14 |
15 | * **Return values:**
16 |
17 | none
18 |
19 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/defaultchannel.md:
--------------------------------------------------------------------------------
1 | # defaultChannel(stick)
2 |
3 |
4 |
5 | Get channel assigned to stick. See Default Channel Order in General Settings
6 |
7 | @status current Introduced in 2.0.0
8 |
9 |
10 | ## Parameters
11 |
12 | * `stick` (number) stick number (from 0 to 3)
13 |
14 |
15 |
16 | ## Return value
17 |
18 | * `number` channel assigned to this stick (from 0 to 3)
19 |
20 | * `nil` stick not found
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/general/multiBuffer.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## multiBuffer(address[,value])
4 |
5 |
6 |
7 | This function reads/writes the Multi protocol buffer to interact with a protocol².
8 |
9 | @status current Introduced in 2.3.2
10 |
11 |
12 | #### Parameters
13 |
14 | * `address` to read/write in the buffer
15 | @param (optional): value to write in the buffer
16 |
17 |
18 |
19 | #### Return value
20 |
21 | * `buffer` value (number)
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/part_ii_-_opentx_lua_api_programming_guide/included_lua_libraries/README.md:
--------------------------------------------------------------------------------
1 | # Included Lua Libraries
2 |
3 | | Lua Standard Libraries | Included |
4 | | :--- | :--- |
5 | | package | - |
6 | | coroutine | - |
7 | | table | - |
8 | | [io](https://github.com/opentx/lua-reference-guide/tree/89b65e383782af902c0528c648021268417248da/lib/io.md) | since OpenTX 2.1.0 \(with limitations\) |
9 | | os | - |
10 | | string | since OpenTX 2.1.7 |
11 | | bit32 | since OpenTX 2.1.0 |
12 | | math | since OpenTX 2.0.0 |
13 | | debug | - |
14 |
15 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/lcd-functions-less-than-greater-than-luadoc-begin-lcd/drawsource.md:
--------------------------------------------------------------------------------
1 | # lcd.drawSource(x, y, source [, flags])
2 |
3 |
4 |
5 | Displays the name of the corresponding input as defined by the source at (x,y)
6 |
7 | @status current Introduced in 2.0.0
8 |
9 |
10 | ## Parameters
11 |
12 | * `x,y` (positive numbers) starting coordinate
13 |
14 | * `source` (number) source index
15 |
16 | * `flags` (unsigned number) drawing flags
17 |
18 |
19 |
20 | ## Return value
21 |
22 | none
23 |
24 |
--------------------------------------------------------------------------------
/lcd/getLastPos.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## lcd.getLastPos()
4 |
5 |
6 |
7 | Returns the rightmost x position from previous output
8 |
9 | @status current Introduced in 2.0.0
10 |
11 |
12 | #### Parameters
13 |
14 | none
15 |
16 | #### Return value
17 |
18 | * `number` (integer) x position
19 |
20 |
21 |
22 | ##### Notice
23 | Only available on Taranis
24 |
25 |
26 | For added clarity, it is recommended to use lcd.getLastRightPos()
27 |
28 |
29 |
--------------------------------------------------------------------------------
/model/setInfo.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## model.setInfo(value)
4 |
5 |
6 |
7 | Set the current Model information
8 |
9 | @status current Introduced in 2.0.6, changed in TODO
10 |
11 |
12 | #### Parameters
13 |
14 | * `value` model information data, see model.getInfo()
15 |
16 |
17 |
18 | #### Return value
19 |
20 | none
21 |
22 | ##### Notice
23 | If a parameter is missing from the value, then
24 | that parameter remains unchanged.
25 |
26 |
27 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/lcd-functions-less-than-greater-than-luadoc-begin-lcd/getlastrightpos.md:
--------------------------------------------------------------------------------
1 | # lcd.getLastRightPos()
2 |
3 |
4 |
5 | Returns the rightest x position from previous drawtext or drawNumber output
6 |
7 | @status current Introduced in 2.2.0
8 |
9 |
10 | ## Parameters
11 |
12 | none
13 |
14 | ## Return value
15 |
16 | * `number` (integer) x position
17 |
18 |
19 |
20 | ### Notice
21 | Only available on Taranis
22 |
23 |
24 | This is strictly equivalent to former lcd.getLastPos()
25 |
26 |
27 |
--------------------------------------------------------------------------------
/general/defaultChannel.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## defaultChannel(stick)
4 |
5 |
6 |
7 | Get channel assigned to stick. See Default Channel Order in General Settings
8 |
9 | @status current Introduced in 2.0.0
10 |
11 |
12 | #### Parameters
13 |
14 | * `stick` (number) stick number (from 0 to 3)
15 |
16 |
17 |
18 | #### Return value
19 |
20 | * `number` channel assigned to this stick (from 0 to 3)
21 |
22 | * `nil` stick not found
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/crossfiretelemetrypop.md:
--------------------------------------------------------------------------------
1 | # crossfireTelemetryPop()
2 |
3 |
4 |
5 | Pops a received Crossfire Telemetry packet from the queue.
6 |
7 | @status current Introduced in 2.2.0
8 |
9 |
10 | ## Parameters
11 |
12 | none
13 |
14 | ## Return value
15 |
16 | * `nil` queue does not contain any (or enough) bytes to form a whole packet
17 |
18 | * `multiple` returns 2 values:
19 | * command (number)
20 | * packet (table) data bytes
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/lcd/drawSource.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## lcd.drawSource(x, y, source [, flags])
4 |
5 |
6 |
7 | Displays the name of the corresponding input as defined by the source at (x,y)
8 |
9 | @status current Introduced in 2.0.0
10 |
11 |
12 | #### Parameters
13 |
14 | * `x,y` (positive numbers) starting coordinate
15 |
16 | * `source` (number) source index
17 |
18 | * `flags` (unsigned number) drawing flags
19 |
20 |
21 |
22 | #### Return value
23 |
24 | none
25 |
26 |
--------------------------------------------------------------------------------
/lcd/getLastRightPos.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## lcd.getLastRightPos()
4 |
5 |
6 |
7 | Returns the rightest x position from previous drawtext or drawNumber output
8 |
9 | @status current Introduced in 2.2.0
10 |
11 |
12 | #### Parameters
13 |
14 | none
15 |
16 | #### Return value
17 |
18 | * `number` (integer) x position
19 |
20 |
21 |
22 | ##### Notice
23 | Only available on Taranis
24 |
25 |
26 | This is strictly equivalent to former lcd.getLastPos()
27 |
28 |
29 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/lcd-functions-less-than-greater-than-luadoc-begin-lcd/drawpixmap.md:
--------------------------------------------------------------------------------
1 | # lcd.drawPixmap(x, y, name)
2 |
3 |
4 |
5 | Draw a bitmap at (x,y)
6 |
7 | @status current Introduced in 2.0.0
8 |
9 |
10 | ## Parameters
11 |
12 | * `x,y` (positive numbers) starting coordinates
13 |
14 | * `name` (string) full path to the bitmap on SD card (i.e. “/IMAGES/test.bmp”)
15 |
16 |
17 |
18 | ## Return value
19 |
20 | none
21 |
22 | ### Notice
23 | Maximum image size is [display width / 2] x [display height] pixels.
24 |
25 |
26 |
--------------------------------------------------------------------------------
/general/crossfireTelemetryPop.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## crossfireTelemetryPop()
4 |
5 |
6 |
7 | Pops a received Crossfire Telemetry packet from the queue.
8 |
9 | @status current Introduced in 2.2.0
10 |
11 |
12 | #### Parameters
13 |
14 | none
15 |
16 | #### Return value
17 |
18 | * `nil` queue does not contain any (or enough) bytes to form a whole packet
19 |
20 | * `multiple` returns 2 values:
21 | * command (number)
22 | * packet (table) data bytes
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/bitmap-functions-less-than-greater-than-luadoc-begin-bitmap/getsize.md:
--------------------------------------------------------------------------------
1 | # Bitmap.getSize(name)
2 |
3 |
4 |
5 | Return width, height of a bitmap object
6 |
7 | @status current Introduced in 2.2.0
8 |
9 |
10 | ## Parameters
11 |
12 | * `bitmap` (pointer) point to a bitmap previously opened with Bitmap.open()
13 |
14 |
15 |
16 | ## Return value
17 |
18 | * `multiple` returns 2 values:
19 | * (number) width in pixels
20 | * (number) height in pixels
21 |
22 |
23 |
24 | ### Notice
25 | Only available on Horus
26 |
27 |
28 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/playfile.md:
--------------------------------------------------------------------------------
1 | # playFile(name)
2 |
3 |
4 |
5 | Play a file from the SD card
6 |
7 | @status current Introduced in 2.0.0, changed in 2.1.0
8 |
9 |
10 | ## Parameters
11 |
12 | * `path` (string) full path to wav file (i.e. “/SOUNDS/en/system/tada.wav”)
13 | Introduced in 2.1.0: If you use a relative path, the current language is appended
14 | to the path (example: for English language: `/SOUNDS/en` is appended)
15 |
16 |
17 |
18 | ## Return value
19 |
20 | none
21 |
22 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/settimer.md:
--------------------------------------------------------------------------------
1 | # model.setTimer(timer, value)
2 |
3 |
4 |
5 | Set model timer parameters
6 |
7 | @status current Introduced in 2.0.0, name added in 2.3.6
8 |
9 |
10 | ## Parameters
11 |
12 | * `timer` (number) timer index (0 for Timer 1)
13 |
14 | * `value` timer parameters, see model.getTimer()
15 |
16 |
17 |
18 | ## Return value
19 |
20 | none
21 |
22 | ### Notice
23 | If a parameter is missing from the value, then
24 | that parameter remains unchanged.
25 |
26 |
27 |
--------------------------------------------------------------------------------
/lcd/drawPixmap.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## lcd.drawPixmap(x, y, name)
4 |
5 |
6 |
7 | Draw a bitmap at (x,y)
8 |
9 | @status current Introduced in 2.0.0
10 |
11 |
12 | #### Parameters
13 |
14 | * `x,y` (positive numbers) starting coordinates
15 |
16 | * `name` (string) full path to the bitmap on SD card (i.e. “/IMAGES/test.bmp”)
17 |
18 |
19 |
20 | #### Return value
21 |
22 | none
23 |
24 | ##### Notice
25 | Maximum image size is [display width / 2] x [display height] pixels.
26 |
27 |
28 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/playduration.md:
--------------------------------------------------------------------------------
1 | # playDuration(duration [, hourFormat])
2 |
3 |
4 |
5 | Play a time value (text to speech)
6 |
7 | @status current Introduced in 2.1.0
8 |
9 |
10 | ## Parameters
11 |
12 | * `duration` (number) number of seconds to play. Only integral part is used.
13 |
14 | * `hourFormat` (number):
15 | * `0 or not present` play format: minutes and seconds.
16 | * `!= 0` play format: hours, minutes and seconds.
17 |
18 |
19 |
20 | ## Return value
21 |
22 | none
23 |
24 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/getglobaltimer.md:
--------------------------------------------------------------------------------
1 | # getGlobalTimer()
2 |
3 |
4 |
5 | Returns radio timers
6 |
7 | @status current Introduced added in 2.3.0.
8 |
9 |
10 |
11 | ## Parameters
12 |
13 | none
14 |
15 | ## Return value
16 |
17 | * `table` with elements:
18 | * `gtimer` (number) radio global timer in seconds
19 | * `session` (number) radio session in seconds
20 | * `ttimer` (number) radio throttle timer in seconds
21 | * `tptimer` (number) radio throttle percent timer in seconds
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/gettime.md:
--------------------------------------------------------------------------------
1 | # getTime()
2 |
3 |
4 |
5 | Return the time since the radio was started in multiple of 10ms
6 |
7 | The timer internally uses a 32-bit counter which is enough for 497 days so
8 | overflows will not happen.
9 |
10 | @status current Introduced in 2.0.0
11 |
12 |
13 | ## Parameters
14 |
15 | none
16 |
17 | ## Return value
18 |
19 | * `number` Number of 10ms ticks since the radio was started Example:
20 | run time: 12.54 seconds, return value: 1254
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/setoutput.md:
--------------------------------------------------------------------------------
1 | # model.setOutput(index, value)
2 |
3 |
4 |
5 | Set servo parameters
6 |
7 | @status current Introduced in 2.0.0
8 |
9 |
10 | ## Parameters
11 |
12 | * `index` (unsigned number) channel number (use 0 for CH1)
13 |
14 | * `value` (table) servo parameters, see model.getOutput() for table format
15 |
16 |
17 |
18 | ## Return value
19 |
20 | none
21 |
22 | ### Notice
23 | If a parameter is missing from the value, then
24 | that parameter remains unchanged.
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Bitmap/getSize.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## Bitmap.getSize(name)
4 |
5 |
6 |
7 | Return width, height of a bitmap object
8 |
9 | @status current Introduced in 2.2.0
10 |
11 |
12 | #### Parameters
13 |
14 | * `bitmap` (pointer) point to a bitmap previously opened with Bitmap.open()
15 |
16 |
17 |
18 | #### Return value
19 |
20 | * `multiple` returns 2 values:
21 | * (number) width in pixels
22 | * (number) height in pixels
23 |
24 |
25 |
26 | ##### Notice
27 | Only available on Horus
28 |
29 |
30 |
--------------------------------------------------------------------------------
/general/playFile.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## playFile(name)
4 |
5 |
6 |
7 | Play a file from the SD card
8 |
9 | @status current Introduced in 2.0.0, changed in 2.1.0
10 |
11 |
12 | #### Parameters
13 |
14 | * `path` (string) full path to wav file (i.e. “/SOUNDS/en/system/tada.wav”)
15 | Introduced in 2.1.0: If you use a relative path, the current language is appended
16 | to the path (example: for English language: `/SOUNDS/en` is appended)
17 |
18 |
19 |
20 | #### Return value
21 |
22 | none
23 |
24 |
--------------------------------------------------------------------------------
/included_lua_libraries.md:
--------------------------------------------------------------------------------
1 |
2 | # The following Lua libraries are available in OpenTx
3 |
4 |
5 | | Lua Standard Libraries | Included |
6 | | -- | -- |
7 | | package | - |
8 | | coroutine | - |
9 | | table | - |
10 | | [io](lib/io.md) | since OpenTX 2.1.0 (with limitations) |
11 | | os | - |
12 | | string | since OpenTX 2.1.7 |
13 | | bit32 | since OpenTX 2.1.0 |
14 | | math | since OpenTX 2.0.0 |
15 | | debug | - |
16 |
17 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/lcd-functions-less-than-greater-than-luadoc-begin-lcd/drawswitch.md:
--------------------------------------------------------------------------------
1 | # lcd.drawSwitch(x, y, switch, flags)
2 |
3 |
4 |
5 | Draw a text representation of switch at (x,y)
6 |
7 | @status current Introduced in 2.0.0
8 |
9 |
10 | ## Parameters
11 |
12 | * `x,y` (positive numbers) starting coordinate
13 |
14 | * `switch` (number) number of switch to display, negative number
15 | displays negated switch
16 |
17 | * `flags` (unsigned number) drawing flags, only SMLSIZE, BLINK and INVERS.
18 |
19 |
20 |
21 | ## Return value
22 |
23 | none
24 |
25 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/insertmix.md:
--------------------------------------------------------------------------------
1 | # model.insertMix(channel, line, value)
2 |
3 |
4 |
5 | Insert a mixer line into Channel
6 |
7 | @status current Introduced in 2.0.0, parameters below `multiplex` added in 2.0.13
8 |
9 |
10 | ## Parameters
11 |
12 | * `channel` (unsigned number) channel number (use 0 for CH1)
13 |
14 | * `line` (unsigned number) mix number (use 0 for first line(mix))
15 |
16 | * `value` (table) see model.getMix() for table format
17 |
18 |
19 |
20 | ## Return value
21 |
22 | none
23 |
24 |
--------------------------------------------------------------------------------
/general/playDuration.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## playDuration(duration [, hourFormat])
4 |
5 |
6 |
7 | Play a time value (text to speech)
8 |
9 | @status current Introduced in 2.1.0
10 |
11 |
12 | #### Parameters
13 |
14 | * `duration` (number) number of seconds to play. Only integral part is used.
15 |
16 | * `hourFormat` (number):
17 | * `0 or not present` play format: minutes and seconds.
18 | * `!= 0` play format: hours, minutes and seconds.
19 |
20 |
21 |
22 | #### Return value
23 |
24 | none
25 |
26 |
--------------------------------------------------------------------------------
/model/setTimer.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## model.setTimer(timer, value)
4 |
5 |
6 |
7 | Set model timer parameters
8 |
9 | @status current Introduced in 2.0.0, name added in 2.3.6
10 |
11 |
12 | #### Parameters
13 |
14 | * `timer` (number) timer index (0 for Timer 1)
15 |
16 | * `value` timer parameters, see model.getTimer()
17 |
18 |
19 |
20 | #### Return value
21 |
22 | none
23 |
24 | ##### Notice
25 | If a parameter is missing from the value, then
26 | that parameter remains unchanged.
27 |
28 |
29 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/lcd-functions-less-than-greater-than-luadoc-begin-lcd/drawfilledrectangle.md:
--------------------------------------------------------------------------------
1 | # lcd.drawFilledRectangle(x, y, w, h [, flags])
2 |
3 |
4 |
5 | Draw a solid rectangle from top left corner (x,y) of specified width and height
6 |
7 | @status current Introduced in 2.0.0
8 |
9 |
10 | ## Parameters
11 |
12 | * `x,y` (positive numbers) top left corner position
13 |
14 | * `w` (number) width in pixels
15 |
16 | * `h` (number) height in pixels
17 |
18 | * `flags` (unsigned number) drawing flags
19 |
20 |
21 |
22 | ## Return value
23 |
24 | none
25 |
26 |
--------------------------------------------------------------------------------
/general/getGlobalTimer.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## getGlobalTimer()
4 |
5 |
6 |
7 | Returns radio timers
8 |
9 | @status current Introduced added in 2.3.0.
10 |
11 |
12 |
13 | #### Parameters
14 |
15 | none
16 |
17 | #### Return value
18 |
19 | * `table` with elements:
20 | * `gtimer` (number) radio global timer in seconds
21 | * `session` (number) radio session in seconds
22 | * `ttimer` (number) radio throttle timer in seconds
23 | * `tptimer` (number) radio throttle percent timer in seconds
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/general/getTime.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## getTime()
4 |
5 |
6 |
7 | Return the time since the radio was started in multiple of 10ms
8 |
9 | The timer internally uses a 32-bit counter which is enough for 497 days so
10 | overflows will not happen.
11 |
12 | @status current Introduced in 2.0.0
13 |
14 |
15 | #### Parameters
16 |
17 | none
18 |
19 | #### Return value
20 |
21 | * `number` Number of 10ms ticks since the radio was started Example:
22 | run time: 12.54 seconds, return value: 1254
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/lcd-functions-less-than-greater-than-luadoc-begin-lcd/drawchannel.md:
--------------------------------------------------------------------------------
1 | # lcd.drawChannel(x, y, source, flags)
2 |
3 |
4 |
5 | Display a telemetry value at (x,y)
6 |
7 | @status current Introduced in 2.0.6, changed in 2.1.0 (only telemetry sources are valid)
8 |
9 |
10 | ## Parameters
11 |
12 | * `x,y` (positive numbers) starting coordinate
13 |
14 | * `source` can be a source identifier (number) or a source name (string).
15 | See getValue()
16 |
17 | * `flags` (unsigned number) drawing flags
18 |
19 |
20 |
21 | ## Return value
22 |
23 | none
24 |
25 |
--------------------------------------------------------------------------------
/model/setOutput.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## model.setOutput(index, value)
4 |
5 |
6 |
7 | Set servo parameters
8 |
9 | @status current Introduced in 2.0.0
10 |
11 |
12 | #### Parameters
13 |
14 | * `index` (unsigned number) channel number (use 0 for CH1)
15 |
16 | * `value` (table) servo parameters, see model.getOutput() for table format
17 |
18 |
19 |
20 | #### Return value
21 |
22 | none
23 |
24 | ##### Notice
25 | If a parameter is missing from the value, then
26 | that parameter remains unchanged.
27 |
28 |
29 |
--------------------------------------------------------------------------------
/lcd/drawSwitch.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## lcd.drawSwitch(x, y, switch, flags)
4 |
5 |
6 |
7 | Draw a text representation of switch at (x,y)
8 |
9 | @status current Introduced in 2.0.0
10 |
11 |
12 | #### Parameters
13 |
14 | * `x,y` (positive numbers) starting coordinate
15 |
16 | * `switch` (number) number of switch to display, negative number
17 | displays negated switch
18 |
19 | * `flags` (unsigned number) drawing flags, only SMLSIZE, BLINK and INVERS.
20 |
21 |
22 |
23 | #### Return value
24 |
25 | none
26 |
27 |
--------------------------------------------------------------------------------
/model/insertMix.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## model.insertMix(channel, line, value)
4 |
5 |
6 |
7 | Insert a mixer line into Channel
8 |
9 | @status current Introduced in 2.0.0, parameters below `multiplex` added in 2.0.13
10 |
11 |
12 | #### Parameters
13 |
14 | * `channel` (unsigned number) channel number (use 0 for CH1)
15 |
16 | * `line` (unsigned number) mix number (use 0 for first line(mix))
17 |
18 | * `value` (table) see model.getMix() for table format
19 |
20 |
21 |
22 | #### Return value
23 |
24 | none
25 |
26 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/insertinput.md:
--------------------------------------------------------------------------------
1 | # model.insertInput(input, line, value)
2 |
3 |
4 |
5 | Insert an Input at specified line
6 |
7 | @status current Introduced in 2.0.0, curveType/curveValue/carryTrim added in 2.3, inputName added 2.3.10
8 |
9 |
10 | ## Parameters
11 |
12 | * `input` (unsigned number) input number (use 0 for Input1)
13 |
14 | * `line` (unsigned number) input line (use 0 for first line)
15 |
16 | * `value` (table) input data, see model.getInput()
17 |
18 |
19 |
20 | ## Return value
21 |
22 | none
23 |
24 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/setmodule.md:
--------------------------------------------------------------------------------
1 | # model.setModule(index, value)
2 |
3 |
4 |
5 | Set RF module parameters
6 |
7 | @status current Introduced in 2.2.0, modified in 2.3.12 (proto/subproto)
8 |
9 |
10 | ## Parameters
11 |
12 | * `index` (number) module index (0 for internal, 1 for external)
13 |
14 | * `value` module parameters, see model.getModule()
15 |
16 |
17 |
18 | ## Return value
19 |
20 | none
21 |
22 | ### Notice
23 | If a parameter is missing from the value, then
24 | that parameter remains unchanged.
25 |
26 |
27 |
--------------------------------------------------------------------------------
/lcd/drawFilledRectangle.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## lcd.drawFilledRectangle(x, y, w, h [, flags])
4 |
5 |
6 |
7 | Draw a solid rectangle from top left corner (x,y) of specified width and height
8 |
9 | @status current Introduced in 2.0.0
10 |
11 |
12 | #### Parameters
13 |
14 | * `x,y` (positive numbers) top left corner position
15 |
16 | * `w` (number) width in pixels
17 |
18 | * `h` (number) height in pixels
19 |
20 | * `flags` (unsigned number) drawing flags
21 |
22 |
23 |
24 | #### Return value
25 |
26 | none
27 |
28 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/playhaptic.md:
--------------------------------------------------------------------------------
1 | # playHaptic(duration, pause [, flags])
2 |
3 |
4 |
5 | Generate haptic feedback
6 |
7 | @status current Introduced in 2.2.0
8 |
9 |
10 | ## Parameters
11 |
12 | * `duration` (number) length of the haptic feedback in milliseconds
13 |
14 | * `pause` (number) length of the silence after haptic feedback in milliseconds
15 |
16 | * `flags` (number):
17 | * `0 or not present` play with normal priority
18 | * `PLAY_NOW` play immediately
19 |
20 |
21 |
22 | ## Return value
23 |
24 | none
25 |
26 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/lcd-functions-less-than-greater-than-luadoc-begin-lcd/drawscreentitle.md:
--------------------------------------------------------------------------------
1 | # lcd.drawScreenTitle(title, page, pages)
2 |
3 |
4 |
5 | Draw a title bar
6 |
7 | @status current Introduced in 2.0.0
8 |
9 |
10 | ## Parameters
11 |
12 | * `title` (string) text for the title
13 |
14 | * `page` (number) page number
15 |
16 | * `pages` (number) total number of pages. Only used as indicator on
17 | the right side of title bar. (i.e. idx=2, cnt=5, display `2/5`)
18 |
19 |
20 |
21 | ## Return value
22 |
23 | none
24 |
25 | ### Notice
26 | Only available on Taranis
27 |
28 |
29 |
--------------------------------------------------------------------------------
/lcd/drawChannel.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## lcd.drawChannel(x, y, source, flags)
4 |
5 |
6 |
7 | Display a telemetry value at (x,y)
8 |
9 | @status current Introduced in 2.0.6, changed in 2.1.0 (only telemetry sources are valid)
10 |
11 |
12 | #### Parameters
13 |
14 | * `x,y` (positive numbers) starting coordinate
15 |
16 | * `source` can be a source identifier (number) or a source name (string).
17 | See getValue()
18 |
19 | * `flags` (unsigned number) drawing flags
20 |
21 |
22 |
23 | #### Return value
24 |
25 | none
26 |
27 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/getdatetime.md:
--------------------------------------------------------------------------------
1 | # getDateTime()
2 |
3 |
4 |
5 | Return current system date and time that is kept by the RTC unit
6 |
7 |
8 | ## Parameters
9 |
10 | none
11 |
12 | ## Return value
13 |
14 | * `table` current date and time, table elements:
15 | * `year` (number) year
16 | * `mon` (number) month
17 | * `day` (number) day of month
18 | * `hour` (number) hours
19 | * `hour12` (number) hours in US format
20 | * `min` (number) minutes
21 | * `sec` (number) seconds
22 | * `suffix` (text) am or pm
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/popupwarning.md:
--------------------------------------------------------------------------------
1 | # popupWarning(title, event)
2 |
3 |
4 |
5 | Raises a pop-up on screen that shows a warning
6 |
7 | @status current Introduced in 2.2.0
8 |
9 |
10 | ## Parameters
11 |
12 | * `title` (string) text to display
13 |
14 | * `event` (number) the event variable that is passed in from the
15 | Run function (key pressed)
16 |
17 |
18 |
19 | ## Return value
20 |
21 | * `"CANCEL"` user pushed EXIT key
22 |
23 |
24 |
25 | ### Notice
26 | Use only from stand-alone and telemetry scripts.
27 |
28 |
29 |
--------------------------------------------------------------------------------
/model/insertInput.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## model.insertInput(input, line, value)
4 |
5 |
6 |
7 | Insert an Input at specified line
8 |
9 | @status current Introduced in 2.0.0, curveType/curveValue/carryTrim added in 2.3, inputName added 2.3.10
10 |
11 |
12 | #### Parameters
13 |
14 | * `input` (unsigned number) input number (use 0 for Input1)
15 |
16 | * `line` (unsigned number) input line (use 0 for first line)
17 |
18 | * `value` (table) input data, see model.getInput()
19 |
20 |
21 |
22 | #### Return value
23 |
24 | none
25 |
26 |
--------------------------------------------------------------------------------
/model/setModule.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## model.setModule(index, value)
4 |
5 |
6 |
7 | Set RF module parameters
8 |
9 | @status current Introduced in 2.2.0, modified in 2.3.12 (proto/subproto)
10 |
11 |
12 | #### Parameters
13 |
14 | * `index` (number) module index (0 for internal, 1 for external)
15 |
16 | * `value` module parameters, see model.getModule()
17 |
18 |
19 |
20 | #### Return value
21 |
22 | none
23 |
24 | ##### Notice
25 | If a parameter is missing from the value, then
26 | that parameter remains unchanged.
27 |
28 |
29 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/getflightmode.md:
--------------------------------------------------------------------------------
1 | # getFlightMode(mode)
2 |
3 |
4 |
5 | Return flight mode data.
6 |
7 | @status current Introduced in 2.1.7
8 |
9 |
10 | ## Parameters
11 |
12 | * `mode` (number) flight mode number to return (0 - 8). If mode parameter
13 | is not specified (or contains invalid value), then the current flight mode data is returned.
14 |
15 |
16 |
17 | ## Return value
18 |
19 | * `multiple` returns 2 values:
20 | * (number) (current) flight mode number (0 - 8)
21 | * (string) (current) flight mode name
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/getras.md:
--------------------------------------------------------------------------------
1 | # getRAS()
2 |
3 |
4 |
5 | Return the RAS value or nil if no valid hardware found
6 |
7 | @status current Introduced in 2.2.0
8 |
9 |
10 | ## Parameters
11 |
12 | none
13 |
14 | ## Return value
15 |
16 | * `number` representing RAS value. Value bellow 0x33 (51 decimal) are all ok, value above 0x33 indicate a hardware antenna issue.
17 | This is just a hardware pass/fail measure and does not represent the quality of the radio link
18 |
19 |
20 |
21 | ### Notice
22 | RAS was called SWR in the past
23 |
24 |
25 |
--------------------------------------------------------------------------------
/general/playHaptic.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## playHaptic(duration, pause [, flags])
4 |
5 |
6 |
7 | Generate haptic feedback
8 |
9 | @status current Introduced in 2.2.0
10 |
11 |
12 | #### Parameters
13 |
14 | * `duration` (number) length of the haptic feedback in milliseconds
15 |
16 | * `pause` (number) length of the silence after haptic feedback in milliseconds
17 |
18 | * `flags` (number):
19 | * `0 or not present` play with normal priority
20 | * `PLAY_NOW` play immediately
21 |
22 |
23 |
24 | #### Return value
25 |
26 | none
27 |
28 |
--------------------------------------------------------------------------------
/general/popupWarning.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## popupWarning(title, event)
4 |
5 |
6 |
7 | Raises a pop-up on screen that shows a warning
8 |
9 | @status current Introduced in 2.2.0
10 |
11 |
12 | #### Parameters
13 |
14 | * `title` (string) text to display
15 |
16 | * `event` (number) the event variable that is passed in from the
17 | Run function (key pressed)
18 |
19 |
20 |
21 | #### Return value
22 |
23 | * `"CANCEL"` user pushed EXIT key
24 |
25 |
26 |
27 | ##### Notice
28 | Use only from stand-alone and telemetry scripts.
29 |
30 |
31 |
--------------------------------------------------------------------------------
/general/getDateTime.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## getDateTime()
4 |
5 |
6 |
7 | Return current system date and time that is kept by the RTC unit
8 |
9 |
10 | #### Parameters
11 |
12 | none
13 |
14 | #### Return value
15 |
16 | * `table` current date and time, table elements:
17 | * `year` (number) year
18 | * `mon` (number) month
19 | * `day` (number) day of month
20 | * `hour` (number) hours
21 | * `hour12` (number) hours in US format
22 | * `min` (number) minutes
23 | * `sec` (number) seconds
24 | * `suffix` (text) am or pm
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/lcd/drawScreenTitle.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## lcd.drawScreenTitle(title, page, pages)
4 |
5 |
6 |
7 | Draw a title bar
8 |
9 | @status current Introduced in 2.0.0
10 |
11 |
12 | #### Parameters
13 |
14 | * `title` (string) text for the title
15 |
16 | * `page` (number) page number
17 |
18 | * `pages` (number) total number of pages. Only used as indicator on
19 | the right side of title bar. (i.e. idx=2, cnt=5, display `2/5`)
20 |
21 |
22 |
23 | #### Return value
24 |
25 | none
26 |
27 | ##### Notice
28 | Only available on Taranis
29 |
30 |
31 |
--------------------------------------------------------------------------------
/general/getFlightMode.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## getFlightMode(mode)
4 |
5 |
6 |
7 | Return flight mode data.
8 |
9 | @status current Introduced in 2.1.7
10 |
11 |
12 | #### Parameters
13 |
14 | * `mode` (number) flight mode number to return (0 - 8). If mode parameter
15 | is not specified (or contains invalid value), then the current flight mode data is returned.
16 |
17 |
18 |
19 | #### Return value
20 |
21 | * `multiple` returns 2 values:
22 | * (number) (current) flight mode number (0 - 8)
23 | * (string) (current) flight mode name
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/general/getRAS.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## getRAS()
4 |
5 |
6 |
7 | Return the RAS value or nil if no valid hardware found
8 |
9 | @status current Introduced in 2.2.0
10 |
11 |
12 | #### Parameters
13 |
14 | none
15 |
16 | #### Return value
17 |
18 | * `number` representing RAS value. Value bellow 0x33 (51 decimal) are all ok, value above 0x33 indicate a hardware antenna issue.
19 | This is just a hardware pass/fail measure and does not represent the quality of the radio link
20 |
21 |
22 |
23 | ##### Notice
24 | RAS was called SWR in the past
25 |
26 |
27 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/ghosttelemetrypush.md:
--------------------------------------------------------------------------------
1 | # ghostTelemetryPush()
2 | This functions allows for sending telemetry data toward the Ghost link.
3 | When called without parameters, it will only return the status of the output buffer without sending anything.
4 | @param command command
5 | @param data table of data bytes
6 | @retval boolean data queued in output buffer or not.
7 | @retval nil incorrect telemetry protocol.
8 | @status current Introduced in 2.3.15
9 |
10 |
11 |
12 |
13 | ## Parameters
14 |
15 | none
16 |
17 | ## Return value
18 |
19 | none
20 |
21 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/setcustomfunction.md:
--------------------------------------------------------------------------------
1 | # model.setCustomFunction(function, value)
2 |
3 |
4 |
5 | Set Custom Function parameters
6 |
7 | @status current Introduced in 2.0.0, TODO rename function
8 |
9 |
10 | ## Parameters
11 |
12 | * `function` (unsigned number) custom function number (use 0 for CF1)
13 |
14 | * `value` (table) custom function parameters, see model.getCustomFunction() for table format
15 |
16 |
17 |
18 | ## Return value
19 |
20 | none
21 |
22 | ### Notice
23 | If a parameter is missing from the value, then
24 | that parameter remains unchanged.
25 |
26 |
27 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/lcd-functions-less-than-greater-than-luadoc-begin-lcd/drawrectangle.md:
--------------------------------------------------------------------------------
1 | # lcd.drawRectangle(x, y, w, h [, flags [, t]])
2 |
3 |
4 |
5 | Draw a rectangle from top left corner (x,y) of specified width and height
6 |
7 | @status current Introduced in 2.0.0, changed in 2.2.0
8 |
9 |
10 | ## Parameters
11 |
12 | * `x,y` (positive numbers) top left corner position
13 |
14 | * `w` (number) width in pixels
15 |
16 | * `h` (number) height in pixels
17 |
18 | * `flags` (unsigned number) drawing flags
19 |
20 | * `t` (number) thickness in pixels, defaults to 1 (only on Horus)
21 |
22 |
23 |
24 | ## Return value
25 |
26 | none
27 |
28 |
--------------------------------------------------------------------------------
/model/setCustomFunction.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## model.setCustomFunction(function, value)
4 |
5 |
6 |
7 | Set Custom Function parameters
8 |
9 | @status current Introduced in 2.0.0, TODO rename function
10 |
11 |
12 | #### Parameters
13 |
14 | * `function` (unsigned number) custom function number (use 0 for CF1)
15 |
16 | * `value` (table) custom function parameters, see model.getCustomFunction() for table format
17 |
18 |
19 |
20 | #### Return value
21 |
22 | none
23 |
24 | ##### Notice
25 | If a parameter is missing from the value, then
26 | that parameter remains unchanged.
27 |
28 |
29 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/lcd-functions-less-than-greater-than-luadoc-begin-lcd/drawgauge.md:
--------------------------------------------------------------------------------
1 | # lcd.drawGauge(x, y, w, h, fill, maxfill [, flags])
2 |
3 |
4 |
5 | Draw a simple gauge that is filled based upon fill value
6 |
7 | @status current Introduced in 2.0.0, changed in 2.2.0
8 |
9 |
10 | ## Parameters
11 |
12 | * `x,y` (positive numbers) top left corner position
13 |
14 | * `w` (number) width in pixels
15 |
16 | * `h` (number) height in pixels
17 |
18 | * `fill` (number) amount of fill to apply
19 |
20 | * `maxfill` (number) total value of fill
21 |
22 | * `flags` (unsigned number) drawing flags
23 |
24 |
25 |
26 | ## Return value
27 |
28 | none
29 |
30 |
--------------------------------------------------------------------------------
/lcd/drawRectangle.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## lcd.drawRectangle(x, y, w, h [, flags [, t]])
4 |
5 |
6 |
7 | Draw a rectangle from top left corner (x,y) of specified width and height
8 |
9 | @status current Introduced in 2.0.0, changed in 2.2.0
10 |
11 |
12 | #### Parameters
13 |
14 | * `x,y` (positive numbers) top left corner position
15 |
16 | * `w` (number) width in pixels
17 |
18 | * `h` (number) height in pixels
19 |
20 | * `flags` (unsigned number) drawing flags
21 |
22 | * `t` (number) thickness in pixels, defaults to 1 (only on Horus)
23 |
24 |
25 |
26 | #### Return value
27 |
28 | none
29 |
30 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/resetglobaltimer.md:
--------------------------------------------------------------------------------
1 | # resetGlobalTimer([type])
2 |
3 |
4 |
5 | Resets the radio global timer to 0.
6 |
7 | @status current Introduced in 2.2.2, param added in 2.3
8 |
9 |
10 | ## Parameters
11 |
12 | * `(optional)` : if set to 'all', throttle ,throttle percent and session timers are reset too
13 | if set to 'session', radio session timer is reset too
14 | if set to 'ttimer', radio throttle timer is reset too
15 | if set to 'tptimer', radio throttle percent timer is reset too
16 |
17 |
18 |
19 | ## Return value
20 |
21 | none
22 |
23 |
--------------------------------------------------------------------------------
/lcd/drawGauge.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## lcd.drawGauge(x, y, w, h, fill, maxfill [, flags])
4 |
5 |
6 |
7 | Draw a simple gauge that is filled based upon fill value
8 |
9 | @status current Introduced in 2.0.0, changed in 2.2.0
10 |
11 |
12 | #### Parameters
13 |
14 | * `x,y` (positive numbers) top left corner position
15 |
16 | * `w` (number) width in pixels
17 |
18 | * `h` (number) height in pixels
19 |
20 | * `fill` (number) amount of fill to apply
21 |
22 | * `maxfill` (number) total value of fill
23 |
24 | * `flags` (unsigned number) drawing flags
25 |
26 |
27 |
28 | #### Return value
29 |
30 | none
31 |
32 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/crossfiretelemetrypush.md:
--------------------------------------------------------------------------------
1 | # crossfireTelemetryPush()
2 |
3 |
4 |
5 | This functions allows for sending telemetry data toward the TBS Crossfire link.
6 |
7 | When called without parameters, it will only return the status of the output buffer without sending anything.
8 |
9 | @status current Introduced in 2.2.0, retval nil added in 2.3.4
10 |
11 |
12 | ## Parameters
13 |
14 | * `command` command
15 |
16 | * `data` table of data bytes
17 |
18 |
19 |
20 | ## Return value
21 |
22 | * `boolean` data queued in output buffer or not.
23 |
24 | * `nil` incorrect telemetry protocol.
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/lcd-functions-less-than-greater-than-luadoc-begin-lcd/drawline.md:
--------------------------------------------------------------------------------
1 | # lcd.drawLine(x1, y1, x2, y2, pattern, flags)
2 |
3 |
4 |
5 | Draw a straight line on LCD
6 |
7 | @status current Introduced in 2.0.0, flags introduced in 2.3.6
8 |
9 |
10 | ## Parameters
11 |
12 | * `x1,y1` (positive numbers) starting coordinate
13 |
14 | * `x2,y2` (positive numbers) end coordinate
15 |
16 | * `pattern` SOLID or DOTTED
17 |
18 | * `flags` lcdflags
19 |
20 |
21 |
22 | ## Return value
23 |
24 | none
25 |
26 | ### Notice
27 | If the start or the end of the line is outside the LCD dimensions, then the
28 | whole line will not be drawn (starting from OpenTX 2.1.5)
29 |
30 |
31 |
--------------------------------------------------------------------------------
/general/resetGlobalTimer.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## resetGlobalTimer([type])
4 |
5 |
6 |
7 | Resets the radio global timer to 0.
8 |
9 | @status current Introduced in 2.2.2, param added in 2.3
10 |
11 |
12 | #### Parameters
13 |
14 | * `(optional)` : if set to 'all', throttle ,throttle percent and session timers are reset too
15 | if set to 'session', radio session timer is reset too
16 | if set to 'ttimer', radio throttle timer is reset too
17 | if set to 'tptimer', radio throttle percent timer is reset too
18 |
19 |
20 |
21 | #### Return value
22 |
23 | none
24 |
25 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/lcd-functions-less-than-greater-than-luadoc-begin-lcd/drawpoint.md:
--------------------------------------------------------------------------------
1 | # lcd.drawPoint(x, y)
2 |
3 |
4 |
5 | Draw a single pixel at (x,y) position
6 |
7 | @status current Introduced in 2.0.0
8 |
9 |
10 | ## Parameters
11 |
12 | * `x` (positive number) x position
13 |
14 | * `y` (positive number) y position
15 |
16 | * `flags` (optional) lcdflags
17 |
18 |
19 |
20 | ## Return value
21 |
22 | none
23 |
24 | ### Notice
25 | Taranis has an LCD display width of 212 pixels and height of 64 pixels.
26 | Position (0,0) is at top left. Y axis is negative, top line is 0,
27 | bottom line is 63. Drawing on an existing black pixel produces white pixel (TODO check this!)
28 |
29 |
30 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/getswashring.md:
--------------------------------------------------------------------------------
1 | # model.getSwashRing(params)
2 | Get heli swash parameters
3 |
4 |
5 |
6 | @status current Introduced in 2.3.15
7 |
8 |
9 | ## Parameters
10 |
11 | * `params` (table):
12 | * `type` (number) 0=---, 1=120, 2=120X, 3=140, 4=90
13 | * `value` (number) swash ring value (normally 0)
14 | * 'collectiveSource' (number) source index
15 | * 'aileronSource' (number) source index
16 | * 'elevatorSource' (number) source index
17 | * 'collectiveWeight'(value) -100 to 100
18 | * 'aileronWeight' (value) -100 to 100
19 | * 'elevatorWeight' (value) -100 to 100
20 |
21 |
22 |
23 | ## Return value
24 |
25 | none
26 |
27 |
--------------------------------------------------------------------------------
/general/crossfireTelemetryPush.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## crossfireTelemetryPush()
4 |
5 |
6 |
7 | This functions allows for sending telemetry data toward the TBS Crossfire link.
8 |
9 | When called without parameters, it will only return the status of the output buffer without sending anything.
10 |
11 | @status current Introduced in 2.2.0, retval nil added in 2.3.4
12 |
13 |
14 | #### Parameters
15 |
16 | * `command` command
17 |
18 | * `data` table of data bytes
19 |
20 |
21 |
22 | #### Return value
23 |
24 | * `boolean` data queued in output buffer or not.
25 |
26 | * `nil` incorrect telemetry protocol.
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/lcd-functions-less-than-greater-than-luadoc-begin-lcd/drawbitmap.md:
--------------------------------------------------------------------------------
1 | # lcd.drawBitmap(bitmap, x, y [, scale])
2 |
3 |
4 |
5 | Displays a bitmap at (x,y)
6 |
7 | @status current Introduced in 2.2.0
8 |
9 |
10 | ## Parameters
11 |
12 | * `bitmap` (pointer) point to a bitmap previously opened with Bitmap.open()
13 |
14 | * `x,y` (positive numbers) starting coordinates
15 |
16 | * `scale` (positive numbers) scale in %, 50 divides size by two, 100 is unchanged, 200 doubles size.
17 | Omitting scale draws image in 1:1 scale and is faster than specifying 100 for scale.
18 |
19 |
20 |
21 | ## Return value
22 |
23 | none
24 |
25 | ### Notice
26 | Only available on Horus
27 |
28 |
29 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/lcd-functions-less-than-greater-than-luadoc-begin-lcd/drawtimer.md:
--------------------------------------------------------------------------------
1 | # lcd.drawTimer(x, y, value [, flags])
2 |
3 |
4 |
5 | Display a value formatted as time at (x,y)
6 |
7 | @status current Introduced in 2.0.0, `SHADOWED` introduced in 2.2.1
8 |
9 |
10 | ## Parameters
11 |
12 | * `x,y` (positive numbers) starting coordinate
13 |
14 | * `value` (number) time in seconds
15 |
16 | * `flags` (unsigned number) drawing flags:
17 | * `0 or not specified` normal representation (minutes and seconds)
18 | * `TIMEHOUR` display hours
19 | * other general LCD flag also apply
20 | * `SHADOWED` Horus only, apply a shadow effect
21 |
22 |
23 |
24 | ## Return value
25 |
26 | none
27 |
28 |
--------------------------------------------------------------------------------
/lcd/drawLine.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## lcd.drawLine(x1, y1, x2, y2, pattern, flags)
4 |
5 |
6 |
7 | Draw a straight line on LCD
8 |
9 | @status current Introduced in 2.0.0, flags introduced in 2.3.6
10 |
11 |
12 | #### Parameters
13 |
14 | * `x1,y1` (positive numbers) starting coordinate
15 |
16 | * `x2,y2` (positive numbers) end coordinate
17 |
18 | * `pattern` SOLID or DOTTED
19 |
20 | * `flags` lcdflags
21 |
22 |
23 |
24 | #### Return value
25 |
26 | none
27 |
28 | ##### Notice
29 | If the start or the end of the line is outside the LCD dimensions, then the
30 | whole line will not be drawn (starting from OpenTX 2.1.5)
31 |
32 |
33 |
--------------------------------------------------------------------------------
/lcd/drawPoint.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## lcd.drawPoint(x, y)
4 |
5 |
6 |
7 | Draw a single pixel at (x,y) position
8 |
9 | @status current Introduced in 2.0.0
10 |
11 |
12 | #### Parameters
13 |
14 | * `x` (positive number) x position
15 |
16 | * `y` (positive number) y position
17 |
18 | * `flags` (optional) lcdflags
19 |
20 |
21 |
22 | #### Return value
23 |
24 | none
25 |
26 | ##### Notice
27 | Taranis has an LCD display width of 212 pixels and height of 64 pixels.
28 | Position (0,0) is at top left. Y axis is negative, top line is 0,
29 | bottom line is 63. Drawing on an existing black pixel produces white pixel (TODO check this!)
30 |
31 |
32 |
--------------------------------------------------------------------------------
/lcd/drawBitmap.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## lcd.drawBitmap(bitmap, x, y [, scale])
4 |
5 |
6 |
7 | Displays a bitmap at (x,y)
8 |
9 | @status current Introduced in 2.2.0
10 |
11 |
12 | #### Parameters
13 |
14 | * `bitmap` (pointer) point to a bitmap previously opened with Bitmap.open()
15 |
16 | * `x,y` (positive numbers) starting coordinates
17 |
18 | * `scale` (positive numbers) scale in %, 50 divides size by two, 100 is unchanged, 200 doubles size.
19 | Omitting scale draws image in 1:1 scale and is faster than specifying 100 for scale.
20 |
21 |
22 |
23 | #### Return value
24 |
25 | none
26 |
27 | ##### Notice
28 | Only available on Horus
29 |
30 |
31 |
--------------------------------------------------------------------------------
/lcd/drawTimer.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## lcd.drawTimer(x, y, value [, flags])
4 |
5 |
6 |
7 | Display a value formatted as time at (x,y)
8 |
9 | @status current Introduced in 2.0.0, `SHADOWED` introduced in 2.2.1
10 |
11 |
12 | #### Parameters
13 |
14 | * `x,y` (positive numbers) starting coordinate
15 |
16 | * `value` (number) time in seconds
17 |
18 | * `flags` (unsigned number) drawing flags:
19 | * `0 or not specified` normal representation (minutes and seconds)
20 | * `TIMEHOUR` display hours
21 | * other general LCD flag also apply
22 | * `SHADOWED` Horus only, apply a shadow effect
23 |
24 |
25 |
26 | #### Return value
27 |
28 | none
29 |
30 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/getglobalvariable.md:
--------------------------------------------------------------------------------
1 | # model.getGlobalVariable(index, flight_mode)
2 |
3 |
4 |
5 | Return current global variable value
6 |
7 | Example:
8 |
9 | ```lua
10 | -- get GV3 (index = 2) from Flight mode 0 (FM0)
11 | val = model.getGlobalVariable(2, 0)
12 | ```
13 |
14 |
15 | ## Parameters
16 |
17 | * `index` zero based global variable index, use 0 for GV1, 8 for GV9
18 |
19 | * `flight_mode` Flight mode number (0 = FM0, 8 = FM8)
20 |
21 |
22 |
23 | ## Return value
24 |
25 | * `nil` requested global variable does not exist
26 |
27 | * `number` current value of global variable
28 |
29 |
30 |
31 | ### Notice
32 | a simple warning or notice
33 |
34 |
35 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/setlogicalswitch.md:
--------------------------------------------------------------------------------
1 | # model.setLogicalSwitch(switch, value)
2 |
3 |
4 |
5 | Set Logical Switch parameters
6 |
7 | @status current Introduced in 2.0.0
8 |
9 |
10 | ## Parameters
11 |
12 | * `switch` (unsigned number) logical switch number (use 0 for LS1)
13 |
14 | * `value` (table) see model.getLogicalSwitch() for table format
15 |
16 |
17 |
18 | ## Return value
19 |
20 | none
21 |
22 | ### Notice
23 | If a parameter is missing from the value, then
24 | that parameter remains unchanged.
25 |
26 |
27 | To set the `and` member (which is Lua keyword)
28 | use the following syntax: `model.setLogicalSwitch(30, {func=4,v1=1,v2=-99, ["and"]=24})`
29 |
30 |
31 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/lcd-functions-less-than-greater-than-luadoc-begin-lcd/rgb.md:
--------------------------------------------------------------------------------
1 | # lcd.RGB(r, g, b)
2 |
3 |
4 |
5 | Returns a 5/6/5 rgb color code, that can be used with lcd.setColor
6 |
7 | @status current Introduced in 2.2.0
8 |
9 |
10 | ## Parameters
11 |
12 | * `r` (integer) a number between 0x00 and 0xff that expresses te amount of red in the color
13 |
14 | * `g` (integer) a number between 0x00 and 0xff that expresses te amount of green in the color
15 |
16 | * `b` (integer) a number between 0x00 and 0xff that expresses te amount of blue in the color
17 |
18 |
19 |
20 | ## Return value
21 |
22 | * `number` (integer) rgb color expressed in 5/6/5 format
23 |
24 |
25 |
26 | ### Notice
27 | Only available on Colorlcd radios
28 |
29 |
30 |
--------------------------------------------------------------------------------
/return_statement_syntax.md:
--------------------------------------------------------------------------------
1 | # Return Statement Syntax
2 |
3 | The return statment is the last statement in an OpenTX Lua script. It defines the input/output table values and functions used to run the script.
4 |
5 | Parameters *init*, *input* and *output* are optional. If a script doesn't use them, they can be omitted from return statement.
6 |
7 | Example without *init* and *output*:
8 |
9 | ```lua
10 | local inputs = { { "Aileron", SOURCE }, { "Ail. ratio", VALUE, -100, 100, 0 } }
11 |
12 | local function run_func(ail, ratio)
13 | -- do some stuff
14 | if (ail > 50) and ( ratio < 40) then
15 | playFile("foo.wav")
16 | end
17 | end
18 |
19 | -- script that only uses input and run
20 | return { run=run_func, input=inputs }
21 | ```
22 |
--------------------------------------------------------------------------------
/model/getGlobalVariable.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## model.getGlobalVariable(index, flight_mode)
4 |
5 |
6 |
7 | Return current global variable value
8 |
9 | Example:
10 |
11 | ```lua
12 | -- get GV3 (index = 2) from Flight mode 0 (FM0)
13 | val = model.getGlobalVariable(2, 0)
14 | ```
15 |
16 |
17 | #### Parameters
18 |
19 | * `index` zero based global variable index, use 0 for GV1, 8 for GV9
20 |
21 | * `flight_mode` Flight mode number (0 = FM0, 8 = FM8)
22 |
23 |
24 |
25 | #### Return value
26 |
27 | * `nil` requested global variable does not exist
28 |
29 | * `number` current value of global variable
30 |
31 |
32 |
33 | ##### Notice
34 | a simple warning or notice
35 |
36 |
37 |
--------------------------------------------------------------------------------
/model/setLogicalSwitch.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## model.setLogicalSwitch(switch, value)
4 |
5 |
6 |
7 | Set Logical Switch parameters
8 |
9 | @status current Introduced in 2.0.0
10 |
11 |
12 | #### Parameters
13 |
14 | * `switch` (unsigned number) logical switch number (use 0 for LS1)
15 |
16 | * `value` (table) see model.getLogicalSwitch() for table format
17 |
18 |
19 |
20 | #### Return value
21 |
22 | none
23 |
24 | ##### Notice
25 | If a parameter is missing from the value, then
26 | that parameter remains unchanged.
27 |
28 |
29 | To set the `and` member (which is Lua keyword)
30 | use the following syntax: `model.setLogicalSwitch(30, {func=4,v1=1,v2=-99, ["and"]=24})`
31 |
32 |
33 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/setglobalvariable.md:
--------------------------------------------------------------------------------
1 | # model.setGlobalVariable(index, flight_mode, value)
2 |
3 |
4 |
5 | Sets current global variable value. See also model.getGlobalVariable()
6 |
7 |
8 | ## Parameters
9 |
10 | * `index` zero based global variable index, use 0 for GV1, 8 for GV9
11 |
12 | * `flight_mode` Flight mode number (0 = FM0, 8 = FM8)
13 |
14 | * `value` new value for global variable. Permitted range is
15 | from -1024 to 1024.
16 |
17 |
18 |
19 | ## Return value
20 |
21 | none
22 |
23 | ### Notice
24 | Global variable can only store integer values,
25 | any floating point value is converted into integer value
26 | by truncating everything behind a floating point.
27 |
28 |
29 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/sporttelemetrypop.md:
--------------------------------------------------------------------------------
1 | # sportTelemetryPop()
2 |
3 |
4 |
5 | Pops a received SPORT packet from the queue. Please note that only packets using a data ID within 0x5000 to 0x50FF
6 | (frame ID == 0x10), as well as packets with a frame ID equal 0x32 (regardless of the data ID) will be passed to
7 | the LUA telemetry receive queue.
8 |
9 | @status current Introduced in 2.2.0
10 |
11 |
12 | ## Parameters
13 |
14 | none
15 |
16 | ## Return value
17 |
18 | * `nil` queue does not contain any (or enough) bytes to form a whole packet
19 |
20 | * `multiple` returns 4 values:
21 | * sensor ID (number)
22 | * frame ID (number)
23 | * data ID (number)
24 | * value (number)
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/lcd/RGB.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## lcd.RGB(r, g, b)
4 |
5 |
6 |
7 | Returns a 5/6/5 rgb color code, that can be used with lcd.setColor
8 |
9 | @status current Introduced in 2.2.0
10 |
11 |
12 | #### Parameters
13 |
14 | * `r` (integer) a number between 0x00 and 0xff that expresses te amount of red in the color
15 |
16 | * `g` (integer) a number between 0x00 and 0xff that expresses te amount of green in the color
17 |
18 | * `b` (integer) a number between 0x00 and 0xff that expresses te amount of blue in the color
19 |
20 |
21 |
22 | #### Return value
23 |
24 | * `number` (integer) rgb color expressed in 5/6/5 format
25 |
26 |
27 |
28 | ##### Notice
29 | Only available on Colorlcd radios
30 |
31 |
32 |
--------------------------------------------------------------------------------
/model/setGlobalVariable.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## model.setGlobalVariable(index, flight_mode, value)
4 |
5 |
6 |
7 | Sets current global variable value. See also model.getGlobalVariable()
8 |
9 |
10 | #### Parameters
11 |
12 | * `index` zero based global variable index, use 0 for GV1, 8 for GV9
13 |
14 | * `flight_mode` Flight mode number (0 = FM0, 8 = FM8)
15 |
16 | * `value` new value for global variable. Permitted range is
17 | from -1024 to 1024.
18 |
19 |
20 |
21 | #### Return value
22 |
23 | none
24 |
25 | ##### Notice
26 | Global variable can only store integer values,
27 | any floating point value is converted into integer value
28 | by truncating everything behind a floating point.
29 |
30 |
31 |
--------------------------------------------------------------------------------
/general/sportTelemetryPop.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## sportTelemetryPop()
4 |
5 |
6 |
7 | Pops a received SPORT packet from the queue. Please note that only packets using a data ID within 0x5000 to 0x50FF
8 | (frame ID == 0x10), as well as packets with a frame ID equal 0x32 (regardless of the data ID) will be passed to
9 | the LUA telemetry receive queue.
10 |
11 | @status current Introduced in 2.2.0
12 |
13 |
14 | #### Parameters
15 |
16 | none
17 |
18 | #### Return value
19 |
20 | * `nil` queue does not contain any (or enough) bytes to form a whole packet
21 |
22 | * `multiple` returns 4 values:
23 | * sensor ID (number)
24 | * frame ID (number)
25 | * data ID (number)
26 | * value (number)
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/part_ii_-_opentx_lua_api_programming_guide/return_statement_syntax.md:
--------------------------------------------------------------------------------
1 | # Return Statement Syntax
2 |
3 | The return statment is the last statement in an OpenTX Lua script. It defines the input/output table values and functions used to run the script.
4 |
5 | Parameters _init_, _input_ and _output_ are optional. If a script doesn't use them, they can be omitted from return statement.
6 |
7 | Example without _init_ and _output_:
8 |
9 | ```lua
10 | local inputs = { { "Aileron", SOURCE }, { "Ail. ratio", VALUE, -100, 100, 0 } }
11 |
12 | local function run_func(ail, ratio)
13 | -- do some stuff
14 | if (ail > 50) and ( ratio < 40) then
15 | playFile("foo.wav")
16 | end
17 | end
18 |
19 | -- script that only uses input and run
20 | return { run=run_func, input=inputs }
21 | ```
22 |
23 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/popupconfirmation.md:
--------------------------------------------------------------------------------
1 | # popupConfirmation(title, event) deprecated, please replace by
2 | @function popupConfirmation(title, message, event)
3 |
4 |
5 |
6 | Raises a pop-up on screen that asks for confirmation
7 |
8 | @status current Introduced in 2.2.0, changed to (title, message, event) in 2.3.8
9 |
10 |
11 | ## Parameters
12 |
13 | * `title` (string) title to display
14 |
15 | * `message` (string) text to display
16 |
17 | * `event` (number) the event variable that is passed in from the
18 | Run function (key pressed)
19 |
20 |
21 |
22 | ## Return value
23 |
24 | * `"CANCEL"` user pushed EXIT key
25 |
26 |
27 |
28 | ### Notice
29 | Use only from stand-alone and telemetry scripts.
30 |
31 |
32 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/getlogicalswitch.md:
--------------------------------------------------------------------------------
1 | # model.getLogicalSwitch(switch)
2 |
3 |
4 |
5 | Get Logical Switch parameters
6 |
7 | @status current Introduced in 2.0.0
8 |
9 |
10 | ## Parameters
11 |
12 | * `switch` (unsigned number) logical switch number (use 0 for LS1)
13 |
14 |
15 |
16 | ## Return value
17 |
18 | * `nil` requested logical switch does not exist
19 |
20 | * `table` logical switch data:
21 | * `func` (number) function index
22 | * `v1` (number) V1 value (index)
23 | * `v2` (number) V2 value (index or value)
24 | * `v3` (number) V3 value (index or value)
25 | * `and` (number) AND switch index
26 | * `delay` (number) delay (time in 1/10 s)
27 | * `duration` (number) duration (time in 1/10 s)
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/general/popupConfirmation.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## popupConfirmation(title, event) deprecated, please replace by
4 | @function popupConfirmation(title, message, event)
5 |
6 |
7 |
8 | Raises a pop-up on screen that asks for confirmation
9 |
10 | @status current Introduced in 2.2.0, changed to (title, message, event) in 2.3.8
11 |
12 |
13 | #### Parameters
14 |
15 | * `title` (string) title to display
16 |
17 | * `message` (string) text to display
18 |
19 | * `event` (number) the event variable that is passed in from the
20 | Run function (key pressed)
21 |
22 |
23 |
24 | #### Return value
25 |
26 | * `"CANCEL"` user pushed EXIT key
27 |
28 |
29 |
30 | ##### Notice
31 | Use only from stand-alone and telemetry scripts.
32 |
33 |
34 |
--------------------------------------------------------------------------------
/model/getLogicalSwitch.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## model.getLogicalSwitch(switch)
4 |
5 |
6 |
7 | Get Logical Switch parameters
8 |
9 | @status current Introduced in 2.0.0
10 |
11 |
12 | #### Parameters
13 |
14 | * `switch` (unsigned number) logical switch number (use 0 for LS1)
15 |
16 |
17 |
18 | #### Return value
19 |
20 | * `nil` requested logical switch does not exist
21 |
22 | * `table` logical switch data:
23 | * `func` (number) function index
24 | * `v1` (number) V1 value (index)
25 | * `v2` (number) V2 value (index or value)
26 | * `v3` (number) V3 value (index or value)
27 | * `and` (number) AND switch index
28 | * `delay` (number) delay (time in 1/10 s)
29 | * `duration` (number) duration (time in 1/10 s)
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/lcd-functions-less-than-greater-than-luadoc-begin-lcd/drawnumber.md:
--------------------------------------------------------------------------------
1 | # lcd.drawNumber(x, y, value [, flags])
2 |
3 |
4 |
5 | Display a number at (x,y)
6 |
7 | @status current Introduced in 2.0.0, `SHADOWED` introduced in 2.2.1
8 |
9 |
10 | ## Parameters
11 |
12 | * `x,y` (positive numbers) starting coordinate
13 |
14 | * `value` (number) value to display
15 |
16 | * `flags` (unsigned number) drawing flags:
17 | * `0 or not specified` display with no decimal (like abs())
18 | * `PREC1` display with one decimal place (number 386 is displayed as 38.6)
19 | * `PREC2` display with tow decimal places (number 386 is displayed as 3.86)
20 | * other general LCD flag also apply
21 | * `SHADOWED` Horus only, apply a shadow effect
22 |
23 |
24 |
25 | ## Return value
26 |
27 | none
28 |
29 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/playnumber.md:
--------------------------------------------------------------------------------
1 | # playNumber(value, unit [, attributes])
2 |
3 |
4 |
5 | Play a numerical value (text to speech)
6 |
7 | @status current Introduced in 2.0.0
8 |
9 |
10 |
11 | ## Parameters
12 |
13 | * `value` (number) number to play. Value is interpreted as integer.
14 |
15 | * `unit` (number) unit identifier [Full list]((../appendix/units.html))
16 |
17 | * `attributes` (unsigned number) possible values:
18 | * `0 or not present` plays integral part of the number (for a number 123 it plays 123)
19 | * `PREC1` plays a number with one decimal place (for a number 123 it plays 12.3)
20 | * `PREC2` plays a number with two decimal places (for a number 123 it plays 1.23)
21 |
22 |
23 |
24 | ## Return value
25 |
26 | none
27 |
28 |
--------------------------------------------------------------------------------
/general/playNumber.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## playNumber(value, unit [, attributes])
4 |
5 |
6 |
7 | Play a numerical value (text to speech)
8 |
9 | @status current Introduced in 2.0.0
10 |
11 |
12 |
13 | #### Parameters
14 |
15 | * `value` (number) number to play. Value is interpreted as integer.
16 |
17 | * `unit` (number) unit identifier [Full list]((../appendix/units.html))
18 |
19 | * `attributes` (unsigned number) possible values:
20 | * `0 or not present` plays integral part of the number (for a number 123 it plays 123)
21 | * `PREC1` plays a number with one decimal place (for a number 123 it plays 12.3)
22 | * `PREC2` plays a number with two decimal places (for a number 123 it plays 1.23)
23 |
24 |
25 |
26 | #### Return value
27 |
28 | none
29 |
30 |
--------------------------------------------------------------------------------
/getting_started.md:
--------------------------------------------------------------------------------
1 |
2 | ### Getting Started
3 |
4 |
5 | #### Downloading OpenTX Companion
6 |
7 | OpenTX Companion 2.2 is available for download at http://www.open-tx.org/downloads.html
8 |
9 |
10 | #### Updating firmware with Lua option selected
11 |
12 | If you intend to use mixer scripts, when updating the firmware on your transmitter you need to make sure the lua option is checked in the settings for your radio profile (Main menu -> Settings ->Settings...) as shown below. This is not required if you only intend to run telemetry, one-time and function scripts, support for those is included by default.
13 |
14 | Also note that the SD Structure path should contain a valid path to a copy of your transmitter's SD card contents, although that's not specific to Lua.
15 |
16 | 
--------------------------------------------------------------------------------
/lcd/drawNumber.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## lcd.drawNumber(x, y, value [, flags])
4 |
5 |
6 |
7 | Display a number at (x,y)
8 |
9 | @status current Introduced in 2.0.0, `SHADOWED` introduced in 2.2.1
10 |
11 |
12 | #### Parameters
13 |
14 | * `x,y` (positive numbers) starting coordinate
15 |
16 | * `value` (number) value to display
17 |
18 | * `flags` (unsigned number) drawing flags:
19 | * `0 or not specified` display with no decimal (like abs())
20 | * `PREC1` display with one decimal place (number 386 is displayed as 38.6)
21 | * `PREC2` display with tow decimal places (number 386 is displayed as 3.86)
22 | * other general LCD flag also apply
23 | * `SHADOWED` Horus only, apply a shadow effect
24 |
25 |
26 |
27 | #### Return value
28 |
29 | none
30 |
31 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/sporttelemetrypush.md:
--------------------------------------------------------------------------------
1 | # sportTelemetryPush()
2 |
3 |
4 |
5 | This functions allows for sending SPORT telemetry data toward the receiver,
6 | and more generally, to anything connected SPORT bus on the receiver or transmitter.
7 |
8 | When called without parameters, it will only return the status of the output buffer without sending anything.
9 |
10 | @status current Introduced in 2.2.0, retval nil added in 2.3.4
11 |
12 |
13 | ## Parameters
14 |
15 | * `sensorId` physical sensor ID
16 |
17 | * `frameId` frame ID
18 |
19 | * `dataId` data ID
20 |
21 | * `value` value
22 |
23 |
24 |
25 | ## Return value
26 |
27 | * `boolean` data queued in output buffer or not.
28 |
29 | * `nil` incorrect telemetry protocol.
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/lcd-functions-less-than-greater-than-luadoc-begin-lcd/drawcombobox.md:
--------------------------------------------------------------------------------
1 | # lcd.drawCombobox(x, y, w, list, idx [, flags])
2 |
3 |
4 |
5 | Draw a combo box
6 |
7 | @status current Introduced in 2.0.0
8 |
9 |
10 | ## Parameters
11 |
12 | * `x,y` (positive numbers) top left corner position
13 |
14 | * `w` (number) width of combo box in pixels
15 |
16 | * `list` (table) combo box elements, each element is a string
17 |
18 | * `idx` (integer) index of entry to highlight
19 |
20 | * `flags` (unsigned number) drawing flags, the flags can not be combined:
21 | * `BLINK` combo box is expanded
22 | * `INVERS` combo box collapsed, text inversed
23 | * `0 or not present` combo box collapsed, text normal
24 |
25 |
26 |
27 | ## Return value
28 |
29 | none
30 |
31 | ### Notice
32 | Only available on Taranis
33 |
34 |
35 |
--------------------------------------------------------------------------------
/general/sportTelemetryPush.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## sportTelemetryPush()
4 |
5 |
6 |
7 | This functions allows for sending SPORT telemetry data toward the receiver,
8 | and more generally, to anything connected SPORT bus on the receiver or transmitter.
9 |
10 | When called without parameters, it will only return the status of the output buffer without sending anything.
11 |
12 | @status current Introduced in 2.2.0, retval nil added in 2.3.4
13 |
14 |
15 | #### Parameters
16 |
17 | * `sensorId` physical sensor ID
18 |
19 | * `frameId` frame ID
20 |
21 | * `dataId` data ID
22 |
23 | * `value` value
24 |
25 |
26 |
27 | #### Return value
28 |
29 | * `boolean` data queued in output buffer or not.
30 |
31 | * `nil` incorrect telemetry protocol.
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/lcd-functions-less-than-greater-than-luadoc-begin-lcd/rgb2.md:
--------------------------------------------------------------------------------
1 | # lcd.RGB\(r, g, b\)
2 |
3 | Test for summary autogeneration
4 | Returns a 5/6/5 rgb color code, that can be used with lcd.setColor
5 |
6 | @status current Introduced in 2.2.0
7 |
8 | ## Parameters
9 |
10 | * `r` \(integer\) a number between 0x00 and 0xff that expresses te amount of red in the color
11 | * `g` \(integer\) a number between 0x00 and 0xff that expresses te amount of green in the color
12 | * `b` \(integer\) a number between 0x00 and 0xff that expresses te amount of blue in the color
13 |
14 | ## Return value
15 |
16 | * `number` \(integer\) rgb color expressed in 5/6/5 format
17 |
18 | ### Notice
19 |
20 | Only available on Colorlcd radios
21 |
22 | ## Examples
23 |
24 | ### Example1
25 |
26 | Blah
27 |
28 | ### Example2
29 |
30 | Blah again
31 |
32 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/getoutput.md:
--------------------------------------------------------------------------------
1 | # model.getOutput(index)
2 |
3 |
4 |
5 | Get servo parameters
6 |
7 | @status current Introduced in 2.0.0
8 |
9 |
10 | ## Parameters
11 |
12 | * `index` (unsigned number) output number (use 0 for CH1)
13 |
14 |
15 |
16 | ## Return value
17 |
18 | * `nil` requested output does not exist
19 |
20 | * `table` output parameters:
21 | * `name` (string) name
22 | * `min` (number) Minimum % * 10
23 | * `max` (number) Maximum % * 10
24 | * `offset` (number) Subtrim * 10
25 | * `ppmCenter` (number) offset from PPM Center. 0 = 1500
26 | * `symetrical` (number) linear Subtrim 0 = Off, 1 = On
27 | * `revert` (number) irection 0 = ---, 1 = INV
28 | * `curve`
29 | * (number) Curve number (0 for Curve1)
30 | * or `nil` if no curve set
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/lcd/drawCombobox.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## lcd.drawCombobox(x, y, w, list, idx [, flags])
4 |
5 |
6 |
7 | Draw a combo box
8 |
9 | @status current Introduced in 2.0.0
10 |
11 |
12 | #### Parameters
13 |
14 | * `x,y` (positive numbers) top left corner position
15 |
16 | * `w` (number) width of combo box in pixels
17 |
18 | * `list` (table) combo box elements, each element is a string
19 |
20 | * `idx` (integer) index of entry to highlight
21 |
22 | * `flags` (unsigned number) drawing flags, the flags can not be combined:
23 | * `BLINK` combo box is expanded
24 | * `INVERS` combo box collapsed, text inversed
25 | * `0 or not present` combo box collapsed, text normal
26 |
27 |
28 |
29 | #### Return value
30 |
31 | none
32 |
33 | ##### Notice
34 | Only available on Taranis
35 |
36 |
37 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/serialread.md:
--------------------------------------------------------------------------------
1 | # serialRead([num])
2 | @param num (optional): maximum number of bytes to read.
3 | If non-zero, serialRead will read up to num characters from the buffer.
4 | If 0 or left out, serialRead will read up to and including the first newline character or the end of the buffer.
5 | Note that the returned string may not end in a newline if this character is not present in the buffer.
6 |
7 |
8 |
9 | Reads characters from the serial port. The string is allowed to contain any character, including 0.
10 |
11 | @status current Introduced in 2.3.8
12 |
13 |
14 | ## Parameters
15 |
16 | none
17 |
18 | ## Return value
19 |
20 | * `str` string. Empty if no new characters were available.
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/getsensor.md:
--------------------------------------------------------------------------------
1 | # model.getSensor(sensor)
2 |
3 |
4 |
5 | Get Telemetry Sensor parameters
6 |
7 | @status current Introduced in 2.3.0
8 |
9 |
10 | ## Parameters
11 |
12 | * `sensor` (unsigned number) sensor number (use 0 for sensor 1)
13 |
14 |
15 |
16 | ## Return value
17 |
18 | * `nil` requested sensor does not exist
19 |
20 | * `table` with sensor data:
21 | * `type` (number) 0 = custom, 1 = calculated
22 | * `name` (string) Name
23 | * `unit` (number) See list of units in the appendix of the OpenTX Lua Reference Guide
24 | * `prec` (number) Number of decimals
25 | * `id` (number) Only custom sensors
26 | * `instance` (number) Only custom sensors
27 | * `formula` (number) Only calculated sensors. 0 = Add etc. see list of formula choices in Companion popup
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/general/serialRead.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## serialRead([num])
4 | @param num (optional): maximum number of bytes to read.
5 | If non-zero, serialRead will read up to num characters from the buffer.
6 | If 0 or left out, serialRead will read up to and including the first newline character or the end of the buffer.
7 | Note that the returned string may not end in a newline if this character is not present in the buffer.
8 |
9 |
10 |
11 | Reads characters from the serial port. The string is allowed to contain any character, including 0.
12 |
13 | @status current Introduced in 2.3.8
14 |
15 |
16 | #### Parameters
17 |
18 | none
19 |
20 | #### Return value
21 |
22 | * `str` string. Empty if no new characters were available.
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/model/getOutput.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## model.getOutput(index)
4 |
5 |
6 |
7 | Get servo parameters
8 |
9 | @status current Introduced in 2.0.0
10 |
11 |
12 | #### Parameters
13 |
14 | * `index` (unsigned number) output number (use 0 for CH1)
15 |
16 |
17 |
18 | #### Return value
19 |
20 | * `nil` requested output does not exist
21 |
22 | * `table` output parameters:
23 | * `name` (string) name
24 | * `min` (number) Minimum % * 10
25 | * `max` (number) Maximum % * 10
26 | * `offset` (number) Subtrim * 10
27 | * `ppmCenter` (number) offset from PPM Center. 0 = 1500
28 | * `symetrical` (number) linear Subtrim 0 = Off, 1 = On
29 | * `revert` (number) irection 0 = ---, 1 = INV
30 | * `curve`
31 | * (number) Curve number (0 for Curve1)
32 | * or `nil` if no curve set
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/accesstelemetrypush.md:
--------------------------------------------------------------------------------
1 | # accessTelemetryPush()
2 |
3 |
4 |
5 | This functions allows for sending SPORT / ACCESS telemetry data toward the receiver,
6 | and more generally, to anything connected SPORT bus on the receiver or transmitter.
7 |
8 | When called without parameters, it will only return the status of the output buffer without sending anything.
9 |
10 | @status current Introduced in 2.3
11 |
12 |
13 |
14 | ## Parameters
15 |
16 | * `module` module index (0 = internal, 1 = external)
17 |
18 | * `rxUid` receiver index
19 |
20 | * `sensorId` physical sensor ID
21 |
22 | * `frameId` frame ID
23 |
24 | * `dataId` data ID
25 |
26 | * `value` value
27 |
28 |
29 |
30 | ## Return value
31 |
32 | * `boolean` data queued in output buffer or not.
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/gettxgps.md:
--------------------------------------------------------------------------------
1 | # getTxGPS()
2 |
3 |
4 |
5 | Return the internal GPS position or nil if no valid hardware found
6 |
7 | @status current Introduced in 2.2.2
8 |
9 |
10 | ## Parameters
11 |
12 | none
13 |
14 | ## Return value
15 |
16 | * `table` representing the current radio position
17 | * `lat` (number) internal GPS latitude, positive is North
18 | * `lon` (number) internal GPS longitude, positive is East
19 | * 'numsat' (number) current number of sats locked in by the GPS sensor
20 | * 'fix' (boolean) fix status
21 | * 'alt' (number) internal GPS altitude in 0.1m
22 | * 'speed' (number) internal GPSspeed in 0.1m/s
23 | * 'heading' (number) internal GPS ground course estimation in degrees * 10
24 | * 'hdop' (number) internal GPS horizontal dilution of precision
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/gettimer.md:
--------------------------------------------------------------------------------
1 | # model.getTimer(timer)
2 |
3 |
4 |
5 | Get model timer parameters
6 |
7 | @status current Introduced in 2.0.0, name added in 2.3.6
8 |
9 |
10 | ## Parameters
11 |
12 | * `timer` (number) timer index (0 for Timer 1)
13 |
14 |
15 |
16 | ## Return value
17 |
18 | * `nil` requested timer does not exist
19 |
20 | * `table` timer parameters:
21 | * `mode` (number) timer trigger source: off, abs, stk, stk%, sw/!sw, !m_sw/!m_sw
22 | * `start` (number) start value [seconds], 0 for up timer, 0> down timer
23 | * `value` (number) current value [seconds]
24 | * `countdownBeep` (number) countdown beep (0 = silent, 1 = beeps, 2 = voice)
25 | * `minuteBeep` (boolean) minute beep
26 | * `persistent` (number) persistent timer
27 | * `name` (string) timer name
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/general/accessTelemetryPush.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## accessTelemetryPush()
4 |
5 |
6 |
7 | This functions allows for sending SPORT / ACCESS telemetry data toward the receiver,
8 | and more generally, to anything connected SPORT bus on the receiver or transmitter.
9 |
10 | When called without parameters, it will only return the status of the output buffer without sending anything.
11 |
12 | @status current Introduced in 2.3
13 |
14 |
15 |
16 | #### Parameters
17 |
18 | * `module` module index (0 = internal, 1 = external)
19 |
20 | * `rxUid` receiver index
21 |
22 | * `sensorId` physical sensor ID
23 |
24 | * `frameId` frame ID
25 |
26 | * `dataId` data ID
27 |
28 | * `value` value
29 |
30 |
31 |
32 | #### Return value
33 |
34 | * `boolean` data queued in output buffer or not.
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/general/getTxGPS.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## getTxGPS()
4 |
5 |
6 |
7 | Return the internal GPS position or nil if no valid hardware found
8 |
9 | @status current Introduced in 2.2.2
10 |
11 |
12 | #### Parameters
13 |
14 | none
15 |
16 | #### Return value
17 |
18 | * `table` representing the current radio position
19 | * `lat` (number) internal GPS latitude, positive is North
20 | * `lon` (number) internal GPS longitude, positive is East
21 | * 'numsat' (number) current number of sats locked in by the GPS sensor
22 | * 'fix' (boolean) fix status
23 | * 'alt' (number) internal GPS altitude in 0.1m
24 | * 'speed' (number) internal GPSspeed in 0.1m/s
25 | * 'heading' (number) internal GPS ground course estimation in degrees * 10
26 | * 'hdop' (number) internal GPS horizontal dilution of precision
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/model/getSensor.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## model.getSensor(sensor)
4 |
5 |
6 |
7 | Get Telemetry Sensor parameters
8 |
9 | @status current Introduced in 2.3.0
10 |
11 |
12 | #### Parameters
13 |
14 | * `sensor` (unsigned number) sensor number (use 0 for sensor 1)
15 |
16 |
17 |
18 | #### Return value
19 |
20 | * `nil` requested sensor does not exist
21 |
22 | * `table` with sensor data:
23 | * `type` (number) 0 = custom, 1 = calculated
24 | * `name` (string) Name
25 | * `unit` (number) See list of units in the appendix of the OpenTX Lua Reference Guide
26 | * `prec` (number) Number of decimals
27 | * `id` (number) Only custom sensors
28 | * `instance` (number) Only custom sensors
29 | * `formula` (number) Only calculated sensors. 0 = Add etc. see list of formula choices in Companion popup
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/model/getTimer.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## model.getTimer(timer)
4 |
5 |
6 |
7 | Get model timer parameters
8 |
9 | @status current Introduced in 2.0.0, name added in 2.3.6
10 |
11 |
12 | #### Parameters
13 |
14 | * `timer` (number) timer index (0 for Timer 1)
15 |
16 |
17 |
18 | #### Return value
19 |
20 | * `nil` requested timer does not exist
21 |
22 | * `table` timer parameters:
23 | * `mode` (number) timer trigger source: off, abs, stk, stk%, sw/!sw, !m_sw/!m_sw
24 | * `start` (number) start value [seconds], 0 for up timer, 0> down timer
25 | * `value` (number) current value [seconds]
26 | * `countdownBeep` (number) countdown beep (0 = silent, 1 = beeps, 2 = voice)
27 | * `minuteBeep` (boolean) minute beep
28 | * `persistent` (number) persistent timer
29 | * `name` (string) timer name
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/getflightmode.md:
--------------------------------------------------------------------------------
1 | # model.getFlightMode(index)
2 |
3 |
4 |
5 | Return input data for given input and line number
6 |
7 | @status current Introduced in 2.3.10
8 |
9 |
10 | ## Parameters
11 |
12 | * `index` (unsigned number) flight mode number (use 0 for FM0)
13 |
14 |
15 |
16 | ## Return value
17 |
18 | * `nil` requested input or line does not exist
19 |
20 | * `table` input data:
21 | * `name` (string) input line name
22 | * `switch` (number) input switch index
23 | * `fadeIn` (number) fade in value (in 0.1s)
24 | * `fadeOut` (number) fade out value (in 0.1s)
25 | * `trimsValues` (table) table of trim values:
26 | * `key` is trim number (zero based)
27 | * `value` is trim value
28 | * `trimsModes` (table) table of trim mode:
29 | * `key` is trim number (zero based)
30 | * `value` is trim mode
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/popupinput.md:
--------------------------------------------------------------------------------
1 | # popupInput(title, event, input, min, max)
2 |
3 |
4 |
5 | Raises a pop-up on screen that allows uses input
6 |
7 | @status current Introduced in 2.0.0
8 |
9 |
10 | ## Parameters
11 |
12 | * `title` (string) text to display
13 |
14 | * `event` (number) the event variable that is passed in from the
15 | Run function (key pressed)
16 |
17 | * `input` (number) value that can be adjusted by the +/- keys
18 |
19 | * `min` (number) min value that input can reach (by pressing the - key)
20 |
21 | * `max` (number) max value that input can reach
22 |
23 |
24 |
25 | ## Return value
26 |
27 | * `number` result of the input adjustment
28 |
29 | * `"OK"` user pushed ENT key
30 |
31 | * `"CANCEL"` user pushed EXIT key
32 |
33 |
34 |
35 | ### Notice
36 | Use only from stand-alone and telemetry scripts.
37 |
38 |
39 |
--------------------------------------------------------------------------------
/model/getFlightMode.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## model.getFlightMode(index)
4 |
5 |
6 |
7 | Return input data for given input and line number
8 |
9 | @status current Introduced in 2.3.10
10 |
11 |
12 | #### Parameters
13 |
14 | * `index` (unsigned number) flight mode number (use 0 for FM0)
15 |
16 |
17 |
18 | #### Return value
19 |
20 | * `nil` requested input or line does not exist
21 |
22 | * `table` input data:
23 | * `name` (string) input line name
24 | * `switch` (number) input switch index
25 | * `fadeIn` (number) fade in value (in 0.1s)
26 | * `fadeOut` (number) fade out value (in 0.1s)
27 | * `trimsValues` (table) table of trim values:
28 | * `key` is trim number (zero based)
29 | * `value` is trim value
30 | * `trimsModes` (table) table of trim mode:
31 | * `key` is trim number (zero based)
32 | * `value` is trim mode
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/getcurve.md:
--------------------------------------------------------------------------------
1 | # model.getCurve(curve)
2 |
3 |
4 |
5 | Get Curve parameters
6 |
7 | Note that functions returns the tables starting with index 0 contrary to LUA's
8 | usual index starting with 1
9 |
10 | @status current Introduced in 2.0.12
11 |
12 |
13 | ## Parameters
14 |
15 | * `curve` (unsigned number) curve number (use 0 for Curve1)
16 |
17 |
18 |
19 | ## Return value
20 |
21 | * `nil` requested curve does not exist
22 |
23 | * `table` curve data:
24 | * `name` (string) name
25 | * `type` (number) type
26 | * `smooth` (boolean) smooth
27 | * `points` (number) number of points
28 | * `y` (table) table of Y values:
29 | * `key` is point number (zero based)
30 | * `value` is y value
31 | * `x` (table) **only included for custom curve type**:
32 | * `key` is point number (zero based)
33 | * `value` is x value
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/general/popupInput.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## popupInput(title, event, input, min, max)
4 |
5 |
6 |
7 | Raises a pop-up on screen that allows uses input
8 |
9 | @status current Introduced in 2.0.0
10 |
11 |
12 | #### Parameters
13 |
14 | * `title` (string) text to display
15 |
16 | * `event` (number) the event variable that is passed in from the
17 | Run function (key pressed)
18 |
19 | * `input` (number) value that can be adjusted by the +/- keys
20 |
21 | * `min` (number) min value that input can reach (by pressing the - key)
22 |
23 | * `max` (number) max value that input can reach
24 |
25 |
26 |
27 | #### Return value
28 |
29 | * `number` result of the input adjustment
30 |
31 | * `"OK"` user pushed ENT key
32 |
33 | * `"CANCEL"` user pushed EXIT key
34 |
35 |
36 |
37 | ##### Notice
38 | Use only from stand-alone and telemetry scripts.
39 |
40 |
41 |
--------------------------------------------------------------------------------
/output_table_syntax.md:
--------------------------------------------------------------------------------
1 | # Output Table Syntax
2 |
3 | #####Overview
4 |
5 | Outputs are only used in mix scripts. The output table defines only name(s), the actual values are determined by the script's [run function](run_function_syntax.md).
6 |
7 | ```lua
8 | { "", "" }
9 | ```
10 |
11 |
12 | Example:
13 | ```lua
14 | local output { "Val1", "Val2" }
15 |
16 | local function run()
17 | return 0, -1024 -- these values will be available in OpenTX as Val1 and Val2
18 | end
19 |
20 | return {output=output, run=run}
21 | ```
22 |
23 | #####Notes:
24 |
25 | * Output name is limited to four characters.
26 |
27 | * A maximum of 6 outputs are supported
28 |
29 | * Number Format
30 | Outputs are 16 bit signed integers when they leave Lua script and are then divided by 10.24 to produce output value in percent:
31 |
32 | |Script Return Value|Mix Value in OpenTX|
33 | |-----|----|
34 | |0| 0%|
35 | |996| 97.2%|
36 | |1024| 100%|
37 | |-1024|-100%|
38 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/lcd-functions-less-than-greater-than-luadoc-begin-lcd/drawtext.md:
--------------------------------------------------------------------------------
1 | # lcd.drawText(x, y, text [, flags])
2 |
3 |
4 |
5 | Draw a text beginning at (x,y)
6 |
7 | @status current Introduced in 2.0.0, `SHADOWED` introduced in 2.2.1
8 |
9 |
10 | ## Parameters
11 |
12 | * `x,y` (positive numbers) starting coordinate
13 |
14 | * `text` (string) text to display
15 |
16 | * `flags` (unsigned number) drawing flags. All values can be
17 | combined together using the + character. ie BLINK + DBLSIZE.
18 | See the [Appendix](../appendix/fonts.md) for available characters in each font set.
19 | * `0 or not specified` normal font
20 | * `XXLSIZE` jumbo sized font
21 | * `DBLSIZE` double size font
22 | * `MIDSIZE` mid sized font
23 | * `SMLSIZE` small font
24 | * `INVERS` inverted display
25 | * `BLINK` blinking text
26 | * `SHADOWED` Horus only, apply a shadow effect
27 |
28 |
29 |
30 | ## Return value
31 |
32 | none
33 |
34 |
--------------------------------------------------------------------------------
/model/getCurve.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## model.getCurve(curve)
4 |
5 |
6 |
7 | Get Curve parameters
8 |
9 | Note that functions returns the tables starting with index 0 contrary to LUA's
10 | usual index starting with 1
11 |
12 | @status current Introduced in 2.0.12
13 |
14 |
15 | #### Parameters
16 |
17 | * `curve` (unsigned number) curve number (use 0 for Curve1)
18 |
19 |
20 |
21 | #### Return value
22 |
23 | * `nil` requested curve does not exist
24 |
25 | * `table` curve data:
26 | * `name` (string) name
27 | * `type` (number) type
28 | * `smooth` (boolean) smooth
29 | * `points` (number) number of points
30 | * `y` (table) table of Y values:
31 | * `key` is point number (zero based)
32 | * `value` is y value
33 | * `x` (table) **only included for custom curve type**:
34 | * `key` is point number (zero based)
35 | * `value` is x value
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/bitmap-functions-less-than-greater-than-luadoc-begin-bitmap/open.md:
--------------------------------------------------------------------------------
1 | # Bitmap.open(name)
2 |
3 |
4 |
5 | Loads a bitmap in memory, for later use with lcd.drawBitmap(). Bitmaps should be loaded only
6 | once, returned object should be stored and used for drawing. If loading fails for whatever
7 | reason the resulting bitmap object will have width and height set to zero.
8 |
9 | Bitmap loading can fail if:
10 | * File is not found or contains invalid image
11 | * System is low on memory
12 | * Combined memory usage of all Lua script bitmaps exceeds certain value
13 |
14 | @status current Introduced in 2.2.0
15 |
16 |
17 | ## Parameters
18 |
19 | * `name` (string) full path to the bitmap on SD card (i.e. “/IMAGES/test.bmp”)
20 |
21 |
22 |
23 | ## Return value
24 |
25 | * `bitmap` (object) a bitmap object that can be used with other bitmap functions
26 |
27 |
28 |
29 | ### Notice
30 | Only available on Horus
31 |
32 |
33 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/getgeneralsettings.md:
--------------------------------------------------------------------------------
1 | # getGeneralSettings()
2 |
3 |
4 |
5 | Returns (some of) the general radio settings
6 |
7 | @status current Introduced in 2.0.6, `imperial` added in TODO,
8 | `language` and `voice` added in 2.2.0, gtimer added in 2.2.2.
9 |
10 |
11 |
12 | ## Parameters
13 |
14 | none
15 |
16 | ## Return value
17 |
18 | * `table` with elements:
19 | * `battWarn` (number) radio battery range - warning value
20 | * `battMin` (number) radio battery range - minimum value
21 | * `battMax` (number) radio battery range - maximum value
22 | * `imperial` (number) set to a value different from 0 if the radio is set to the
23 | IMPERIAL units
24 | * `language` (string) radio language (used for menus)
25 | * `voice` (string) voice language (used for speech)
26 | * `gtimer` (number) radio global timer in seconds (does not include current session)
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/lcd/drawText.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## lcd.drawText(x, y, text [, flags])
4 |
5 |
6 |
7 | Draw a text beginning at (x,y)
8 |
9 | @status current Introduced in 2.0.0, `SHADOWED` introduced in 2.2.1
10 |
11 |
12 | #### Parameters
13 |
14 | * `x,y` (positive numbers) starting coordinate
15 |
16 | * `text` (string) text to display
17 |
18 | * `flags` (unsigned number) drawing flags. All values can be
19 | combined together using the + character. ie BLINK + DBLSIZE.
20 | See the [Appendix](../appendix/fonts.md) for available characters in each font set.
21 | * `0 or not specified` normal font
22 | * `XXLSIZE` jumbo sized font
23 | * `DBLSIZE` double size font
24 | * `MIDSIZE` mid sized font
25 | * `SMLSIZE` small font
26 | * `INVERS` inverted display
27 | * `BLINK` blinking text
28 | * `SHADOWED` Horus only, apply a shadow effect
29 |
30 |
31 |
32 | #### Return value
33 |
34 | none
35 |
36 |
--------------------------------------------------------------------------------
/Bitmap/open.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## Bitmap.open(name)
4 |
5 |
6 |
7 | Loads a bitmap in memory, for later use with lcd.drawBitmap(). Bitmaps should be loaded only
8 | once, returned object should be stored and used for drawing. If loading fails for whatever
9 | reason the resulting bitmap object will have width and height set to zero.
10 |
11 | Bitmap loading can fail if:
12 | * File is not found or contains invalid image
13 | * System is low on memory
14 | * Combined memory usage of all Lua script bitmaps exceeds certain value
15 |
16 | @status current Introduced in 2.2.0
17 |
18 |
19 | #### Parameters
20 |
21 | * `name` (string) full path to the bitmap on SD card (i.e. “/IMAGES/test.bmp”)
22 |
23 |
24 |
25 | #### Return value
26 |
27 | * `bitmap` (object) a bitmap object that can be used with other bitmap functions
28 |
29 |
30 |
31 | ##### Notice
32 | Only available on Horus
33 |
34 |
35 |
--------------------------------------------------------------------------------
/general/getGeneralSettings.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## getGeneralSettings()
4 |
5 |
6 |
7 | Returns (some of) the general radio settings
8 |
9 | @status current Introduced in 2.0.6, `imperial` added in TODO,
10 | `language` and `voice` added in 2.2.0, gtimer added in 2.2.2.
11 |
12 |
13 |
14 | #### Parameters
15 |
16 | none
17 |
18 | #### Return value
19 |
20 | * `table` with elements:
21 | * `battWarn` (number) radio battery range - warning value
22 | * `battMin` (number) radio battery range - minimum value
23 | * `battMax` (number) radio battery range - maximum value
24 | * `imperial` (number) set to a value different from 0 if the radio is set to the
25 | IMPERIAL units
26 | * `language` (string) radio language (used for menus)
27 | * `voice` (string) voice language (used for speech)
28 | * `gtimer` (number) radio global timer in seconds (does not include current session)
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/introduction/getting_started.md:
--------------------------------------------------------------------------------
1 | # Getting Started
2 |
3 | ## Downloading OpenTX Companion
4 |
5 | OpenTX Companion 2.2 is available for download at [http://www.open-tx.org/downloads.html](http://www.open-tx.org/downloads.html)
6 |
7 | ## Updating firmware with Lua option selected
8 |
9 | If you intend to use mixer scripts, when updating the firmware on your transmitter you need to make sure the lua option is checked in the settings for your radio profile \(Main menu -> Settings ->Settings...\) as shown below. This is not required if you only intend to run telemetry, one-time and function scripts, support for those is included by default.
10 |
11 | Also note that the SD Structure path should contain a valid path to a copy of your transmitter's SD card contents, although that's not specific to Lua.
12 |
13 | 
14 |
15 |
--------------------------------------------------------------------------------
/part_ii_-_opentx_lua_api_programming_guide/output_table_syntax.md:
--------------------------------------------------------------------------------
1 | # Output Table Syntax
2 |
3 | ## Overview
4 |
5 | Outputs are only used in mix scripts. The output table defines only name\(s\), the actual values are determined by the script's [run function](run_function_syntax.md).
6 |
7 | ```lua
8 | { "", "" }
9 | ```
10 |
11 | Example:
12 |
13 | ```lua
14 | local output { "Val1", "Val2" }
15 |
16 | local function run()
17 | return 0, -1024 -- these values will be available in OpenTX as Val1 and Val2
18 | end
19 |
20 | return {output=output, run=run}
21 | ```
22 |
23 | ## Notes:
24 |
25 | * Output name is limited to four characters.
26 | * A maximum of 6 outputs are supported
27 | * Number Format Outputs are 16 bit signed integers when they leave Lua script and are then divided by 10.24 to produce output value in percent:
28 |
29 | | Script Return Value | Mix Value in OpenTX |
30 | | :--- | :--- |
31 | | 0 | 0% |
32 | | 996 | 97.2% |
33 | | 1024 | 100% |
34 | | -1024 | -100% |
35 |
36 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/playtone.md:
--------------------------------------------------------------------------------
1 | # playTone(frequency, duration, pause [, flags [, freqIncr]])
2 |
3 |
4 |
5 | Play a tone
6 |
7 | @status current Introduced in 2.1.0
8 |
9 |
10 | ## Parameters
11 |
12 | * `frequency` (number) tone frequency in Hz (from 150 to 15000)
13 |
14 | * `duration` (number) length of the tone in milliseconds
15 |
16 | * `pause` (number) length of the silence after the tone in milliseconds
17 |
18 | * `flags` (number):
19 | * `0 or not present` play with normal priority.
20 | * `PLAY_BACKGROUND` play in background (built in vario function uses this context)
21 | * `PLAY_NOW` play immediately
22 |
23 | * `freqIncr` (number) positive number increases the tone pitch (frequency with time),
24 | negative number decreases it. The frequency changes every 10 milliseconds, the change is `freqIncr * 10Hz`.
25 | The valid range is from -127 to 127.
26 |
27 |
28 |
29 | ## Return value
30 |
31 | none
32 |
33 |
--------------------------------------------------------------------------------
/general/playTone.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## playTone(frequency, duration, pause [, flags [, freqIncr]])
4 |
5 |
6 |
7 | Play a tone
8 |
9 | @status current Introduced in 2.1.0
10 |
11 |
12 | #### Parameters
13 |
14 | * `frequency` (number) tone frequency in Hz (from 150 to 15000)
15 |
16 | * `duration` (number) length of the tone in milliseconds
17 |
18 | * `pause` (number) length of the silence after the tone in milliseconds
19 |
20 | * `flags` (number):
21 | * `0 or not present` play with normal priority.
22 | * `PLAY_BACKGROUND` play in background (built in vario function uses this context)
23 | * `PLAY_NOW` play immediately
24 |
25 | * `freqIncr` (number) positive number increases the tone pitch (frequency with time),
26 | negative number decreases it. The frequency changes every 10 milliseconds, the change is `freqIncr * 10Hz`.
27 | The valid range is from -127 to 127.
28 |
29 |
30 |
31 | #### Return value
32 |
33 | none
34 |
35 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/getcustomfunction.md:
--------------------------------------------------------------------------------
1 | # model.getCustomFunction(function)
2 |
3 |
4 |
5 | Get Custom Function parameters
6 |
7 | @status current Introduced in 2.0.0, TODO rename function
8 |
9 |
10 | ## Parameters
11 |
12 | * `function` (unsigned number) custom function number (use 0 for CF1)
13 |
14 |
15 |
16 | ## Return value
17 |
18 | * `nil` requested custom function does not exist
19 |
20 | * `table` custom function data:
21 | * `switch` (number) switch index
22 | * `func` (number) function index
23 | * `name` (string) Name of track to play (only returned only returned if action is play track, sound or script)
24 | * `value` (number) value (only returned only returned if action is **not** play track, sound or script)
25 | * `mode` (number) mode (only returned only returned if action is **not** play track, sound or script)
26 | * `param` (number) parameter (only returned only returned if action is **not** play track, sound or script)
27 | * `active` (number) 0 = disabled, 1 = enabled
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/model/getCustomFunction.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## model.getCustomFunction(function)
4 |
5 |
6 |
7 | Get Custom Function parameters
8 |
9 | @status current Introduced in 2.0.0, TODO rename function
10 |
11 |
12 | #### Parameters
13 |
14 | * `function` (unsigned number) custom function number (use 0 for CF1)
15 |
16 |
17 |
18 | #### Return value
19 |
20 | * `nil` requested custom function does not exist
21 |
22 | * `table` custom function data:
23 | * `switch` (number) switch index
24 | * `func` (number) function index
25 | * `name` (string) Name of track to play (only returned only returned if action is play track, sound or script)
26 | * `value` (number) value (only returned only returned if action is **not** play track, sound or script)
27 | * `mode` (number) mode (only returned only returned if action is **not** play track, sound or script)
28 | * `param` (number) parameter (only returned only returned if action is **not** play track, sound or script)
29 | * `active` (number) 0 = disabled, 1 = enabled
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/acknowledgments.md:
--------------------------------------------------------------------------------
1 |
2 | ### Acknowledgments
3 | The OpenTX team has no intention of making a profit from their work. OpenTX is free and open source and will remain free and open source. But OpenTX is more expensive to maintain than most open source projects. The reason is that there is a never ending flood of hardware to integrate and maintain code for. Hardware that costs.
4 |
5 | Another reason is that OpenTX maintains a build server that serves firmware compiled on demand. This is where OpenTX Companion orders your customized firmware. The server is not for free and the bandwidth is ever increasing with tens of thousands of firmware downloads each month.
6 |
7 | The OpenTX team is grateful to those who have donated to the project. You have helped making OpenTX and OpenTX Companion great.
8 |
9 | The [Github Donor List](https://github.com/opentx/opentx/blob/master/DONATIONS.txt) is updated at each OpenTX release.
10 |
11 | If you would like to contribute to OpenTX, donations are welcome and appreciated:
12 |
13 | [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=DJ9MASSKVW8WN)
14 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/getinput.md:
--------------------------------------------------------------------------------
1 | # model.getInput(input, line)
2 |
3 |
4 |
5 | Return input data for given input and line number
6 |
7 | @status current Introduced in 2.0.0, curveType/curveValue/carryTrim added in 2.3, inputName added 2.3.10, flighmode reworked in 2.3.11
8 |
9 |
10 | ## Parameters
11 |
12 | * `input` (unsigned number) input number (use 0 for Input1)
13 |
14 | * `line` (unsigned number) input line (use 0 for first line)
15 |
16 |
17 |
18 | ## Return value
19 |
20 | * `nil` requested input or line does not exist
21 |
22 | * `table` input data:
23 | * `name` (string) input line name
24 | * `inputName` (string) input input name
25 | * `source` (number) input source index
26 | * `weight` (number) input weight
27 | * `offset` (number) input offset
28 | * `switch` (number) input switch index
29 | * `curveType` (number) curve type (function, expo, custom curve)
30 | * `curveValue` (number) curve index
31 | * `carryTrim` (boolean) input trims applied
32 | * 'flightModes' (number) bit-mask of active flight modes
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/model/getInput.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## model.getInput(input, line)
4 |
5 |
6 |
7 | Return input data for given input and line number
8 |
9 | @status current Introduced in 2.0.0, curveType/curveValue/carryTrim added in 2.3, inputName added 2.3.10, flighmode reworked in 2.3.11
10 |
11 |
12 | #### Parameters
13 |
14 | * `input` (unsigned number) input number (use 0 for Input1)
15 |
16 | * `line` (unsigned number) input line (use 0 for first line)
17 |
18 |
19 |
20 | #### Return value
21 |
22 | * `nil` requested input or line does not exist
23 |
24 | * `table` input data:
25 | * `name` (string) input line name
26 | * `inputName` (string) input input name
27 | * `source` (number) input source index
28 | * `weight` (number) input weight
29 | * `offset` (number) input offset
30 | * `switch` (number) input switch index
31 | * `curveType` (number) curve type (function, expo, custom curve)
32 | * `curveValue` (number) curve index
33 | * `carryTrim` (boolean) input trims applied
34 | * 'flightModes' (number) bit-mask of active flight modes
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # OpenTX 2.3 Lua Reference Guide
2 |
3 | [Join the chat on Discord](https://discord.gg/CZCwVx2)
4 |
5 | Go to [https://doc.open-tx.org/opentx-2-3-lua-reference-guide/](https://doc.open-tx.org/opentx-2-3-lua-reference-guide/) for the latest published version of this guide.
6 |
7 | This guide covers the development of user-written scripts for R/C transmitters running the OpenTX 2.3 operating system with Lua support. Readers should be familiar with OpenTX, the OpenTX Companion, and know how to transfer files the SD card in the transmitter.
8 |
9 | Part I of the guide shows how to enable Lua support for Taranis and includes basic examples of each types of script.
10 |
11 | Part II is a programming guide that introduces the types of OpenTX Lua scripts and how to use them.
12 |
13 | Part III is the OpenTX Lua API Reference
14 |
15 | Part IV addresses common issues in converting Lua scripts that were originally written for OpenTX 2.0
16 |
17 | Part V addresses common issues in converting Lua scripts that were originally written for OpenTX 2.1
18 |
19 | Part VI covers advanced topics with examples
20 |
21 | last updated on 2022/05/03 08:34:00 UTC
22 |
23 |
--------------------------------------------------------------------------------
/part_iv_-_converting_opentx_20_scripts/known_issues.md:
--------------------------------------------------------------------------------
1 | # General Issues
2 |
3 | ## Deprecated Functions
4 |
5 | **lcd.Lock\(\)** is deprecated, will be obsolete in 2.2. Lua scripts must now explicitly call lcd.Clear\(\) and re-draw the whole display if necessary.
6 |
7 | TODO: research killEvents\(\) and use of keys in telemetry scripts
8 |
9 | ## Obsolete Telemetry Field Names
10 |
11 | OpenTX since version 2.1 provides more flexibility in the number and type of supported remote sensors. As a result, several field name constants are obsolete and need to be modified in scripts originally written for OpenTX 2.0.
12 |
13 | **GPS field names** are covered in [Handling GPS Sensor Data](handling_gps_sensor_data.md)
14 |
15 | **Lipo voltage field names \(LVSS\)** are covered in [Handling Lipo Sensor Data](handling_lipo_sensor_data.md)
16 |
17 | ## Maintaining compatibility with OpenTX 2.0
18 |
19 | **Automatic invocation of the background function** - Beginning in OpenTX 2.1 the background\(\) function is called automatically prior to each invocation of the run\(\) function. Under 2.0 you must explicitly call your background function within your run function.
20 |
21 |
--------------------------------------------------------------------------------
/known_issues.md:
--------------------------------------------------------------------------------
1 | ### General Issues in converting scripts written for OpenTX 2.0
2 |
3 | #### Deprecated Functions
4 |
5 | **lcd.Lock()** is deprecated, will be obsolete in 2.2. Lua scripts must now explicitly call lcd.Clear() and re-draw the whole display if necessary.
6 |
7 |
8 | TODO: research killEvents() and use of keys in telemetry scripts
9 |
10 |
11 | #### Obsolete Telemetry Field Names
12 |
13 | OpenTX since version 2.1 provides more flexibility in the number and type of supported remote sensors. As a result, several field name constants are obsolete and need to be modified in scripts originally written for OpenTX 2.0.
14 |
15 | **GPS field names** are covered in [Handling GPS Sensor Data](handling_gps_sensor_data.md)
16 |
17 | **Lipo voltage field names (LVSS)** are covered in [Handling Lipo Sensor Data](handling_lipo_sensor_data.md)
18 |
19 | #### Maintaining compatibility with OpenTX 2.0
20 |
21 | **Automatic invocation of the background function** - Beginning in OpenTX 2.1 the background() function is called automatically prior to each invocation of the run() function. Under 2.0 you must explicitly call your background function within your run function.
--------------------------------------------------------------------------------
/introduction/acknowledgments.md:
--------------------------------------------------------------------------------
1 | # Acknowledgments
2 |
3 | The OpenTX team has no intention of making a profit from their work. OpenTX is free and open source and will remain free and open source. But OpenTX is more expensive to maintain than most open source projects. The reason is that there is a never ending flood of hardware to integrate and maintain code for. Hardware that costs.
4 |
5 | Another reason is that OpenTX maintains a build server that serves firmware compiled on demand. This is where OpenTX Companion orders your customized firmware. The server is not for free and the bandwidth is ever increasing with tens of thousands of firmware downloads each month.
6 |
7 | The OpenTX team is grateful to those who have donated to the project. You have helped making OpenTX and OpenTX Companion great.
8 |
9 | The [Github Donor List](https://github.com/opentx/opentx/blob/master/DONATIONS.txt) is updated at each OpenTX release.
10 |
11 | If you would like to contribute to OpenTX, donations are welcome and appreciated:
12 |
13 | [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=DJ9MASSKVW8WN)
14 |
15 |
--------------------------------------------------------------------------------
/one-time_scripts.md:
--------------------------------------------------------------------------------
1 | # One-Time Scripts
2 |
3 | #####Overview
4 |
5 | One-Time scripts start when called upon by a specific radio function or when the user selects them from a contextual menu. They do their task and are then terminated and unloaded. Please note that all persistent scripts are halted during the execution of one time scripts. They are automatically restarted once the one time script is finished. This is done to provide enough system resources to execute the one time script.
6 |
7 | #####***WARNING! - ***
8 | - Running a One-Time script will suspend execution of all other currently loaded Lua scripts (Mix, Telemetry, and Functions)
9 |
10 | ##### File Location
11 |
12 | Place them anywhere on SD card, the folder /SCRIPTS/ is recommended. The only exception is official model wizard script, that should be put into /SCRIPTS/WIZARD/ folder that way it will start automatically
13 | when new model is created.
14 |
15 | ##### Lifetime of One-Time scripts
16 |
17 | Script is executed when user selects Execute on a script file from SD card browser screen.
18 |
19 | Script executes until:
20 | - it returns value different from 0
21 | - is forcefully closed by user by long press of EXIT key
22 | - is forcefully closed by system if if it misbehaves (too long runtime, error in code, low
23 | memory)
--------------------------------------------------------------------------------
/part_i_-_script_type_overview/one-time_scripts.md:
--------------------------------------------------------------------------------
1 | # One-Time Scripts
2 |
3 | ## Overview
4 |
5 | One-Time scripts start when called upon by a specific radio function or when the user selects them from a contextual menu. They do their task and are then terminated and unloaded. Please note that all persistent scripts are halted during the execution of one time scripts. They are automatically restarted once the one time script is finished. This is done to provide enough system resources to execute the one time script.
6 |
7 | ## _**WARNING! -**_
8 |
9 | * Running a One-Time script will suspend execution of all other currently loaded Lua scripts \(Mix, Telemetry, and Functions\)
10 |
11 | ## File Location
12 |
13 | Place them anywhere on SD card, the folder /SCRIPTS/ is recommended. The only exception is official model wizard script, that should be put into /SCRIPTS/WIZARD/ folder that way it will start automatically when new model is created.
14 |
15 | ## Lifetime of One-Time scripts
16 |
17 | Script is executed when user selects Execute on a script file from SD card browser screen.
18 |
19 | Script executes until:
20 |
21 | * it returns value different from 0
22 | * is forcefully closed by user by long press of EXIT key
23 | * is forcefully closed by system if if it misbehaves \(too long runtime, error in code, low
24 |
25 | memory\)
26 |
27 |
--------------------------------------------------------------------------------
/handling_lipo_sensor_data.md:
--------------------------------------------------------------------------------
1 | # Handling Lipo Sensor Data
2 | With OpenTx 2.2 it is possible to have multiple Lipo sensors, each with a user-assigned name. The call to getValue() returns a table with the current voltage of each of the cells it is monitoring.
3 |
4 | This example demonstrates getting Lipo cell voltage from a sensor with the default name of 'Cels'
5 |
6 | #####Example:
7 |
8 | ```lua
9 | local cellValue = "unknown"
10 | local cellResult = nil
11 | local cellID = nil
12 |
13 | local function getTelemetryId(name)
14 | field = getFieldInfo(name)
15 | if field then
16 | return field.id
17 | else
18 | return -1
19 | end
20 | end
21 |
22 | local function init()
23 | cellId = getTelemetryId("Cels")
24 | end
25 |
26 | local function background()
27 | cellResult = getValue(cellId)
28 | if (type(cellResult) == "table") then
29 | cellValue = ""
30 | for i, v in ipairs(cellResult) do
31 | cellValue = cellValue .. i .. ": " .. v .. " "
32 | end
33 | else
34 | cellValue = "telemetry not available"
35 | end
36 | end
37 |
38 | local function run(e)
39 | background()
40 | lcd.clear()
41 | lcd.drawText(1,1,"OpenTX 2.2 cell voltage example",0)
42 | lcd.drawText(1,11,"Cels:", 0)
43 | lcd.drawText(lcd.getLastPos()+2,11,cellValue,0)
44 | end
45 |
46 | return{init=init,run=run,background=background}
47 | ```
48 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/settelemetryvalue.md:
--------------------------------------------------------------------------------
1 | # setTelemetryValue(id, subID, instance, value [, unit [, precision [, name]]])
2 |
3 |
4 |
5 | @status current Introduced in 2.2.0
6 |
7 |
8 | ## Parameters
9 |
10 | * `id` Id of the sensor, valid range is from 0 to 0xFFFF
11 |
12 | * `subID` subID of the sensor, usually 0, valid range is from 0 to 7
13 |
14 | * `instance` instance of the sensor (SensorID), valid range is from 0 to 0xFF
15 |
16 | * `value` fed to the sensor
17 |
18 | * `unit` unit of the sensor [Full list](../appendix/units.html)
19 |
20 | * `precision` the precision of the sensor
21 | * `0 or not present` no decimal precision.
22 | * `!= 0` value is divided by 10^precision, e.g. value=1000, prec=2 => 10.00.
23 |
24 | * `name` (string) Name of the sensor if it does not yet exist (4 chars).
25 | * `not present` Name defaults to the Id.
26 | * `present` Sensor takes name of the argument. Argument must have name surrounded by quotes: e.g., "Name"
27 |
28 |
29 |
30 | ## Return value
31 |
32 | * `true,` if the sensor was just added. In this case the value is ignored (subsequent call will set the value)
33 |
34 |
35 |
36 | ### Notice
37 | All three parameters `id`, `subID` and `instance` can't be zero at the same time. At least one of them
38 | must be different from zero.
39 |
40 |
41 |
--------------------------------------------------------------------------------
/optimization_tricks.md:
--------------------------------------------------------------------------------
1 | # Speed and Memory Optimization Tricks
2 |
3 |
4 | ## Faster getValue()
5 |
6 | Normally one uses [getValue()](general/getValue.md) function with the source/filed name like so:
7 |
8 | ```lua
9 | local foo = getValue("bar")
10 | ```
11 |
12 | This works and is recommended method for portability. But if a particular script needs to get the value of certain field a lot, then it is faster to use this syntax:
13 |
14 | ```lua
15 |
16 | local my_id = getFiledInfo("bar").id -- here we get the numerical id of the filed "bar"
17 |
18 | local function run_a_lot()
19 | local my_value = getValue(my_id) -- exactly the same effect as local my_value = getValue("bar"), but faster
20 | end
21 | ```
22 |
23 | Why is this method faster? With the function [getFieldInfo(name)](general/getFieldInfo.md) we get the `numerical id` of the wanted filed. The function has to find the requested value by its name in the table of all available sources. That search takes some time.
24 |
25 | When we use this syntax the search is only done once. In comparison in the first
26 | example the search must be performed every time `getValue("bar")` is called.
27 |
28 | So when the `getValue(my_id)` is called the search can be skipped and the requested value if fetched directly.
29 |
30 | Of course there is a trade-of, the second example uses little more memory (for variable `my_id`).
31 |
32 |
--------------------------------------------------------------------------------
/general/setTelemetryValue.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## setTelemetryValue(id, subID, instance, value [, unit [, precision [, name]]])
4 |
5 |
6 |
7 | @status current Introduced in 2.2.0
8 |
9 |
10 | #### Parameters
11 |
12 | * `id` Id of the sensor, valid range is from 0 to 0xFFFF
13 |
14 | * `subID` subID of the sensor, usually 0, valid range is from 0 to 7
15 |
16 | * `instance` instance of the sensor (SensorID), valid range is from 0 to 0xFF
17 |
18 | * `value` fed to the sensor
19 |
20 | * `unit` unit of the sensor [Full list](../appendix/units.html)
21 |
22 | * `precision` the precision of the sensor
23 | * `0 or not present` no decimal precision.
24 | * `!= 0` value is divided by 10^precision, e.g. value=1000, prec=2 => 10.00.
25 |
26 | * `name` (string) Name of the sensor if it does not yet exist (4 chars).
27 | * `not present` Name defaults to the Id.
28 | * `present` Sensor takes name of the argument. Argument must have name surrounded by quotes: e.g., "Name"
29 |
30 |
31 |
32 | #### Return value
33 |
34 | * `true,` if the sensor was just added. In this case the value is ignored (subsequent call will set the value)
35 |
36 |
37 |
38 | ##### Notice
39 | All three parameters `id`, `subID` and `instance` can't be zero at the same time. At least one of them
40 | must be different from zero.
41 |
42 |
43 |
--------------------------------------------------------------------------------
/part_vii_-_appendix/units.md:
--------------------------------------------------------------------------------
1 | # Units
2 |
3 | | Index | Unit | Defined as |
4 | | :--- | :--- | :--- |
5 | | 0 | Raw unit \(no unit\) | UNIT\_RAW |
6 | | 1 | Volts | UNIT\_VOLTS |
7 | | 2 | Amps | UNIT\_AMPS |
8 | | 3 | Milliamps | UNIT\_MILLIAMPS |
9 | | 4 | Knots | UNIT\_KTS |
10 | | 5 | Meters per Second | UNIT\_METERS\_PER\_SECOND |
11 | | 6 | Feet per Second | UNIT\_FEET\_PER\_SECOND |
12 | | 7 | Kilometers per Hour | UNIT\_KMH |
13 | | 8 | Miles per Hour | UNIT\_MPH |
14 | | 9 | Meters | UNIT\_METERS |
15 | | 10 | Feet | UNIT\_FEET |
16 | | 11 | Degrees Celsius | UNIT\_CELSIUS |
17 | | 12 | Degrees Fahrenheit | UNIT\_FAHRENHEIT |
18 | | 13 | Percent | UNIT\_PERCENT |
19 | | 14 | Milliamp Hour | UNIT\_MAH |
20 | | 15 | Watts | UNIT\_WATTS |
21 | | 16 | Milliwatts | UNIT\_MILLIWATTS |
22 | | 17 | dB | UNIT\_DB |
23 | | 18 | RPM | UNIT\_RPMS |
24 | | 19 | G | UNIT\_G |
25 | | 20 | Degrees | UNIT\_DEGREE |
26 | | 21 | Radians | UNIT\_RADIANS |
27 | | 22 | Milliliters | UNIT\_MILLILITERS |
28 | | 23 | Fluid Ounces | UNIT\_FLOZ |
29 | | 24 | Ml per minute | UNIT\_MILLILITERS\_PER\_MINUTE |
30 | | 35 | Hours | UNIT\_HOURS |
31 | | 36 | Minutes | UNIT\_MINUTES |
32 | | 37 | Seconds | UNIT\_SECONDS |
33 | | 38 | Virtual unit | UNIT\_CELLS |
34 | | 39 | Virtual unit | UNIT\_DATETIME |
35 | | 40 | Virtual unit | UNIT\_GPS |
36 | | 41 | Virtual unit | UNIT\_BITFIELD |
37 | | 42 | Virtual unit | UNIT\_TEXT |
38 |
39 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/setcurve.md:
--------------------------------------------------------------------------------
1 | # model.setCurve(curve, params)
2 |
3 |
4 |
5 | Set Curve parameters
6 |
7 | The first and last x value must -100 and 100 and x values must be monotonically increasing
8 |
9 | @status current Introduced in 2.2.0
10 |
11 | Example setting a 4-point custom curve:
12 | ```lua
13 | params = {}
14 | params["x"] = {-100, -34, 77, 100}
15 | params["y"] = {-70, 20, -89, -100}
16 | params["smooth"] = true
17 | params["type"] = 1
18 | val = model.setCurve(2, params)
19 | ```
20 | setting a 6-point standard smoothed curve
21 | ```lua
22 | val = model.setCurve(3, {smooth=true, y={-100, -50, 0, 50, 100, 80}})
23 | ```
24 |
25 |
26 |
27 | ## Parameters
28 |
29 | * `curve` (unsigned number) curve number (use 0 for Curve1)
30 |
31 | * `params` see model.getCurve return format for table format. setCurve uses standard
32 | lua array indexing and arrays start at index 1
33 |
34 |
35 |
36 | ## Return value
37 |
38 | * `curve` status data:
39 | * 0 - Everything okay
40 | * 1 - Wrong number of points
41 | * 2 - Invalid Curve number
42 | * 3 - Cuve does not fit anymore
43 | * 4 - point of out of index
44 | * 5 - x value not monotonically increasing
45 | * 6 - y value not in range [-100;100]
46 | * 7 - extra values for y are set
47 | * 8 - extra values for x are set
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/getmodule.md:
--------------------------------------------------------------------------------
1 | # model.getModule(index)
2 |
3 |
4 |
5 | Get RF module parameters
6 |
7 | `Type` values:
8 | * 0 NONE
9 | * 1 PPM
10 | * 2 XJT_PXX1
11 | * 3 ISRM_PXX2
12 | * 4 DSM2
13 | * 5 CROSSFIRE
14 | * 6 MULTIMODULE
15 | * 7 R9M_PXX1
16 | * 8 R9M_PXX2
17 | * 9 R9M_LITE_PXX1
18 | * 10 R9M_LITE_PXX2
19 | * 11 R9M_LITE_PRO_PXX1
20 | * 12 R9M_LITE_PRO_PXX2
21 | * 13 SBUS
22 | * 14 XJT_LITE_PXX2
23 |
24 | `subType` values for XJT_PXX1:
25 | * -1 OFF
26 | * 0 D16
27 | * 1 D8
28 | * 2 LR12
29 |
30 | @status current Introduced in 2.2.0
31 |
32 |
33 | ## Parameters
34 |
35 | * `index` (number) module index (0 for internal, 1 for external)
36 |
37 |
38 |
39 | ## Return value
40 |
41 | * `nil` requested module does not exist
42 |
43 | * `table` module parameters:
44 | * `subType` (number) protocol index
45 | * `modelId` (number) receiver number
46 | * `firstChannel` (number) start channel (0 is CH1)
47 | * `channelsCount` (number) number of channels sent to module
48 | * `Type` (number) module type
49 | * if the module type is Multi additional information are available
50 | * `protocol` (number) protocol number (Multi only)
51 | * `subProtocol` (number) sub-protocol number (Multi only)
52 | * `channelsOrder` (number) first 4 channels expected order (Multi only)
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/model-functions-less-than-greater-than-luadoc-begin-model/getmix.md:
--------------------------------------------------------------------------------
1 | # model.getMix(channel, line)
2 |
3 |
4 |
5 | Get configuration for specified Mix
6 |
7 | @status current Introduced in 2.0.0, parameters below `multiplex` added in 2.0.13
8 |
9 |
10 | ## Parameters
11 |
12 | * `channel` (unsigned number) channel number (use 0 for CH1)
13 |
14 | * `line` (unsigned number) mix number (use 0 for first line(mix))
15 |
16 |
17 |
18 | ## Return value
19 |
20 | * `nil` requested channel or line does not exist
21 |
22 | * `table` mix data:
23 | * `name` (string) mix line name
24 | * `source` (number) source index
25 | * `weight` (number) weight (1024 == 100%) value or GVAR1..9 = 4096..4011, -GVAR1..9 = 4095..4087
26 | * `offset` (number) offset value or GVAR1..9 = 4096..4011, -GVAR1..9 = 4095..4087
27 | * `switch` (number) switch index
28 | * `multiplex` (number) multiplex (0 = ADD, 1 = MULTIPLY, 2 = REPLACE)
29 | * `curveType` (number) curve type (function, expo, custom curve)
30 | * `curveValue` (number) curve index
31 | * `flightModes` (number) bit-mask of active flight modes
32 | * `carryTrim` (boolean) carry trim
33 | * `mixWarn` (number) warning (0 = off, 1 = 1 beep, .. 3 = 3 beeps)
34 | * `delayUp` (number) delay up (time in 1/10 s)
35 | * `delayDown` (number) delay down
36 | * `speedUp` (number) speed up
37 | * `speedDown` (number) speed down
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/part_iv_-_converting_opentx_20_scripts/handling_lipo_sensor_data.md:
--------------------------------------------------------------------------------
1 | # Handling Lipo Sensor Data
2 |
3 | With OpenTx 2.2 it is possible to have multiple Lipo sensors, each with a user-assigned name. The call to getValue\(\) returns a table with the current voltage of each of the cells it is monitoring.
4 |
5 | This example demonstrates getting Lipo cell voltage from a sensor with the default name of 'Cels'
6 |
7 | ## Example:
8 |
9 | ```lua
10 | local cellValue = "unknown"
11 | local cellResult = nil
12 | local cellID = nil
13 |
14 | local function getTelemetryId(name)
15 | field = getFieldInfo(name)
16 | if field then
17 | return field.id
18 | else
19 | return -1
20 | end
21 | end
22 |
23 | local function init()
24 | cellId = getTelemetryId("Cels")
25 | end
26 |
27 | local function background()
28 | cellResult = getValue(cellId)
29 | if (type(cellResult) == "table") then
30 | cellValue = ""
31 | for i, v in ipairs(cellResult) do
32 | cellValue = cellValue .. i .. ": " .. v .. " "
33 | end
34 | else
35 | cellValue = "telemetry not available"
36 | end
37 | end
38 |
39 | local function run(e)
40 | background()
41 | lcd.clear()
42 | lcd.drawText(1,1,"OpenTX 2.2 cell voltage example",0)
43 | lcd.drawText(1,11,"Cels:", 0)
44 | lcd.drawText(lcd.getLastPos()+2,11,cellValue,0)
45 | end
46 |
47 | return{init=init,run=run,background=background}
48 | ```
49 |
50 |
--------------------------------------------------------------------------------
/model/getModule.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## model.getModule(index)
4 |
5 |
6 |
7 | Get RF module parameters
8 |
9 | `Type` values:
10 | * 0 NONE
11 | * 1 PPM
12 | * 2 XJT_PXX1
13 | * 3 ISRM_PXX2
14 | * 4 DSM2
15 | * 5 CROSSFIRE
16 | * 6 MULTIMODULE
17 | * 7 R9M_PXX1
18 | * 8 R9M_PXX2
19 | * 9 R9M_LITE_PXX1
20 | * 10 R9M_LITE_PXX2
21 | * 11 R9M_LITE_PRO_PXX1
22 | * 12 R9M_LITE_PRO_PXX2
23 | * 13 SBUS
24 | * 14 XJT_LITE_PXX2
25 |
26 | `subType` values for XJT_PXX1:
27 | * -1 OFF
28 | * 0 D16
29 | * 1 D8
30 | * 2 LR12
31 |
32 | @status current Introduced in 2.2.0
33 |
34 |
35 | #### Parameters
36 |
37 | * `index` (number) module index (0 for internal, 1 for external)
38 |
39 |
40 |
41 | #### Return value
42 |
43 | * `nil` requested module does not exist
44 |
45 | * `table` module parameters:
46 | * `subType` (number) protocol index
47 | * `modelId` (number) receiver number
48 | * `firstChannel` (number) start channel (0 is CH1)
49 | * `channelsCount` (number) number of channels sent to module
50 | * `Type` (number) module type
51 | * if the module type is Multi additional information are available
52 | * `protocol` (number) protocol number (Multi only)
53 | * `subProtocol` (number) sub-protocol number (Multi only)
54 | * `channelsOrder` (number) first 4 channels expected order (Multi only)
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/model/getMix.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## model.getMix(channel, line)
4 |
5 |
6 |
7 | Get configuration for specified Mix
8 |
9 | @status current Introduced in 2.0.0, parameters below `multiplex` added in 2.0.13
10 |
11 |
12 | #### Parameters
13 |
14 | * `channel` (unsigned number) channel number (use 0 for CH1)
15 |
16 | * `line` (unsigned number) mix number (use 0 for first line(mix))
17 |
18 |
19 |
20 | #### Return value
21 |
22 | * `nil` requested channel or line does not exist
23 |
24 | * `table` mix data:
25 | * `name` (string) mix line name
26 | * `source` (number) source index
27 | * `weight` (number) weight (1024 == 100%) value or GVAR1..9 = 4096..4011, -GVAR1..9 = 4095..4087
28 | * `offset` (number) offset value or GVAR1..9 = 4096..4011, -GVAR1..9 = 4095..4087
29 | * `switch` (number) switch index
30 | * `multiplex` (number) multiplex (0 = ADD, 1 = MULTIPLY, 2 = REPLACE)
31 | * `curveType` (number) curve type (function, expo, custom curve)
32 | * `curveValue` (number) curve index
33 | * `flightModes` (number) bit-mask of active flight modes
34 | * `carryTrim` (boolean) carry trim
35 | * `mixWarn` (number) warning (0 = off, 1 = 1 beep, .. 3 = 3 beeps)
36 | * `delayUp` (number) delay up (time in 1/10 s)
37 | * `delayDown` (number) delay down
38 | * `speedUp` (number) speed up
39 | * `speedDown` (number) speed down
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/model/setCurve.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## model.setCurve(curve, params)
4 |
5 |
6 |
7 | Set Curve parameters
8 |
9 | The first and last x value must -100 and 100 and x values must be monotonically increasing
10 |
11 | @status current Introduced in 2.2.0
12 |
13 | Example setting a 4-point custom curve:
14 | ```lua
15 | params = {}
16 | params["x"] = {-100, -34, 77, 100}
17 | params["y"] = {-70, 20, -89, -100}
18 | params["smooth"] = true
19 | params["type"] = 1
20 | val = model.setCurve(2, params)
21 | ```
22 | setting a 6-point standard smoothed curve
23 | ```lua
24 | val = model.setCurve(3, {smooth=true, y={-100, -50, 0, 50, 100, 80}})
25 | ```
26 |
27 |
28 |
29 | #### Parameters
30 |
31 | * `curve` (unsigned number) curve number (use 0 for Curve1)
32 |
33 | * `params` see model.getCurve return format for table format. setCurve uses standard
34 | lua array indexing and arrays start at index 1
35 |
36 |
37 |
38 | #### Return value
39 |
40 | * `` 0 - Everything okay
41 | 1 - Wrong number of points
42 | 2 - Invalid Curve number
43 | 3 - Cuve does not fit anymore
44 | 4 - point of out of index
45 | 5 - x value not monotonically increasing
46 | 6 - y value not in range [-100;100]
47 | 7 - extra values for y are set
48 | 8 - extra values for x are set
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/lcd-functions-less-than-greater-than-luadoc-begin-lcd/setcolor.md:
--------------------------------------------------------------------------------
1 | # lcd.setColor(area, color)
2 |
3 |
4 |
5 | Set a color for specific area
6 |
7 | @status current Introduced in 2.2.0
8 |
9 |
10 | ## Parameters
11 |
12 | * `area` (unsigned number) specific screen area in the list bellow
13 | * `TEXT_COLOR`
14 | * `TEXT_BGCOLOR`
15 | * `TEXT_INVERTED_COLOR`
16 | * `TEXT_INVERTED_BGCOLOR`
17 | * `LINE_COLOR`
18 | * `SCROLLBOX_COLOR`
19 | * `MENU_TITLE_BGCOLOR`
20 | * `MENU_TITLE_COLOR`
21 | * `MENU_TITLE_DISABLE_COLOR`
22 | * `HEADER_COLOR`
23 | * `ALARM_COLOR`
24 | * `WARNING_COLOR`
25 | * `TEXT_DISABLE_COLOR`
26 | * `CURVE_AXIS_COLOR`
27 | * `CURVE_COLOR`
28 | * `CURVE_CURSOR_COLOR`
29 | * `TITLE_BGCOLOR`
30 | * `TRIM_BGCOLOR`
31 | * `TRIM_SHADOW_COLOR`
32 | * `HEADER_BGCOLOR`
33 | * `HEADER_ICON_BGCOLOR`
34 | * `HEADER_CURRENT_BGCOLOR`
35 | * `MAINVIEW_PANES_COLOR`
36 | * `MAINVIEW_GRAPHICS_COLOR`
37 | * `OVERLAY_COLOR`
38 | * `BARGRAPH1_COLOR`
39 | * `BARGRAPH2_COLOR`
40 | * `BARGRAPH_BGCOLOR`
41 | * `CUSTOM_COLOR`
42 |
43 | * `color` (number) color in 5/6/5 rgb format. The following prefined colors are available
44 | * `WHITE`
45 | * `GREY`
46 | * `LIGHTGREY`
47 | * `DARKGREY`
48 | * `BLACK`
49 | * `YELLOW`
50 | * `BLUE`
51 | * `RED`
52 | * `DARKRED`
53 |
54 |
55 |
56 | ## Return value
57 |
58 | none
59 |
60 | ### Notice
61 | Only available on Colorlcd radios
62 |
63 |
64 |
--------------------------------------------------------------------------------
/lcd/setColor.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## lcd.setColor(area, color)
4 |
5 |
6 |
7 | Set a color for specific area
8 |
9 | @status current Introduced in 2.2.0
10 |
11 |
12 | #### Parameters
13 |
14 | * `area` (unsigned number) specific screen area in the list bellow
15 | * `TEXT_COLOR`
16 | * `TEXT_BGCOLOR`
17 | * `TEXT_INVERTED_COLOR`
18 | * `TEXT_INVERTED_BGCOLOR`
19 | * `LINE_COLOR`
20 | * `SCROLLBOX_COLOR`
21 | * `MENU_TITLE_BGCOLOR`
22 | * `MENU_TITLE_COLOR`
23 | * `MENU_TITLE_DISABLE_COLOR`
24 | * `HEADER_COLOR`
25 | * `ALARM_COLOR`
26 | * `WARNING_COLOR`
27 | * `TEXT_DISABLE_COLOR`
28 | * `CURVE_AXIS_COLOR`
29 | * `CURVE_COLOR`
30 | * `CURVE_CURSOR_COLOR`
31 | * `TITLE_BGCOLOR`
32 | * `TRIM_BGCOLOR`
33 | * `TRIM_SHADOW_COLOR`
34 | * `HEADER_BGCOLOR`
35 | * `HEADER_ICON_BGCOLOR`
36 | * `HEADER_CURRENT_BGCOLOR`
37 | * `MAINVIEW_PANES_COLOR`
38 | * `MAINVIEW_GRAPHICS_COLOR`
39 | * `OVERLAY_COLOR`
40 | * `BARGRAPH1_COLOR`
41 | * `BARGRAPH2_COLOR`
42 | * `BARGRAPH_BGCOLOR`
43 | * `CUSTOM_COLOR`
44 |
45 | * `color` (number) color in 5/6/5 rgb format. The following prefined colors are available
46 | * `WHITE`
47 | * `GREY`
48 | * `LIGHTGREY`
49 | * `DARKGREY`
50 | * `BLACK`
51 | * `YELLOW`
52 | * `BLUE`
53 | * `RED`
54 | * `DARKRED`
55 |
56 |
57 |
58 | #### Return value
59 |
60 | none
61 |
62 | ##### Notice
63 | Only available on Colorlcd radios
64 |
65 |
66 |
--------------------------------------------------------------------------------
/run_function_syntax.md:
--------------------------------------------------------------------------------
1 | # Run Function Syntax
2 |
3 | The run function is the function that is periodically called for the lifetime of script execution. Syntax of the run function is different between [mix scripts](mix.md) and [telemetry scripts](telemetry.md).
4 |
5 |
6 | ---
7 |
8 |
9 | #### Run Function for Mix Scripts
10 | ```lua
11 | local function ([first input, [second input], …])
12 |
13 | -- if mix has no return values
14 | return
15 |
16 | -- if mix has two return values
17 | return value1, value2
18 |
19 | end
20 | ```
21 | * #####Input parameters:
22 | zero or more input values, their names are arbitrary, their meaning and order is defined by the input table. (see [Input Table Syntax](input_table_syntax.md))
23 |
24 | * #####Return values:
25 | - none - if output table is empty (i.e. script has no output)
26 | values
\- or \-
27 | - comma separated list of output values, their order and meaning is defined by the output table. (see [Output Table Syntax](output_table_syntax.md))
28 |
29 |
30 |
31 | ---
32 |
33 |
34 | ####Run Function for Telemetry Scripts
35 | ```lua
36 | local function (key-event)
37 | return 0 -- values other than zero will halt the script
38 | end
39 | ```
40 |
41 | * #####Input parameters:
42 | The *key-event* parameter indicates which transmitter button has been pressed (see [Key Events](key_events.md))
43 | * #####Return values:
44 | A non-zero return value will halt the script
45 |
--------------------------------------------------------------------------------
/part_vi_-_advanced_topics/optimization_tricks.md:
--------------------------------------------------------------------------------
1 | # Speed/memory optimizaton tricks
2 |
3 | ## Faster getValue\(\)
4 |
5 | Normally one uses [getValue\(\)](../part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/getvalue.md) function with the source/filed name like so:
6 |
7 | ```lua
8 | local foo = getValue("bar")
9 | ```
10 |
11 | This works and is recommended method for portability. But if a particular script needs to get the value of certain field a lot, then it is faster to use this syntax:
12 |
13 | ```lua
14 | local my_id = getFiledInfo("bar").id -- here we get the numerical id of the filed "bar"
15 |
16 | local function run_a_lot()
17 | local my_value = getValue(my_id) -- exactly the same effect as local my_value = getValue("bar"), but faster
18 | end
19 | ```
20 |
21 | Why is this method faster? With the function [getFieldInfo\(name\)](../part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/getfieldinfo.md) we get the `numerical id` of the wanted filed. The function has to find the requested value by its name in the table of all available sources. That search takes some time.
22 |
23 | When we use this syntax the search is only done once. In comparison in the first example the search must be performed every time `getValue("bar")` is called.
24 |
25 | So when the `getValue(my_id)` is called the search can be skipped and the requested value if fetched directly.
26 |
27 | Of course there is a trade-of, the second example uses little more memory \(for variable `my_id`\).
28 |
29 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/getversion.md:
--------------------------------------------------------------------------------
1 | # getVersion()
2 |
3 |
4 |
5 | Return OpenTX version
6 |
7 | @status current Introduced in 2.0.0, expanded in 2.1.7, radio type strings changed in 2.2.0, OS name added in 2.3.14
8 |
9 | ### Example
10 |
11 | This example also runs in OpenTX versions where the function returned only one value:
12 |
13 | ```lua
14 | local function run(event)
15 | local ver, radio, maj, minor, rev, osname = getVersion()
16 | print("version: "..ver)
17 | if radio then print ("radio: "..radio) end
18 | if maj then print ("maj: "..maj) end
19 | if minor then print ("minor: "..minor) end
20 | if rev then print ("rev: "..rev) end
21 | if osname then print ("osname: "..osname) end
22 | return 1
23 | end
24 |
25 | return { run=run }
26 | ```
27 | Output of the above script in simulator:
28 | ```
29 | version: 2.3.14
30 | radio: taranis-simu
31 | maj: 2
32 | minor: 3
33 | rev: 14
34 | osname: OpenTX
35 | ```
36 |
37 |
38 | ## Parameters
39 |
40 | none
41 |
42 | ## Return value
43 |
44 | * `string` OpenTX version (ie "2.1.5")
45 |
46 | * `multiple` (available since 2.1.7) returns 6 values:
47 | * (string) OpenTX version (ie "2.1.5")
48 | * (string) radio type: `x12s`, `x10`, `x9e`, `x9d+`, `x9d` or `x7`.
49 | If running in simulator the "-simu" is added
50 | * (number) major version (ie 2 if version 2.1.5)
51 | * (number) minor version (ie 1 if version 2.1.5)
52 | * (number) revision number (ie 5 if version 2.1.5)
53 | * (string) OS name (ie "OpenTX" if OpenTX)
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/general/getVersion.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## getVersion()
4 |
5 |
6 |
7 | Return OpenTX version
8 |
9 | @status current Introduced in 2.0.0, expanded in 2.1.7, radio type strings changed in 2.2.0, OS name added in 2.3.14
10 |
11 | ### Example
12 |
13 | This example also runs in OpenTX versions where the function returned only one value:
14 |
15 | ```lua
16 | local function run(event)
17 | local ver, radio, maj, minor, rev, osname = getVersion()
18 | print("version: "..ver)
19 | if radio then print ("radio: "..radio) end
20 | if maj then print ("maj: "..maj) end
21 | if minor then print ("minor: "..minor) end
22 | if rev then print ("rev: "..rev) end
23 | if osname then print ("osname: "..osname) end
24 | return 1
25 | end
26 |
27 | return { run=run }
28 | ```
29 | Output of the above script in simulator:
30 | ```
31 | version: 2.3.14
32 | radio: taranis-simu
33 | maj: 2
34 | minor: 3
35 | rev: 14
36 | osname: OpenTX
37 | ```
38 |
39 |
40 | #### Parameters
41 |
42 | none
43 |
44 | #### Return value
45 |
46 | * `string` OpenTX version (ie "2.1.5")
47 |
48 | * `multiple` (available since 2.1.7) returns 6 values:
49 | * (string) OpenTX version (ie "2.1.5")
50 | * (string) radio type: `x12s`, `x10`, `x9e`, `x9d+`, `x9d` or `x7`.
51 | If running in simulator the "-simu" is added
52 | * (number) major version (ie 2 if version 2.1.5)
53 | * (number) minor version (ie 1 if version 2.1.5)
54 | * (number) revision number (ie 5 if version 2.1.5)
55 | * (string) OS name (ie "OpenTX" if OpenTX)
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/part_v_-_converting_opentx_21_scripts.md:
--------------------------------------------------------------------------------
1 | # Part V - Converting OpenTX 2.1 Scripts
2 |
3 | This section also covers some of the requirements for scripts that are necessary for them to function properly under both OpenTX 2.2.
4 |
5 | ## New features
6 |
7 | * LUA Widgets \(Horus only\)
8 | * LUA Themes \(Horus only\)
9 |
10 | ## Changes
11 |
12 | * Lua Themes and Widgets run in a separate Lua environment. They are isolated from the other Lua environment which runs other scripts. This means they can not share variables, etc... \(Horus only\)
13 | * Function scripts can have a `background()` function defined \(similar to the Telemetry scripts\). It will be called periodically when the switch that activates it is FALSE.
14 | * Horus doesn't support Telemetry scripts.
15 | * Telemetry and Mix scripts maximum file name length \(without extension\) was reduced from 8 to 6 characters.
16 | * Telemetry and Mix scripts maximum number of inputs reduced from 8 to 6
17 |
18 | ### LCD Functions
19 |
20 | * Function `lcd.lock()` was removed.
21 | * New function `lcd.refresh()`.
22 | * Default number alignment changed from RIGHT to LEFT.
23 | * `lcd.getLastPos()` is not available on Horus
24 | * Functions only available on Horus:
25 | * `lcd.drawBitmap()`
26 | * `lcd.setColor()`
27 | * `lcd.RGB()`
28 | * Functions only available on Taranis:
29 | * `lcd.drawPixmap`
30 | * `lcd.drawScreenTitle`
31 | * `lcd.drawCombobox`
32 |
33 | ### General Functions
34 |
35 | * `RIGHT` added
36 | * Rotary encoder events added:
37 | * `EVT_ROT_BREAK`
38 | * `EVT_ROT_LONG`
39 | * `EVT_ROT_LEFT`
40 | * `EVT_ROT_RIGHT`
41 |
42 |
--------------------------------------------------------------------------------
/part_ii_-_opentx_lua_api_programming_guide/run_function_syntax.md:
--------------------------------------------------------------------------------
1 | # Run Function Syntax
2 |
3 | The run function is the function that is periodically called for the lifetime of script execution. Syntax of the run function is different between [mix scripts](../part_i_-_script_type_overview/mix.md) and [telemetry scripts](../part_i_-_script_type_overview/telemetry.md).
4 |
5 | ## Run Function for Mix Scripts
6 |
7 | ```lua
8 | local function ([first input, [second input], …])
9 |
10 | -- if mix has no return values
11 | return
12 |
13 | -- if mix has two return values
14 | return value1, value2
15 |
16 | end
17 | ```
18 |
19 | * **Input parameters:**
20 |
21 | zero or more input values, their names are arbitrary, their meaning and order is defined by the input table. \(see [Input Table Syntax](input_table_syntax.md)\)
22 |
23 | * **Return values:**
24 | * none - if output table is empty \(i.e. script has no output\)
25 |
26 | values
27 | - or -
28 |
29 | * comma separated list of output values, their order and meaning is defined by the output table. \(see [Output Table Syntax](output_table_syntax.md)\)
30 |
31 | ## Run Function for Telemetry Scripts
32 |
33 | ```lua
34 | local function (key-event)
35 | return 0 -- values other than zero will halt the script
36 | end
37 | ```
38 |
39 | * **Input parameters:**
40 |
41 | The _key-event_ parameter indicates which transmitter button has been pressed \(see [Key Events](../part_iii_-_opentx_lua_api_reference/constants/key_events.md)\)
42 |
43 | * **Return values:**
44 |
45 | A non-zero return value will halt the script
46 |
47 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/general-functions-less-than-greater-than-luadoc-begin-general/getfieldinfo.md:
--------------------------------------------------------------------------------
1 | # getFieldInfo(name)
2 |
3 |
4 |
5 | Return detailed information about field (source)
6 |
7 | The list of valid sources is available:
8 |
9 | | OpenTX Version | Radio |
10 | |----------------|-------|
11 | | 2.0 | [all](http://downloads-20.open-tx.org/firmware/lua_fields.txt) |
12 | | 2.1 | [X9D and X9D+](http://downloads-21.open-tx.org/firmware/lua_fields_taranis.txt), [X9E](http://downloads-21.open-tx.org/firmware/lua_fields_taranis_x9e.txt) |
13 | | 2.2 | [X9D and X9D+](http://downloads.open-tx.org/2.2/release/firmware/lua_fields_x9d.txt), [X9E](http://downloads.open-tx.org/2.2/release/firmware/lua_fields_x9e.txt), [Horus](http://downloads.open-tx.org/2.2/release/firmware/lua_fields_x12s.txt) |
14 | | 2.3 | [X9D and X9D+](http://downloads.open-tx.org/2.3/release/firmware/lua_fields_x9d.txt), [X9E](http://downloads.open-tx.org/2.3/release/firmware/lua_fields_x9e.txt), [X7](http://downloads.open-tx.org/2.3/release/firmware/lua_fields_x7.txt), [Horus](http://downloads.open-tx.org/2.3/release/firmware/lua_fields_x12s.txt) |
15 |
16 | @status current Introduced in 2.0.8, 'unit' field added in 2.2.0
17 |
18 |
19 | ## Parameters
20 |
21 | * `name` (string) name of the field
22 |
23 |
24 |
25 | ## Return value
26 |
27 | * `table` information about requested field, table elements:
28 | * `id` (number) field identifier
29 | * `name` (string) field name
30 | * `desc` (string) field description
31 | * 'unit' (number) unit identifier [Full list](../appendix/units.html)
32 |
33 | * `nil` the requested field was not found
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/general/getFieldInfo.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## getFieldInfo(name)
4 |
5 |
6 |
7 | Return detailed information about field (source)
8 |
9 | The list of valid sources is available:
10 |
11 | | OpenTX Version | Radio |
12 | |----------------|-------|
13 | | 2.0 | [all](http://downloads-20.open-tx.org/firmware/lua_fields.txt) |
14 | | 2.1 | [X9D and X9D+](http://downloads-21.open-tx.org/firmware/lua_fields_taranis.txt), [X9E](http://downloads-21.open-tx.org/firmware/lua_fields_taranis_x9e.txt) |
15 | | 2.2 | [X9D and X9D+](http://downloads.open-tx.org/2.2/release/firmware/lua_fields_x9d.txt), [X9E](http://downloads.open-tx.org/2.2/release/firmware/lua_fields_x9e.txt), [Horus](http://downloads.open-tx.org/2.2/release/firmware/lua_fields_x12s.txt) |
16 | | 2.3 | [X9D and X9D+](http://downloads.open-tx.org/2.3/release/firmware/lua_fields_x9d.txt), [X9E](http://downloads.open-tx.org/2.3/release/firmware/lua_fields_x9e.txt), [X7](http://downloads.open-tx.org/2.3/release/firmware/lua_fields_x7.txt), [Horus](http://downloads.open-tx.org/2.3/release/firmware/lua_fields_x12s.txt) |
17 |
18 | @status current Introduced in 2.0.8, 'unit' field added in 2.2.0
19 |
20 |
21 | #### Parameters
22 |
23 | * `name` (string) name of the field
24 |
25 |
26 |
27 | #### Return value
28 |
29 | * `table` information about requested field, table elements:
30 | * `id` (number) field identifier
31 | * `name` (string) field name
32 | * `desc` (string) field description
33 | * 'unit' (number) unit identifier [Full list](../appendix/units.html)
34 |
35 | * `nil` the requested field was not found
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/handling_gps_sensor_data.md:
--------------------------------------------------------------------------------
1 | # Handling GPS Sensor data
2 |
3 | #####Overview
4 |
5 | With OpenTx 2.2 it is possible to have multiple GPS sensors, each with their own set of telemetry values which may have user-assigned names.
6 |
7 | Value names are case sensitive and may include some or all of the following:
8 | - GPS (latitude and longitude as a lua table containing [lat] and [lng])
9 | - GSpd (speed in knots)
10 | - GAlt (altitude in meters)
11 | - Date (gps date converted to local time as a lua table containing [year] [mon] [day] [hour] [min] [sec])
12 | - Hdg (heading in degrees true)
13 |
14 | This example demonstrates getting latitude and longitude from a sensor with the default name of 'GPS'
15 |
16 | ```lua
17 | local gpsValue = "unknown"
18 |
19 | local function rnd(v,d)
20 | if d then
21 | return math.floor((v*10^d)+0.5)/(10^d)
22 | else
23 | return math.floor(v+0.5)
24 | end
25 | end
26 |
27 | local function getTelemetryId(name)
28 | field = getFieldInfo(name)
29 | if field then
30 | return field.id
31 | else
32 | return -1
33 | end
34 | end
35 |
36 | local function init()
37 | gpsId = getTelemetryId("GPS")
38 | end
39 |
40 | local function background()
41 | gpsLatLon = getValue(gpsId)
42 | if (type(gpsLatLon) == "table") then
43 | gpsValue = rnd(gpsLatLon["lat"],4) .. ", " .. rnd(gpsLatLon["lon"],4)
44 | else
45 | gpsValue = "not currently available"
46 | end
47 | end
48 |
49 | local function run(e)
50 | lcd.clear()
51 | background() -- update current GPS position
52 | lcd.drawText(1,1,"OpenTX 2.2 GPS example",0)
53 | lcd.drawText(1,11,"GPS:", 0)
54 | lcd.drawText(lcd.getLastPos()+2,11,gpsValue,0)
55 | end
56 |
57 | return{init=init,run=run,background=background}
58 | ```
59 |
--------------------------------------------------------------------------------
/input_table_syntax.md:
--------------------------------------------------------------------------------
1 | # Input Table Syntax
2 |
3 | #####Overview
4 |
5 | The input table defines what values are available as input(s) to [mix scripts](mix.md). There are two forms of input table entries.
6 |
7 | * #####SOURCE syntax
8 | ```lua
9 | { "", SOURCE }
10 | ```
11 | SOURCE inputs provide the current value of a selected OpenTX variable. The source must set by the user when the mix script is configured. Source can be any value OpenTX knows about (inputs, channels, telemetry values, switches, custom functions,...).
12 | *Note:* typical range is -1024 thru +1024. Simply divide the input value by 10.24 to interpret as a percentage from -100% to +100%.
13 |
14 | * #####VALUE syntax
15 | ```lua
16 | { "", VALUE, , , }
17 | ```
18 | VALUE inputs provide a constant value that is set by the user when the mix script is configured.
19 | * *name* - maximum length of 8 characters
20 | * *min* - minimum value of -128
21 | * *max* - maximum value of 127
22 | * *default* - must be within the valid range specified
23 |
24 |
25 | * #####Maximum of 6 inputs per script (warning : was 8 in 2.1)
26 |
27 | #####Example using a SOURCE and a VALUE
28 | ```lua
29 | local input =
30 | {
31 | { "Strength", SOURCE}, -- user selects source (typically slider or knob)
32 | { "Interval", VALUE, 0, 100, 0 } -- interval value, default = 0.
33 | }
34 |
35 | local function run(strength, interval)
36 | -- variable strength will contain the current slider value
37 | -- variable interval is set by the user and constant through script lifetime
38 |
39 | -- this script has no return value but may use playFile() to alert user
40 |
41 | return
42 | end
43 |
44 | return {input=input, run=run}
45 | ```
46 |
47 |
--------------------------------------------------------------------------------
/part_iv_-_converting_opentx_20_scripts/handling_gps_sensor_data.md:
--------------------------------------------------------------------------------
1 | # Handling GPS Sensor data
2 |
3 | ## Overview
4 |
5 | With OpenTx 2.2 it is possible to have multiple GPS sensors, each with their own set of telemetry values which may have user-assigned names.
6 |
7 | Value names are case sensitive and may include some or all of the following:
8 |
9 | * GPS \(latitude and longitude as a lua table containing \[lat\] and \[lng\]\)
10 | * GSpd \(speed in knots\)
11 | * GAlt \(altitude in meters\)
12 | * Date \(gps date converted to local time as a lua table containing \[year\] \[mon\] \[day\] \[hour\] \[min\] \[sec\]\)
13 | * Hdg \(heading in degrees true\)
14 |
15 | This example demonstrates getting latitude and longitude from a sensor with the default name of 'GPS'
16 |
17 | ```lua
18 | local gpsValue = "unknown"
19 |
20 | local function rnd(v,d)
21 | if d then
22 | return math.floor((v*10^d)+0.5)/(10^d)
23 | else
24 | return math.floor(v+0.5)
25 | end
26 | end
27 |
28 | local function getTelemetryId(name)
29 | field = getFieldInfo(name)
30 | if field then
31 | return field.id
32 | else
33 | return -1
34 | end
35 | end
36 |
37 | local function init()
38 | gpsId = getTelemetryId("GPS")
39 | end
40 |
41 | local function background()
42 | gpsLatLon = getValue(gpsId)
43 | if (type(gpsLatLon) == "table") then
44 | gpsValue = rnd(gpsLatLon["lat"],4) .. ", " .. rnd(gpsLatLon["lon"],4)
45 | else
46 | gpsValue = "not currently available"
47 | end
48 | end
49 |
50 | local function run(e)
51 | lcd.clear()
52 | background() -- update current GPS position
53 | lcd.drawText(1,1,"OpenTX 2.2 GPS example",0)
54 | lcd.drawText(1,11,"GPS:", 0)
55 | lcd.drawText(lcd.getLastPos()+2,11,gpsValue,0)
56 | end
57 |
58 | return{init=init,run=run,background=background}
59 | ```
60 |
61 |
--------------------------------------------------------------------------------
/part_ii_-_opentx_lua_api_programming_guide/input_table_syntax.md:
--------------------------------------------------------------------------------
1 | # Input Table Syntax
2 |
3 | ## Overview
4 |
5 | The input table defines what values are available as input\(s\) to [mix scripts](../part_i_-_script_type_overview/mix.md). There are two forms of input table entries.
6 |
7 | * **SOURCE syntax**
8 |
9 | ```lua
10 | { "", SOURCE }
11 | ```
12 |
13 | SOURCE inputs provide the current value of a selected OpenTX variable. The source must set by the user when the mix script is configured. Source can be any value OpenTX knows about \(inputs, channels, telemetry values, switches, custom functions,...\).
14 | _Note:_ typical range is -1024 thru +1024. Simply divide the input value by 10.24 to interpret as a percentage from -100% to +100%.
15 |
16 | * **VALUE syntax**
17 |
18 | ```lua
19 | { "", VALUE, , , }
20 | ```
21 |
22 | VALUE inputs provide a constant value that is set by the user when the mix script is configured.
23 |
24 | * _name_ - maximum length of 8 characters
25 | * _min_ - minimum value of -128
26 | * _max_ - maximum value of 127
27 | * _default_ - must be within the valid range specified
28 |
29 | * **Maximum of 6 inputs per script \(warning : was 8 in 2.1\)**
30 |
31 | ## Example using a SOURCE and a VALUE
32 |
33 | ```lua
34 | local input =
35 | {
36 | { "Strength", SOURCE}, -- user selects source (typically slider or knob)
37 | { "Interval", VALUE, 0, 100, 0 } -- interval value, default = 0.
38 | }
39 |
40 | local function run(strength, interval)
41 | -- variable strength will contain the current slider value
42 | -- variable interval is set by the user and constant through script lifetime
43 |
44 | -- this script has no return value but may use playFile() to alert user
45 |
46 | return
47 | end
48 |
49 | return {input=input, run=run}
50 | ```
51 |
52 |
--------------------------------------------------------------------------------
/appendix/units.md:
--------------------------------------------------------------------------------
1 | # OpenTx 2.3 Units reference
2 |
3 | | Index | Unit | Defined as |
4 | | --- | --- |--- |
5 | | 0 | Raw unit (no unit) | UNIT_RAW |
6 | | 1 | Volts | UNIT_VOLTS |
7 | | 2 | Amps | UNIT_AMPS |
8 | | 3 | Milliamps | UNIT_MILLIAMPS |
9 | | 4 | Knots | UNIT_KTS |
10 | | 5 | Meters per Second | UNIT_METERS_PER_SECOND |
11 | | 6 | Feet per Second | UNIT_FEET_PER_SECOND |
12 | | 7 | Kilometers per Hour| UNIT_KMH |
13 | | 8 | Miles per Hour | UNIT_MPH |
14 | | 9 | Meters | UNIT_METERS |
15 | | 10 | Feet | UNIT_FEET |
16 | | 11 | Degrees Celsius | UNIT_CELSIUS |
17 | | 12 | Degrees Fahrenheit | UNIT_FAHRENHEIT |
18 | | 13 | Percent | UNIT_PERCENT |
19 | | 14 | Milliamp Hour | UNIT_MAH |
20 | | 15 | Watts | UNIT_WATTS |
21 | | 16 | Milliwatts | UNIT_MILLIWATTS |
22 | | 17 | dB | UNIT_DB |
23 | | 18 | RPM | UNIT_RPMS |
24 | | 19 | G | UNIT_G |
25 | | 20 | Degrees | UNIT_DEGREE |
26 | | 21 | Radians | UNIT_RADIANS |
27 | | 22 | Milliliters | UNIT_MILLILITERS |
28 | | 23 | Fluid Ounces | UNIT_FLOZ |
29 | | 24 | Ml per minute | UNIT_MILLILITERS_PER_MINUTE |
30 | | 35 | Hours | UNIT_HOURS |
31 | | 36 | Minutes | UNIT_MINUTES |
32 | | 37 | Seconds | UNIT_SECONDS |
33 | | 38 | Virtual unit | UNIT_CELLS |
34 | | 39 | Virtual unit | UNIT_DATETIME |
35 | | 40 | Virtual unit | UNIT_GPS |
36 | | 41 | Virtual unit | UNIT_BITFIELD |
37 | | 42 | Virtual unit | UNIT_TEXT |
38 |
--------------------------------------------------------------------------------
/lcd/lcd_functions-overview.md:
--------------------------------------------------------------------------------
1 | # Lcd Functions Overview
2 |
3 | ##### Description
4 |
5 | Lcd functions allow scripts to interact with the transmitter display. This access is limited to the 'run' functions of One-Time and Telemetry scripts. Widget scripts on the Horus (X10 and X12S) can make use of the lcd functions as well.
6 |
7 | ##### Notes:
8 |
9 | The run function is periodically called when the screen is visible. In OpenTX 2.0 each invocation starts with a blank screen (unless lcd.lock() is used). Under OpenTX 2.1 screen state is always persisted across calls to the run function. **Many scripts originally written for OpenTX 2.0 require a call to lcd.clear() at the beginning of their run function in order to display properly under 2.1 and 2.2.**
10 |
11 | Many of the lcd functions accept parameters named *flags* and *patterns*. The names and their meanings are described below.
12 |
13 | #### Flags Constants
14 |
15 | |Name|Description|Version|Notes|
16 | |---|---|---|---|
17 | |0|normal font, default precision for numeric|||
18 | |DBLSIZE|double size font|||
19 | |MIDSIZE|mid sized font|||
20 | |SMLSIZE|small font|||
21 | |INVERS|inverted display|||
22 | |BLINK|blinking text|||
23 | |XXLSIZE|jumbo font|2.0.6||
24 | |LEFT|left justify|2.0.6| Default for most functions not related to bitmaps|
25 | |RIGHT|right justify|||
26 | |PREC1|single decimal place|||
27 | |PREC2|two decimal places|||
28 | |GREY_DEFAULT|grey fill|||
29 | |TIMEHOUR|dislay hours||Only for drawTimer|
30 |
31 | #### Patterns Constants
32 |
33 | |Name|Description|
34 | |---|---|
35 | |FORCE|pixels will be black|
36 | |ERASE|pixels will be white|
37 | |DOTTED|lines will appear dotted|
38 |
39 | #### Screen Constants
40 |
41 | |Name|Description|
42 | |---|---|
43 | |LCD_W|width in pixels|
44 | |LCD_H|height in pixels|
45 |
46 | #### Screen Information
47 |
48 | | Radio | LCD_W | LCD_H | Colours |
49 | | --- | --- | --- | --- |
50 | | X7 | 128 | 64 | 1 bit |
51 | | X9D | 212 | 64 | 4 bit |
52 | | X9D+ | 212 | 64 | 4 bit |
53 | | X9E | 212 | 64 | 4 bit |
54 | | X10 | 480 | 272 | RGB565 |
55 | | X12S | 480 | 272 | RGB565 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/part_iii_-_opentx_lua_api_reference/lcd-functions-less-than-greater-than-luadoc-begin-lcd/lcd_functions-overview.md:
--------------------------------------------------------------------------------
1 | # Lcd Functions Overview
2 |
3 | ### Description
4 |
5 | Lcd functions allow scripts to interact with the transmitter display. This access is limited to the 'run' functions of One-Time and Telemetry scripts. Widget scripts on the Horus \(X10 and X12S\) can make use of the lcd functions as well.
6 |
7 | ### Notes:
8 |
9 | The run function is periodically called when the screen is visible. In OpenTX 2.0 each invocation starts with a blank screen \(unless lcd.lock\(\) is used\). Under OpenTX 2.1 screen state is always persisted across calls to the run function. **Many scripts originally written for OpenTX 2.0 require a call to lcd.clear\(\) at the beginning of their run function in order to display properly under 2.1 and 2.2.**
10 |
11 | Many of the lcd functions accept parameters named _flags_ and _patterns_. The names and their meanings are described below.
12 |
13 | ## Flags Constants
14 |
15 | | Name | Description | Version | Notes |
16 | | :--- | :--- | :--- | :--- |
17 | | 0 | normal font, default precision for numeric | | |
18 | | DBLSIZE | double size font | | |
19 | | MIDSIZE | mid sized font | | |
20 | | SMLSIZE | small font | | |
21 | | INVERS | inverted display | | |
22 | | BLINK | blinking text | | |
23 | | XXLSIZE | jumbo font | 2.0.6 | |
24 | | LEFT | left justify | 2.0.6 | Default for most functions not related to bitmaps |
25 | | RIGHT | right justify | | |
26 | | PREC1 | single decimal place | | |
27 | | PREC2 | two decimal places | | |
28 | | GREY\_DEFAULT | grey fill | | |
29 | | TIMEHOUR | dislay hours | | Only for drawTimer |
30 |
31 | ## Patterns Constants
32 |
33 | | Name | Description |
34 | | :--- | :--- |
35 | | FORCE | pixels will be black |
36 | | ERASE | pixels will be white |
37 | | DOTTED | lines will appear dotted |
38 |
39 | ## Screen Constants
40 |
41 | | Name | Description |
42 | | :--- | :--- |
43 | | LCD\_W | width in pixels |
44 | | LCD\_H | height in pixels |
45 |
46 | ## Screen Information
47 |
48 | | Radio | LCD\_W | LCD\_H | Colours |
49 | | :--- | :--- | :--- | :--- |
50 | | X7 | 128 | 64 | 1 bit |
51 | | X9D | 212 | 64 | 4 bit |
52 | | X9D+ | 212 | 64 | 4 bit |
53 | | X9E | 212 | 64 | 4 bit |
54 | | X10 | 480 | 272 | RGB565 |
55 | | X12S | 480 | 272 | RGB565 |
56 |
57 |
--------------------------------------------------------------------------------
/telemetry.md:
--------------------------------------------------------------------------------
1 | ##Telemetry Scripts
2 |
3 | ## General description
4 |
5 | Telemetry scripts are used for building customized screens. Each model can have up to three active scripts as configured on the model's telemetry configuration page. The same script can be assigned to multiple models.
6 |
7 | ## File Location
8 |
9 | Scripts are located on the SD card in the folder /SCRIPTS/TELEMETRY/<*name*>.lua. File name length (without extension) **must be 6 characters or less** (this limit was 8 characters in OpenTX 2.1).
10 |
11 | ## Lifetime of telemetry script
12 |
13 | Telemetry scripts are started when the model is loaded.
14 |
15 | * script init function is called
16 | * script background function is periodically called when custom telemetry screen is **not visible**. *Notice*:
17 | * In OpenTX 2.0 this function is **not called** when the custom telemetry screen is visible.
18 | * Starting from OpenTX 2.1 this function is **always called** no matter if the custom screen is visible or not.
19 | * script run function is periodically called when custom telemetry screen is **visible**
20 | * script is stopped and disabled if it misbehaves (too long runtime, error in code, low memory)
21 | * all telemetry scripts are stopped while one-time script is running (see Lua One-time scripts)
22 |
23 | ## Script interface definition
24 |
25 | Every script must include a return statement at the end, that defines its interface to the rest of OpenTX code. This statement defines:
26 | * script **init** function *(optional)*
27 | * script **background** function
28 | * script **run** function
29 |
30 | ### Example (interface only):
31 |
32 | ```lua
33 | local function init_func()
34 | -- init_func is called once when model is loaded
35 | end
36 |
37 | local function bg_func()
38 | -- bg_func is called periodically (always, the screen visibility does not matter)
39 | end
40 |
41 | local function run_func(event)
42 | -- run_func is called periodically only when screen is visible
43 | end
44 |
45 | return { run=run_func, background=bg_func, init=init_func }
46 | ```
47 |
48 | ### Notes:
49 |
50 | * `init_func()` function is called once when script is loaded and begins execution.
51 |
52 | * `bg_func()` is called periodically, the screen visibility does not matter.
53 |
54 | * `run_func(event)` function is called periodically when custom telemetry screen is visible. The `event` parameter indicates which transmitter button has been pressed (see [Key Events](key_events.md)). This is the time when the script has full control of the LCD screen and keys and should draw something on the screen.
55 |
56 |
57 |
--------------------------------------------------------------------------------