Results 1 to 3 of 3
  1. #1
    New Member
    Join Date
    Aug 2016
    Location
    Sweden
    Posts
    4
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Question Could someone please point me in the right direction

    I'm just in the beginning of my Arduino+FSX journey and have build my self the multi radio panel with some changes to make it work with a I2C controller for the display. I've been experimenting with both Link2FS and MobiFlight with some basic switches and I have been reading a lot of forums, tutorials and code examples. However, I obviously miss the basic knowledge on how everything (FSUIPC, Link2FS, LUA, Lvars, offsets etc) fits together and no matter how much I read about it I don't quite get it. I have some experience in both coding in general and Arduino development, so when I managed to build a working com/nav panel I thought I had what it takes to take the next step but obviously I don't.

    I would like to build an "FCU" panel for my Aerosoft A320, but for the last couple of days I've been sitting here with a Mega board and a 7 segment Max7219 display just trying to figure out how to get those darn altitude numbers to show up on my display. "There's a SDK for that bird" someone pointed out to me, and I have that right in front of me but I have no idea no idea what to do with it. I found LINDA and have been experimenting with that as well, looking at the AB_AP_ALT_select Lvar as it changes when I turn the knob in FSX. I've been experimenting with Link2FS, both the regular and the expert version, trying get the value from an Lvar to my Arduino. I've also been experimenting with MobiFlight, but everything seems to circle around those FSUIPC offsets and I think that's where I loose it.

    I'm looking at the screen shots in the "Level-D B767 MCP and Link2fs Multi" thread and wonder, where did those offsets come from? Since the A320 LUA script don't mention any offsets I just can't figure out how, for example, the AB_AP_ALT_select Lvar relate to any offset.

    I'm not asking for someone to give me a complete solution for my whole project, but I would really appreciate if someone could point me in the right direction so I can move on. In short: How can I get the altitude selected on my A320 FCU to my Arduino? If I only got that right I think I'll be able to sort the rest out on my own.

  2. #2
    New Member
    Join Date
    Aug 2016
    Location
    Sweden
    Posts
    4
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Could someone please point me in the right direction

    I think I've manage to take one step closer to getting that altitude on my led display. Excuse me if this isn't a Link2FS solution, but I found a thread in the MobiFlight forum about this particular issue. Unfortunately there's a link in the chain that's missing in that thread.

    Now I know that I should write my own LUA script with something like the following:
    Code:
    function MobiFlight_Map_FSUIPC ()
    	
      while true do
      	alt = 0
      	alt = ipc.readLvar("L:AB_AP_ALT_select")
      	ipc.writeSD(0x66C0, alt)
      	ipc.sleep(800)
      end
    end
    I've placed this in the modules folder but how do I get that function executed?

  3. #3
    New Member
    Join Date
    Aug 2016
    Location
    Sweden
    Posts
    4
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Could someone please point me in the right direction

    I finally did it and even though this is probably at such a level that it's obvious for everyone I though I would share what I did. If someone have a better solution, please share it!


    In order to read/write values that belongs to an Lvar they have to be "assigned" to "user offsets", a range starting from 0x66C0. In my case I wanted to read out the selected altitude on my Aerosoft A320 and since it doesn't use the default FSX auto pilot and Aerosoft doesn't provide offsets, all I had was its Lvar, AB_AP_ALT_Select.


    In order to "assign" an offset to the Lvar I found out that I needed a lua script in the modules folder. This little script does not only give me the readings, it also makes it possible for me to change it (in my case I use a rotary encoder in MobiFlight, haven't tested it with Link2FS yet):


    Code:
    first = true
    
    
    while true do
        if first then
            initialALTVal = ipc.readLvar("L:AB_AP_ALT_Select")
            ipc.writeUD(0x66C0, initialALTVal)
            first = false
        else
            currentALTVal = ipc.readUD(0x66C0)
            ipc.writeLvar("L:AB_AP_ALT_Select", currentALTVal)
        end
    end

    As I understand it, the Lvar allways contains the current value that is displayed in the simulator. In my case reading the value for AB_AP_ALT_Select will always give me the value displayed in the altitude display in the "cockpit". The offset value however doesn't necessarily need to be the same as the Lvar. For instance, when I turn my encoder assigned to the offset it will change the value of the offset but in order to change the value in the "cockpit" I need to write that to the Lvar.


    In the script above the value of the Lvar is written to the offset I've choosen (0x66C0) upon the first execution of the loop. This is the part where the offset gets assigned to the Lvar and this is necessary to get those values "in sync". Then it reads the value of the offset, over and over again, and write that to the Lvar.


    So far so good, but then I realized that I needed to do something to get that lua script executed. I found out that I could assign a keypress combination that executed the script. In FSUIPC, under Key Presses, I choose a combination that is not in use and choose lua a320script in the drop down list, where "a320script" is the name of the lua script file. Then pressed confirm and pressed the combination of keys. That euphoric feeling of success as the numbers finally turned up on my display is something special


    However, as I read the example lua scripts provided with FSUIPC I realize that maybe I don't need to assign a key combination to execute the script. I haven't tested this but I think that if I place a script called Ipcready.lua in the modules folder with the following content it will be executed as soon as I choose one of my Airbus models:

    Code:
    if ipc.readSTR(0x3D00, 6) == "Airbus" then
    
    
        ipc.runlua("a320script")
    
    
    end

    As I mentioned above I'm more than happy to hear about better solutions or corrections on things that's wrong with this.