MobiFlight Community Support

Welcome to the forum for MobiFlight! Feel free to reach out to the community in case you have questions, issues or just want to share great ideas or details about your latest home cockpit project.

You like MobiFlight? Donate via PayPal and support the MobiFlight development. Thanks! 

Go to page 1Go to page 0123Go to page 2Go to page 3
Avatar
inancatil
Posts: 47
Hi,
I am using aerosoft and I need to write offset data to Lvar. I can read values from Lvar and write them to free offsets. Then I used mobiflight to show that data on my 7 segment display. I used following lua script for it.

Now I want to use my rotaries. I can change the offset value inside mobiflight. But since I do not write new value to Lvar , it doesnt work. Is anyone using lua script to change Lvar value?
2015-08-18 16:16
Avatar
DocMoebiuz
Moderator
From: NW of KPWK, United States
Posts: 1443
I have a function prepared for my A2A Cessna where I set an Offset and sync it with the LUA variable.
In this case it is very simple.
iconCode:
function MobiFlight_Map_FSUIPC ()
  -- write LVar to variable
  Bat_Lvar = ipc.readLvar("Battery1Switch")
  -- write FSUIPC value to variable
  Bat_Offset = ipc.readUD(0x66C0);

  -- if FSUIPC differs from LUA variable...
  if Bat_Lvar ~= BatOffset then
    ipc.writeLvar("Battery1Switch", BatOffset);
  end
end


In your case you might want to first and only once write the current Airbus value to your custom FSUIPC.
After this, your FSUIPC value is the "leading" value, you increment or decrement the value and sync it back to the LVar.

Maybe something like this could work for you
iconCode:
first = true
while true do
  if first then
    first = false
    initialValue = ipc.readLvar("L:YOUR_SPECIFIC_VALUE")
    ipc.writeXX(0x66C0, initialValue)
  else
    currentValue = ipc.readXX(0x66C0)
    ipc.writeLvar("L:YOUR_SPECIFIC_VALUE", currentValue)
  end
end


It is not tested but it could guide you towards the correct solution
Have a great day!
Sebastian

MobiFlight - Simply build your own home cockpit for your favorite flight sim - FSX, Prepar3D (FSUIPC), X-Plane (XPUIPC)
2015-08-18 21:52
Avatar
inancatil
Posts: 47
Hi,
Thanks for answer! It works for IAS and I am sure it will also work with ALT and V/S. However I got into trouble with heading. I modified the code and it seems working but when heading comes to 179 it doesnt go up to 180. Same for 180 , it doesnt go down to 179. I used following lua for heading
iconCode:
first = true
while true do
  if first then
    first = false
    initialValue = ipc.readLvar("L:AB_AP_HDG_Select")
    ipc.writeSD(0x66C0, math.floor(initialValue*(65535/360)+1))
  else
    currentValue = math.floor(ipc.readSD(0x66C0)*0.0054945054945055)
    ipc.writeLvar("L:AB_AP_HDG_Select", currentValue)
  end
end

In mobiflight part , I write $+182 for increasing , $-182 for decreasing. I dont understand why it stop at 179 and 180.

if I get Lvar value of heading directly , after 360 it goes 361,362,363 and so on. So I decided to get it as default heading. But this interesting problem occured.
Thanks for any help.
[Last edited by inancatil, 2015-08-19 21:20]
2015-08-19 13:28
Avatar
inancatil
Posts: 47
I found the problem. I am using ipc.writeUD and ipc.readUD functions. The problem is , fsuipc recognized the range as -32767 to 32767 instead of 0 to 65535. So if I am not using wrong functions it is fsuipc releated problem. I will open new topic on their forum but if you know something about it , please let me know.
Thanks.
2015-08-19 21:20
Avatar
inancatil
Posts: 47
I found my answer in German part :D I will test for the last time tomorrow. If everything works , I will post my lua files and mobiflight settings here.
2015-08-19 22:12
Avatar
DocMoebiuz
Moderator
From: NW of KPWK, United States
Posts: 1443
iconinancatil:

I found my answer in German part :D I will test for the last time tomorrow. If everything works , I will post my lua files and mobiflight settings here.



Sounds great!
Have a great day!
Sebastian

MobiFlight - Simply build your own home cockpit for your favorite flight sim - FSX, Prepar3D (FSUIPC), X-Plane (XPUIPC)
2015-08-19 22:59
Avatar
inancatil
Posts: 47
Hi,
Unfortunately heading bug is not working properly. I read the FSUIPC documentation and some forums. I found this saying:
"2 bytes (known as a WORD or SMALLINT) can store a number between 0-65535 unsigned or -32767 – 32767 signed "
I am using writeUD and readUD functions. (First post was really wrong , I understood after it :) ). I am monitoring offset value with fsuipc log and mobiflight at the same time. While fsuipc reads right value , mobiflight doesnt. Here is a screenshot; (look for heading , 0x66C8)

I used 2 bytes size and "0xFFFF" mask value in this screenshot. It seems mobiflight reads as signed value or whatever I dont know. If I choose 4 bytes , which I did yesterday and thought it was working, after 65535 it goes on instead of returning 0. I am really confused. Either mobiflight is wrong or I really dont get this stuff.
2015-08-20 16:57
Avatar
DocMoebiuz
Moderator
From: NW of KPWK, United States
Posts: 1443
Hi Incantil,

just add 180 in case the value is smaller than 0... compare the preset setting that ships with MobiFlight "General - Current Heading"
That should do!
Have a great day!
Sebastian

MobiFlight - Simply build your own home cockpit for your favorite flight sim - FSX, Prepar3D (FSUIPC), X-Plane (XPUIPC)
2015-08-20 19:33
Avatar
inancatil
Posts: 47
Aerosoft airbus system is too complicated and is gettiing more and more complicated with the usage of offsets :( But I will do it anyway.(I hope :D ) Furthermore I want to ask 1 thing, I have created a lua file which toggles the heading mode. (SET and MANAGED mod). I assigned "F3" to run this lua file and it works. Then in mobiflight I added button and chose emulate key action. But when I press the button it doesnt toggle. To test if button is working , I changed the key to "A" and open text file then pressed button and it wrote "A". So it is working. The problem is between mobiflight and fsuipc. Could you look for it?
Thanks
2015-08-22 19:25
Avatar
DocMoebiuz
Moderator
From: NW of KPWK, United States
Posts: 1443
That is strange. The keyboard commands are sent globally and not to an application in particular. Maybe some assignment in the FSX is "covering" the F3 since this is a default assignment as far as I know...

Have you tried another key for the assignment in FSUIPC?
Have a great day!
Sebastian

MobiFlight - Simply build your own home cockpit for your favorite flight sim - FSX, Prepar3D (FSUIPC), X-Plane (XPUIPC)
2015-08-23 12:30
Avatar
inancatil
Posts: 47
F3 is increase throttle as default in p3d settings but I deleted it. So normally when I press F3 nothing happens. I assigned F3 action into fsuipc, key press section.Also I tried "ctrl+alt+shift+h" combo but It doesnt work either. Can you please check same options? Because I use win10 and p3d. Maybe there are some incompatibilities.

In addition: I assign "G" key in mobiflight which toggles landing gears. It doesnt work too. Now I can say if it works for you , then this this is win10 and/or p3d problem sadly :(
[Last edited by inancatil, 2015-08-23 13:10]
2015-08-23 12:45
Avatar
inancatil
Posts: 47
About Update------------------
New update broke my mobiflight. It doesnt recognize my arduino board. I am using 6.0.2 for now.
2015-08-23 13:05
Avatar
DocMoebiuz
Moderator
From: NW of KPWK, United States
Posts: 1443
iconinancatil:

About Update------------------
New update broke my mobiflight. It doesnt recognize my arduino board. I am using 6.0.2 for now.



Oh man, what a pitty!!! I have tested with XP and Win7.

Please go to "Devices and Printers" and look for your Arduino Board. Right click on the icon and choose "Properties". There go to "Details"-Tab and check for "Device Description".
It should say "Arduino Mega 2560". What does it say in your installation?
Have a great day!
Sebastian

MobiFlight - Simply build your own home cockpit for your favorite flight sim - FSX, Prepar3D (FSUIPC), X-Plane (XPUIPC)
2015-08-23 17:21
Avatar
inancatil
Posts: 47
My board is clone and it says "USB-SERIAL CH340"
2015-08-23 17:37
Avatar
DocMoebiuz
Moderator
From: NW of KPWK, United States
Posts: 1443
And the PID/VID combination?
Have a great day!
Sebastian

MobiFlight - Simply build your own home cockpit for your favorite flight sim - FSX, Prepar3D (FSUIPC), X-Plane (XPUIPC)
2015-08-23 17:57
Go to page 1Go to page 0123Go to page 2Go to page 3