-
-
Notifications
You must be signed in to change notification settings - Fork 19
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[QUESTION] How to set LVAR #39
Comments
Maybe this is the solution: |
Thank you @SQLSammy I probably found a part of the answer in #14 "Conditional triggers can set and get global variables", but it doesn't work for local variables. For instance, I wish to change the MFD range of the A32NX using the encoder 3:
|
Since you linked the simvars documentation of the FBW A320 I guess you want to directly change a simvar with an encoder. In this case you should be able to use the get_simvar_value and set_simvar_value. But there might be a problem with the way python-simconnect returns None when you request a simvar that is not in it's list. I will do some research for this. {
"index": 3,
"event_up": {
"type": "condition",
"event": [ "{% set mfd_range = data.get_simvar_value('A320_NEO_MFD_RANGE_1') %}",
"{{ data.set_simvar_value('A320_NEO_MFD_RANGE_1', mfd_range + 1) }}"]
},
"event_down": {
"type": "condition",
"event": [ "{% set mfd_range = data.get_simvar_value('A320_NEO_MFD_RANGE_1') %}",
"{{ data.set_simvar_value('A320_NEO_MFD_RANGE_1', mfd_range - 1) }}"]
}
}, For more information about how to write code for the condition events. I use jinja2 to parse and execute the template https://jinja.palletsprojects.com/en/2.11.x/templates/ |
I've been looking into this and I'm not fully aware what an LVAR is. But I guess that it is a local variable that stays inside of the simulator / aircraft code. With that I was unable to connect to them using the simconnect API. I used the latest experimtal build of the FBW A320 and the simconnect API gave me this:
also tried with the L: in front of it
|
Hi, I've been able to use some of LVAR variables of the FBW 320NX thanks to the Mobifligh WASM module. Note everything is not available, as some commands use "HVAR" variables. I don't know the difference between LVAR and HVAR. Personnaly, I recently move from X-Touch-Mini-FS2020 to SPAD.NEXT, to be able to manage two X-Touch at the same time (and to gain the benefit of a UI tool to setup the commands). But I keep an eye on X-Touch-Mini-FS2020, I might switch back some time ;-) @gleclere funny, we've recently been in touch on "Flight Simulator 2020 France" facebook group :-) |
#41 has changes so the mobiflight WASM module can be used in conditional triggers. The config is really complex. So I will investigate adding a feature for using the encoder as a selector switch. Since these selector switches are quite common in aircraft. |
Release https://github.com/maartentamboer/X-Touch-Mini-FS2020/releases/tag/v1.3.0 is now available. This release can set the range using conditional triggers and the mobiflight wasm module. I've added it to the config_a320.json in the release. {
"index": 8,
"event_up": {
"type": "condition",
"event": [ "{% if data.get_global_variable('MFD_RANGE') == 10 %}",
"{{ data.trigger_event('MobiFlight.A320_neo_MFD_Range_1_20', 1) }}",
"{{ data.set_global_variable('MFD_RANGE', 20) }}",
"{% elif data.get_global_variable('MFD_RANGE') == 20 %}",
"{{ data.trigger_event('MobiFlight.A320_neo_MFD_Range_1_40', 1) }}",
"{{ data.set_global_variable('MFD_RANGE', 40) }}",
"{% elif data.get_global_variable('MFD_RANGE') == 40 %}",
"{{ data.trigger_event('MobiFlight.A320_neo_MFD_Range_1_80', 1) }}",
"{{ data.set_global_variable('MFD_RANGE', 80) }}",
"{% elif data.get_global_variable('MFD_RANGE') == 80 %}",
"{{ data.trigger_event('MobiFlight.A320_neo_MFD_Range_1_160', 1) }}",
"{{ data.set_global_variable('MFD_RANGE', 160) }}",
"{% elif data.get_global_variable('MFD_RANGE') == 160 %}",
"{{ data.trigger_event('MobiFlight.A320_neo_MFD_Range_1_320', 1) }}",
"{{ data.set_global_variable('MFD_RANGE', 320) }}",
"{% elif data.get_global_variable('MFD_RANGE') == 320 %}",
"{{ data.trigger_event('MobiFlight.A320_neo_MFD_Range_1_320', 1) }}",
"{% else %}",
"{{ data.trigger_event('MobiFlight.A320_neo_MFD_Range_1_10', 1) }}",
"{{ data.set_global_variable('MFD_RANGE', 10) }}",
"{% endif %}" ]
},
"event_down": {
"type": "condition",
"event": [ "{% if data.get_global_variable('MFD_RANGE') == 320 %}",
"{{ data.trigger_event('MobiFlight.A320_neo_MFD_Range_1_160', 1) }}",
"{{ data.set_global_variable('MFD_RANGE', 160) }}",
"{% elif data.get_global_variable('MFD_RANGE') == 160 %}",
"{{ data.trigger_event('MobiFlight.A320_neo_MFD_Range_1_80', 1) }}",
"{{ data.set_global_variable('MFD_RANGE', 80) }}",
"{% elif data.get_global_variable('MFD_RANGE') == 80 %}",
"{{ data.trigger_event('MobiFlight.A320_neo_MFD_Range_1_40', 1) }}",
"{{ data.set_global_variable('MFD_RANGE', 40) }}",
"{% elif data.get_global_variable('MFD_RANGE') == 40 %}",
"{{ data.trigger_event('MobiFlight.A320_neo_MFD_Range_1_20', 1) }}",
"{{ data.set_global_variable('MFD_RANGE', 20) }}",
"{% elif data.get_global_variable('MFD_RANGE') == 20 %}",
"{{ data.trigger_event('MobiFlight.A320_neo_MFD_Range_1_10', 1) }}",
"{{ data.set_global_variable('MFD_RANGE', 10) }}",
"{% elif data.get_global_variable('MFD_RANGE') == 10 %}",
"{{ data.trigger_event('MobiFlight.A320_neo_MFD_Range_1_10', 1) }}",
"{% else %}",
"{{ data.trigger_event('MobiFlight.A320_neo_MFD_Range_1_10', 1) }}",
"{{ data.set_global_variable('MFD_RANGE', 10) }}",
"{% endif %}" ]
}
} |
Hello, Any ideas? Thanks for your great work. |
If I understand correctly from my playing around last night, the MFD_RANGE is an internal variable. You can set it to whatever, introduce your own etc. And you need to use the MobiFlight implementation of the NAV_MODE. It's easy from there, I've just implemented NAV mode myself:
One question I have myself, just trying to implement the radio - even though it says tested on the WASM Events list, I'm getting no response with this code. Any glaring obvious reason I'm missing here?
|
Too quick - apparently the FBW team fixed the default call. So we can just use:
|
For radios its easier |
Thanks for that mate, great stuff. One more, I'm having an issue setting the Captain EFIS for the ILS - is the following the right way to make a single call to MobiFlight?
|
If you want to fire off a single event you can just place the name of the event: {
"index": 2,
"event_press": "MobiFlight.A320_Neo_PFD_BTN_LS_1"
}, Some events have an option of passing a value with them, for those you can either use the manual event or the condition event. |
That makes way more sense, thanks @maartentamboer . This does throw a warning "WARNING: Event MobiFlight.A320_Neo_PFD_BTN_LS_1, was not found in simconnect list. Using a manual binding". I'm assuming this is fine (edit: should've set "type" to "manual" to suppress this message) - however I'm not getting the expected result. I was hoping to control this button but so far without success. Is there anything I'm missing? |
Is it possible that you read and print sample has some missing or wrong brackets? |
...
I am trying to use BTN_LS_1_FILTER_ACTIVE variable , which i have found in the FBW file for YourControls First i try to get the read and print sample working to look which values it needs and then try to toggle it |
Hello, sorry, my original code included a statement to light up the encoder LED. I thought it would be confusing so I dropped it. But without that line, it produces an error. The "event" statement seems to need 3 arguments. So here my complete code: (tested) In the beginning if you press the button 8, it prints out None. You have to turn the encoder knob once to change the MFD_RANGE value at least once, then it works. |
@TheJAG 👍 |
Concerning A320_Neo_PFD_BTN_LS_1: I think you need the latest beta 8.2.0.1 form the Mobiflight to use it succesfully. It has more functions and an extend events.txt. It can be found at https://bitbucket.org/mobiflight/mobiflightfc/downloads/ In the events.txt the line 296 With the "short" syntax With the (old?) long syntax |
Frank, you are an absolute legend! That's exactly it, the events.txt actually quite a few of these trailing underscores, and of course none of those calls work. Thanks for confirming I'm not going crazy haha, never thought about checking the events.txt in that kind of detail. Great catch mate! |
Is it possible to open the WIKI to collect snippets, tipps and tricks for configuration? like In the events.txt of mobiflight WASM in community folder the line 296 and in config use
NAV1 frequency and Swap demonstrating alternate events Use this snippet to dial freqency of NAV1, short press switches between FULL and FRACT, long press swaps
|
I'm learning so much reading this thread! I agree it should be nice to open a Wiki, or to add a "docs" folder to the project with markdown documentations. |
This sounds like a great idea. I think there's 2 options.
To edit a wiki people need to be added as a collaborator to the repository, because you cannot edit a wiki trough a PR. If we go the gh-pages route everyone can just open a PR to propose changes to the website |
3rd option would be readthedocs which might be the best one since it works great with multiple pages |
I think the important thing is, that it will be a structured, tagged and searchable. I see 2 different ways to look for samples/snippets
Below the line every variant is better than documenting it just by creating sample configs or Which solution can be combined with the issues tracker to discuss and test snippets? |
This is an example of a readthedocs site https://docs.readthedocs.io/en/stable/intro/getting-started-with-sphinx.html . As you can see you can create separate pages that are searchable. So we could create different pages for different functions and dedicated pages or even whole sections for specific aircraft. We could discuss snippets in the https://github.com/maartentamboer/X-Touch-Mini-FS2020/discussions tab and then anyone can create a PR to add it to the docs |
Before we have the new knowledge base, here is my new Baro config for the A32NX {
|
I've made the baro somewhat more complicated .. ;)
NB The events.txt does require the following lines to be added, best to put them in the >> // A32X FBW - GLARE << section.
|
Website is live at https://dev-tty.nl/X-Touch-Mini-FS2020/ I've opened up a discussion over at #48 to further discuss website content / snippets and so on. Since this issue has deviated quite a bit from the original LVAR issue. |
Since the conditional triggers in this topic are becoming quite complex, I've just made a new release that enables you to have the conditional trigger in a seperate file. This means you can also get syntax highlighting in Visual Studio Code with the https://marketplace.visualstudio.com/items?itemName=samuelcolvin.jinjahtml plugin. Nice benefit is that these conditional-file triggers can now be reused accross multiple config files Example: Download is at https://github.com/maartentamboer/X-Touch-Mini-FS2020/releases/tag/v1.4.0 |
Coming back to the Lvars, do you have an idea if we can get the value of the MobiFlight Lvars? For example, I have these Lvars in MobiFlight's events.txt: A320_Neo_MFD_NAV_MODE_1_LS#0 (>L:A320_Neo_MFD_NAV_MODE_1) Is there a way to get the value of L:A320_Neo_MFD_NAV_MODE_1? But it's not working, the value I get for that Lvar is 'None' |
With the mobiflight plugin we call events and then they set the value in the simulator. It appears that they don't provide any simvars |
Thanks a lot! I have asked the question in MobiFlight's forum. :) |
Does anyone have the description of the format used in MobiFlight's |
The first part appears the event that you can call using simconnect, between the braces () stands the variable that you want to write it to. I think it works like this: |
I’ve modded the code so you can use a new function data.get_mobiflightsimvar_value(‘L:A320_Neo_MFD_NAV_MODE_1’) I’ve sent a pull request to Maarten with the modded code |
New release has been made: https://github.com/maartentamboer/X-Touch-Mini-FS2020/releases/tag/v1.7.0 |
If those are the new variables, I guess you would need to add them to Mobiflight as well (if not done already). |
See a solution here #89 |
I've tried mimicking other variables in the events txt but I don't really understand how it works so I don't think I'm doing it right. And it doesn't work obviously. Is there a tutorial somewhere that illustrates the process of adding new variables? |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Hi Maarten,
I'm wondering if it's possible to set LVAR such as A32NX ones described here https://github.com/flybywiresim/a32nx/blob/master/docs/a320-simvars.md
More generally, where can I find some documentation about the way the code should be written in type condition events?
Thank you for the great job you're doing.
The text was updated successfully, but these errors were encountered: