Code Monkey home page Code Monkey logo

lua-reference-guide's Introduction

OpenTX 2.3 Lua Reference Guide

Join the chat on Discord

Go to https://doc.open-tx.org/opentx-2-3-lua-reference-guide/ for the latest published version of this guide.

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.

Part I of the guide shows how to enable Lua support for Taranis and includes basic examples of each types of script.

Part II is a programming guide that introduces the types of OpenTX Lua scripts and how to use them.

Part III is the OpenTX Lua API Reference

Part IV addresses common issues in converting Lua scripts that were originally written for OpenTX 2.0

Part V addresses common issues in converting Lua scripts that were originally written for OpenTX 2.1

Part VI covers advanced topics with examples

last updated on 2022/05/03 08:34:00 UTC

lua-reference-guide's People

Contributors

3djc avatar bsongis avatar dsbeach avatar jfrickmann avatar kilrah avatar lshems avatar mhotar avatar projectkk2glider avatar raphaelcoeffic avatar rcdiy avatar schwabe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lua-reference-guide's Issues

Improve API texts

Lua API docs (in opentx repository) are mostly done. They now need some attention in the grammar and spelling department.

@dsbeach whenever you have the time and will πŸ˜‰

Reminder to document IO library

OpenTX 2.1.x (after pull opentx/opentx#3011 is merged) has Lua subset of io library implemented with a few differences:

Available functions:

  • io.close()
  • io.seek()
  • io.open()
  • io.read()
  • io.write()

Differences from standard library:

io.open(filename [, mode])

mode only supported mode strings are:

  • "r" read access, file is opened if it exists and read pointer is located at the beginning of file (default)
  • "w" write access, file is opened and truncated (or created if it did not exist)
  • "a" write access, file is opened (or created if it did not exist) and write pointer is located at the end of the file.

Returns file object.

io.seek(fd, offset)

fd file object
offset is always based from the beginning of the file. If offset is bigger than the file size, the pointer is moved to the end of the file.
Other standard seek bases (like "cur", "end") are not supported.

io.read(fd, length)

fd file object
length number of characters to read.

Other read commands (like "_all") are _not supported*.

Return: string, number of characters returned is <= length. If end of file is reached, then empty string is returned.

INAV LUA menu / the horizontal movement of the right stick does not work with Radiomaster TX16S

I can do that with the Radiomaster TX16S
Call up INAV LUA menu with the left stick and scroll up and down within this munu by moving the right stick. Unfortunately it does not work with the right stick to change the values ​​and to leave the menu again. The horizontal movement of the right stick does not work! This is not a problem with the transmitter Jumper T16 and it is possible to change the settings in the INAV LUA menu with the right stick and to exit the menu again.
I tested it with the current openTX-version also with the last nightly-version.

Numbering problem with auto generated content

The comments in the SUMMARY.md file cause the gitbook numbering for chapters to be wrong, example:

3. Part III - OpenTX Lua API Reference

    3.1. Constants
        3.1.1. Key Event Constants

4. General Functions

    4.1. GREY()
    4.2. defaultChannel(stick)
    4.3. defaultStick(channel)

To fix it the delimiters should be at the end of the lines like so:

   * [General Functions](general/general_functions.md) [//]: <> (LUADOC-BEGIN:general)
      * [GREY()](general/GREY.md)
      * [popupInput(title, event, input, min, max)](general/popupInput.md)       [//]: <> (LUADOC-END:general)  
   * [Model Functions](model/model_functions.md) [//]: <> (LUADOC-BEGIN:model)
      * [model.defaultInputs()](model/defaultInputs.md)

A process to generate function documentation from the sources

Original idea came from Bertrand.

We should try to develop a system that allows us to document OpenTX Lua API functions in the source code files (like Doxygen style documentation) and then have a python script that will auto-generate files and their contents in markdown format that will be directly useable in the gitbook.

Other parts of the Lua manual will still be developed in the current way. So the automatic docs generation would only document the https://github.com/opentx/lua-reference-guide/blob/master/part_iii_-_opentx_lua_api_reference.md

So the process would be:

  • write documentation for each Lua exported function in the source code, rigth there where the actual function implementing it is defined. This way we have a better chance to keep the actual function functionality and it's documentation in sync.
  • in-source documentation format is still yet to be decided, possible options are:
    • directly use the markdown
    • use (simplified) Doxygen format
  • when we decide to update the docs (gitbook) we run the custom python script that will:
    • parse lua_api.cpp file from OpenTX repository
    • look for special comment sections that contain documentation
    • parse and format each documentation section and generate a markdown file for each function.
    • script could also generate a subsection of index for generated functions (that goes into SUMMARY.md)

Comments welcome

Add link generation for function names

If a function name (different from the current function) is found in a function documentation, replace it with a link to that function.

Example: in module.setModule() docs, replace reference to module.getModule() with a link syntax [module.getModule()](model/getModule.md)

Only do replace if the actual documentation for that function exists (has been parsed in the current script run).

LCD dimensions appendix

I plan on doing up a list/table for LCD dimensions LCD_W/LCD_H for the radios... if an admin creates a place holder page for me in the appendix I'll add in the contents.. please @RCdiy me when added...

getFieldInfo(name) has invalid link references

Documentation for getFieldInfo(name) references below:

The list of valid sources is available:
for OpenTX 2.0.x at http://downloads-20.open-tx.org/firmware/lua_fields.txt
for OpenTX 2.1.x at http://downloads-21.open-tx.org/firmware/lua_fields.txt (depreciated)
for OpenTX 2.1.x Taranis and Taranis Plus at http://downloads-21.open-tx.org/firmware/lua_fields_taranis.txt
for OpenTX 2.1.x Taranis X9E at http://downloads-21.open-tx.org/firmware/lua_fields_taranis_x9e.txt

The last two links above result in '404 - not found'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.