Co-pilot altimeter FSX / Prepar3D

Help creating logic scripts for Air Manager Instruments

Moderators: russ, Ralph

Post Reply
Message
Author
User avatar
Ralph
Posts: 7933
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Co-pilot altimeter FSX / Prepar3D

#1 Post by Ralph »

I had to make a co-pilot altimeter for FSX / Prepar3D. Other than X-Plane, FSX and Prepar3D don't have a barometric pressure setting and altimeter readout for the co-pilot, so I had to a little bit of hacking. So for anyone who wants to create a co-pilot altimeter for FSX / Prepar3D, this might help.

Code: Select all

-- This is your co-pilot pressure setting, change this value with your pressure setting dial
local gbl_inhg = 29.00
function new_data(pres_alt)
altitude = ((gbl_inhg - 29.92) * 1000) + pres_alt
print("The co-pilot altitude is: " .. altitude .. "ft")
end
-- Data Subscription
fsx_variable_subscribe("PRESSURE ALTITUDE", "Feet", new_data)

flbessa
Posts: 69
Joined: Thu Jan 28, 2016 4:07 pm

Re: Co-pilot altimeter FSX / Prepar3D

#2 Post by flbessa »

Thanks Ralph.. I was able to split Altimeter and heading to the co-pilot in P3D. =)

Question: is the a proper way to call back the script. In this case I assigned the encoder to the increase/decrease the gbl_inhg. At the end of the encoder function I send a fsx_event AP_MACH_HOLD_INC so I can read the script via variable, but not sure if there is a proper way.

Thanks,
Filipe

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

Re: Co-pilot altimeter FSX / Prepar3D

#3 Post by Ralph »

Maybe like this?

Code: Select all

-- This is your co-pilot pressure setting, change this value with your pressure setting dial
persist_pres = persist_add("Pressure", "FLOAT", 29.92)
local gbl_inhg = persist_get(persist_pres)

function new_data(pres_alt)
 
  altitude = ((gbl_inhg - 29.92) * 1000) + pres_alt
  print("The co-pilot altitude is: " .. altitude .. "ft")
 
end

function dial_altimeter(direction)

    if direction == 1 then
        gbl_inhg = var_cap(gbl_inhg + 0.02, 27.2, 31.9)
    else
        gbl_inhg = var_cap(gbl_inhg - 0.02, 27.2, 31.9)
    end

    persist_put(persist_pres, gbl_inhg)

end

-- Altimeter rotary encoder
hw_dial_add("Altimeter", dial_altimeter)

-- Data Subscription
fsx_variable_subscribe("PRESSURE ALTITUDE", "Feet", new_data)

flbessa
Posts: 69
Joined: Thu Jan 28, 2016 4:07 pm

Re: Co-pilot altimeter FSX / Prepar3D

#4 Post by flbessa »

Thanks for the reply.

I'll give it a try and will let you know.

Cheers,
Filipe

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

Re: Co-pilot altimeter FSX / Prepar3D

#5 Post by Ralph »

You can make it go slower by adding or subtracting less than 0.02. I think you shouldn't go higher than 0.02.

Post Reply