LUA telemetry to percentage with a twist

LUA is here, we all heard that. The question on everyone’s lips is “what can you do with it?” Well, pretty much what you want. So I wanted to do some learning of different possibilities with a new language, so here we go.

Disclaimer

ALWAYS check everything after downloading a script! Do NOT use any scripts to control anything that could cause a crash!

What does this script do?

Quite a lot actually. Like many things I do they tend to grow while doing stuff…

  • Two separate calculators with identical functions
  • Convert (almost) any telemetry sensor’s value to percentage
  • User definable sensor value-range
  • Possibility to use 0-100% or 100-0%
  • Creates LUA control (freely usable switch)
  • Enable – disable alarms
  • LUA Control has freely definable alarm-point
  • Alarm-point is definable to ascending or descending
  • Creates telemetry window for main screen (One per sensor)
  • Telemetry window label is user-definable

This is perfect for example showing fuel or mAh capacity used in percentage. User can choose if the percentage-value is 0% or 100% when assigned range is used.

Examples:

  • Show 0% when 480ml fuel is used
  • Alarm when 10% fuel left
  • Show 100% when 3000mAh capacity is used
  • Alarm when 90% capacity is used

Update 09.08.2016:

  • Form easier to read
  • Added “Enable alarm” option
  • Simple Yes/No option to “Enable alarm” and “Low alarm”
  • Added graph-logo to telemetry window

Github is also updated.

Installation

Event Counter is included in RC-Thoughts Jeti Tools found here. Script can be found from RC-Thoughts github here.

 

 

Settings and usage

After opening the application from “Application” -> “Percentage Display” you are greeted with settings for the first screen.

rc-thoughts_tools_08

Setting up is basically the same way as with any other function in Jeti. First let’s create a suitable label for the value, let’s say we want to make a “Battery left” indicator, where we get 0% when all the mAh is consumed. So, change the label from the default:

rc-thoughts_tools_12

After that it is time to select the sensor. From the “Select sensor” menu choose (for example) the capacity-sensor and set rest of the values to your liking:

rc-thoughts_tools_12

Sensor low value is the sensors value where you want to have 0%, sensor high value is the sensors value where you want to have 100% in display. What this means is that you can choose if you want percentage to go 0-100% OR 100-0% when telemetry sensors value increases or decreases. What this means is total freedom in usage.

Enabling alarm gives you possibility to use the application control (switch C01) as alarm for percentage value. If Low alarm is DISABLED alarm will activate when percentage value gets OVER the value set in Alarm point value. If on the other hand Low alarm is ENABLED the alarm will go off when percentage value goes UNDER the value set in Alarm point value.

Using the percentage alarm for example in voice announcements is easy, just choose the corrsponding “PercentageCtrl” switch from “Apps” in switch selection dialog:

rc-thoughts_tools_104

Application also offers a possibility to get the percentage to main screen. Simply go to your “Timers/Sensors” -> “Displayed Telemetry” and choose the telemetry with the name you gave as label earlier:

percentage_011

This will give you a double-size telemetry windows on your main screen in a position of your choosing:

rc-thoughts_tools_29

Windos shows “-” if transmitter does not get any telemetry, this function is on par with the built-in displays of Jeti transmitter. If no sensor is configured the windows shows 0%.

How it works

percentage_016  percentage_017

I have used 72mAh and therefor have 28% battery left, in the second picture more mAh is consumed and percentage is dropping.

Usage is really that simple :)

No values from sensor, model not powered?

The script is made to behave like the “real” telemetry-windows, so it looks like the others when the model is not powered:

percentage_022

So, there you go, something useful to do with LUA.

Some thoughts on LUA

Coding LUA when knowing nothing from LUA took some time and coffee. Also a lot of trial & error. I also emailed Martin at Jetimodel once but to my defence I found the solution before he replied :)

One more thing I learned is that ALL testing and coding has to be done in the way that there is no possibility for the model to do anything. Unhook the motor, take off blades/propellers etc. I learned that it really is possible to make a LUA script that freezes the transmitter…

I’m positive this script is not done “correctly” when we are talking “the right way to make code” but it’s my second LUA-script and I’m learning. If you make it better please send me the improved version :)

Now, get out and fly/drive something!

2 thoughts on “LUA telemetry to percentage with a twist

  1. Hi,

    There is a very nice LiPo monitor script running on the Taranis, you can find it there : http://frskytaranis.forumactif.org/t2800-lua-download-un-testeur-de-batterie-sur-la-radio

    It can be certainly adapted for Jeti Lua if values for each LiPo cells are available with Jeti telemetry.

    Regards, Marco.

Leave a Reply

Your email address will not be published. Required fields are marked *