FS2020 Events

Help creating logic scripts for Air Manager Instruments

Moderators: Ralph, russ

Post Reply
Message
Author
Mike Horsten
Posts: 79
Joined: Tue Dec 01, 2020 8:50 am

FS2020 Events

#1 Post by Mike Horsten » Fri Apr 23, 2021 9:29 am

Hi,

Just a question, i have been looking in conversion of some ADF and XPND code from XP to FS2020. When i look up the value of the Standby ADF currently set at. i get some really weird text back. My displays display rubbish. I looked at direct output so no mods and still rubbish.
When i switch over to the XP version all works. I understand tha tthe code is different so that why the question what im i doing wrong.

If the standby call is ADF STANDBY FREQUENCY and it responds in "Hz". this should be readable right? and it does but when i want to read out the current ADF i use ADF FREQUENCY (the FSX Legacy, use ADF ACTIVE FREQUENCY should also work) i should get the freq. But i dont i get rubsish, now im confused because i get the following from the MSFS API the value returned is in "Frequency BCD16" and a "TYPE_BCD16" value

Also if checking the Xpnder i get BCD32. Can anybody explain what the BCD16/32 are and how to convert to text to display on a 7 segment display. I have it working well for some time on the XP version but MSFS2020 misses a lot of commands that XP does have.

Also is there some code where i can do the same as in Xplane to move the digits 12 and 34 only (example Xplane datacommand = sim/transponder/transponder_12_XXX)
Seems MSFS does not have anything close, but only a command for each digit. I really would like to use only 2 encoders to move the transponder and/or ADF. (Why? low on real estate )

thanks
Mike
Building a home Cessna 172SP Steam. X-plane/MFS2020
(ex Name on Airmanager forum Polarair)

User avatar
Sling
Posts: 4504
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: FS2020 Events

#2 Post by Sling » Fri Apr 23, 2021 10:12 am

Hi Mike,

I think it’s a yes to all what you want to do but the big caveat to that yes is I’m not sure if FS2020 has all this working correctly. If it’s the same as FSX then we can get you going.

First up on the BCD thing it certainly is a weird implementation. I posted a solution for Ralph a while back when he was struggling with a very similar issue. You can learn how BCD works if you want to understand it but MS implementation adds a bit more weirdness to basic BCD so it takes getting your head around. I’d be happy to explain in detail but I may have to refresh myself first. The alternative is to use the code I supplied back then and just accept it works.

The 12 34 thing I’m not quite sure what you mean. Are you seeking a way to separately control the 100khz from say the 1khz. Perhaps you could explain a bit further.

It would also be useful to know what instrument you are trying to convert and any code you already have.

Tony

User avatar
bartroozendaal
Posts: 30
Joined: Wed Jan 06, 2021 8:01 pm
Contact:

Re: FS2020 Events

#3 Post by bartroozendaal » Fri Apr 23, 2021 12:12 pm

This works for me in FS2020 to read the frequencies:

fs2020_variable_subscribe("COM ACTIVE FREQUENCY:1", "Mhz", "COM STANDBY FREQUENCY:1", "MHz", newCom1Frequencies)
fs2020_variable_subscribe("COM ACTIVE FREQUENCY:2", "Mhz", "COM STANDBY FREQUENCY:2", "MHz", newCom2Frequencies)
Bart Roozendaal
https://fsarduino.com

Mike Horsten
Posts: 79
Joined: Tue Dec 01, 2020 8:50 am

Re: FS2020 Events

#4 Post by Mike Horsten » Fri Apr 23, 2021 12:53 pm

bartroozendaal wrote:
Fri Apr 23, 2021 12:12 pm
This works for me in FS2020 to read the frequencies:

fs2020_variable_subscribe("COM ACTIVE FREQUENCY:1", "Mhz", "COM STANDBY FREQUENCY:1", "MHz", newCom1Frequencies)
fs2020_variable_subscribe("COM ACTIVE FREQUENCY:2", "Mhz", "COM STANDBY FREQUENCY:2", "MHz", newCom2Frequencies)
Hi Bart,

Yes Comms and NAV's work without issues. its the ADF and XPND that are BCF versions.

Tony: Ill look back at the code from some time back. As for the 12 34 code i mean that you can in XPlane use one encoder command ( plus or minus) to raise or lower the tens and hundereds. This means you only need two incoders to move the ADF from 0 to 999 and the transponder has the same function to go from 1000-7777 i believe but you move the 100 and the tens. see the code 1

Code: Select all

--ENCODERS
function ADF_HIGH_ENC_change(direction)
  if direction == -1 then print("The ADF HIGH encoder turned Counterclock -1")
   xpl_command("sim/radios/actv_adf1_hundreds_thous_down")
  elseif direction == 1 then print("The ADF HIGH encoder turned Clockwise +1")
   xpl_command("sim/radios/actv_adf1_hundreds_thous_up")  
end end
function ADF_LOW_ENC_change(direction)
  if direction == -1 then print("The ADF LOW encoder turned Counterclock -1")
    xpl_command("sim/radios/actv_adf1_ones_tens_down")
  elseif direction == 1 then print("The ADF LOW encoder turned Clockwise +1")
   xpl_command("sim/radios/actv_adf1_ones_tens_up")  
end end
As for the display i just want to diplay the active and standby freqs of the ADF and with the transponder only need the actual current transponder code. But dont seem to get that in a nice format. Ill play with the release version of 4 to see if it was a bug in the past but dont believe so.
As i cant get it to work with Prepare3D either.
Building a home Cessna 172SP Steam. X-plane/MFS2020
(ex Name on Airmanager forum Polarair)

User avatar
Sling
Posts: 4504
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: FS2020 Events

#5 Post by Sling » Fri Apr 23, 2021 1:07 pm

Mike,

If I get time over the weekend I’ll knock up a script for the BCD and encoder control. The display thing is just formatting the string which should be straight forward. Again there are examples in these forums.

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests