• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

FSXA ADF Swap

That's what the min and max entries are for...

...although they seem backwards, this is the way they work.

For example, the script below will adjust the value of the (L:SomeVar,enum) from 0 to 9, then repeat

Code:
      <MouseFlags>LeftSingle+RightSingle+WheelUp+WheelDown</MouseFlags>
      <CallbackCode>
        (M:Event) 'LeftSingle' scmp 0 ==
        (M:Event) 'WheelDown' scmp 0 == or
        if{ (L:SomeVar, enum) -- 0 max (>L:SomeVar, enum) }
 
        (M:Event) 'RightSingle' scmp 0 ==
        (M:Event) 'WheelUp' scmp 0 == or
        if{ (L:SomeVar, enum) ++  9 min (>L:SomeVar, enum) }
      </CallbackCode>
 
Yep i knew that i was just thinking i would have to write the code like my knobs that have limits. Not sure why i even mentioned as i know how to cycle knobs within ranges. o_O

Bill the xml you posted will not repeat unless you use more code to reset 9 to 0 and 0 to 9.
But i have another issue. The ADF unit does not use 10's and 1's for the tuning like in example post 25. It uses 1's and decimals.

I am trying to use 0.1 + and 0.1 - but it's not working. Any ideas how to input decimals with no carryover.
 
Last edited:
Testing the decimal knob but can't get it to only input fractions.

Code:
This is for the knob animation

(M:Event) 'LeftSingle' scmp 0 ==
      (M:Event) 'WheelDown' scmp 0 == or
      if{ (L:ADFCUSDEC, enum) -- 0 max (>L:ADFCUSDEC, enum) }
      (L:ADFCUSDEC, enum) 100 == if{ 0 (>L:ADFCUSDEC, enum) }

      (M:Event) 'RightSingle' scmp 0 ==
      (M:Event) 'WheelUp' scmp 0 == or
      if{ (L:ADFCUSDEC, enum) ++  100 min (>L:ADFCUSDEC, enum) }
      (L:ADFCUSDEC, enum) 0 == if{ 100 (>L:ADFCUSDEC, enum) }

This is for the tuning

      (M:Event) 'LeftSingle' scmp 0 ==
      (M:Event) 'WheelDown' scmp 0 == or
      if{ (L:ADF2_Standby_Freq, khz) -- 0.0 max (>L:ADF2_Standby_Freq, khz) 0.1 - }

      (M:Event) 'RightSingle' scmp 0 ==
      (M:Event) 'WheelUp' scmp 0 == or
      if{ (L:ADF2_Standby_Freq, khz) ++ 0.9 min (>L:ADF2_Standby_Freq, khz) 0.1 + }
 
Last edited:
if{ (L:ADF2_Standby_Freq, khz) 0.1 - 0.0 max (>L:ADF2_Standby_Freq, khz) }
if{ (L:ADF2_Standby_Freq, khz) 0.1 + 0.9 min (>L:ADF2_Standby_Freq, khz) }
 
Here is the first look at the entire setup. The swap is now working good!

Problem 1: Decimal can't repeat without carryover and when you roll up it goes from 0.9 to 1.0 If you roll down it goes 0.1 to 0.0 to 0.9 and work fine. So i have it so it only can go up or down at the moment.
Problem 2: You need to add a code for first load so the the standby does not start at 0.0 (Solved)
Problem 3: The whole number from the standby takes for ever to adjust.
Problem 4: The decimal is now causing the whole number to zero out. I was using A + B = standby but then i would have issues making the active swap to thew standby.

Code:
<!--FIRST LOAD--->

(L:ADF2_Standby_Freq, khz) 0 == if{ 100 (>L:ADF2_Standby_Freq, khz) }

<!--SWAP SWITCH--->

  (L:ADF2_Standby_Freq, Frequency ADF BCD32) (>K:ADF2_COMPLETE_SET)
  (A:ADF ACTIVE FREQUENCY:2,kHz)(>L:ADF2_Standby_Freq, khz)

<!--DECINMAL KNOB--->

      (M:Event) 'LeftSingle' scmp 0 ==
      (M:Event) 'WheelDown' scmp 0 == or
      if{ (L:ADFCUSDEC, enum) -- 0 max (>L:ADFCUSDEC, enum) }
      (L:ADFCUSDEC, enum) 100 == if{ 0 (>L:ADFCUSDEC, enum) }

      (M:Event) 'RightSingle' scmp 0 ==
      (M:Event) 'WheelUp' scmp 0 == or
      if{ (L:ADFCUSDEC, enum) ++  100 min (>L:ADFCUSDEC, enum) }
      (L:ADFCUSDEC, enum) 0 == if{ 100 (>L:ADFCUSDEC, enum) }

      (M:Event) 'LeftSingle' scmp 0 ==
      (M:Event) 'WheelDown' scmp 0 == or
      if{ (L:ADF2_Standby_Freq, khz) 0.1 - 0.0 max (>L:ADF2_Standby_Freq, khz) }

      (M:Event) 'RightSingle' scmp 0 ==
      (M:Event) 'WheelUp' scmp 0 == or
      if{ (L:ADF2_Standby_Freq, khz) 0.1 + 0.9 min (>L:ADF2_Standby_Freq, khz) }

<!--WHOLE KNOB--->

      (M:Event) 'LeftSingle' scmp 0 ==
      (M:Event) 'WheelDown' scmp 0 == or
      if{ (L:ADFCUSWHL, enum) -- 0 max (>L:ADFCUSWHL, enum) }
      (L:ADFCUSWHL, enum) 100 == if{ 0 (>L:ADFCUSWHL, enum) }

      (M:Event) 'RightSingle' scmp 0 ==
      (M:Event) 'WheelUp' scmp 0 == or
      if{ (L:ADFCUSWHL, enum) ++  100 min (>L:ADFCUSWHL, enum) }
      (L:ADFCUSWHL, enum) 0 == if{ 100 (>L:ADFCUSWHL, enum) }

      (M:Event) 'LeftSingle' scmp 0 ==
      (M:Event) 'WheelDown' scmp 0 == or
      if{ (L:ADF2_Standby_Freq, khz) -- 99 max (>L:ADF2_Standby_Freq, khz) }
      (L:ADF2_Standby_Freq, khz) 1799 == if{ 100 (>L:ADF2_Standby_Freq, khz) }

      (M:Event) 'RightSingle' scmp 0 ==
      (M:Event) 'WheelUp' scmp 0 == or
      if{ (L:ADF2_Standby_Freq, khz) ++ 1799 min (>L:ADF2_Standby_Freq, khz) }
      (L:ADF2_Standby_Freq, khz) 99 == if{ 1799 (>L:ADF2_Standby_Freq, khz) }


<!--ACTIVE WINDOW--->

(A:ADF ACTIVE FREQUENCY:2,kHz)

<!--STANDBY WINDOW--->

(L:ADF2_Standby_Freq, khz)
 
Last edited:
Problem 4: The correct swap code includes 3 steps, i.e., 3 lines. Your swap code, above, wont work. Please see response 37.
 
Update:
You do not need 3 lines of code to swap since we are not using the default active code and converting to BCD. We are simply using custom BCD to send to default khz. Problem 4 is fixed. Only 2 lines of code needed.

Only 2 small issues left. Working really good!!!:D
Problem 1: The whole number from the standby takes for ever to adjust. (Going to check click types list. There must be a way to speed up the tuning!)
Problem 2: The whole number goes from 1799 to 101 not 100. But going the other way it goes from 100 to 1799 as it should.



Code:
<!--FIRST LOAD--->

(L:ADF2_StandbyB_Freq, khz) 0 == if{ 100 (>L:ADF2_StandbyB_Freq, khz) }

<!--SWAP SWITCH--->

  (L:ADF2_Standby_Freq, Frequency ADF BCD32) (>K:ADF2_COMPLETE_SET)
  (A:ADF ACTIVE FREQUENCY:2,kHz) (>L:ADF2_Standby_Freq, khz)

<!--DECINMAL KNOB--->

      (M:Event) 'LeftSingle' scmp 0 ==
      (M:Event) 'WheelDown' scmp 0 == or
      if{ (L:ADFCUSDEC, enum) -- 0 max (>L:ADFCUSDEC, enum) }
      (L:ADFCUSDEC, enum) 100 == if{ 0 (>L:ADFCUSDEC, enum) }

      (M:Event) 'RightSingle' scmp 0 ==
      (M:Event) 'WheelUp' scmp 0 == or
      if{ (L:ADFCUSDEC, enum) ++  100 min (>L:ADFCUSDEC, enum) }
      (L:ADFCUSDEC, enum) 0 == if{ 100 (>L:ADFCUSDEC, enum) }

      (M:Event) 'LeftSingle' scmp 0 ==
      (M:Event) 'WheelDown' scmp 0 == or
      if{ (L:ADF2_Standby_Freq, khz) 0.1 - 100 max (>L:ADF2_Standby_Freq, khz) }
      (L:ADF2_Standby_Freq, khz) 1799 == if{ 100 (>L:ADF2_Standby_Freq, khz) }

      (M:Event) 'RightSingle' scmp 0 ==
      (M:Event) 'WheelUp' scmp 0 == or
      if{ (L:ADF2_Standby_Freq, khz) 0.1 + 1799 min (>L:ADF2_Standby_Freq, khz) }
      (L:ADF2_Standby_Freq, khz) 100 == if{ 1799 (>L:ADF2_Standby_Freq, khz) }

<!--WHOLE KNOB--->

      (M:Event) 'LeftSingle' scmp 0 ==
      (M:Event) 'WheelDown' scmp 0 == or
      if{ (L:ADFCUSWHL, enum) -- 0 max (>L:ADFCUSWHL, enum) }
      (L:ADFCUSWHL, enum) 100 == if{ 0 (>L:ADFCUSWHL, enum) }

      (M:Event) 'RightSingle' scmp 0 ==
      (M:Event) 'WheelUp' scmp 0 == or
      if{ (L:ADFCUSWHL, enum) ++  100 min (>L:ADFCUSWHL, enum) }
      (L:ADFCUSWHL, enum) 0 == if{ 100 (>L:ADFCUSWHL, enum) }

      (M:Event) 'LeftSingle' scmp 0 ==
      (M:Event) 'WheelDown' scmp 0 == or
      if{ (L:ADF2_Standby_Freq, khz) -- 100 max (>L:ADF2_Standby_Freq, khz) }
      (L:ADF2_Standby_Freq, khz) 1799 == if{ 100 (>L:ADF2_Standby_Freq, khz) }

      (M:Event) 'RightSingle' scmp 0 ==
      (M:Event) 'WheelUp' scmp 0 == or
      if{ (L:ADF2_Standby_Freq, khz) ++ 1799 min (>L:ADF2_Standby_Freq, khz) }
      (L:ADF2_Standby_Freq, khz) 100 == if{ 1799 (>L:ADF2_Standby_Freq, khz) }



<!--ACTIVE WINDOW--->

(A:ADF ACTIVE FREQUENCY:2,kHz)

<!--STANDBY WINDOW--->

(L:ADF2_Standby_Freq, khz)

Update: I made it so left and right click on the whole tuner is in 100 increments and mouse wheel is single. Unless there is a way to change the rate of tuning this will have to work.
 
Last edited:
Update:
You do not need 3 lines of code to swap since we are not using the default active code and converting to BCD. We are simply using custom BCD to send to default khz.
I find the two line swap script to be very interesting. I would have never thought of it and I'm glad you posted it.

Regarding the 3 line swap script that I posted, it doesn't convert the Active to BCD. IMHO, that's not why the two line swap that you use works.

On face value, I thought the two line swap would certainly achieve current Standby to new Active, but not current Active to new Standby, completing the full swap. I thought you would end up with both windows displaying the new Active. But it does work and the full swap is achieved. I believe what is happening is a bit subtle.

The first line issues an event instruction, (L:ADF2_Standby_Freq, Frequency ADF BCD32) (>K:ADF2_COMPLETE_SET), but the event is not executed at that time. Instead, because it is an event, I believe it is queued for execution at the end of the current gauge update cycle.

The second line, (A:ADF ACTIVE FREQUENCY:2,kHz) (>L:ADF2_Standby_Freq, khz), causes the current Active frequency to immediately become the new Standby frequency. There isn't a problem here because the event that re-sets the current Active has not yet been executed; (A:ADF ACTIVE FREQUENCY:2,kHz) has not yet been re-set by the event (>K:ADF2_COMPLETE_SET).

It's like the swap script is processed Line 1 then Line 2, but executed Line 2 then Line 1.

Make sense? This is where Tom Aguilo needs to jump in.

Anyway, you may well be the first person to ever install dual ADFs, both having Active/Standby swap capability. :)

Bob
 
i figured the 3 line code works if you using a different type of ADF unit. But for this unit since we are using the standby as a LVAR there is no need for 3 lines of code as i have figured it only needs 2 commands.

Thanks rpmc, Bill, Spokes and others for helping. Be cool if we can fix the 2 little bugs. I did manage to make the left and right click change values of 100 so your not moving the mouse wheel all day long. I would rather have it like the default and when you move the wheel fast it starts to increase in value. The other bug is no big deal since you can just roll past 1799 and when it gets to 101 you can reverse use the decimal knob to go back to 100.
 
Last edited:
The reason the swap might be slow is if you are flooding FS with commands (K: commands). You could check to see if your code constantly sends K: commands to the sim and if so, add IF statements so they only happen once or when things change.
 
The reason the swap might be slow is if you are flooding FS with commands (K: commands). You could check to see if your code constantly sends K: commands to the sim and if so, add IF statements so they only happen once or when things change.

The swap is working fine. The whole tuning knob is tuning at 1 rate so to tune from 100 to 1799 could take up to 1 minute. The default code for the tuner would increase the rate as you move the mouse wheel faster. But the custom code does not have this effect. This is what could use something to increase the rate.
 
I noticed a post that uses @Plus and @Minus to increase the rate of the mouse wheel. But this was for K events and for the custom Lvar i had no luck getting this to work.
 
Looks like Karol didn't include those macros in his post. If you get those, they might work for you. You need to inspect the macros and then you can decide. Bob
 
Back
Top