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.

icon
Avatar
CaptainJack
Posts: 5
Hello Guys im stepoping forward i have problem with outputs.
I have AP engage LED LVAr is "QW_ap_master_l" values 0=Off, 1=On
Can anyone make me script exapmle how to make it possible to turn led on with mobiflight?
Thanks for help

as i understand it shuld be something like this
iconCode:
AP_MASTER_I = ipc.readLvar("QW_ap_master_l")
ipc.writeUB(0x66C0, AP_MASTER_I)


All led LVARs in loop with 100ms delay ?

I choose in mobiflight offset 0x66C0 for led output
[Last edited by CaptainJack, 2019-11-20 17:00]
2019-11-20 12:37
Avatar
CaptainJack
Posts: 5
Can I use
iconCode:
Goto

For making infinite loop to check states 3 times a second?
2019-11-21 22:18
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
Hi

Here a advanced Programmer must support you.
Whatever i did 3 attemps in the past i not find time to learn programming finaly ( maby on the 4th next try in January :blush: )

I think the "problem" in your logic is the loop.
You will read the value multiple times per second...... And that should normaly work i think.
BUT you also write the Value multiple times per second and thats unless and i think it will occure in massive Problems if you do this with lots of different elements.

So the Code must do semething like .....
Initialising:
1 .Create a Variable (for example "VAR1" ) with Value Zero
Working:
2. Write Variable Data to the Offset
3. Read Lvar
4. Compare the Lvar Value with the Variable Value
5. IF Value is the SAME Then Goto 4 // Cause we not need to write it if its the same we have written before
6. ELSE Goto 2 // If it different then we Jump to 2..... Write the new Variable Data to the offset and go forward to 3 again for next loop.

With this code example a Write is only done one time at beginning and if Value is change.




Much more profitable would be a system that do the Loop "internal" ..... So we would need a "command" that say "Observe Lvar XY and only run our little code ONE TIME if the Lvar change its status. THEN Your Code is fine and need only this "starter" ....

iconCode:
XXXXX      ////////Here must set the command that observe "Lvar ap_master" and run the follow only if value is change

AP_MASTER_I = ipc.readLvar("QW_ap_master_l")
ipc.writeUB(0x66C0, AP_MASTER_I)
END




I not know if this exist..... For Inputs it is possible.
Here we can write a "non loop" script and can set it to a Offset or a Joystick Input.
Then FSUIPC observe the needed Input itself (Internal) and only run our Code ONE TIME if the Input change its status.

AGAIN: I´m not a programmer. Please wait for reply of the professional guys.... Or start to check the example Files from Pete Dowson to maby undertand much more like myself what code is used there.
Good Luck !
2019-11-22 06:30
Avatar
CaptainJack
Posts: 5
I belive that I'm not first in the world maybe someone solved this problem and can paste there example few lines of code that wuld be useful for everyone. I'm note a programmer so searching thru the Web.
2019-11-22 11:10
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
Again....
The most usefull examples are deliverd already by Pete dowson.

If you like please check the examples ( a zip file in the SDK Subfolder of FSUIPC) .
Maby you need to download the SDK itself if its not included in your standard installation.

There are 20-30 Files with different Lua Scripts and most of them include a lot of comments by Pete in the //// "TEXT" form vehind the code.

Please check this if possible,
Good Luck !
2019-11-22 15:21
Avatar
CaptainJack
Posts: 5
Thanks for reply! I'm reading all documents I thi k best option wuld be in every variable check first if state changed to not assign anything to offset till it change state that wuld be not so heavy for pc. I read alot of tutorials till now but programming is something that I can't break in :) I was hoping that someone solved this before and can paste example if no i will prepare such script.

iconCode:
function QW_ap_master_l (offs, val)
ipc.writeUB(0x66C0, val)

end

function at_mode (offs, val)
ipc.writeUB(0x66C1, val)

end

function QW_MCP_L_MFD_L_GREEN (offs, val)
ipc.writeUB(0x66C2, val)

end


event.Lvar("L:QW_ap_master_l",250, "QW_ap_master_l")
event.Lvar("L:at_mode",250, "at_mode")
event.Lvar("L:QW_MCP_L_MFD_L_GREEN",250, "QW_MCP_L_MFD_L_GREEN")


This code works finally i can light up led taht indicates AP Siwtch engage
[Last edited by CaptainJack, 2019-11-25 15:39]
2019-11-23 07:47
icon