Writing Com (standby) frequency

Help creating logic scripts for Air Manager Instruments

Moderators: russ, Ralph

Post Reply
Message
Author
Shimokuta
Posts: 113
Joined: Wed Feb 03, 2021 12:52 pm

Writing Com (standby) frequency

#1 Post by Shimokuta »

hey there

I am trying to write an entire COM1 frequency to the sim (prepar3d)
I know i have to do this in BCD format.
I have a function to convert to BCD

Code: Select all

function decimal_to_bcd16(frequency)

    local returnbcd = 0

    for i = 0, 3 do
        returnbcd = returnbcd + (math.floor(frequency % 10) << (i * 4))
        frequency = frequency / 10
    end
    
    return returnbcd
    
end 
with this function i am able to write my transponder code to the sim , but COM frequency doesn't seem to work. ?!?

Code: Select all

y = math.floor(decimal_to_bcd16(119.60))
      fsx_event("COM_RADIO_SET",y)

User avatar
Ralph
Posts: 7918
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: Writing Com (standby) frequency

#2 Post by Ralph »

It looks like you have used the code from the Flight Illusion gauge. This works perfect with their radio, so you're going wrong somewhere. But with just some bits and pieces of code it is hard to judge.

Shimokuta
Posts: 113
Joined: Wed Feb 03, 2021 12:52 pm

Re: Writing Com (standby) frequency

#3 Post by Shimokuta »

i am not aware using code from a flight illusion gauge.
But ...good tip! ...i will look and see if i can find something there

thx

Shimokuta
Posts: 113
Joined: Wed Feb 03, 2021 12:52 pm

Re: Writing Com (standby) frequency

#4 Post by Shimokuta »

I just found an article on Pete Downson's fsuipc site which triggered me.
For writing to some radio functions you can just multiply the freq with 100 and add 0x to a frequencyin FSX/Prepard3d
So for people who also have issues with this matter , in my case to set the com frequency to 119.60 for instance, i send fsx_event("COM_RADIO_SET",0x11960) and voila.

Post Reply