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! 

05/03/2024 - This forum is read-only

The community support for MobiFlight has moved exclusively over to our Discord server. Register for free and enjoy more interactive functions like image and video upload, voice chat. More than 7,000 registered users around the world make it a great experience!

See you on our MobiFlight Community Discord server.

A HUGE Thank You to everyone who participated in the forum, especially obviously to Pizman and Stephan who did an outstanding job over so many years providing an incredible service to the MobiFlight community.

The forum is still providing a lot of good content, hence we keep this information accessible.

Go to page 1Go to page 1123Go to page 3Go to page 3
Avatar
buddym
Posts: 19
iconzenit_swe:

This may be a very stupid question, but how about just reading Lvars in order to display the value in a 7 segment display? I have a fully functional COM/NAV panel so I thought it wouldn't be that hard to build an auto pilot panel. However, I would like to use it with my Aerosoft A320 and that's where I'm running into a problem that I can't seem to wrap my little head around.

I got the LUA script for the A320 with all the functions for reading and writing the Lvars but I'm just sitting here with a Mega board and a MAX7219 7 segment display trying to figure out what to do in order to just get the FCU altitude on to that display. I'm probably missing the basic knowledge on the relationship between FSX, FSUIPC, LUA and Arduino.

2017-12-09 20:41
Avatar
buddym
Posts: 19
Hi there,

I'm trying to get the same thing working. I have 2 displays on 7219 drivers, I have FCU speed, heading, and vertical speed working, can't figure out how to split the left 2 digits of FCU altitude on display 1, the right 3 digits on display 2..... did you solve this issue?

Thanks,
Buddy
2017-12-09 20:44
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
Hi

AGAIN:
Please NOT reopen Sticky Topics with Personal Requests !

About your question.... THIS is NOT recommend.
To Split ONE Data over 2 Displays you have to figure out a own logic and create this with 2 configs.... Again i high recommend to NOT do this !
Simply buy another Max7219 Chip (tube) and set this 5 Diggits to it....
the Number of Max chips is basicly not limmited ( You can use 4x8 tubes = 32 tubes = 256 Diggits on ONE Arduino..... if you use 20 Arduinos you can set thousends of diggits.
it´s realy not needed to split a Output over 2 Displays !
Good Luck !
2017-12-10 00:03
Avatar
sisoffi
Posts: 91
Hi at all,
i tried to use mobiflight with a macro function set to my Leonardo Maddog2018.
I found the MCO perfectly and in fact work if i set a normal button in a joystick button.

Now i follow the tutorial setting a key press ctrl+shift+L and ctrl+shift+K assign a mouse macro speed increment and decrement for the guidance.
go to mobiflight assign the key to my encoder (ELMA from leo bodnar).

nothing.

if i set default offset to my encoder or buttons work perfectly as like id event for a test with another airplane.
The function for all switch buttons or encoder with KEY not work.

is need some libraries to add for mobiflight using key functions?
is fsuipc5.13 with new mouse macro function not compatible with mobiflight?
i use p3d v4.2

thanks,
Simone
2018-06-14 09:56
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
Hi

PLEASE : NOT Reopen Sticky Posts ! Open a new topic for your questions !

About Problem.

I Not complete understand your situation.... what do you mean with "i tried to use mobiflight with a macro function set to my Leonardo Maddog2018."
Mobiflight not starts macros... and Mobiflight basicly is designed for MEGA not Leonardo.

About Keysend....

This should work but please get shure you did it right.
1. Keys go to active Window... So P3D must be klicked to recive keys.
2. Both ( Mobiflight and P3D) must run in ADMIN Mode OR in Non Admin Mode ( I recommend admin mode at all time)
BUT Problem is if 1 is Admin and the other not.... Then Keys are problematic.
3. Get shure your command is NOT used by P3D or a AddOn at same time
4. I not know the Mobiflight structure here if a 3 way Combi like CTRL-SHIFT-xxx is possible.... For testing use a easy Thing like a simple "g" and not STRG SHIFT and so on.

Summary... The Key Send is a Tool to solve some tricky things that not can be done with Offsets and Events.

If you plan to make ALL your Inputs with Macro Function in FSUIPC then i will NOT recommend Mobiflight.
Mobiflight musst "see" you Button Push and emulate a Key to the Computer... FSUIPC must recive it and must execute the Macro.

HERE a Joystick Input is much more better.... Then the Button Push directly send a Joystick Command and FSUIPC see it. ( Not difficult bypasses)
Check out for a LeoBodnar Board or a Arduinio Micro/Leo with a special Joystick Library like from Mr. Heronimus . ( google for it)
Good Luck !
2018-06-14 16:33
Avatar
sisoffi
Posts: 91
Hi,
it was the mobiflight run not in administrator mode (p3d is in administrator mode) :)

The problem that im in transit to program all guidance with new maddog2018. And there is also display and other functions.
I will try for sure to use directly an eventID but i need to study better the Lvars that is complicate for me.

Simone
2018-06-14 18:09
Avatar
myflightdeck
Posts: 17
Does anyone know if FSUIPC5 LUA SCRIPTS work with P3dv4? I cannot seem to get them to work.

Hi jumpin84 or whoever can help me. I am trying to setup the turbulence button on a CRJ 700. The L-var is ASCRJ_FCP_TURB. I wrote the below .lua script and saved it to the modules folder of my prepar3d V4 (I am running FSUIPC5). I am running both Prepar3d V4 and Mobiflight in "run as administrator" in windows.

In mobiflight I have an "Input" setup and assigned to the proper pin on my arduino mega. I have the offset specified as 66C0 in Mobiflight and my LUA file. (See below). I then have FSUIPC5 "Key Presses" with the script assigned to "shft+J" to fire off the LUA script.

When pushing my button connected to arduino, Mobiflight shows it being pushed in the status feed: "Executing OnPress: turb"

I have the console window open in FSUIPC showing me logs.

I press the Mobiflight button connected ot Arduino and nothing happens in the console window. I then click the actual keys on the kepyboard "shift J" and I see the following message appear in the console: This key is programmed in FSUIPC 'keys' options. It then shows a path to the LUA file. However I do not see the button turn on.

So I am wondering what might be the issue. I know the L-var is correct because I verified it by creating a macro file and execute it with a key press and it works. I would like to assign an offset to this button so I can add an LED so I am trying to do this via a LUA script.

See my code below:

function turb_button(offset, value)
if (value == 1) then ipc.writeLvar("ASCRJ_FCP_XFR=SET", 1)
else ipc.writeLvar("ASCRJ_FCP_XFR=SET", 0)
end
end

function turb_button_led(offset, value)
if (value == 1) then
ipc.writeLvar("ASCRJ_FCP_TURB_LED", 1)

else ipc.writeLvar("ASCRJ_FCP_TURB_LED", 0)

end
end

event.offset("66C0","UB","turb_button")
event.offset("66C2","UB","turb_button_led")
[Last edited by myflightdeck, 2018-11-12 22:50]
2018-11-12 18:52
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
I Think you mix up a bit.

At first you not decleare your button. If i understand the system correct then your Mobiflight button must write the Offset ( 66C0 in that case) to "1" on press and to "0" on release.
Please confirm you do that !

Second the "shift+J" is needed here to startup the complete Lua script itself. This script NOT fire the function directly.... It just run the script that observe Offset 66C0 and will execute the Input when offset is change.

Third.. The script is not logical. ( Here i´m not sure cause i not fully understand the scripting logics)

iconCode:
function turb_button(offset, value)
if (value == 1) then ipc.writeLvar("ASCRJ_FCP_XFR=SET", 1)
else ipc.writeLvar("ASCRJ_FCP_XFR=SET", 0)
end
end

function turb_button_led(offset, value)
if (value == 1) then
ipc.writeLvar("ASCRJ_FCP_TURB_LED", 1)

else ipc.writeLvar("ASCRJ_FCP_TURB_LED", 0)

end
end

event.offset("66C0","UB","turb_button")
event.offset("66C2","UB","turb_button_led")


The first Part seem OK.... It Read the Offset and write the Lvar to the needed state ( Thats the Input ! )
The second part is wrong i think.

That should be the OUTPUT. So you must read The Lvar and not read the Offset !
Logic must be.... READ Lvar .... If Lvar= 1 then write the OFFSET (66c2) to 1 ELSE write it to 0

In your current system you will read the offset (Mobiflight LED Status) and write the "output Lvar" . ( Senseless cause you can not write a Output Variable or you should not do that)

****

Finaly some thinkings about that stuff to you and the guy who build this system.

Why so difficult ?

1. The starting of the script with Shift-J is not needed. You can include the script in the FSUIPC Startup file.... So it will run always when your Aircraft ( For example Aerosof A320) is loaded.

2.Why you work with offsets here for the Inputs. You cn assigne with Mobiflight Keycommands or VJOY Buttons or Virtual Joystick Buttons or LUA Macros
Sure the Executing process of a Input here is done by a little script that will write a LVar ( That is not directly possible in Mobiflight)
BUT
Why do you write a Offset (66c0) with Mobiflight and then your script will observe this offset and then execute the Lvar Write ?

Simply create a script that will write the Lvar .... And start this script via one of the technics above ( Key, VJoy, Virtual Button ,LuaMacro )
Then its directly executed and you not go the wide way over a Custom Offset !

BUT NOTE: The Outputs must be done over custom Offsets !! I just talk about the Inputs !
Good Luck !
2018-11-13 12:53
Avatar
myflightdeck
Posts: 17
iconQuote:

At first you not decleare your button. If i understand the system correct then your Mobiflight button must write the Offset ( 66C0 in that case) to "1" on press and to "0" on release.
Please confirm you do that !



Yes I declared this button before executing any scripts.

iconQuote:

2.Why you work with offsets here for the Inputs. You cn assigne with Mobiflight Keycommands or VJOY Buttons or Virtual Joystick Buttons or LUA Macros



The reason why is that on the CRJ700 AP, each button has an LED associated with it that lights up. The aircraft I am working with does not have standard FCUIPC offsets so I cannot just select an output on Mobiflight for LED and assign it to a generic offset - This does not work. So my objective is to assign a new FSUIPC offset to the button so I can trigger it on the Mobiflight output option and assign it to the LED.

If anybody out there might understand my goal here and can help re-write my script to work, I would be eternally grateful. Please if possible post a sample script here that I can try.
2018-11-15 02:25
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
Hi again.

iconmyflightdeck:


The reason why is that on the CRJ700 AP, each button has an LED associated with it that lights up. The aircraft I am working with does not have standard FCUIPC offsets so I cannot just select an output on Mobiflight for LED and assign it to a generic offset - This does not work. So my objective is to assign a new FSUIPC offset to the button so I can trigger it on the Mobiflight output option and assign it to the LED.



I still understand that fact.... I Just not understand why you try to do this in that way !

Lets talk about the System.
iconQuote:

function turb_button(offset, value)
if (value == 1) then ipc.writeLvar("ASCRJ_FCP_XFR=SET", 1)
else ipc.writeLvar("ASCRJ_FCP_XFR=SET", 0)
.....
function turb_button_led(offset, value)
if (value == 1) then
ipc.writeLvar("ASCRJ_FCP_TURB_LED", 1)



If i understand correct then you have 2 LVars in your AddOn....
The First (ASCRJ_FCP_XFR=SET) is the INPUT.... Here you execute the command to Set it. You can NOT read this out for LED.
The Second (ASCRJ_FCP_TURB_LED) is the OUTPUT . This is used to show LED Status.... That Offset only need to be read and NOT used to SET the Function.

So as i wrote above... It makes no sense to Write the second Lvar like you do in lower part of your code.... You must READ it and then write the Information to a Offset.... And that can be used finaly with Mobiflight to controll the LED.

****
What i mean with " Make it more easy" is just....
Simply use this scripting system just for the OUTPUTS but make the Inputs with direct Lua Macros.

For example the upper situation.

Here i would run a Script all time as aircraft is used (like you) but it will include ONLY the Output System.....
So in tha case it will READ the Lvar "ASCRJ_FCP_TURB_LED" and will Write Data to a Offset ( For example 66C2 like above)
Same is done with all Outputs you need in your system.... Maby 100 different things that will be read from 100 Lvars and write to 100 individual Offsets.
So this "script" simply translate all these LVars to individual Offsets !

Now to the Inputs:
Here you currently write with Mobiflight a Custom Offset.... And your Script will observe this offset and if there is a change it will WRITE the corespondending Lvar (Input set)
And here i think this is not needed or better its to much difficult.
Here i would prefer a "LUA Macro" for each input indipendend.... So if you do a Input it will start the Macro ONE TIME and execute the command to the LVar ... Then it stops.
With FSUIPC it is verry easy to do that... You create just the macro and define a "initial Input" to start it. And that input is what i mean above.... You NOT need to write difficult a Offset that need to be observed.... You can simply use a KeyCommand ( Simmulated by Mobiflight) or a VJoy Button. OR You can use the new LUACall Function to fire the Macro directly in FSUIPC.

*****
Summary.... Your Script is ok... I Just think you should split the inputs from that.
Good Luck !
2018-11-15 15:46
Avatar
myflightdeck
Posts: 17
Oh I see what you mean. I get it. So do not mix the two.

Let me just confirm your suggestion. (This is very good by the way and I think will help others down the road)

So I can easily assign inputs via the macro. So lets not focus on that.

So the output would be an LUA script that auto-starts with the sim and assigns all the FCUIPC values at that time? Then I would simply use that offset in the mobiflight INPUT area to activate the LED?

I know you have already done a ton helping me clear a path. Would you by chance have an example script for assigning the FSUIPC to the L-VARS for the LUA file that auto-starts? Would I include all the L-vars associated with LED's in a single file?

Thanks so much man!
2018-11-15 19:13
Avatar
myflightdeck
Posts: 17
You are awesome. I followed your instructions and it works like a charm!!!!! YEAH!
2018-11-16 01:22
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
Hiho.

That is the point i need to stop until lots of years.... I would say i understand the basic system of informatics.... i can build the logics in my brain.... and i can read a script and understand most of the stuff..... But i never find time or have inspiration to learn a script language like LUA.

Basicy i can tell you the structure.... Like " Read Lvar XY and write status to Offset A" and so on.... BUT i´m not a programmer !
Professional advanced programmer will do this much more productiv....

I´m pretty sure they not build a READ---> WRITE logic for each offset... I Think they will read all the Lvars and put it into a "Array" Then they work with a kind of "checkDiggit" that will show that a value in the whole array is change.... And they then write a whole sequence.
Or they will yust have ONE Read system and they identify the chaing part and then have ONE Writing Script that will write the specific part ...
So a proffesional programmer will write the script i explane for 100 Outputs with a little number of code lines cause they "sum up" the script with some internal variables.

BUT

Basicly the explaned system should work....
So...
Build a script, that will run aslong you need it ( By Autostart in FSUIPC all time or via condition like " Always run if Aircraft XY is load" or via a Key command like explaned above.
Then make a Code Part for every Output You need.... always... READ Lvar A and WRITE to Offset 66C0 ... READ Lvar B and WRITE to Offset 66C1 and so on.
Finaly you can read the Offsets with MF.

thats not a productive system and not a perfect system.... BUT a working system !

Maby some programmers here can help us to provide a better script in the future !
Good Luck !
2018-11-16 02:19
Avatar
myflightdeck
Posts: 17
I have another question I am hoping the community can help answer. Right now, I creates a bunch of LUA script that reads Lvars and then assign it to a keypress in FSUIPC so that I can toggle my switches. My issue is I have run out of keypress options. (used them all up). Is there another way to fire off the lua script via routing it through mobiflight or assigning it to FCUIPC command? I am not using a traditional joystick but am using custom switches. I noticed an option in mobiflight that reference lua sctipt.

I am hoping I can create a lua script that assigns a value to FSUIPC then access that VIA mobflight and somehow trigger it when I press the button. All this without assigning the trigger to a keyboard command but something else.

I am so sorry if this sounds confusing...basically I am asking how to write a script that could be used to trigger the switch using lue but without making you press a keyboard command to run it.

Any ideas?
2018-12-30 20:03
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
Please no Double Requests for same Thing. Your Question is still awnsered in the other topic !
Good Luck !
2019-01-02 05:45
Go to page 1Go to page 1123Go to page 3Go to page 3