maartentamboer / X-Touch-Mini-FS2020

Control FS2020 with a Behringer X-Touch Mini
https://dev-tty.nl/X-Touch-Mini-FS2020/
MIT License
59 stars 19 forks source link

[QUESTION] How to set LVAR #39

Closed gleclere closed 1 year ago

gleclere commented 3 years ago

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.

SQLSammy commented 3 years ago

Maybe this is the solution:

https://github.com/maartentamboer/X-Touch-Mini-FS2020/issues/15

gleclere commented 3 years ago

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:

{
  "index": 3,
  "event_up": {
    "type": "condition",
    "event": [ "{% set mfd_range = data.get_local_variable('A320_NEO_MFD_RANGE_1') %}",
                 "{{ data.set_local_variable('A320_NEO_MFD_RANGE_1', mfd_range + 1) }}"]
  },
  "event_down": {
    "type": "condition",
    "event": [ "{% set mfd_range = data.get_local_variable('A320_NEO_MFD_RANGE_1') %}",
                 "{{ data.set_local_variable('A320_NEO_MFD_RANGE_1', mfd_range - 1) }}"]
  }
},
maartentamboer commented 3 years ago

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/ To see which functions you can call on the data object you can take a look at the https://github.com/maartentamboer/X-Touch-Mini-FS2020/blob/main/conditionalrunner.py file

maartentamboer commented 3 years ago

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:

SIMCONNECT_EXCEPTION_NAME_UNRECOGNIZED
SIMCONNECT_EXCEPTION_UNRECOGNIZED_ID: in (b'A32NX_NO_SMOKING_MEMO', b'Bool')

also tried with the L: in front of it

SIMCONNECT_EXCEPTION_NAME_UNRECOGNIZED
SIMCONNECT_EXCEPTION_UNRECOGNIZED_ID: in (b'L:A32NX_NO_SMOKING_MEMO', b'Bool')
Delta-Charlie-DEV commented 3 years ago

Hi,

I've been able to use some of LVAR variables of the FBW 320NX thanks to the Mobifligh WASM module. You'll find som info here on how to use X-Touch-Mini-FS2020 with Mobifligh: https://pastebin.com/fMdB7at2 (with a sample config file). Here is a list of the commands managed by mobiflight : https://docs.google.com/spreadsheets/d/1jTXlcHaJWx0B7TB63Pmma7bKwpxsxXJO6EJ3ECt7zpc/edit#gid=172455454

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

maartentamboer commented 3 years ago

https://github.com/maartentamboer/X-Touch-Mini-FS2020/pull/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.

maartentamboer commented 3 years ago

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 %}" ]
      }
    }
FraSie commented 3 years ago

Hello, I tried your new version and the above example for MFD_RANGE, it worked for me, great. For testing I played a little bit with a statement like { "index": 8, "event_press": { "type": "condition", "event": [ "{% set myvar02 = (data.get_global_variable('MFD_RANGE')) %}", "{{ data.print(myvar02) }}"
] } just to print out the value to the console, also working great. I jjust have no idea, why/how this 'MFD_RANGE' works. I cannot find any hint where this variable comes from. I was looking for 'A320_NEO_MFD_RANGE_1' and always get the 'None' returned. The reason why I am asking is that I want to have a similar thing for the button left to the range button, the MFD_NAV_MODE button. There are 5 seperate events: A320_Neo_MFD_NAV_MODE_1_LS / ...VOR / ...NAV / ...ARC .../ PLAN I am looking for a variable that shows the state of this button. I tried with A320_NEO_MFD_NAV_MODE_1, but as expected only 'None'...

Any ideas?

Thanks for your great work. Frank

TheJAG commented 3 years ago

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:


    {
      "index": 2,
      "event_up": {
        "description": "MFD NAV MODE - Clockwise",
        "type": "condition",
        "event": [ "{% if data.get_global_variable('MFD_NAV_MODE') == 0 %}",
                     "{{ data.trigger_event('MobiFlight.A320_Neo_MFD_NAV_MODE_1_VOR', 1) }}",
                     "{{ data.set_global_variable('MFD_NAV_MODE', 1) }}",
                   "{% elif data.get_global_variable('MFD_NAV_MODE') == 1 %}",
                     "{{ data.trigger_event('MobiFlight.A320_Neo_MFD_NAV_MODE_1_NAV', 1) }}",
                     "{{ data.set_global_variable('MFD_NAV_MODE', 2) }}",
                   "{% elif data.get_global_variable('MFD_NAV_MODE') == 2 %}",
                     "{{ data.trigger_event('MobiFlight.A320_Neo_MFD_NAV_MODE_1_ARC', 1) }}",
                     "{{ data.set_global_variable('MFD_NAV_MODE', 3) }}",
                   "{% elif data.get_global_variable('MFD_NAV_MODE') == 3 %}",
                     "{{ data.trigger_event('MobiFlight.A320_Neo_MFD_NAV_MODE_1_PLAN', 1) }}",
                     "{{ data.set_global_variable('MFD_NAV_MODE', 4) }}",
                  "{% elif data.get_global_variable('MFD_NAV_MODE') == 4 %}",
                     "{{ data.trigger_event('MobiFlight.A320_Neo_MFD_NAV_MODE_1_PLAN', 1) }}",
                   "{% else %}",
                     "{{ data.trigger_event('MobiFlight.A320_Neo_MFD_NAV_MODE_1_LS', 1) }}",
                     "{{ data.set_global_variable('MFD_NAV_MODE', 0) }}",
                   "{% endif %}" ]
      },
      "event_down": {
        "description": "MFD NAV MODE - Anti-clockwise",
        "type": "condition",
        "event": [ "{% if data.get_global_variable('MFD_NAV_MODE') == 4 %}",
                     "{{ data.trigger_event('MobiFlight.A320_Neo_MFD_NAV_MODE_1_ARC', 1) }}",
                     "{{ data.set_global_variable('MFD_NAV_MODE', 3) }}",
                   "{% elif data.get_global_variable('MFD_NAV_MODE') == 3 %}",
                     "{{ data.trigger_event('MobiFlight.A320_Neo_MFD_NAV_MODE_1_NAV', 1) }}",
                     "{{ data.set_global_variable('MFD_NAV_MODE', 2) }}",
                   "{% elif data.get_global_variable('MFD_NAV_MODE') == 2 %}",
                     "{{ data.trigger_event('MobiFlight.A320_Neo_MFD_NAV_MODE_1_VOR', 1) }}",
                     "{{ data.set_global_variable('MFD_NAV_MODE', 1) }}",
                   "{% elif data.get_global_variable('MFD_NAV_MODE') == 1 %}",
                     "{{ data.trigger_event('MobiFlight.A320_Neo_MFD_NAV_MODE_1_LS', 1) }}",
                     "{{ data.set_global_variable('MFD_NAV_MODE', 0) }}",
                  "{% elif data.get_global_variable('MFD_NAV_MODE') == 0 %}",
                     "{{ data.trigger_event('MobiFlight.A320_Neo_MFD_NAV_MODE_1_LS', 1) }}",
                   "{% else %}",
                     "{{ data.trigger_event('MobiFlight.A320_Neo_MFD_NAV_MODE_1_PLAN', 1) }}",
                     "{{ data.set_global_variable('MFD_NAV_MODE', 4) }}",
                   "{% endif %}" ]
      }
    },

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?


    {
      "index": 8,
      "event_up": {
        "description": "Radio - Increase frequency",
        "type": "condition",
        "event": [ "{% if data.get_global_variable('RADIO_INT_DEC') == 0 %}",
                     "{{ data.trigger_event('MobiFlight.A320_Neo_FDW_DIAL_L_INTEGER_INC', 1) }}",
                   "{% else %}",
                     "{{ data.trigger_event('MobiFlight.A320_Neo_FDW_DIAL_L_DECIMAL_INC', 1) }}",
                   "{% endif %}" ]
      },
      "event_down": {
        "description": "Radio - Decrease frequency",
        "type": "condition",
        "event": [ "{% if data.get_global_variable('RADIO_INT_DEC') == 0 %}",
                     "{{ data.trigger_event('MobiFlight.A320_Neo_FDW_DIAL_L_INTEGER_DEC', 1) }}",
                   "{% else %}",
                     "{{ data.trigger_event('MobiFlight.A320_Neo_FDW_DIAL_L_DECIMAL_DEC', 1) }}",
                   "{% endif %}" ]
      },
      "event_short_press": {
        "description": "Radio - Toggle between whole and decimal values",
        "type": "condition",
        "event": [ "{% if data.get_global_variable('RADIO_INT_DEC') == 0 %}",
                     "{{ data.set_global_variable('RADIO_INT_DEC', 1) }}",
                   "{% else %}",
                     "{{ data.set_global_variable('RADIO_INT_DEC', 0) }}",
                   "{% endif %}" ]
      }
    }
TheJAG commented 3 years ago

Too quick - apparently the FBW team fixed the default call. So we can just use:

    {
      "index": 8,
      "event_up": {
        "description": "Radio - Increase frequency",
        "type": "condition",
        "event": [ "{% if data.get_global_variable('RADIO_INT_DEC') == 0 %}",
                     "{{ data.trigger_event('COM_RADIO_WHOLE_INC', 1) }}",
                   "{% else %}",
                     "{{ data.trigger_event('COM_RADIO_FRACT_INC', 1) }}",
                   "{% endif %}" ]
      },
      "event_down": {
        "description": "Radio - Decrease frequency",
        "type": "condition",
        "event": [ "{% if data.get_global_variable('RADIO_INT_DEC') == 0 %}",
                     "{{ data.trigger_event('COM_RADIO_WHOLE_DEC', 1) }}",
                   "{% else %}",
                     "{{ data.trigger_event('COM_RADIO_FRACT_DEC', 1) }}",
                   "{% endif %}" ]
      },
      "event_short_press": {
        "description": "Radio - Toggle between whole and decimal values",
        "type": "condition",
        "event": [ "{% if data.get_global_variable('RADIO_INT_DEC') == 0 %}",
                     "{{ data.set_global_variable('RADIO_INT_DEC', 1) }}",
                   "{% else %}",
                     "{{ data.set_global_variable('RADIO_INT_DEC', 0) }}",
                   "{% endif %}" ]
      }
    }
SQLSammy commented 3 years ago

For radios its easier { "index": 8, "event_up": "COM_RADIO_WHOLE_INC", "event_down": "COM_RADIO_WHOLE_DEC", "alternate_event_up": "COM_RADIO_FRACT_INC", "alternate_event_down": "COM_RADIO_FRACT_DEC", "event_short_press": "{alternate}", "event_long_press": "COM_STBY_RADIO_SWAP" },

TheJAG commented 3 years ago

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?

    {
      "index": 2,
      "event_press": {
        "description": "Trigger CPT EFIS LS",
        "type": "condition",
        "event": [ "{{ data.trigger_event('MobiFlight.A320_Neo_PFD_BTN_LS_1', 1) }}" ]
      }
    },
maartentamboer commented 3 years ago

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.

TheJAG commented 3 years ago

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.

image

Is there anything I'm missing?

SQLSammy commented 3 years ago

Hello, I tried your new version and the above example for MFD_RANGE, it worked for me, great. For testing I played a little bit with a statement like { "index": 8, "event_press": { "type": "condition", "event": [ "{% set myvar02 = (data.get_global_variable('MFD_RANGE')) %}", "{{ data.print(myvar02) }}" ] } ....

Thanks for your great work. Frank

Is it possible that you read and print sample has some missing or wrong brackets? Is it possible that you post a real working sample?

SQLSammy commented 3 years ago

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?

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 with conditional setvars

FraSie commented 3 years ago

Is it possible that you read and print sample has some missing or wrong brackets? Is it possible that you post a real working sample?

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) { "index": 8, "event_press": { "type": "condition", "event": [ "{% set myvar02 = (data.get_global_variable('MFD_RANGE')) %}", "{{ data.print(myvar02) }}", "{{ data.set_encoder_led_value(8, 7) }}"
] } },

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.

FraSie commented 3 years ago

@TheJAG 👍 Thanks a lot, that helped. With the MFD_NAV_MODE it worked. And after my previous post I also seem to understand one of my problems. I think I also checked the variable with "my print method" and was frustrated because it only always printed out 'None'. I integrated your script, turned the encoder button, it worked, and now it prints out real values for MFD_NAV_MODE. I thought printing the values could be a fast method to help to detect the right variables.

FraSie commented 3 years ago

Concerning A320_Neo_PFD_BTN_LS_1: I just posted an answer in https://forums.flightsimulator.com/t/behringer-x-touch-mini-works-flawless/193140

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 A320_Neo_PFD_BTN_LS1#(>H:A320_Neo_PFD_BTN_LS_1) should be changed to A320_Neo_PFD_BTN_LS_1#(>H:A320_Neo_PFD_BTN_LS1) (remove the '' before the '#', the same for the subsequent lines)

With the "short" syntax "event_press": "MobiFlight.A320_Neo_PFD_BTN_LS_1" I also get a warning, but it works.

With the (old?) long syntax "event_press": { "event": "MobiFlight.A320_Neo_PFD_BTN_LS_1", "type": "manual", "value": 1 } it works without a warning.

TheJAG commented 3 years ago

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!

SQLSammy commented 3 years ago

Is it possible to open the WIKI to collect snippets, tipps and tricks for configuration? I think here in the comments these topics get lost for next users.

like A32NX - LS on left side demonstrating mobiflight usage

In the events.txt of mobiflight WASM in community folder the line 296 A320_Neo_PFD_BTN_LS1#(>H:A320_Neo_PFD_BTN_LS_1) should be changed to A320_Neo_PFD_BTN_LS_1#(>H:A320_Neo_PFD_BTN_LS1) (remove the '' before the '#', the same for the subsequent lines)

and in config use

{
  "index": 15,
  "event_press": {
    "event": "MobiFlight.A320_Neo_PFD_BTN_LS_1",
    "type": "manual",
    "value": 1
  }

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

{
  "index": 6,
  "event_up": "NAV1_RADIO_WHOLE_INC",
  "event_down": "NAV1_RADIO_WHOLE_DEC",
  "alternate_event_up": "NAV1_RADIO_FRACT_INC",
  "alternate_event_down": "NAV1_RADIO_FRACT_DEC",
  "event_short_press": "{alternate}",
  "event_long_press": "NAV1_RADIO_SWAP"
},
gleclere commented 3 years ago

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.

maartentamboer commented 3 years ago

This sounds like a great idea. I think there's 2 options.

  1. Create a wiki
  2. use github pages to make a website

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

maartentamboer commented 3 years ago

3rd option would be readthedocs which might be the best one since it works great with multiple pages

SQLSammy commented 3 years ago

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 1) by aircraft and function 2) by code features like conditions, variables, alternate function, event types or things like general tipps regarding mobiflight wasm

Below the line every variant is better than documenting it just by creating sample configs or post it here in the issues tracker.

Which solution can be combined with the issues tracker to discuss and test snippets?

maartentamboer commented 3 years ago

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

SQLSammy commented 3 years ago

Before we have the new knowledge base, here is my new Baro config for the A32NX long press = std, short press =qnh. I dont think that the value 2 is needed, just had no more time to test it

{ "index": 1, "event_up": "KOHLSMAN_INC", "event_down": "KOHLSMAN_DEC",

  "event_press": {
    "event": "MobiFlight.XMLVAR_Baro1_Mode_QNH",
    "type": "manual",
    "value": 2
  },
  "event_long_press": {
    "event": "MobiFlight.XMLVAR_Baro1_Mode_STD",
    "type": "manual",
    "value": 2
  }
},
TheJAG commented 3 years ago

I've made the baro somewhat more complicated .. ;)

    {
      "index": 1,
      "event_up": {
        "description": "CPT side BARO - Increase barometric pressure",
        "type": "condition",
        "event": [ "{% if data.get_global_variable('BARO_STD') == None %}",
                     "{{ data.trigger_event('KOHLSMAN_INC', 1) }}",
                   "{% endif %}" ]
      },
      "event_down": {
        "description": "CPT side BARO - Decrease barometric pressure",
        "type": "condition",
        "event": [ "{% if data.get_global_variable('BARO_STD') == None %}",
                     "{{ data.trigger_event('KOHLSMAN_DEC', 1) }}",
                   "{% endif %}" ]
      },
      "event_short_press": {
        "description": "CPT side BARO - Switch between QNH and STD",
        "type": "condition",
        "event": [ "{% if data.get_global_variable('BARO_STD') == None %}",
                     "{{ data.trigger_event('MobiFlight.XMLVAR_Baro1_Mode_STD', 1) }}",
                     "{{ data.set_global_variable('BARO_STD', True) }}",
                   "{% else %}",
                     "{{ data.trigger_event('MobiFlight.XMLVAR_Baro1_Mode_QNH', 1) }}",
                     "{{ data.set_global_variable('BARO_STD', None) }}",
                   "{% endif %}" ]
      },
      "event_long_press":  {
        "description": "CPT side BARO - Switch between inHg and hPa",
        "type": "condition",
        "event": [ "{% if data.get_global_variable('BARO_INCH_HP') == 0 %}",
                     "{{ data.trigger_event('MobiFlight.XMLVAR_Baro_Selector_HPA_1_inHg', 1) }}",
                     "{{ data.set_global_variable('BARO_INCH_HP', 1) }}",
                   "{% else %}",
                     "{{ data.trigger_event('MobiFlight.XMLVAR_Baro_Selector_HPA_1_hPa', 1) }}",
                     "{{ data.set_global_variable('BARO_INCH_HP', 0) }}",
                   "{% endif %}" ]
      }
    },

NB The events.txt does require the following lines to be added, best to put them in the >> // A32X FBW - GLARE << section.

XMLVAR_Baro_Selector_HPA_1_hPa#0 (>L:XMLVAR_Baro_Selector_HPA_1)
XMLVAR_Baro_Selector_HPA_1_inHg#1 (>L:XMLVAR_Baro_Selector_HPA_1)
maartentamboer commented 3 years ago

Woah nice config. The website is on its way. I hopefully have some time tonight to push it to the repo and configure the github action so it will be automatically published image

maartentamboer commented 3 years ago

Website is live at https://dev-tty.nl/X-Touch-Mini-FS2020/ I've added a little information about how to add content and preview the site locally in https://dev-tty.nl/X-Touch-Mini-FS2020/getting-started/developing/ It is automatically published every time something changes in the main branch. I will start adding content this weekend. But feel free to open pull-requests

I've opened up a discussion over at https://github.com/maartentamboer/X-Touch-Mini-FS2020/discussions/48 to further discuss website content / snippets and so on. Since this issue has deviated quite a bit from the original LVAR issue.

maartentamboer commented 3 years ago

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: https://github.com/maartentamboer/X-Touch-Mini-FS2020/blob/main/Configurations/config_a320.json#L88-L95 https://github.com/maartentamboer/X-Touch-Mini-FS2020/blob/main/Configurations/Functions/A320/mfd-range-up.jinja2

Download is at https://github.com/maartentamboer/X-Touch-Mini-FS2020/releases/tag/v1.4.0

vicentezc commented 3 years ago

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) A320_Neo_MFD_NAV_MODE_1_VOR#1 (>L:A320_Neo_MFD_NAV_MODE_1) A320_Neo_MFD_NAV_MODE_1_NAV#2 (>L:A320_Neo_MFD_NAV_MODE_1) A320_Neo_MFD_NAV_MODE_1_ARC#3 (>L:A320_Neo_MFD_NAV_MODE_1) A320_Neo_MFD_NAV_MODE_1_PLAN#4 (>L:A320_Neo_MFD_NAV_MODE_1)

Is there a way to get the value of L:A320_Neo_MFD_NAV_MODE_1? I tried using for example: data.get_simvar_value('MobiFlight.A320_Neo_MFD_NAV_MODE_1')

But it's not working, the value I get for that Lvar is 'None'

maartentamboer commented 3 years ago

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

vicentezc commented 3 years ago

Thanks a lot! I have asked the question in MobiFlight's forum. :)

elewarr commented 3 years ago
A320_Neo_MFD_NAV_MODE_1_LS#0 (>L:A320_Neo_MFD_NAV_MODE_1)
A320_Neo_MFD_NAV_MODE_1_VOR#1 (>L:A320_Neo_MFD_NAV_MODE_1)
A320_Neo_MFD_NAV_MODE_1_NAV#2 (>L:A320_Neo_MFD_NAV_MODE_1)
A320_Neo_MFD_NAV_MODE_1_ARC#3 (>L:A320_Neo_MFD_NAV_MODE_1)
A320_Neo_MFD_NAV_MODE_1_PLAN#4 (>L:A320_Neo_MFD_NAV_MODE_1)

Does anyone have the description of the format used in MobiFlight's events.txt?

maartentamboer commented 3 years ago

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: A320_Neo_MFD_NAV_MODE_1_LS: The event that you want to create, call via MobiFlight.A320_Neo_MFD_NAV_MODE_1_LS #0: The value that you want to write into the variable (>L:A320_Neo_MFD_NAV_MODE_1): The variable that you want to write to

bigbrowncow commented 3 years ago

Coming back to the Lvars, do you have an idea if we can get the value of the MobiFlight Lvars?

Is there a way to get the value of L:A320_Neo_MFD_NAV_MODE_1? I tried using for example: data.get_simvar_value('MobiFlight.A320_Neo_MFD_NAV_MODE_1')

But it's not working, the value I get for that Lvar is 'None'

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

maartentamboer commented 3 years ago

New release has been made: https://github.com/maartentamboer/X-Touch-Mini-FS2020/releases/tag/v1.7.0

P1NBA11ER commented 3 years ago

The latest experimental release of the A32NX seems to have changed some things related to the EFIS control panel and the ND as part of their custom LNAV since the current configurations with X-Touch-MSFS aren't working. I would assume the FBW team have created their own local variables for many of these items and I expect this info is documented somewhere, but I've had no luck finding it. Has anyone successfully configured the their X-Touch to work with the A32NX experimental LNAV? I'd like to get the range and mode knobs back to doing something.

I found these... are they the new variables? I can't get any of this to work really. image

vicentezc commented 3 years ago

If those are the new variables, I guess you would need to add them to Mobiflight as well (if not done already). Once they are defined in Mobiflight, I guess they would be usable.

bigbrowncow commented 3 years ago

See a solution here https://github.com/maartentamboer/X-Touch-Mini-FS2020/discussions/89

P1NBA11ER commented 3 years ago

If those are the new variables, I guess you would need to add them to Mobiflight as well (if not done already). Once they are defined in Mobiflight, I guess they would be usable.

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?