Script Language
- MikeB
- 9x Developer
- Posts: 17993
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Script Language
I'm developing a script language for use in ersky9x. This thread is for discussions on the language, and I'll update this post with the latest documentation.
Mike.
Here is an initial document that tries to describe the language. Hopefully the language will improve as the development proceeds. A program to run on a PC (Windows) that runs scripts and simulates the display. Copy this .exe into the directory in which you have installed eepe/eepskye (it needs the QT dll files.
Mike.
Here is an initial document that tries to describe the language. Hopefully the language will improve as the development proceeds. A program to run on a PC (Windows) that runs scripts and simulates the display. Copy this .exe into the directory in which you have installed eepe/eepskye (it needs the QT dll files.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
The difficult we do immediately,
The impossible takes a little longer!
Re: Script Language
Wonderful, thank you..
I bet this will become way better than the existing LUA, as it is being developed specifically for RC..
João
Sent from my thor using Tapatalk
I bet this will become way better than the existing LUA, as it is being developed specifically for RC..
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
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
Re: Script Language
I have attached the Quick Command Reference of an Intel MSC Basic-52
Just as a reference to see, which commands this small Basic supports.
What I'm missing (just a wish list) in your first draft are more control structures e.g.
do - loop / until / while
for - to - STEP - next
iterate
if - then - ELSE
logic compares AND / OR / XOR
abs
NOT
Just a short selection/suggestion of what I would like to see.
BUT IT'S YOUR CHOICE what you do and what can be done.
Reinhard
Just as a reference to see, which commands this small Basic supports.
What I'm missing (just a wish list) in your first draft are more control structures e.g.
do - loop / until / while
for - to - STEP - next
iterate
if - then - ELSE
logic compares AND / OR / XOR
abs
NOT
Just a short selection/suggestion of what I would like to see.
BUT IT'S YOUR CHOICE what you do and what can be done.
Reinhard
Re: Script Language
Mike,
Possible "drawcircle"??
What about some "Pause" function?? Like the script does something and then pauses for a defined time?
I am asking these questions based on what I think I have understood
Thanks
João
EDIT: Also it would help some examples with real values and variables..
Possible to add P4 and P5??Control names: (Rud, Ele, Ail, Thr, P1,P2,P3, PPM1-PPM8, CH1-CH24)
Possible "drawcircle"??
What about HUB telemetry?sportTelemetrySend
syntax: sportTelemetrySend( <expression>, <expression>, <expression>, <expression> )
sportTelemetrySend( PhyId, Command, AppId, data)
sportTelemetryReceive
syntax: sportTelemetryReceive( <variable>, <variable>, <variable>, <variable>)
sportTelemetryReceive( PhyId, Command, AppId, data)
What about some "Pause" function?? Like the script does something and then pauses for a defined time?
I am asking these questions based on what I think I have understood
Thanks
João
EDIT: Also it would help some examples with real values and variables..
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
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
- MikeB
- 9x Developer
- Posts: 17993
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Re: Script Language
I hope to add more control structures. I need to work out how to process them when the script is loaded as they all require some "forward references", and also, with the looping structures, they may be nested so multiple forward references need to be handled.
All may be simulated with the code already implemented of course.
I'll add more names to getvalue() as we go on, if you know the numbers to which they correspond all items may be accessed, I'll try to compile a list of them.
Hub (and other) telemetry, will require reading bytes from a "data stream" and then processing them. This is something I have i mind.
Pause may be handled by using the gettime() function, noting the current "time" at the start and waiting until the time exceeds this by your delay time.
HOWEVER, you need to be aware of the way in which scripts are processed, they are not separate programs that run by themselves, they execute as part of the main code. Basically, a script runs from its start until it reaches a "stop" instruction every 10mS. If a script tries to execute "too many" instructions each time it executes, it will be terminated to prevent the script from stopping everything else (like control of the model) from taking place.
With this intial implementation of loading and executing now working, more features should be possible to be added as required.
I have a few more tests I need to do then I'll hopefully post some test versions for others to try.
Mike.
All may be simulated with the code already implemented of course.
I'll add more names to getvalue() as we go on, if you know the numbers to which they correspond all items may be accessed, I'll try to compile a list of them.
Hub (and other) telemetry, will require reading bytes from a "data stream" and then processing them. This is something I have i mind.
Pause may be handled by using the gettime() function, noting the current "time" at the start and waiting until the time exceeds this by your delay time.
HOWEVER, you need to be aware of the way in which scripts are processed, they are not separate programs that run by themselves, they execute as part of the main code. Basically, a script runs from its start until it reaches a "stop" instruction every 10mS. If a script tries to execute "too many" instructions each time it executes, it will be terminated to prevent the script from stopping everything else (like control of the model) from taking place.
With this intial implementation of loading and executing now working, more features should be possible to be added as required.
I have a few more tests I need to do then I'll hopefully post some test versions for others to try.
Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
The difficult we do immediately,
The impossible takes a little longer!
Re: Script Language
Thanks Mike.. I will be glad to test as always.. But I will need some examples to get me started, otherwise I won't know what to test I am a good example of the average user, I know nothing
João
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
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
Re: Script Language
Is there a test version of firmware for 9xtreme available so we could start porting the Lua scripts?
- MikeB
- 9x Developer
- Posts: 17993
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Re: Script Language
I should have a test version either later today or tomorrow.
I've just added allowing numerical constants to be in hex, binary or octal as well as decimal.
I've also added the functions not() and abs().
Mike.
I've just added allowing numerical constants to be in hex, binary or octal as well as decimal.
I've also added the functions not() and abs().
Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
The difficult we do immediately,
The impossible takes a little longer!
- MikeB
- 9x Developer
- Posts: 17993
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Re: Script Language
Fixed a few bugs so now it looks like it is working, although I would expect some problems to occur.
I've posted test versions of ersky9x with this scripting language in, and also updated the document on the first post.
Scripts must have an extension of ".bas", and be put into a "\scripts" directory on the SD card. Only "standalone" scripts are available so far. From the main display go UP LONG (or select "statistics"), then RIGHT about 6 times to get to the script menu to run one.
Errors may occur when loading, or when running. Error reporting is just "Error 3 at line 7", error numbers are in the document. The error number will have 100 added to it if it occured at run time.
This is early days, so hopefully lots more facilities will be added as we go on.
There are some limits built in at present, like the loaded script and it's variables must fit in 6000 bytes, and you can only have 100 (ordinary) variables.
It also only executes 300 lines of script every 10mS.
While loading, I have to create a "symbol table". This also uses the same 6000 bytes, as the loaded code, so may also limit the size of script that may be loaded.
These limits will be reviewed, and the 6000 will also probably change to use available RAM.
I've attached a test script I've been using. It is nothing special, just something to test the operation, but it has worked on a SKY board, a 9Xtreme and a QX7. It just displays some numbers, graphics and text. You should see the Ail stick value, the battery voltage, idletime, and elapsed time (units of 10mS), with a small rectangle flashing on/off every 2 seconds.
Exit the script with either a press of the EXIT button or the rotary encoder button.
Mike.
I've posted test versions of ersky9x with this scripting language in, and also updated the document on the first post.
Scripts must have an extension of ".bas", and be put into a "\scripts" directory on the SD card. Only "standalone" scripts are available so far. From the main display go UP LONG (or select "statistics"), then RIGHT about 6 times to get to the script menu to run one.
Errors may occur when loading, or when running. Error reporting is just "Error 3 at line 7", error numbers are in the document. The error number will have 100 added to it if it occured at run time.
This is early days, so hopefully lots more facilities will be added as we go on.
There are some limits built in at present, like the loaded script and it's variables must fit in 6000 bytes, and you can only have 100 (ordinary) variables.
It also only executes 300 lines of script every 10mS.
While loading, I have to create a "symbol table". This also uses the same 6000 bytes, as the loaded code, so may also limit the size of script that may be loaded.
These limits will be reviewed, and the 6000 will also probably change to use available RAM.
I've attached a test script I've been using. It is nothing special, just something to test the operation, but it has worked on a SKY board, a 9Xtreme and a QX7. It just displays some numbers, graphics and text. You should see the Ail stick value, the battery voltage, idletime, and elapsed time (units of 10mS), with a small rectangle flashing on/off every 2 seconds.
Exit the script with either a press of the EXIT button or the rotary encoder button.
Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
The difficult we do immediately,
The impossible takes a little longer!
Re: Script Language
Thank you.. will try it later.. A bit busy at the moment
João
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
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
Re: Script Language
Loaded the script on the Ar9x board, it seems to be working as you described.. I also see a little diagonal line on the lower left corner.. Did you program it?
Thanks
João
Thanks
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
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
- MikeB
- 9x Developer
- Posts: 17993
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Re: Script Language
Yes, the little line is drawn by the script, also a single pixel near the top left corner of the display.
I'll see if I can get a script loading as a telemetry script as well as standalone.
Mike.
I'll see if I can get a script loading as a telemetry script as well as standalone.
Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
The difficult we do immediately,
The impossible takes a little longer!
Re: Script Language
Then it looks like it is all good.. Didn't try to control a model while using a script.. Maybe with a heavier script.. If someone writes it of course
Tnx
João
Tnx
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
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
- MikeB
- 9x Developer
- Posts: 17993
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Re: Script Language
One interesting thing is the "idletime" shown by that script (65% on a SKY board), is about the same as that shown on the STAT2 display.
I have an enhancement in test, the command "while", with an "end", so you will be able to have:
while condition
statements
end
The statements between the while and the end will be repeatedly executed as long as condition is not zero.
Mike.
I have an enhancement in test, the command "while", with an "end", so you will be able to have:
while condition
statements
end
The statements between the while and the end will be repeatedly executed as long as condition is not zero.
Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
The difficult we do immediately,
The impossible takes a little longer!
- MikeB
- 9x Developer
- Posts: 17993
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Re: Script Language
Just got a "Telemetry" script running on a custom telemetry screen. This loads automatically, if selected, stops while a stand alone script runs, and reloads when the stand alone script terminates.
The "Telemetry" script is run, whether you have the custom screen showing or not. There is a new function "sysflags()", which returns several bits, bit 0 is set if the display is available, so you may check whether to run in the "foreground" or in the "background".
I'll be posting "d7" soon with this in.
Mike.
The "Telemetry" script is run, whether you have the custom screen showing or not. There is a new function "sysflags()", which returns several bits, bit 0 is set if the display is available, so you may check whether to run in the "foreground" or in the "background".
I'll be posting "d7" soon with this in.
Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
The difficult we do immediately,
The impossible takes a little longer!
Re: Script Language
Mike, could you please include that telemetry script in the zip file when you post d7?
Thanks
João
Thanks
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
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
- MikeB
- 9x Developer
- Posts: 17993
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Re: Script Language
"d7" posted (includes COM2 interrupt priority raised on 9Xtreme). You may now have a single "Telemetry" script, configure in the custom telemetry menu.
You need to create a "TELEMETRY" directory in the "SCRIPTS" directory, and put "tel0.bas" from the attached .zip in it, then change the custom telemetry screen to type "script" and select "tel0" as the script. There is a limit of 6 characters for the filename.
There is a new function available "settelitem()" that allows you to set a telemetry value from the script. THe syntax is:
settelitem( "name", value ), where the name text is the name of a telemetry item. The example telemetry script uses this to set the telemetry item "Cus1" to be the same as the radio battery voltage, then also displays the resulting value. If you set the other custom telemetry display to show "Cus1", you should see it having the battery voltage in tenths of a volt.
This script copies the battery value to Cus1 every time it runs, then checks to see if the custom telemetry screen is available (sysflags()) and either stops or displays information as required.
Mike.
You need to create a "TELEMETRY" directory in the "SCRIPTS" directory, and put "tel0.bas" from the attached .zip in it, then change the custom telemetry screen to type "script" and select "tel0" as the script. There is a limit of 6 characters for the filename.
There is a new function available "settelitem()" that allows you to set a telemetry value from the script. THe syntax is:
settelitem( "name", value ), where the name text is the name of a telemetry item. The example telemetry script uses this to set the telemetry item "Cus1" to be the same as the radio battery voltage, then also displays the resulting value. If you set the other custom telemetry display to show "Cus1", you should see it having the battery voltage in tenths of a volt.
This script copies the battery value to Cus1 every time it runs, then checks to see if the custom telemetry screen is available (sysflags()) and either stops or displays information as required.
Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
The difficult we do immediately,
The impossible takes a little longer!
Re: Script Language
Thanks Mike.. Will test.. But weather today isn't good around here..
João
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
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
- bob195558
- Posts: 2377
- Joined: Sun Dec 16, 2012 7:24 pm
- Country: United States
- Location: New England, Vermont
- Contact:
Re: Script Language
So the Micro SD Card list of folder Directories will have "SCRIPTS" added to it ?
I added the new info to this post: (viewtopic.php?f=35&t=9034&p=116984#p116984).
Bob B.
I added the new info to this post: (viewtopic.php?f=35&t=9034&p=116984#p116984).
Bob B.
Er9x on 9x radio, with Smartieparts Programmer and TelemetrEZ Board.
ErSky9x on Taranis, Sky9x, 9Xtreme radios.
3D-Printing: (https://openrcforums.com/forum/viewforum.php?f=129).
ErSky9x on Taranis, Sky9x, 9Xtreme radios.
3D-Printing: (https://openrcforums.com/forum/viewforum.php?f=129).
Re: Script Language
And inside the "scripts" directory, another one called "Telemetry", as far as I understand..
João
Sent from my thor using Tapatalk
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
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
- bob195558
- Posts: 2377
- Joined: Sun Dec 16, 2012 7:24 pm
- Country: United States
- Location: New England, Vermont
- Contact:
Re: Script Language
OK thanks !
I will add it to the (Micro SD Card list of folder Directories) list: (viewtopic.php?f=35&t=9034&p=116984#p116984).
Bob B.
I will add it to the (Micro SD Card list of folder Directories) list: (viewtopic.php?f=35&t=9034&p=116984#p116984).
Bob B.
Er9x on 9x radio, with Smartieparts Programmer and TelemetrEZ Board.
ErSky9x on Taranis, Sky9x, 9Xtreme radios.
3D-Printing: (https://openrcforums.com/forum/viewforum.php?f=129).
ErSky9x on Taranis, Sky9x, 9Xtreme radios.
3D-Printing: (https://openrcforums.com/forum/viewforum.php?f=129).
Re: Script Language
Mike, I have just flashed d7 to my 9XT and enabled the attached script on one of the custom displays. I have "SCRIPT ERROR" on the screen. I have no receiver ON, does it make a difference? Shouldn't it say "No telemetry" or similar instead?
Encoder problem is fixed, the other problem when moving the stick to bypass the splash screen at power ON is still there..
Thanks
João
Encoder problem is fixed, the other problem when moving the stick to bypass the splash screen at power ON is still there..
Thanks
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
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
- MikeB
- 9x Developer
- Posts: 17993
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Re: Script Language
Try a power off and on, when you select the script in the menu, it (currently) doesn't start it, only on loading a model or ending a stand alone script is it loaded and run.
Mike.
Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
The difficult we do immediately,
The impossible takes a little longer!
Re: Script Language
Ok, that worked now on both 9XT and Ar9x.. Funny, I could swear that I did cycle the power before and it didn't work
Ar9x, moving the stick right after power ON. I can hear 2 loud clicks (normally one at power ON), and the model name is not played. This seems to be the same problem as on the 9XT, but it behaves differently. The 9XT plays the model name and the voices associated with !THR.
Changing models doesn't stop the script.. It keeps running on the new model.. This doesn't seem right??
João
Ar9x, moving the stick right after power ON. I can hear 2 loud clicks (normally one at power ON), and the model name is not played. This seems to be the same problem as on the 9XT, but it behaves differently. The 9XT plays the model name and the voices associated with !THR.
Changing models doesn't stop the script.. It keeps running on the new model.. This doesn't seem right??
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
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
- MikeB
- 9x Developer
- Posts: 17993
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Re: Script Language
I've fixed the script running on the new model when it shouldn't.
Some additions that will be in the next test version:
Strings may now include "special" characters, e.g.
\n - newline (also \t \r etc.)
\037 - Octal value
\x45 - Hex value
Three new functions:
strtoarray - initialises a byte array from a string
getswitch - gets the current state (on or off) of a switch, physical or logical
setswitch - sets a (unused) logical switch on or off
Examples:
strtoarray(barray[2],"xyz\n\"\xF4\037")
sets barray[2] to 'x', barray[3] to 'y' and so on as long as the items fit in the array as declared.
getswitch("AIL") returns the state of the AIL switch as 0 or 1 (9X radios)
getswitch("SCv") returns the state of the SCv as 0 or 1 (FrSky radios)
setswitch("L5",0) sets logical switch L5 to off, as long as the switch function is defined as "----"
Mike.
Some additions that will be in the next test version:
Strings may now include "special" characters, e.g.
\n - newline (also \t \r etc.)
\037 - Octal value
\x45 - Hex value
Three new functions:
strtoarray - initialises a byte array from a string
getswitch - gets the current state (on or off) of a switch, physical or logical
setswitch - sets a (unused) logical switch on or off
Examples:
strtoarray(barray[2],"xyz\n\"\xF4\037")
sets barray[2] to 'x', barray[3] to 'y' and so on as long as the items fit in the array as declared.
getswitch("AIL") returns the state of the AIL switch as 0 or 1 (9X radios)
getswitch("SCv") returns the state of the SCv as 0 or 1 (FrSky radios)
setswitch("L5",0) sets logical switch L5 to off, as long as the switch function is defined as "----"
Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
The difficult we do immediately,
The impossible takes a little longer!
- MikeB
- 9x Developer
- Posts: 17993
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Re: Script Language
I've posted "d9", with the items in the preceeding post included.
Since then, I've enhanced the operation of "if".
Options are:
if <expression> then goto <label>
if <expression> then gosub <label>
if <expression> then <statement>
and in the next test version (note no "then" keyword)
if <expression>
<statement>
. . .
<statement>
end
if <expression>
<statement>
. . .
else
<statement>
. . .
end
Mike.
Since then, I've enhanced the operation of "if".
Options are:
if <expression> then goto <label>
if <expression> then gosub <label>
if <expression> then <statement>
and in the next test version (note no "then" keyword)
if <expression>
<statement>
. . .
<statement>
end
if <expression>
<statement>
. . .
else
<statement>
. . .
end
Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
The difficult we do immediately,
The impossible takes a little longer!
- MikeB
- 9x Developer
- Posts: 17993
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Re: Script Language
I've posted "e3". This supports multiple scripts running. The script.pdf file on the first post is updated.
Also supported is an elseif option like:
if <expression>
<statement>
. . .
elseif <expression>
. . .
elseif <expression>
. . .
else
<statement>
. . .
end
Mike.
Also supported is an elseif option like:
if <expression>
<statement>
. . .
elseif <expression>
. . .
elseif <expression>
. . .
else
<statement>
. . .
end
Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
The difficult we do immediately,
The impossible takes a little longer!
Re: Script Language
Wonderful, thanks Mike.
João
Sent from my thor using Tapatalk
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
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
Re: Script Language
Hi MikeB,
Do you have any working examples with sportTelemetryRecieve and Send? Really interesting project!
Thank you.
Do you have any working examples with sportTelemetryRecieve and Send? Really interesting project!
Thank you.
- MikeB
- 9x Developer
- Posts: 17993
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Re: Script Language
Here is a simple (standalone) script that lets you adjust a reference voltage and then send it to a particular sensor for calibration purposes:
Do you have anything you can receive SPort telemetry from?
Currently configuration data and User ID passthrough data is available (similar to openTx LUA).
An S6R or S8R receiver would be useful for receiving configuration data.
Normal SPort telemetry data is processed by ersky9x, and the telemetry values may be accessed from a script, so not much point in passing those SPort data packets to the script.
Mike.
Code: Select all
if init = 0
init = 1
voltage = 500
end
drawclear()
drawtext(20, 16, "Mini Hub", 0)
drawtext(0, 24, "Voltage", 0)
drawnumber(78, 24, voltage, PREC2)
drawnumber(50, 32, value, 0)
drawnumber(50, 40, result, 0)
drawnumber(50, 48, temp, 0)
drawnumber(120, 48, getvalue( "A3=" ), 0)
drawnumber(120, 56, getvalue( "A4=" ), 0)
if Event = EVT_MENU_BREAK
result = sportTelemetrySend( 0x1B, 0x31, 0x50FF, voltage )
let value = value + 1
temp = 0
end
if Event = EVT_LEFT_FIRST then voltage -= 1
if Event = EVT_RIGHT_FIRST then voltage += 1
if Event = EVT_DOWN_FIRST then voltage -= 10
if Event = EVT_UP_FIRST then voltage += 10
if voltage < 400 then voltage = 400
if voltage > 600 then voltage = 600
if Event = EVT_EXIT_BREAK then goto done
if Event = EVT_BTN_BREAK then goto done
stop
done:
finish
Currently configuration data and User ID passthrough data is available (similar to openTx LUA).
An S6R or S8R receiver would be useful for receiving configuration data.
Normal SPort telemetry data is processed by ersky9x, and the telemetry values may be accessed from a script, so not much point in passing those SPort data packets to the script.
Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
The difficult we do immediately,
The impossible takes a little longer!