Script Language
- MikeB
- 9x Developer
- Posts: 17990
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Re: Script Language
The AR9X board, as standard, doesn't support the Smart Port in bi-directional mode needed to send data to the Rx.
You need to add a diode to the inverted COM1 connections for this to work. Have you done this?
Mike.
You need to add a diode to the inverted COM1 connections for this to work. Have you done this?
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
No, now I have added the diode and ist is working now. Thank you.
Re: Script Language
I tried to add vtx setup to midelics script. I can read the values, but when I change and save them betaflight does not accept them. I have no Idea why.
@midelic
what does packet_size do. From where do you get the values?
@midelic
what does packet_size do. From where do you get the values?
Re: Script Language
Hi nico84. I am posting on Midelic's behalf as he cannot access this forum at the moment.
João
Here is his message:
João
Here is his message:
Please check an older version LUA script to adapt version of getWriteValuesVTX and postReadVTX to bas script ,I'm not at home to test and come back in January.
As an example:
Code: Select all
saveSettings: rem --write commands page= currentPage gosub check_values if v_flag cmnd = write p_size = packet_size j=1 while j<=packet_size if page=1 payloadReq[j]=values_pid[j] elseif page= 2 payloadReq[j]=values_rates[j] else gosub getWriteValuesVTX payloadReq[j]= values_vtx[j] end j=j+1 end gosub mspSendRequest _______________________________
https://github.com/betaflight/betafligh ... eb67234b3b
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 Midelic and João,
thank you. I will try. But I think my code is bad. PID read and write is fine.
Edit:
Ok I see it. I will try.
thank you. I will try. But I think my code is bad. PID read and write is fine.
Edit:
Ok I see it. I will try.
Re: Script Language
I works. Added:
Now I have to define the allowed values and to differentiate between tramp and TBS
Code: Select all
saveSettings:
rem --write commands
page= currentPage
gosub check_values
if v_flag
cmnd = write
p_size = packet_size
j = 1
while j <= packet_size
if page = 1
payloadReq[j] = values_pid[j]
elseif page = 2
payloadReq[j] = values_rates[j]
elseif page = 3
gosub getWriteValuesVTX
payloadReq[j] = values_vtx_rx[j]
end
j = j+1
end
gosub mspSendRequest
saveTS = gettime()
if gState = PAGE_SAVING
saveRetries = saveRetries + 1
else
gState = PAGE_SAVING
end
end
return
getWriteValuesVTX:
values_vtx_rx[1] = (values_vtx[2]-1)*8 + values_vtx[3]-1
values_vtx_rx[2] = 0
values_vtx_rx[3] = values_vtx[4]
values_vtx_rx[4] = values_vtx[5]
return
- gizmatron
- Posts: 40
- Joined: Fri Jun 27, 2014 6:35 am
- Country: France
- Location: somewhere on the limits
Re: Script Language
great work guys .. seems like we almost have a working script for pids and vtx... now i just need to read back and work out how to add it all to my 9xr-pro
Re: Script Language
Is there a way to write a value to a channel?
Like for the Logical switches if they are unused?
Like for the Logical switches if they are unused?
- MikeB
- 9x Developer
- Posts: 17990
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Re: Script Language
At the moment, I've deliberately made this non-obvious, as I feel scripts shouldn't be used for significant control functions.
You need to use a GVAR to do this, in the script use:
settelitem( "GVAR1", value )
where value goes from -125 to +125 (%), then use GVAR1 as the source for the channel.
Mike
You need to use a GVAR to do this, in the script use:
settelitem( "GVAR1", value )
where value goes from -125 to +125 (%), then use GVAR1 as the source for the channel.
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've got other questions:
- Can we set haptic? example vibrate(x) with x in ms.
- Can there be an overlay on the existing display? I'm thinking of replacing for example the low part of the main screen where the channels are displayed with the script output. It could be an additional page. The script is informed that the page has been selected (sysflags.0?) and starts to draw over the bottom part. That would enable the script to run in background and only display when asked. If that's too complicated at least a blank page you could access, inform the script that it can draw and a way to exit it without ending the script.
- Can we set haptic? example vibrate(x) with x in ms.
- Can there be an overlay on the existing display? I'm thinking of replacing for example the low part of the main screen where the channels are displayed with the script output. It could be an additional page. The script is informed that the page has been selected (sysflags.0?) and starts to draw over the bottom part. That would enable the script to run in background and only display when asked. If that's too complicated at least a blank page you could access, inform the script that it can draw and a way to exit it without ending the script.
Re: Script Language
Perhaps a script could create a "Custom" main screen if needed when it starts? And then close it again when the script stops?
or is this a nonsense??
João
or is this a nonsense??
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
I completely agree..
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
That's not the idea... I woud like my script to run when my model is loaded. It should work in background all the time and display information when you request it.
I could use a switch and only display when it is pushed but I was thinking of a better integration within the radio. I don't know if that's hard to do or not... But if you don't ask...
I could use a switch and only display when it is pushed but I was thinking of a better integration within the radio. I don't know if that's hard to do or not... But if you don't ask...
Re: Script Language
I probably was talking something a bit different, which is, when a script needs to show data on a screen, it could create a new screen when it is running, and actually not use the telemetry custom screens... This would be nice.
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
- MikeB
- 9x Developer
- Posts: 17990
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Re: Script Language
Not at present. You have:
1. A standalone script that writes to the LCD, no menus run.
Or
2. 1 or 2 "Telemetry" scripts that write to the custom telemetry screens, menus run unless the custom telemetry screen is selected.
3. A model scrip that runs in the background, and cannot write to the display, menus run normally.
Scripts run before menus, so if a script as the display available, the menus do not run.
Mike
1. A standalone script that writes to the LCD, no menus run.
Or
2. 1 or 2 "Telemetry" scripts that write to the custom telemetry screens, menus run unless the custom telemetry screen is selected.
3. A model scrip that runs in the background, and cannot write to the display, menus run normally.
Scripts run before menus, so if a script as the display available, the menus do not run.
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
It was just an idea
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
Re: Script Language
Mike, what about haptic?
Can we get a haptic/vibrate instruction?
Can we get a haptic/vibrate instruction?
- MikeB
- 9x Developer
- Posts: 17990
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Re: Script Language
I'll look into what is possible, I don't, currently, have a low level function to drive the haptic in that way.
A work-around, for now, is to configure a voice alarm to play one of the three, pre-defined, haptic outputs, trigger the voice alarm using a logical switch, and then set the logical switch from the script to play the haptic!
Mike
A work-around, for now, is to configure a voice alarm to play one of the three, pre-defined, haptic outputs, trigger the voice alarm using a logical switch, and then set the logical switch from the script to play the haptic!
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
simple and working
Re: Script Language
Simple for you
João
Sent from my BLN-L21 using Tapatalk
João
Sent from my BLN-L21 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
- MikeB
- 9x Developer
- Posts: 17990
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Re: Script Language
I've done a change to the "playfile" function. It will now look for the following names:
"Warn1"
"Warn2"
"Cheap"
"Ring"
"SciFi"
"Robot"
"Chirp"
"Tada"
"Crickt"
"Siren"
"AlmClk"
"Ratata"
"Tick"
"Haptc1"
"Haptc2"
"Haptc3"
and if one is found, then the corresponding audio sound will be played (or the haptic run for the last three).
There may still be a better implementation, but this was easy to do.
Mike
"Warn1"
"Warn2"
"Cheap"
"Ring"
"SciFi"
"Robot"
"Chirp"
"Tada"
"Crickt"
"Siren"
"AlmClk"
"Ratata"
"Tick"
"Haptc1"
"Haptc2"
"Haptc3"
and if one is found, then the corresponding audio sound will be played (or the haptic run for the last three).
There may still be a better implementation, but this was easy to do.
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
Note: you shouldn't put the extension .wav in playfile...
Last edited by planger on Thu Jan 25, 2018 4:12 pm, edited 2 times in total.
Re: Script Language
Is there a way to empty the play queue? or a parameter to playfile to either queue the file or play it immediately (=empty queue+play).
- MikeB
- 9x Developer
- Posts: 17990
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Re: Script Language
At the bottom of the model voice menu there is a "Voice Flush Switch" option, where you select a switch (physical or logical) to empty the play queue. You may set this to a logical switch, then set the switch from the script.
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
Mike, could this "flush switch" be implemented in every voice Alarm switch? I'll try to explain why
the reason is sometimes we would like some information like a telemetry value or alarm that it is very important and need playing immediately, jump to the front of the cue, or delete all events before it. So, if this option was ON when the condition of the switch is true, all the other voice events of the cue would be discarded, and this voice Alarm switch would be played right after.
For example, a battery alarm is being played, or some other events triggered by the user, like altitude, voltage, etc, but suddenly there is a RSSI critical alarm. This should have priority over any other voice event.
The option could be called for example "Voice Flush", and then be ON or OFF.. No need to assign a switch to it in this case as it is triggered by its own voice switch only.. I hope I explained the idea well, you know that my English is far from perfect..
Thanks´
João
EDIT: also, if implemented this way, the current implemented voice flush switch wouldn't be needed, because you could just create a normal voice switch without source / function, and without a voice file selected.
Just assign a switch to it and turn the new option "Voice Flush" ON.
This way, the voice switch would just delete the voice cue without playing any file..
This would solve both problems with just one implementation.. and still keep the things organized.
the reason is sometimes we would like some information like a telemetry value or alarm that it is very important and need playing immediately, jump to the front of the cue, or delete all events before it. So, if this option was ON when the condition of the switch is true, all the other voice events of the cue would be discarded, and this voice Alarm switch would be played right after.
For example, a battery alarm is being played, or some other events triggered by the user, like altitude, voltage, etc, but suddenly there is a RSSI critical alarm. This should have priority over any other voice event.
The option could be called for example "Voice Flush", and then be ON or OFF.. No need to assign a switch to it in this case as it is triggered by its own voice switch only.. I hope I explained the idea well, you know that my English is far from perfect..
Thanks´
João
EDIT: also, if implemented this way, the current implemented voice flush switch wouldn't be needed, because you could just create a normal voice switch without source / function, and without a voice file selected.
Just assign a switch to it and turn the new option "Voice Flush" ON.
This way, the voice switch would just delete the voice cue without playing any file..
This would solve both problems with just one implementation.. and still keep the things organized.
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: 17990
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Re: Script Language
Currently, there could be problems with activating the queue flushing and immediately sending another voice message. The queue flushing operation is done by setting a flag for the voice task to pick up next time it processes the voice queue. It's done this way to avoid having two different tasks both trying to remove items from the queue.
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
One more question: How can I access trim switches? I've tried "Atu" and "Atd" with no luck. I've checked and they are not set in the AIL mixer.
Pascal
Pascal
- MikeB
- 9x Developer
- Posts: 17990
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Re: Script Language
That is supposed to be working, but I just did a test and all eight trims switches "names" seem to be responding to the Ele down trim switch!
Investigating.
Mike
Investigating.
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: 17990
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Re: Script Language
OK, I've found the problem, I 'll get an updated test version out, probably tomorrow.
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!