• 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.

FSX Emergency Frequency Button

n4gix

Resource contributor
Messages
11,674
Country
unitedstates
I'm glad that there are so many ways to write scripts, because some methods just don't seem to work out too well for me.

In any case, the King Air 350i has a pushbutton near the center of the main panel that will tune COM1 Active to the emergency frequency of 121.50 MHz with a single push. Pressing the button again will revert to the previously tuned frequency.

For the VC, I wrote this bit of script that controls the illuminated button, and sends a flag to my logic gauge to handle the hard stuff:

Code:
  <PartInfo>
    <Name>KA350i_EmerFreq_ON</Name>
    <Visibility>
      <Parameter>
        <Code>
          (L:KA350i_EmerFreq,bool)
          (L:ANNUN_TEST,bool) or
        </Code>
      </Parameter>
    </Visibility>
    <MouseRect>
      <Cursor>Hand</Cursor>
      <MouseFlags>LeftSingle</MouseFlags>
      <CallbackCode>
        (L:KA350i_EmerFreq,bool) ! (>L:KA350i_EmerFreq,bool)
        1 (>L:EmerFreqClicked,bool)
        1 (>L:XMLSND5,bool)
      </CallbackCode>
    </MouseRect>
  </PartInfo>
In the logic gauge, both the control variable and the button's flag variable are monitored. Once the appropriate action is taken, the flag variable is reset so the evaluation will stop.

Code:
<Update>
 
    <!-- COM EMER FREQUENCY -->
    (L:KA350i_EmerFreq,bool)
    (L:EmerFreqClicked,bool) and
    if{
      (A:COM ACTIVE FREQUENCY:1,MHz) (>L:ComActiveFreqBackup,enum)
      @SetCOM1(121.50)
      0 (>L:EmerFreqClicked,bool)
    }
    <!-- COM PREVIOUS FREQUENCY -->
    (L:KA350i_EmerFreq,bool) !
    (L:EmerFreqClicked,bool) and
    if{
      @SetCOM1((L:ComActiveFreqBackup,enum))
      0 (>L:EmerFreqClicked,bool)
    }
The @Macro though is where nothing seems to work except the old-fashioned, tried and true Horner Scheme:
Code:
  <Macro Name="SetCOM1">
    @1 100 * near 10000 % d 10 % r 10 / int d 10 % r 10 / int d 10 % r 10 / int 16 * + 16 * + 16 * + (&gt;K:COM_RADIO_SET)
  </Macro>
</Update>
Ah well, at least it does work 100% of the time! :confused:
 
Actually, that button doesn't tune... it simply tells the radio head to go into emergency mode, which does tune the emergency frequency. Just FYI. ;)
 
Well of course that is technically correct. Frankly this is simply another case of useless 'eye candy' since no sim platform actually supports any emergency frequency anyway... :laughing:
 
The emergency frequency itself exists in the sim... there's just no ATC monitoring it. However, if you were flying with a multiplayer environment that supported said communications system... then the sim platform would indeed support it... per se. ;)

Or in short... not everything's as useless as one might see on the 'surface'.
 
Bill,

Using the Horner Scheme seems rather prehistoric to me :eek:

Much simpler:

Code:
<Macro Name="SetCOM1">
  @1 (>L:RadioConvert,Mhz) (L:RadioConvert,Frequency BDC16) (>K:COM_RADIO_SET)
</Macro>

Tom
 
Unfortunately Tom, although it may be 'prehistoric' it does at least have the decency to work 100% of the time, unlike that much 'simpler' alternative, which lamentably stubbornly refuses to work 100% of the time, even with the correction factor and typo fixed...
Code:
  <Macro Name="SetCOM1">
    @1 0.001 + (>L:RadioConvert,Mhz) (L:RadioConvert,Frequency BCD16) (>K:COM_RADIO_SET)
  </Macro>
 
Bill, it should always work even without the 0.001 factor.

But, if you want something out of question, just write:

Code:
<Macro Name="SetCOM1">
    @1 (>L:RadioConvert,Hz) (L:RadioConvert,Frequency BCD16) (>K:COM_RADIO_SET)
</Macro>
....
@SetCom1(121500000)
.....

This must work 100 % as the value taken is an integer with no fractional value that might give floating point issues.

If this still doesn't work for you then the problem is elsewhere, but not in that piece of code.

Tom

PS: I've used Mhz with factor correction in many panels and never had a problem
 
Back
Top