Lua scripts: blinking lines and aligning text

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
bnwgraaf
Posts: 18
Joined: Sun Sep 03, 2017 7:18 am
Country: -

Lua scripts: blinking lines and aligning text

Post by bnwgraaf »

Hello.

I have just started with the lua scripts. I am not new in programming and scripting, but new to OpenTX Lua scripts.

I am discovering peace by peace.
I am running into 2 issues:

- If I draw a line or rectangle and starts the simulator, the line or rectangle is visible, but is rappidly blinking/flickering.
Is this a simulator problem?

- Is it possible to align text center or right?

User avatar
rcdiy
Posts: 190
Joined: Fri Jul 01, 2016 6:13 am
Country: Canada
Contact:

Re: Lua scripts: blinking lines and aligning text

Post by rcdiy »

bnwgraaf wrote: Tue Sep 12, 2017 10:59 am - If I draw a line or rectangle and starts the simulator, the line or rectangle is visible, but is rappidly blinking/flickering.
Is this a simulator problem?
If you send me your code I'll check.
Tx?
OpenTX version?
- Is it possible to align text center or right?
No

Have you seen this manual?
https://www.gitbook.com/book/opentx/ope ... de/details
RCdiy.ca
Stay Safe & Have Fun
OpenTX Manual http://rcdiy.ca
Paying it forward by sharing my Lua scripts, documentation and videos.
bnwgraaf
Posts: 18
Joined: Sun Sep 03, 2017 7:18 am
Country: -

Re: Lua scripts: blinking lines and aligning text

Post by bnwgraaf »

Hello rcdiy,

Thank you for your answers.
I have seen the reference guide and already used some things of it.

My script gives the flickering lines and rectangles, even if it is the only thing in the script. Do I have placed the code in the wrong place?
I mean, the values will have to be refreshed all the time, but the lines do not....
I have sent the script with only the lines and a rectangle....and in THIS VIDEO you can see what happens in the simulator but also in the screen of my Taranis.

Oh and I am using OpenTX 2.2 on a Taranis X9D Plus.

Another question: If I have a text or value and I replace this text with another text, which is shorter than the last text, than the last part of the previous text stays visible. Do I have to clear the old text in some way, before drawing a new text?
Attachments
lines.lua
(800 Bytes) Downloaded 350 times
rdeanchurch
Posts: 750
Joined: Tue Dec 27, 2011 11:22 pm
Country: United States
Location: Carson City, Nv

Re: Lua scripts: blinking lines and aligning text

Post by rdeanchurch »

I drop a lcd.clear() as the first line in main and the symptom went away.

Don't ask me why, as I have no idea....but it has 'fixed' some of my scripts before.
Dean
OldDmbThms: 1. Takeoff, 2. Crash, 3. Repair, GOTO 1
User avatar
rcdiy
Posts: 190
Joined: Fri Jul 01, 2016 6:13 am
Country: Canada
Contact:

Re: Lua scripts: blinking lines and aligning text

Post by rcdiy »

https://opentx.gitbooks.io/opentx-2-2-l ... rview.html
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.

I suggest reading through the manual. I did but find myself having to read it again on occasion to check for updates. The manual is a work in progress.
RCdiy.ca
Stay Safe & Have Fun
OpenTX Manual http://rcdiy.ca
Paying it forward by sharing my Lua scripts, documentation and videos.

bnwgraaf
Posts: 18
Joined: Sun Sep 03, 2017 7:18 am
Country: -

Re: Lua scripts: blinking lines and aligning text

Post by bnwgraaf »

Thank you both, the lcd.clear() function did the trick for both the flickering lines as for the text which was not overwritten...

No I have made my first telemtry screen (See attachment). Not all the functions do work yet and some values are fake values, just for testing the screen.
I now have to buy/make a APM to FrSky converter to get the fake data also filled with real world values.

But I am very excited about the possibilities with the lua scripts in my Taranis!
Attachments
My Screen
My Screen
User avatar
rcdiy
Posts: 190
Joined: Fri Jul 01, 2016 6:13 am
Country: Canada
Contact:

Re: Lua scripts: blinking lines and aligning text

Post by rcdiy »

There has been talk of having the option to have the Taranis go straight to the Telemetry screen.
https://github.com/opentx/opentx/issues/5156

If that is implemented you may want to have the model name show up on that screen.... Maybe show name and disappear after a few seconds if you don't have space....

That is an awesome screen...

If you are open to sharing that script check out rcdiy.ca
RCdiy.ca
Stay Safe & Have Fun
OpenTX Manual http://rcdiy.ca
Paying it forward by sharing my Lua scripts, documentation and videos.
bnwgraaf
Posts: 18
Joined: Sun Sep 03, 2017 7:18 am
Country: -

Re: Lua scripts: blinking lines and aligning text

Post by bnwgraaf »

In the end I want to share it, but it is not finished at the moment. There are still some things to do.

Do you know how to get the value of the transmitter battery.
I have tried things like:
getValue("Batt")

But the value stays zero.....
rdeanchurch
Posts: 750
Joined: Tue Dec 27, 2011 11:22 pm
Country: United States
Location: Carson City, Nv

Re: Lua scripts: blinking lines and aligning text

Post by rdeanchurch »

I don't think you can. getValue only works on telemetry that shows in the discovered sensors AFAIK.
None of my models show a txVolt or txBt like rxBt.
Seems to be an oversight, might be worth an OpenTx issue.

It might be worth trying "txBt" in a getValue just for laughs, but I don't think it will play.
Dean
OldDmbThms: 1. Takeoff, 2. Crash, 3. Repair, GOTO 1
bnwgraaf
Posts: 18
Joined: Sun Sep 03, 2017 7:18 am
Country: -

Re: Lua scripts: blinking lines and aligning text

Post by bnwgraaf »

That would be a pitty....in the default telemetry screens you can select "batt"....

Verstuurd vanaf mijn A0001 met Tapatalk

User avatar
Kilrah
Posts: 11108
Joined: Sat Feb 18, 2012 6:56 pm
Country: Switzerland

Re: Lua scripts: blinking lines and aligning text

Post by Kilrah »

getValue("tx-voltage")
User avatar
rcdiy
Posts: 190
Joined: Fri Jul 01, 2016 6:13 am
Country: Canada
Contact:

Re: Lua scripts: blinking lines and aligning text

Post by rcdiy »

RCdiy.ca
Stay Safe & Have Fun
OpenTX Manual http://rcdiy.ca
Paying it forward by sharing my Lua scripts, documentation and videos.
bnwgraaf
Posts: 18
Joined: Sun Sep 03, 2017 7:18 am
Country: -

Re: Lua scripts: blinking lines and aligning text

Post by bnwgraaf »

That did the trick! Tnx you both!

Verstuurd vanaf mijn A0001 met Tapatalk


Post Reply

Return to “openTx”