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 012Go to page 2Go to page 2
Avatar
RudyB
Posts: 38
Hi all,

I have an encoder working perfectly well to move the heading bug with the HEADING_BUG_DEC / _INC events.

What I haven't found yet is how to set the heading bug to the current heading with the press of a button, simulating a press of the G1000 HDG knob.

Is there someone who knows the way?

Greetings, Rudy.
Always have fun!
2020-05-22 13:34
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 4647
Supporter
Hi

Not posible at the moment with Mobiflight !

Thats the first time a User request for that..... When we implement "Placeholder tool" 7 Month ago i also vote to use it in Inputs.... But finaly Sebastian and also Stephan and myself decide to implement this "at first" only for Outputs.

This situation would need it in INPUT..... then we can say:
Read Current Heading in a output Config Called e.g. "HDG" .
Then we define in INPUT Config a Placeholder ..... Symbol "a" und use the HDG Config for it.
Finaly we say ON PRESS "a"
Means it send on press simply the current value of HDG Config to the AP Heading Bug.

Whatever again.... NOT Possible a.t.m.

****************
Solution:
1. You can send a "hard" value..... For example 360(0) Degrees..... So a press set HDG to Zero ( Or each other value you like) But always only this fix value you define in the Config.

2. With a LUA Script you can write this code yourself as i said Above.... If script is running it must read Current Heading from it´s Offset and then it must write that value to the AP Heading Offset.
With porgramming skills pretty sure no problem to do.
Good Luck !
2020-05-22 21:58
Avatar
RydyB
Posts: 18
Thanks for your reply pizman. I bet also the G1000 press of the CRS knob to align the VOR needle is not (yet) implemented?

I have been writing LUA code before, so that should not be too hard. What I haven't tried yet is how to get a LUA script to work with/in MobiFlight. I'll make a start studying that. Any tips as to where I can find some info on how to use LUA with MF?
Always have fun.
2020-05-23 00:39
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 4647
Supporter
2 Questions...... 2 awnsers :lol:

1. G1000.
I not use those stuff so i´m not a pro here.... Do you mean if you press this virtual button then the Bug is do exactly what you need ??
If Yes the logical result should be to try to controll this button..... then you need no difficult code or workaround.
Check the EventID List..... On first view all Buttons got a EventID.
For example: G1000 MFD SOFTKEY1---- 66789

EDIT: Logging Mode show me "HEADING BUG SET 66042" when i use that button. Pleae try out with parameter 0..... Maybe it work !




About LUA Macro.
Here you got a lot of ways.

Most easy is to assign the macro to a Key in FSUIPC (Registred Version) ..... then In mobiflight you just use Keypress (with that key) ...... So you Press button and mobiflight send e.g. a "A" Button..... And in FSUIPC you say : If "A" is pressed execute your macro.
This also works for Joybuttons ( Via VJOY and Mobiflight OR Via a real JoystickController like LeoBodnar external of Mobiflight)


More advanced is to bind the macro to a Offset.... So macro runs if Offset e.g. 66C0 is "1" and set the offset after running back to "0".
Here you say in Mobiflight Buttonpress should write that Offset to 1

Also Possible is the LUA MACRO Function of Mobiflight..... In Input you can use this to start/stop a Macro or script.
https://www.mobiflight.com/forum/message/10232.html
[Last edited by pizman82, 2020-05-23 04:09]
Good Luck !
2020-05-23 03:57
Avatar
RydyB
Posts: 18
Yes, the G1000, used in many 'glass cockpits', has HDG and CRS knobs that can be rotated with the mouse and they can also be pressed. Pressing HDG sets the heading bug to the current heading, eliminating the need to rotate the knob. Same for the CRS knob, it aligns the VOR needle, eliminating the need to rotate.

So yes, they are virtual switches, and I reckon they have an Event ID or an FSUIPC offset ... it's just that I can't find them. For the heading bug there are:
HEADING_BUG_SELECT: I have no idea what it does, nothing seems to happen
HEADING_BUG_SET: it sets the HB to North, 0/360

I haven't tried all the possible G1000 codes yet ... I was hoping maybe someone had already found the right ones. :)

I'll have a look into how to run a LUA script and see if I can get that to work one way or another. Once I understand how to start and stop a script then maybe I can get set the HB to the current heading via LUA code.
[Last edited by RydyB, 2020-05-23 09:49]
Always have fun.
2020-05-23 09:31
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 4647
Supporter
Do you have FSUIPC in registred Version ???

With "logging Mode Typ Event" you can click on a spot and you see there the event that was executed.

I will also check this within the next time and will report results here.
Good Luck !
2020-05-23 18:57
Avatar
RudyB
Posts: 38
Been on a holiday ... back to hobby now.

Yes, the FSUIPC logging is very helpful. It works with the unregistered version too. Via the logging I found the two Event ID's I was looking for with the G1000 glass cockpit:

Press CRS knob: ID 65716 PAR 223 VOR1_SET
Press HDG knob: ID 66042 PAR 216 HEADING_BUG_SET

Now having some trouble finding the correct ID for several autopilot push buttons, FSUIPC often gives a series of events, not just one. Figuring that out now, will post here when I have it working.
Always have fun!
2020-05-29 13:21
Avatar
Endprodukt
Posts: 7
How far did you get?

I'm building a complete G1000 and the only thing that worries me is the actual SDK not supporting many of the inputs
2020-10-07 17:39
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 4647
Supporter
Ahh OK. Then we can NOT use it.

iconRudyB:


Press HDG knob: ID 66042 PAR 216 HEADING_BUG_SET



This is a SET event.... NOT a execute Event !

Means the Parameter here is the value we like to SET the HEading Bug. If you build a INPUT Config and use e.g. as parameter "123" then it will SET the Bug to 123.
Problem.... We can in Mobiflight NOT say " Read current value of Heading/ Magnetic Compas etc and USE this Value as Parameter in that EventID."
Here interesting would be a "PRemade Event" that exactly do this.... So a internal function we can simply call or execute.

Summary: At the moment in INPUTS there is no posibility in MF to use Variables. Maybe a got point to request again for this. The number of situations we would need this increase again.
Good Luck !
2020-10-10 15:52
Avatar
Nosferatie
Posts: 6
Yeah i would like if we can add this as a development request. Even if we could so something like for the LCD where we set an output value, but then somehow reference it on the input value set.

This would make a great feature.
2020-12-04 20:05
Avatar
Dante777
Posts: 2
I've made this function with simple LUA script (take the idea from Pete Dowson post)

hdg = ipc.readSW(0x582) -- Gets current TRUE heading, in same units as AP Hdg
hdg = hdg - ipc.readSW(0x2A0) -- convert to MAGNETIC by subtracting Mag Var
ipc.writeSW(0x7cc, hdg) -- write to the A/P Hdg bug

place script in FSUIPC folder (i.e. named 'currheading.lua'), and set the button action (I use encoder press button) to execute this LUA script

But I completely agree that input configs support would be great anyway :)
[Last edited by Dante777, 2020-12-05 19:27]
2020-12-05 19:17
Avatar
Nosferatie
Posts: 6
Buy this man a beer!!!! It workz... :w00t: :thumbup:
2020-12-11 15:37
Avatar
jlayers
Posts: 3
I'm having difficulty getting this lua script to run. This is my first lua script in mobiflight. I can't find any good tutorials for lua on the forum. Does lua need to be installed or is it built into mobiflight? Also where do you put the lua script? Any help would be greatly appreciated
2021-03-20 17:18
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 4647
Supporter
The Lua stuff is NOT a part of Mobiflight !

With LUA ( Basicly a programming language) you can include new things within FSUIPC !

Mobiflight not care about that..... It read a Offset from FSUIPC.... The Lua Scripts does ( inside of FSUIPC) get information from the Sim and write it e.g. to a free Offset we finaly read again with Mobiflight.

Whatever.... Hopefully soon the new "Input Placeholders" come into MF.... Then all this stuff can be done more easy within the Mobiflight GUI.
Until then..... If you like to learn more about LUA..... Read the Manual of FSUIPC or google for "LUA FSUIPC" to get a lot of tutorial !!
Good Luck !
2021-03-20 18:08
Avatar
rycco
Posts: 2
iconDante777:

I've made this function with simple LUA script (take the idea from Pete Dowson post)

hdg = ipc.readSW(0x582) -- Gets current TRUE heading, in same units as AP Hdg
hdg = hdg - ipc.readSW(0x2A0) -- convert to MAGNETIC by subtracting Mag Var
ipc.writeSW(0x7cc, hdg) -- write to the A/P Hdg bug

place script in FSUIPC folder (i.e. named 'currheading.lua'), and set the button action (I use encoder press button) to execute this LUA script

But I completely agree that input configs support would be great anyway :)




Hello, can you please provide a step-by-step guide how to make this script run ?

I have placed this next to the fsuipc.exe, I have tried all possible names that i could think of to set in Mobiflight configuration to run Lua Macro for a encoder push action but I can not get it to work., I cant find anything that would describe how to create macro and run it through mobiflight so a detailed guide would be very appreciated
[Last edited by rycco, 2021-04-27 01:16]
2021-04-27 00:43
Go to page 1Go to page 012Go to page 2Go to page 2