Lua
OpenTX 2.2 Lua Reference Guide
0.1.
Introduction
0.1.1.
Acknowledgments
0.1.2.
Getting Started
1.
Part I - Script Type Overview
1.1.
Mix Scripts
1.2.
Telemetry Scripts
1.3.
One-Time Scripts
1.4.
Wizard Script
1.5.
Function Scripts
1.6.
Widget Scripts
1.7.
Theme Scripts
2.
Part II - OpenTX Lua API Programming Guide
2.1.
Input Table Syntax
2.2.
Output Table Syntax
2.3.
Init Function Syntax
2.4.
Run Function Syntax
2.5.
Return Statement Syntax
2.6.
Included Lua Libraries
2.6.1.
io Library
2.6.1.1.
io.open()
2.6.1.2.
io.close()
2.6.1.3.
io.read()
2.6.1.4.
io.write()
2.6.1.5.
io.seek()
3.
Part III - OpenTX Lua API Reference
3.1.
Constants
3.1.1.
Key Event Constants
3.2.
General Functions
3.2.1.
GREY()
3.2.2.
crossfireTelemetryPop()
3.2.3.
crossfireTelemetryPush()
3.2.4.
defaultChannel(stick)
3.2.5.
defaultStick(channel)
3.2.6.
getDateTime()
3.2.7.
getFieldInfo(name)
3.2.8.
getFlightMode(mode)
3.2.9.
getGeneralSettings()
3.2.10.
getRAS()
3.2.11.
getRSSI()
3.2.12.
getTime()
3.2.13.
getValue(source)
3.2.14.
getVersion()
3.2.15.
killEvents(key)
3.2.16.
loadScript(file [, mode], [,env])
3.2.17.
playDuration(duration [, hourFormat])
3.2.18.
playFile(name)
3.2.19.
playHaptic(duration, pause [, flags])
3.2.20.
playNumber(value, unit [, attributes])
3.2.21.
playTone(frequency, duration, pause [, flags [, freqIncr]])
3.2.22.
popupConfirmation(title, event)
3.2.23.
popupInput(title, event, input, min, max)
3.2.24.
popupWarning(title, event)
3.2.25.
setTelemetryValue(id, subID, instance, value [, unit [, precision [, name]]])
3.2.26.
sportTelemetryPop()
3.2.27.
sportTelemetryPush()
3.3.
Model Functions
3.3.1.
model.defaultInputs()
3.3.2.
model.deleteInput(input, line)
3.3.3.
model.deleteInputs()
3.3.4.
model.deleteMix(channel, line)
3.3.5.
model.deleteMixes()
3.3.6.
model.getCurve(curve)
3.3.7.
model.getCustomFunction(function)
3.3.8.
model.getGlobalVariable(index [, flight_mode])
3.3.9.
model.getInfo()
3.3.10.
model.getInput(input, line)
3.3.11.
model.getInputsCount(input)
3.3.12.
model.getLogicalSwitch(switch)
3.3.13.
model.getMix(channel, line)
3.3.14.
model.getMixesCount(channel)
3.3.15.
model.getModule(index)
3.3.16.
model.getOutput(index)
3.3.17.
model.getTimer(timer)
3.3.18.
model.insertInput(input, line, value)
3.3.19.
model.insertMix(channel, line, value)
3.3.20.
model.resetTimer(timer)
3.3.21.
model.setCustomFunction(function, value)
3.3.22.
model.setGlobalVariable(index, flight_mode, value)
3.3.23.
model.setInfo(value)
3.3.24.
model.setLogicalSwitch(switch, value)
3.3.25.
model.setModule(index, value)
3.3.26.
model.setOutput(index, value)
3.3.27.
model.setTimer(timer, value)
3.4.
Lcd Functions
3.4.1.
Lcd Functions Overview
3.4.2.
lcd.RGB(r, g, b)
3.4.3.
lcd.clear()
3.4.4.
lcd.drawBitmap(bitmap, x, y [, scale])
3.4.5.
lcd.drawChannel(x, y, source, flags)
3.4.6.
lcd.drawCombobox(x, y, w, list, idx [, flags])
3.4.7.
lcd.drawFilledRectangle(x, y, w, h [, flags])
3.4.8.
lcd.drawGauge(x, y, w, h, fill, maxfill [, flags])
3.4.9.
lcd.drawLine(x1, y1, x2, y2, pattern, flags)
3.4.10.
lcd.drawNumber(x, y, value [, flags])
3.4.11.
lcd.drawPixmap(x, y, name)
3.4.12.
lcd.drawPoint(x, y)
3.4.13.
lcd.drawRectangle(x, y, w, h [, flags [, t]])
3.4.14.
lcd.drawScreenTitle(title, page, pages)
3.4.15.
lcd.drawSource(x, y, source [, flags])
3.4.16.
lcd.drawSwitch(x, y, switch, flags)
3.4.17.
lcd.drawText(x, y, text [, flags])
3.4.18.
lcd.drawTimer(x, y, value [, flags])
3.4.19.
lcd.getLastPos()
3.4.20.
lcd.refresh()
3.4.21.
lcd.setColor(area, color)
3.5.
Bitmap Functions
3.5.1.
Bitmap.getSize(name)
3.5.2.
Bitmap.open(name)
4.
Part IV - Converting OpenTX 2.0 Scripts
4.1.
General Issues
4.2.
Handling GPS Sensor data
4.3.
Handling Lipo Sensor Data
5.
Part V - Converting OpenTX 2.1 Scripts
6.
Part VI - Advanced Topics
6.1.
Lua data sharing across scripts
6.2.
Debugging techniques
Powered by
GitBook
Lua
io.close(<file object>)
The io.close() function is used to close open file.
Parameters
file object
a file object that was returned by the io.open() function.
Return value
none