Page 8 of 12

Re: Script Language

Posted: Fri Mar 30, 2018 11:17 am
by MikeB
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: RE: Re: Script Language

Posted: Fri Mar 30, 2018 12:26 pm
by lshems
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
It's getting interesting.

Re: Script Language

Posted: Fri Mar 30, 2018 3:16 pm
by planger
I confirm at least that r222a3 is solving the off grid inverse issue on my 9XR Pro.
I haven't tried r222a4...
Pascal

Re: Script Language

Posted: Fri Mar 30, 2018 4:55 pm
by planger
...

Re: Script Language

Posted: Tue Apr 03, 2018 8:21 pm
by planger
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

Re: Script Language

Posted: Wed Apr 04, 2018 10:34 am
by MikeB
I can reproduce this result, I'll look into it later today (I get 0.8 when the A1 value is 4.9).

Mike

Re: Script Language

Posted: Wed Apr 04, 2018 4:18 pm
by MikeB
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

Re: Script Language

Posted: Mon Apr 30, 2018 10:58 am
by MikeB
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.

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
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

Re: Script Language

Posted: Fri Jun 22, 2018 6:51 am
by bnbarr
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.

Re: Script Language

Posted: Fri Jun 22, 2018 8:46 am
by MikeB
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

Re: Script Language

Posted: Sun Jul 15, 2018 9:22 pm
by MikeB
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

Re: Script Language

Posted: Sun Sep 16, 2018 5:05 pm
by rcfish
Hello
is it possible that a delay function and a getValue("Modelname") is implementet?

Re: Script Language

Posted: Sun Sep 16, 2018 7:33 pm
by MikeB
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

Re: Script Language

Posted: Sun Sep 16, 2018 10:06 pm
by rcfish
thank you

Re: Script Language

Posted: Wed Sep 19, 2018 7:50 pm
by rcfish
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

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
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

Re: Script Language

Posted: Wed Sep 19, 2018 9:52 pm
by MikeB
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

Re: Script Language

Posted: Wed Sep 19, 2018 10:37 pm
by rcfish
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.

Re: Script Language

Posted: Thu Sep 20, 2018 8:41 am
by ReSt
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

Re: Script Language

Posted: Fri Sep 21, 2018 8:42 pm
by vodkabears
No, it's not possible. There isn't any function for binding and I think it will never be implemented.

Re: Script Language

Posted: Sat Sep 22, 2018 8:16 am
by ReSt
Thanks,
that is what I was afraid of.

Reinhard

Re: Script Language

Posted: Tue Sep 25, 2018 10:55 am
by vodkabears
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.

Re: Script Language

Posted: Tue Sep 25, 2018 11:59 am
by MikeB
One of the "Telemetry" values available is "RTC" that returns the (real) time in minutes for the current day.

Mike

Re: Script Language

Posted: Tue Sep 25, 2018 5:48 pm
by MikeB
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

Re: Script Language

Posted: Tue Sep 25, 2018 10:44 pm
by MikeB
rcfish wrote: Wed Sep 19, 2018 7:50 pm I'm trying to improve the iNAV script. Can you please tell me how I get the telemetry data from Tmp1, Tmp2 and 0420.
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

Re: Script Language

Posted: Tue Sep 25, 2018 11:16 pm
by jhsa
Thank you...

Re: Script Language

Posted: Wed Sep 26, 2018 7:28 pm
by vodkabears
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

Posted: Wed Sep 26, 2018 7:46 pm
by jhsa
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

Re: Script Language

Posted: Wed Sep 26, 2018 9:27 pm
by rcfish
thank you

Re: Script Language

Posted: Sat Sep 29, 2018 11:05 am
by vodkabears
BTW, what is error 112?

P.S. What does it mean if a script stops running without any error and finish is not run?

Re: Script Language

Posted: Sat Sep 29, 2018 3:05 pm
by MikeB
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