Writing Lua Widgets for Horus

openTx has introduced a range of new features, ideas and bling. It is fast becoming the firmware of choice for many users. openTx will run on ALL current hardware platforms, including the gruvin9x and sky9x boards. Work has already started to support the new FrSky X9D radio!
Post Reply
tonnie78
Posts: 123
Joined: Mon Jan 12, 2015 9:33 am
Country: -

Writing Lua Widgets for Horus

Post by tonnie78 »

I want to start creating Widgets for my Horus X10S

Is there a place where I can find some basic information about Lua scripting?

User avatar
3djc
Posts: 77
Joined: Mon Feb 22, 2016 7:15 am
Country: -

Re: Writing Lua Widgets for Horus

Post by 3djc »

There are some widgets writen in LUA to understand the basic structure. Details on available functions is here : https://legacy.gitbook.com/book/opentx/ ... de/details
tonnie78
Posts: 123
Joined: Mon Jan 12, 2015 9:33 am
Country: -

Re: Writing Lua Widgets for Horus

Post by tonnie78 »

Thanks 3djc.

Just what I was looking for!!!
tonnie78
Posts: 123
Joined: Mon Jan 12, 2015 9:33 am
Country: -

Re: Writing Lua Widgets for Horus

Post by tonnie78 »

I am trying to create the following.

I want to display a map of our field on the screen of my FrSky Horus.
On top of this image I want to have an Icon of an Airplane showing my location on this map based on GPS data from my plane.

So far I managed to get the map image displayed and I can draw lines ontop of this image.
Can someone assist me in getting the GPS telemetry data into the Lua script?

I need the actual GPS Latitude and Longitude and the heading.

The final result should not only show me where I am but also warn me when I cross the red line, because then I am entering a now flight zone.
I already found a solution for calculating when you cross the line.
I have everything functional in an Excel sheet, but I am completely new to Lua and writing Widgets for OpenTx. Also a lot of information in the OpenTx 2.2 Lua manual is based on the Taranis monochrome screen.

By the way is it possible to draw thicker lines with the function drawline, or should I keep doing as I did, draw multiple lines next to each other?


GPS Widget.jpg
User avatar
3djc
Posts: 77
Joined: Mon Feb 22, 2016 7:15 am
Country: -

Re: Writing Lua Widgets for Horus

Post by 3djc »


tonnie78
Posts: 123
Joined: Mon Jan 12, 2015 9:33 am
Country: -

Re: Writing Lua Widgets for Horus

Post by tonnie78 »

Thanks for all the help.

I have my first Widget working. There are still some small issues but it works!!!

https://youtu.be/rxGZqBGFMuc
tonnie78
Posts: 123
Joined: Mon Jan 12, 2015 9:33 am
Country: -

Re: Writing Lua Widgets for Horus

Post by tonnie78 »

First inflight test with no flight zone warning

https://youtu.be/kybwabBwatA
tonnie78
Posts: 123
Joined: Mon Jan 12, 2015 9:33 am
Country: -

Re: Writing Lua Widgets for Horus

Post by tonnie78 »

Have changed the code today.

Update time was very poor.
Around once a second. Now with chanced code its more then 15 times a second.

Will do testflight tomorrow
tonnie78
Posts: 123
Joined: Mon Jan 12, 2015 9:33 am
Country: -

Re: Writing Lua Widgets for Horus

Post by tonnie78 »

Update time is great now. Very happy with the results.
ozphoenix
Posts: 404
Joined: Fri Oct 28, 2016 11:51 am
Country: Australia

Re: Writing Lua Widgets for Horus

Post by ozphoenix »

Newbie to OpenTX 2.2.3, now have it on my FrSky X12S (I have been using Ersk9x on my 9XRPro and my QX7) -- I use MLVSS in my larger planes and have an audio special function to audio/read out flight pack voltage -- that works ok for me. I also use a widget (on FrSKy X12S) to display pack voltage and remaining percentage -- that works ok for me, also. But, how do I have an audio/read out of the PERCENTAGE remaining figure (not the voltage) of flying power? I usually like to start to make my landing approaches at 20% remaining, to give a margin for go-arounds, if necessary.
I can only see how to display remaining % in the widget, not play it as a value.
In ErSky9x, without LUA or any other programming, I could read the pack voltage telemetry data, feed it to a Global Scaler, offset/deduct the minimum pack voltage I am prepared to fly with and then convert the remaining amount as a percentage amount and audio that out.
I cannot see how to achieve that in OpenTX. I've tried Adding a New Sensor (Custom), I've tried Global Variable Change, I've tried Special Function options, I've tried creating a new Input. To no avail. Can only audio remaining voltage, but not remaining percentage.
Can some of the more experienced OpenTX users enlighten me to the trick (without using LUA scripting) if it exists, please?
TIA
ozphoenix
User avatar
3djc
Posts: 77
Joined: Mon Feb 22, 2016 7:15 am
Country: -

Re: Writing Lua Widgets for Horus

Post by 3djc »

Please do not crosspost your issue, specialy if you ask for non LUA solution in a thread ABOUT LUA ...

3djc
ozphoenix
Posts: 404
Joined: Fri Oct 28, 2016 11:51 am
Country: Australia

Re: Writing Lua Widgets for Horus

Post by ozphoenix »

Thanks for answering my question, over in the other post (even though you have said it probably can't be done easily in OpenTX without using LUA).
sintax69
Posts: 1
Joined: Sun Apr 12, 2020 4:48 am
Country: -

Re: Writing Lua Widgets for Horus

Post by sintax69 »

I have a t16 and im trying to have a string of text file showup in a widget or a picture just trying to store some info on settings etc on the lCD any idea where to start

Post Reply

Return to “openTx”