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