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
Samhaho
Posts: 8
Supporter
I am trying to help someone programming his Mobiflight module as Zibo MCP.

While the basics work fine (heading, speed, altitude, CMD, auto-throttle, etc.) it is now about handling a little more complex feature. One of them is the management of airspeed display. In the zibo this display turns blank in some cases (VNAV for example). The question is what is the best and more accurate way to handle this? Not in terms of how to make blank display but in terms of when to do that in accurate and complete way. Is there any dataref that can be used for this? I noticed for example the promising Laminar/B738/autopilot/speed_mode but unfortunately it doesn't correlate to the speed display status.

How do Zibo MCP Mobiflight based users handle this?

Sam
2022-03-30 11:29
Avatar
ChrisInUT
Posts: 9
Supporter
The dataref you are looking for is laminar/B738/autopilot/show_ias. I've included my dataref code below. The offset should be changed to work with whatever memory usage scheme you are using.

XPUIPCOffsets.cfg

iconCode:
#MCP SHOW IAS INDICATOR
Dataref iasshow laminar/B738/autopilot/show_ias int
Offset 0x656D UINT8 1 r $iasshow

#MCP IAS KTS/MACH INDICATOR
Dataref iasmach laminar/B738/autopilot/mcp_speed_dial_kts_mach float
Offset 0x6586 FLOAT64 1 rw $iasmach

Within MF setup two outputs in the main config. I called mine MCP_IAS_DISPLAY and MCP_IAS_ACTIVE. DISPLAY is the item that will be connected to a 7-segment display. Its display will be cleared when the ACTIVE output is false or 0.

Here's the step-by-step:

Create MCP_IAS_ACTIVE

  1. Set MCP_IAS_ACTIVE to FSUIPC Offset.
  2. Set the offset to '0x656D' or whatever you choose to use.
  3. Set the value type to 'int', the Size to '1' and the mask I just left at '0xFF'
  4. Click 'Okay'. This one is complete.

Create MCP_IAS_DISPLAY

  1. Set MCP_IAS_DISPLAY to FSUIPC Offset
  2. Set the offset to '0x6586' or whatever you choose to use.
  3. Set the value type to 'float', the Size to '8'.
  4. Check the transform box.
  5. Enter if($<1,Round($,2)*100*#,$*#) within the Transform textbox.
  6. (Note: The math uses the ACTIVE dataref to zero the IAS when it is not displayed.)
  7. Under 'Config References' Add a reference to MCP_IAS_ACTIVE using # as the character ref.
  8. Next select the 'Compare' tab at the top of the screen.
  9. In the 'Comparison Settings' frame select the check box. Then enter the following:
    1. If current value '=' '0'
    2. set it to ' '
    3. (Note: Enter a single space in this textbox. Leaving it with no space will cause a '0' to show on the IAS Display.)
    4. else set it to '$'
  10. On the 'Display' tab check 'Use Left Padding'
  11. Select 'Space' as your Padding character
  12. On the Compare tab check 'Apply comparison to modify the current value'
    1. If current value '=' '0'
    2. set it to ' '
    3. (Note: Enter a single space in this textbox. Leaving it with no space will cause a '0' to show on the IAS Display.)
    4. else set it to 'if($<100,'.'+$,$)'
    Thanks pizman82 for the fix here.:thumbup:

While this setup will display the mach and kts airspeed at the appropriate times, the mach airspeed will not have a decimal in front of it. If you or anyone else has fix for this please share it.

Cheers!
[Last edited by ChrisInUT, 2022-04-03 21:39]
2022-04-03 01:10
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
Hi

At first... thank you for sharing your experience and helping other users !

I wondering that you say this config is working.... From my point of view there is a syntax error !


if($<1,$*100*#=.499999999,$*#)

I expext you will say IF Value is less then 1 then its pretty sure a mach number like 0,62 .
So you correctly say $*100 to get a integer and for sure you use *# for the "Display Active Check.
If Number is 1 or greater we expect a IAS Value. So you say in the Else part $*# to show value directly and again check for Display Active.
So WHAT means =.4999999999 ? Logical this can not work cause you use as operator $<1 her the "=" is wrong.... And also 4.9999 make no sense to me.

Please Confirm this really workes and why you use it.
For me correct syntax should be..... if($<1,$*100*#,$*#) OR more tidy .... if($<1,$*100,$)*#

Also additional i recommend to use in Compare THREE Spaces instead of one.... Display have 3 Digits. To avoid problems you should blank all 3 with ' '
**********

About last question

The DECIMAL currently is hardcoded in MF.... We can not show a Value like 123,45 ..... We must show 12345 and set the Decimal FIXED via the Mobiflight GUI.
In the future we plan for a more intuituive Way to do this !

BUT:
For sure its possible today with a little workflow.

Way 1. Using Preconditions.
You have 2 Configs for the same Display.... One use a Decimal Point within .... the other Not.
And you make a condition what is active.
In your case you could use each config as precondition for the other.... Or you read the Speed once again in a 3rd Config.
Then you can say..... The Config with the decimal should only work if the Indicator Config currently is less then 1
The IAS Config ( without the decimal) only work if the indicator is Greater 1

Way 2. Using the Decimal as a String !
This is Possible with one little bad factor.
The Decimal is used as a Full Digit. IF we would show 123,45 the it is shown as 123_,45 So there is one "Blank Digit between where the decimal is set.
So not usefull for a COM Frequency BUT in case of speed its working ( cause the decimal is already empty. We not show "0,86" we show ",86" so we not care about the blocked Display.

Solution: Say in compare:
IF Value = 0 THEN ' ' ( 3 Speaces in braket)
ELSE: if($<100,'.'+$,$)
So we say.... if "0" then Spaces ( Blank logic) and we also say if value less 100 ( all 2 number values are MACH) then show a Point'.' and Value behind ELSE show just Value.
So a Value of 123 is shown "123" a mach Value of 69 is shown as ".69"

Tricky but working !
NOTE: I´m not 100 % sure if we need the "+" Maybe its worng and you need if($<100,'.'$,$) ... Please try out !
Good Luck !
2022-04-03 15:58
Avatar
ChrisInUT
Posts: 9
Supporter
pizman82, thank you for looking at my post so closely. You are correct. The =.499999999 should have been +.499999999. I have corrected my original post as indicated below. I would have preferred posting screenshots, but I haven't figured out how to post those......

The .4999999 was added to act like a rounding function. Because of order of operation, if the variable returns a value .786123 simply multiplying by 100 will yield a mach number of '78' but this Zibo the MCP reads '.79'. So, the by adding .49999999 the product of mach*100 (78.6123) the value becomes 79.12999999 and the display value becomes 79 and is consistent with the simulator on screen display. All that said in retrospect this really should just be +.5. Logic error on my part. Original post has been with updated and an explanation of the math.

Regarding the 3 spaces versus a single space, I forgot to mention in my original post that I have the display set to use a space for padding rather that leading zeroes. With the display settings this way a single space will suffice. I have added this comment to the original post. (I think it was good planning on the MF developer's part to include both options.)

Regarding your solution in compare:
This works perfectly. Thank you for the input. My mach speeds are now indicating correctly. I have also updated the original post to include your solution.

Pizman82 thanks again for you thorough review and direction.

Cheers
2022-04-03 17:08
Avatar
Samhaho
Posts: 8
Supporter
iconChrisInUT:

The dataref you are looking for is laminar/B738/autopilot/show_ias. I've included my dataref code below. The offset should be changed to work with whatever memory usage scheme you are using.

XPUIPCOffsets.cfg

iconCode:
#MCP SHOW IAS INDICATOR
Dataref iasshow laminar/B738/autopilot/show_ias int
Offset 0x656D UINT8 1 r $iasshow

#MCP IAS KTS/MACH INDICATOR
Dataref iasmach laminar/B738/autopilot/mcp_speed_dial_kts_mach float
Offset 0x6586 FLOAT64 1 rw $iasmach

Within MF setup two outputs in the main config. I called mine MCP_IAS_DISPLAY and MCP_IAS_ACTIVE. DISPLAY is the item that will be connected to a 7-segment display. Its display will be cleared when the ACTIVE output is false or 0.

Here's the step-by-step:

Create MCP_IAS_ACTIVE

  1. Set MCP_IAS_ACTIVE to FSUIPC Offset.
  2. Set the offset to '0x656D' or whatever you choose to use.
  3. Set the value type to 'int', the Size to '1' and the mask I just left at '0xFF'
  4. Click 'Okay'. This one is complete.

Create MCP_IAS_DISPLAY

  1. Set MCP_IAS_DISPLAY to FSUIPC Offset
  2. Set the offset to '0x6586' or whatever you choose to use.
  3. Set the value type to 'float', the Size to '8'.
  4. Check the transform box.
  5. Enter 'if($<1,($*100+.5)*#,$*#)' within the Transform textbox.
  6. (Note: The math uses the ACTIVE dataref to zero the IAS when it is not displayed and round the mach speed to align with the sim with mach is displayed.)
  7. Under 'Config References' Add a reference to MCP_IAS_ACTIVE using # as the character ref.
  8. Next select the 'Compare' tab at the top of the screen.
  9. In the 'Comparison Settings' frame select the check box. Then enter the following:
    1. If current value '=' '0'
    2. set it to ' '
    3. (Note: Enter a single space in this textbox. Leaving it with no space will cause a '0' to show on the IAS Display.)
    4. else set it to '$'
  10. On the 'Display' tab check 'Use Left Padding'
  11. Select 'Space' as your Padding character
  12. On the Compare tab check 'Apply comparison to modify the current value'
    1. If current value '=' '0'
    2. set it to ' '
    3. (Note: Enter a single space in this textbox. Leaving it with no space will cause a '0' to show on the IAS Display.)
    4. else set it to 'if($<100,'.'+$,$)'
    Thanks pizman82 for the fix here.:thumbup:

While this setup will display the mach and kts airspeed at the appropriate times, the mach airspeed will not have a decimal in front of it. If you or anyone else has fix for this please share it.

Cheers!





Many thanks for responding.

In the meantime along with pizman82 we have developed very similar solution using Transform to display a blank. However since I did not know about the laminar/B738/autopilot/show_ias dataref we have used the following two datarefs:
laminar/B738/autopilot/vnav_engaged
laminar/B738/autopilot/spd_interv_status
When they are respectively true (1) and false (0) then we show a blank on the display (instead if the IAS).
Also I noticed the rounding problem. To address this I simply used the Round function.
The solution is working fine.

Thanks again.

Sam
[Last edited by Samhaho, 2022-04-04 10:49]
2022-04-03 17:30
Avatar
ChrisInUT
Posts: 9
Supporter
@samhaho, thanks for the response.
iconQuote:

Also I noticed the rounding problem. To address this I simply used the Round function.


I had tried round(var) and rnd(var). I missed the link in the MF documentation to the NCalc engine. Wouldn't have taken another look if you hadn't mentioned using the Round function.

I have changed my Transform to if($<1,Round($,2)*100*#,$*#). Took me a bit. It seems to be case sensitive.

Cheers
2022-04-03 21:36
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
YES

There is a Round Function in NCalc!
https://github.com/ncalc/ncalc/wiki
So this +4,9999 us not needed.
(Sorry i not directly understand it..... In case i use the Round, i never think about this ! )

IMPORTANT:
Round is as you expect case sensitive!
Correct syntax is Round(Value,Decimalnumbers) ..... E.g. Round($,2) will round a Value of 1,23455 to 1,23 ..... A Value of 1,239999 into 1,24.
NOTE: round(a,b) and also ROUND(a,b) will not work..... It must be "Round" ...... Confising in case "If" will not work.... Here it must be non capital here its "if"

So yes... It should be then something like if($<1,Round($*100,0),$)*#
In words... If value is below "1"m then multiply by 100 and round it to Zero Decimal Numbers.... (e.g. 0,62999 goes via 62,999 to rounded 63)
If Value is above 1 then show $ (Value) .... And finaly in both cases multiply it with "#" ( The status of Display Active or not )


EDIT: By the way..... With this logic you could also include Lighttest and Battery Off.
Battery OFF is a additional Variable (lets say X) So we make our formula and at the end we say *X If Master Switch is ON then its "*1" and occure in current value..... ELSE if Master switch is OFF then "*0" occure in always Zero (Blank)
Light test is finally a value of 0 and 1. .... We can simply say at beginning IF Lighttest ( lets say Variable §) is Active then set always to 888.

Something finally like if(§=1,888,if($<1,Round($*100,0)*#,$*#))*X
So.... If Lighttest is active then 888, Elseif Value below 1 then Show MAch with the round and make DisplayActive Check, Else show IAS with display Active check.... And at the end check if Master switch is On.

You hopefully see..... this Syntax and Variable usage allow a very deep system !
[Last edited by pizman82, 2022-04-04 00:33]
Good Luck !
2022-04-04 00:18
Avatar
ChrisInUT
Posts: 9
Supporter
iconQuote:

pizman82
So yes... It should be then something like if($<1,Round($*100,0),$)*#
In words... If value is below "1"m then multiply by 100 and round it to Zero Decimal Numbers.... (e.g. 0,62999 goes via 62,999 to rounded 63)


Less code, I like that. Moving the *# outside of the if is a good step.

iconQuote:

pizman82
if(§=1,888,if($<1,Round($*100,0)*#,$*#))*X


That's cool. I hadn't even thought about the light test functionality or cold and dark. That is something to add to all of the MCP lights and displays.

Still pretty new to this. Still trying to learn how to fly and building an MCP at the same time. 3 months in on MF and I am starting to make sense of it. Such a powerful tool.

Thanks for all of insight and advice.

Cheers
2022-04-04 01:44
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
iconChrisInUT:

I hadn't even thought about the light test functionality or cold and dark. That is something to add to all of the MCP lights and displays.



For 7SEG its a little tricky.... In case we need this "888" Stuff.
Here you must check the used Aircraft.
For example some more professional AddOn Aircrafts still include this.
E.g. PMDG use for the FLT ALT and the LDG ALT Display a "String" instead of a Integer Value.
This String include correctly "Spaces" if Display is Blank ( e.g. Cold and Dark) .... It Include 888888 for Lighttest.... It Include Dahses ----- for Mode inactive and finaly the Number if there is shown a Value in the Sim.

Other AddOns like Jeehell Airbus make this with The Value itself.... if Display must be blank then Value internal already change to "-1" and it also show "8888" in lighttest instead.
Here you just need to say in Compare IF Value = -1 Then ' ' (Spaces) ELSE $


For sure... If Aircraft not support you here with internal stuff, then you must exactly go the way we talk above!

******************
About LED .

NOTE: Also here some AddOns already include this. The NEw PMDG for most LED show corectly the status of Sim LED.... So its 0 in Cold and Dark and 1 in Lighttest by itself !
The follow logic is only needed if Aircraft not support this clean value !

Here its much more easy in case a LED is only 0 or 1
Basic logic: A LED must be OFF at all time if in Cold and dark ..... It must be Light while Lighttest ( But NOT in Cold and Dark) and it finally show the Status when Power is there and no lighttest in Progress.
Here we use 2 Variables .... lets say "a" = MasterPower 1 for ON 0 for Cold and Dark. ......
And "b" is Lighttest ... 1 for active 0 for non active.
Basic Formula in ALL LED Configs is the same..... ($+b)*a
The *a finally check MAsterSwitch .... If OFF it will always show Zero.
The +b include the Lighttest.... If Funtion is OFF then 0+1=1 If Function would be already on then 1+1=2 But thats no mater cause a LED light same way whatever 1,2,or 99999

At Last.... About shorting the Code.
We could make this LED also in a way like this. ....
if(a=0,0,if(b=1,1,$)) (If Battery = 0 then show 0 Elseif Lighttest=1 show 1 Else show Dollar)
But for sure ($+b)*a do the same at the end but is more logical and shorter !

I love Math Logics ! :love: :P
Good Luck !
2022-04-04 13:17
icon