LUA on ersky9x

erskyTx runs on many radios and upgrade boards
ersky9x was a port of er9x for use on the sky9x board.
ReSt
Posts: 1581
Joined: Tue Dec 27, 2011 11:34 pm
Country: -

Re: LUA on ersky9x

Post by ReSt »

I assume at least easier than with LUA

Reinhard

User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: LUA on ersky9x

Post by MikeB »

I'm starting from tiny basic!

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
gizmatron
Posts: 40
Joined: Fri Jun 27, 2014 6:35 am
Country: France
Location: somewhere on the limits

Re: LUA on ersky9x

Post by gizmatron »

well at least basic is a language i once studied and programmed in
User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: LUA on ersky9x

Post by MikeB »

I've made quite a lot of progress with a "tiny" script language, testing it out on a PC. It is a bit like "tiny basic", but has some "improvements".
It doesn't use line numbers, but uses lables. Variables are 32-bit integers, either individual or arrays, and you have byte arrays as well.
It is fairly simple, but that might make it easier to understand and use.

The next step is to include it in ersky9x and see if it works OK there.
I've started on a document that describes how it works.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: LUA on ersky9x

Post by jhsa »

Thank you Mike, You made me interested in this and I am looking forward to learn it.. I am sure that has been quite a lot of work for you. I hope you enjoy developing it at least as much as we will enjoy using and testing it..

Thank you so much for all you do..

João

Sent from my thor using Tapatalk

My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW

flybabo
Posts: 143
Joined: Wed May 16, 2012 11:41 pm
Country: United States
Location: SF Bay Area, CA

Re: LUA on ersky9x

Post by flybabo »

Mike, do you believe that the ersky9x community has enough developers who will write, test and deploy the useful scripts written in "tiny" BASIC?
If I had time, I would implement thin C++ APIs for the position independent compiled executable that can be loaded from an SD card and run from RAM.
LUA-to-C translator may be used to translate existing LUA scripts.
User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: LUA on ersky9x

Post by MikeB »

I don't know if others will write scripts. My thought is a number of "enhancement" requests might be satisfied with a script, so avoiding a change to ersky9x itself.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: LUA on ersky9x

Post by MikeB »

flybabo wrote: Fri Jun 23, 2017 7:52 pmIf I had time, I would implement thin C++ APIs for the position independent compiled executable that can be loaded from an SD card and run from RAM.
The danger with that approach is the loaded code may be able to randomly access all of memory and so possibly cause the radio to malfunction and lose control of the model. The script approach should keep the main code and RAM protected.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
Hertz
Posts: 72
Joined: Wed Sep 30, 2015 2:14 pm
Country: -

Re: LUA on ersky9x

Post by Hertz »

Surely there will be people who will write necessary scripts for Er9x even if it uses it's own scripting language.
Mike, is there some test version which I could look at? I could start playing with it and implementing Lua scripts in "TInyBasic" as I have a few vacation days coming.
rsilk49
Posts: 140
Joined: Wed Oct 26, 2016 10:33 am
Country: United Kingdom

Re: LUA on ersky9x

Post by rsilk49 »

Hi Mike,
Before you give up on Lua, have you seen this? I came across this "Lua tiny RAM" patch to reduce RAM even further in eLua. I don't know if it is applicable to your implementation . . .

http://www.eluaproject.net/doc/v0.9/en_arch_ltr.html

The benefit of going with Lua, should be that we might be able to leverage some of the many scripts already written for the Taranis. And who knows, in the not too distant future, the 9XR platform might even be upgraded by Turnigy with a more powerful processor with more RAM :)
S500 + Pixhawk 1 clone + Mauch PM + C&T Telemetry adapter + 9XR-Pro (Taranis gimbals)/XJT/X8R
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: LUA on ersky9x

Post by jhsa »

In my opinion, if Mike finds something lighter and/or better than LUA that runs on the current stock processors, this would be the way to go.. Not everybody will upgrade the processors on their radios. Most of the people can't do it..
There will be always someone that will write / adapt scripts for the new implementation.. :)

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
rsilk49
Posts: 140
Joined: Wed Oct 26, 2016 10:33 am
Country: United Kingdom

Re: LUA on ersky9x

Post by rsilk49 »

jhsa wrote: Wed Jun 28, 2017 4:57 pm In my opinion, if Mike finds something lighter and/or better than LUA that runs on the current stock processors, this would be the way to go.. Not everybody will upgrade the processors on their radios. Most of the people can't do it..
There will be always someone that will write / adapt scripts for the new implementation.. :)

João
I completely agree with you that whatever scripting language does get implemented, it must run on the current stock processor. I see the significant advantage of Lua is that scripts already exist for the Taranis. If these can be repurposed, that would be better than converting or writing new scripts from scratch. But if Lua cannot fit, even with the LTR patch, and/or the Taranis scripts are not suitable, then the alternative will be required.
S500 + Pixhawk 1 clone + Mauch PM + C&T Telemetry adapter + 9XR-Pro (Taranis gimbals)/XJT/X8R
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: LUA on ersky9x

Post by jhsa »

I believe that the most important is that they do what is needed using as less RAM as possible.. The scripts being easy to understand and write, would be a nice bonus :)

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: LUA on ersky9x

Post by MikeB »

rsilk49 wrote: Wed Jun 28, 2017 4:40 pmBefore you give up on Lua, have you seen this? I came across this "Lua tiny RAM" patch to reduce RAM even further in eLua.
That is already incorporated in standard LUA I believe, and is certainly in the implementation I'm using.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: LUA on ersky9x

Post by MikeB »

I've now got something actually working using my own script language. It is working as a standalone script only so far, but does mean I have the functionality operating.
The script is read in and "compiled" into tokens that are then interpreted to run the script. This significantly reduces the amount of RAM needed for a script. I'm actually testing this on a SKY board with ony 256K of flash and 48K of RAM.
This is the test script I'm using:

Code: Select all

drawclear()
drawtext(20, 16, "Hello")
let value = getvalue( 3 )
drawnumber(50, 24, value)
let value = getvalue( "Batt" )
drawnumber(50, 32, value)
if Event = EVT_EXIT_BREAK then goto done
if Event = EVT_BTN_BREAK then goto done
stop
done:
finish
drawclear() just clears the display.
drawtext() puts the text on the display at 10 pixels in from the left and 16 down from the top.
getvalue(3) fetches the current value of the right horizontal stick, and this is stored on the variable "value". Variables are mostly 32-bit, signed integers.
drawnumber() puts the number on the display, the x-y position is the rightmost position of the number.
getvalue("Batt") fetches the named telemetry value, in this case the radio battery. drawnumber() is again used to display this. I still need to add "attributes" so it may be displayed with 1 ot 2 decimal places, or be highlighted.
Every time the script runs, the variable "Event" is set to th "standard" button press event, so either of the next two lines detect a specific button operation, and jump to the label "done".
The "stop" instruction indicates this run of the script has ended, but the script should be run again.
The "finish" instruction indicated the script is complete and should not run again, indeed any RAM it is using is then available for another script.

This script uses about 110 bytes of RAM for the loaded code, and just 8 bytes of RAM for the two variables.
The variable "value" is not actually needed, I could have used:
drawnumber(50, 32, getvalue( "Batt" ))
but I was just testing it was handling the variable correctly.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: LUA on ersky9x

Post by jhsa »

It doesn't look so difficult.. So, what that basically does is display the value from a stick and the radio Battery?
I am not understanding the "EVT_EXIT_BREAK". Does this stop the script if you press EXIT??

If more complicated scripts end up running well on the skyboard, we'll be all laughin' :D

Thanks for all..

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
Hertz
Posts: 72
Joined: Wed Sep 30, 2015 2:14 pm
Country: -

Re: LUA on ersky9x

Post by Hertz »

MikeB, are you working on making it feature-complete when comparing to current LUA scripts or just playing with the language so far?
It would be nice to rewrite existing Lua scripts to some pseudo-code and then make your language and this pseudo-code "meet" each other.
Please tell us if you need some help with implementation or testing, e.g. implementing parts of the scripting language, language constructs, intrinsic functions etc.
As a ErSky9x and 9xtreme user I'd be happy to help and make SmartPort-based features a reality :-)
User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: LUA on ersky9x

Post by MikeB »

Since this new script language is not LUA, I've started a new thread (viewtopic.php?f=7&t=10325#p129830) for it.
I've quickly put together a bit of a description of what it is, posted on that thread.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: LUA on ersky9x

Post by jhsa »

Thank you..

João

Sent from my thor using Tapatalk

My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW

Post Reply

Return to “erskyTx (was ersky9x)”