Script Language
- MikeB
- 9x Developer
- Posts: 17849
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Re: Script Language
r222A4 now posted for all radios. This fixes the "off grid inverse video" bug, and also fixes a bug in the bitfield function.
I've updated the "Script.pdf" document on the first post to show recently added functions.
Mike
I've updated the "Script.pdf" document on the first post to show recently added functions.
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: RE: Re: Script Language
It's getting interesting.MikeB wrote:r222A4 now posted for all radios. This fixes the "off grid inverse video" bug, and also fixes a bug in the bitfield function.
I've updated the "Script.pdf" document on the first post to show recently added functions.
Mike
Re: Script Language
I confirm at least that r222a3 is solving the off grid inverse issue on my 9XR Pro.
I haven't tried r222a4...
Pascal
I haven't tried r222a4...
Pascal
Re: Script Language
Mike,
I can't display within the script a correct value of A1.
I can get the radio to display the correct value in Config->Telemetry -> A1 channel 13.5v 7.6 <= 7.6V is my 2S lipo voltage. This value is displayed correctly on the telemetry screen A1=7.6,RX=.., TX=... But within the script if I do:
tmp = getvalue("A1= ")
drawnumber(84, 0, tmp, PREC1)
I'm getting a displayed value of 1.4 .
Any clue of what I'm doing wrong?
Notes:
- I've tried "A1= ", "A1=","A1" and I always end up with 1.4 .
- I have no issues with "Batt" for which I get the correct value.
Pascal
I can't display within the script a correct value of A1.
I can get the radio to display the correct value in Config->Telemetry -> A1 channel 13.5v 7.6 <= 7.6V is my 2S lipo voltage. This value is displayed correctly on the telemetry screen A1=7.6,RX=.., TX=... But within the script if I do:
tmp = getvalue("A1= ")
drawnumber(84, 0, tmp, PREC1)
I'm getting a displayed value of 1.4 .
Any clue of what I'm doing wrong?
Notes:
- I've tried "A1= ", "A1=","A1" and I always end up with 1.4 .
- I have no issues with "Batt" for which I get the correct value.
Pascal
- MikeB
- 9x Developer
- Posts: 17849
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Re: Script Language
I can reproduce this result, I'll look into it later today (I get 0.8 when the A1 value is 4.9).
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!
- MikeB
- 9x Developer
- Posts: 17849
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Re: Script Language
OK, problem(s) fixed in "A5", just posted. I had a "boundary condition" that included A1 in some scaling when it should not have been included, and also A1 and A2 were not being scaled by their set ratio, so you got the raw A2D value.
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!
- MikeB
- 9x Developer
- Posts: 17849
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Re: Script Language
The most recent test version (ersky9xProvR222a6.zip), includes an option to display a popup menu. Here is a description (being added to the "manual" of how to use it.
popup
syntax: popup( option_list, mask, width )
Returns 0 while nothing selected, 1 to 16 if an item selected and 99 if EXIT is pressed to cancel the popup.
The option_list is a string with each option separated by a null ('\0') character, e.g."Opt 1\0Opt 2\0Opt 3\0Opt 4"
The mask is a bitfield of 16 bits that indicates which of the options are to be displayed in the popup, with the least significant bit indicating the first option e.g. a mask of 13 (0x0D, 0b00001101), would cause the above list to display Opt1, Opt3 and Opt4. Note the return value always returns the exact position in the list of a selected item, so with a mask of 13, only values 1, 3 or 4 will be returned.
I'm also adding in detection of a label if it starts at the first character on a line and has no characters after it on the line. This will help should you forget to put the ':' at the end!
Mike
popup
syntax: popup( option_list, mask, width )
Returns 0 while nothing selected, 1 to 16 if an item selected and 99 if EXIT is pressed to cancel the popup.
The option_list is a string with each option separated by a null ('\0') character, e.g."Opt 1\0Opt 2\0Opt 3\0Opt 4"
The mask is a bitfield of 16 bits that indicates which of the options are to be displayed in the popup, with the least significant bit indicating the first option e.g. a mask of 13 (0x0D, 0b00001101), would cause the above list to display Opt1, Opt3 and Opt4. Note the return value always returns the exact position in the list of a selected item, so with a mask of 13, only values 1, 3 or 4 will be returned.
Code: Select all
if init = 0
init = 1
end
drawclear()
drawtext(20, 16, "Hello", 0)
rem Pressing MENU starts the popup
if Event = EVT_MENU_BREAK
rem But only if it isn't already running
if pop = 0
pop = 1
rxres = 0
rem Setting Event to 0 removes the EVT_MENU_BREAK event so the popup doesn't “see” it
Event = 0
end
end
rem Test if the popup is running
if pop
result = popup( "Opt 1\0Opt 2\0Opt 3\0Opt 4", 0x0D, 6)
rem If anything non-zero is returned, terminate the popup
if result
rxres = result
pop = 0
end
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
Has something has changed between r221 and r222a6 or betaflight 3.2 to 3.3 and now 3.4?.
The BF_basic.bas pid script no longer returns any values.... the only changes since it was working have been firmware upgrades.
The BF_basic.bas pid script no longer returns any values.... the only changes since it was working have been firmware upgrades.
- MikeB
- 9x Developer
- Posts: 17849
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Re: Script Language
No intentional changes to the script operation in ersky9x. You could try backing up your EEPROM (just to be sure), then put r221 back on to see if the problem is with ersky9x or betaflight. Then, could you try reverting the betaflight firmware? I don't have betaflight so I can't do any testing.
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!
- MikeB
- 9x Developer
- Posts: 17849
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Re: Script Language
Some updates to the script language.
crossfiresend() included.
const added to allow defining numeric values by name.
drawrectangle now takes an optional fifth parameter (percent from 0 to 100). If present then the rectangle will be filled for that percentage from the left.
drawline now takes an optional fifth parameter (colour), 0 for XOR, 1 for BLACK, 2 for WHITE.
I've posted an updated pdf file on the first post.
Mike
crossfiresend() included.
const added to allow defining numeric values by name.
drawrectangle now takes an optional fifth parameter (percent from 0 to 100). If present then the rectangle will be filled for that percentage from the left.
drawline now takes an optional fifth parameter (colour), 0 for XOR, 1 for BLACK, 2 for WHITE.
I've posted an updated pdf file on the first post.
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
Hello
is it possible that a delay function and a getValue("Modelname") is implementet?
is it possible that a delay function and a getValue("Modelname") is implementet?
- MikeB
- 9x Developer
- Posts: 17849
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Re: Script Language
For getValue("Modelname"), you may use:
sysstrtoarray( name1, 0 )
where name1 is a byte array that needs to be at least of size 12, e.g.:
array byte name1[12]
sysstrtoarray( name1, 0 )
will result in the byte array "name1" containing the model name in the first 10 bytes terninated by a null (zero) byte.
drawtext( x, y, name1 ) should then display the model name.
sysstrtoarray() currently takes the values 0 or 1 for the second parameter, a 1 fetches the "owner name".
There is no delay function, but a delay may be implemented by using the gettime() function.
Mike
sysstrtoarray( name1, 0 )
where name1 is a byte array that needs to be at least of size 12, e.g.:
array byte name1[12]
sysstrtoarray( name1, 0 )
will result in the byte array "name1" containing the model name in the first 10 bytes terninated by a null (zero) byte.
drawtext( x, y, name1 ) should then display the model name.
sysstrtoarray() currently takes the values 0 or 1 for the second parameter, a 1 fetches the "owner name".
There is no delay function, but a delay may be implemented by using the gettime() function.
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
Re: Script Language
I have a problem with the popup menu.
The rotoary encoder isn't working correctly. It jumps over the option or it scrolls the wrong way. In the video I only scrolled to the right
Please have a look at the video. https://www.youtube.com/watch?v=sTtlqbwe6fo
Can you please tell me what's the page button event on the QX7 ?
Also is it possible to implement an option to be able to have a config file for a script?
I'm trying to improve the iNAV script. Can you please tell me how I get the telemetry data from Tmp1, Tmp2 and 0420.
https://github.com/iNavFlight/inav/blob ... lemetry.md
Hope you can have a look at it, Mike.
Thanks
The rotoary encoder isn't working correctly. It jumps over the option or it scrolls the wrong way. In the video I only scrolled to the right
Please have a look at the video. https://www.youtube.com/watch?v=sTtlqbwe6fo
Code: Select all
if Event = EVT_MENU_BREAK
if pop = 0
pop = 1
Event = 1
rxres = 0
end
end
if page = 1
if pop
result = popup( "Option1\0Option2\0Option3", 0x07, 15)
if result
rxres = result
pop = 0
end
end
end
Also is it possible to implement an option to be able to have a config file for a script?
I'm trying to improve the iNAV script. Can you please tell me how I get the telemetry data from Tmp1, Tmp2 and 0420.
https://github.com/iNavFlight/inav/blob ... lemetry.md
Hope you can have a look at it, Mike.
Thanks
- MikeB
- 9x Developer
- Posts: 17849
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Re: Script Language
I can't see anything wrong with the encoder in the popup on the X7, I just tried the code you have on my X7 and it worked fine.
I assume the encoder is working fine for "normal" navigation?
Please explain exactly what you mean by a "config file" for a script.
Tmp1 has the name "T1=" and Tmp2 has the name "T2=", I think you could just use:
value = getvalue( "T1" )
to get Tmp1.
Since 0420 is a non-FrSky ID, it won't (currently) be available. Inav shouldn't really be using that as FrSky might decide to use it for something "official". FrSky have made a range of ID values available for user use.
I will be looking into detecting non-implemented IDs, perhaps providing a method where you could specify an ID to detect and somewhere to put it (e.g. one of the custom values).
The Page button appears as the "Left" button (e.g. "EVT_LEFT_FIRST").
Mike
I assume the encoder is working fine for "normal" navigation?
Please explain exactly what you mean by a "config file" for a script.
Tmp1 has the name "T1=" and Tmp2 has the name "T2=", I think you could just use:
value = getvalue( "T1" )
to get Tmp1.
Since 0420 is a non-FrSky ID, it won't (currently) be available. Inav shouldn't really be using that as FrSky might decide to use it for something "official". FrSky have made a range of ID values available for user use.
I will be looking into detecting non-implemented IDs, perhaps providing a method where you could specify an ID to detect and somewhere to put it (e.g. one of the custom values).
The Page button appears as the "Left" button (e.g. "EVT_LEFT_FIRST").
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
Yes the encoder is working fine normally. But in the script it isn't for some reason.
Maybe I got another fault in the script which causes the rotary encoder to behave strange. I'll post the script tomorrow so that you can try it.
In the inav.lua script it is possible to set up a personal config which is saved inside a config(.lua) file.
Maybe I got another fault in the script which causes the rotary encoder to behave strange. I'll post the script tomorrow so that you can try it.
In the inav.lua script it is possible to set up a personal config which is saved inside a config(.lua) file.
Re: Script Language
Since short, I have a 9xr Pro (latest fw) with an STM32.. Multi protocol module (Banggood).
I also have a little heli, where I don't know, if it's protocol is suported or not.
Is it possible to write a script, that, step by step, tries to bind to every available protocol (and option) without manual intervention. After bind process, it should move channels 1 - 4, call a voice file with the number of the tested protocol and switch to the next protocol.
This way, whenever the attached model reacts to the protocol, you knew the number of the successful protocol.
Since I assume, this would be a long running script, it should be possible to restart it at a certain protocol number.
Reinhard
I also have a little heli, where I don't know, if it's protocol is suported or not.
Is it possible to write a script, that, step by step, tries to bind to every available protocol (and option) without manual intervention. After bind process, it should move channels 1 - 4, call a voice file with the number of the tested protocol and switch to the next protocol.
This way, whenever the attached model reacts to the protocol, you knew the number of the successful protocol.
Since I assume, this would be a long running script, it should be possible to restart it at a certain protocol number.
Reinhard
-
- Posts: 47
- Joined: Thu Aug 23, 2018 5:37 am
- Country: Russian Federation
- Contact:
Re: Script Language
No, it's not possible. There isn't any function for binding and I think it will never be implemented.
Re: Script Language
Thanks,
that is what I was afraid of.
Reinhard
that is what I was afraid of.
Reinhard
-
- Posts: 47
- Joined: Thu Aug 23, 2018 5:37 am
- Country: Russian Federation
- Contact:
Re: Script Language
Hello everyone.
Here's my feature request. It'd be nice to have some functions like gettime() which would return a UNIX time or even better getyear(), getmonth(), getday(), etc.
Here's my feature request. It'd be nice to have some functions like gettime() which would return a UNIX time or even better getyear(), getmonth(), getday(), etc.
- MikeB
- 9x Developer
- Posts: 17849
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Re: Script Language
One of the "Telemetry" values available is "RTC" that returns the (real) time in minutes for the current day.
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!
- MikeB
- 9x Developer
- Posts: 17849
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Re: Script Language
OK, I'll add a change to gettime(). If called with no parameter it functions as it does now (units of 10mS).
Pass in a parameter 0-5:
gettime(0) returns the year (e.g. 2018)
gettime(1) returns the month (1-12)
gettime(2) returns the date (1-31)
gettime(3) returns the hour (0-23)
gettime(4) returns the minute (0-59)
gettime(5) returns the second (0-59)
This will be in the next test version, together with the "fix" for the startup of a model script.
Mike
Pass in a parameter 0-5:
gettime(0) returns the year (e.g. 2018)
gettime(1) returns the month (1-12)
gettime(2) returns the date (1-31)
gettime(3) returns the hour (0-23)
gettime(4) returns the minute (0-59)
gettime(5) returns the second (0-59)
This will be in the next test version, together with the "fix" for the startup of a model 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!
- MikeB
- 9x Developer
- Posts: 17849
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Re: Script Language
The next test version will have something in to handle a few, currently, unimplemented IDs (like 0420).
The first 4 unknown IDs that are received will be stored, and an new sub-menu called "Sensors" will be available from the Telemetry popup. This will list these unknown IDs, and allow you to choose somewhere to store them. The destination choices will be limited to start with (to the same list available for scalers), but does include all the "Custom" values (Cus1, Cus2 etc.). If you put such a value into (e.g.) Cus1, you may then use Cus1 as the source of a scaler to manipulate it, if required, and give it a name and units.
The only IDs that will appear, to start with, will be those received over the FrSky SPort telemetry. I'll look to add IDs from FrSky hub telemetry, and possible other telemetry sources later.
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...
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
-
- Posts: 47
- Joined: Thu Aug 23, 2018 5:37 am
- Country: Russian Federation
- Contact:
Re: Script Language
Thanks Mike. When will be the next stable release? I don't use test versions thus I wouldn't flash a test version just to write scripts. And if i write a script for a test version I think it won't be usable for most users.
Re: Script Language
Test versions of Ersky9x are very stable, I use them all the time and never had a problem. When Mike releases a test version, it might only be an addition of a new feature, or a fix for some minor problem. When there are some critical changes, Mike will warn us to that fact in the file comments..
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
thank you
-
- Posts: 47
- Joined: Thu Aug 23, 2018 5:37 am
- Country: Russian Federation
- Contact:
Re: Script Language
BTW, what is error 112?
P.S. What does it mean if a script stops running without any error and finish is not run?
P.S. What does it mean if a script stops running without any error and finish is not run?
- MikeB
- 9x Developer
- Posts: 17849
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Re: Script Language
Error 112 is "Too many nested calls". I (currently) have a call stack of size 20. Either you have subroutines calling subroutines to a nesting level of greater than 20, you are calling a subroutine and not returning from it so the stack fills up, or I have a bug in handling subroutine calling.
Possibly you are calling a subroutine and then stopping the script from within the subroutine and I'm not clearing the call stack when the script next runs.
Mike
Possibly you are calling a subroutine and then stopping the script from within the subroutine and I'm not clearing the call stack when the script next runs.
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!