Code: Select all
--add background image
img_add_fullscreen ("powerbk.png")
--define output text size, colour and location on back ground image. Need 3 colours because of 3 parameters I will use to make each one visible as needed
txt_shp1 = txt_add( "0.0", "size:60px; color: green; halign:center;valign:center;", 50, 10, 150, 90)
txt_shp2 = txt_add( "0.0", "size:60px; color: goldenrod; halign:center;valign:center;", 50, 10, 150, 90)
txt_shp3 = txt_add( "0.0", "size:60px; color: red; halign:center;valign:center;", 50, 10, 150, 90)
txt_shp4 = txt_add( "0.0", "size:60px; color: green; halign:center;valign:center;", 300, 10, 150, 90)
txt_shp5 = txt_add( "0.0", "size:60px; color: goldenrod; halign:center;valign:center;", 300, 10, 150, 90)
txt_shp6 = txt_add( "0.0", "size:60px; color: red; halign:center;valign:center;", 300, 10, 150, 90)
--[[convert output from torque callback --eng_torque-- of newton meters to foot pounds Left Engine. Since the ouput of the callback is a FLOAT[8]
xplane has the ability to have 8 engines and the left one on a twin is engine 1 The right eng is 2 so we perform the same caluclation for each engine]]
function eng_torque(trq_nms)
-- Convert to foot pounds
trq_fpsL=trq_nms[1] * 0.73756 --engine 1
--convert foot pounds to psi
--
trq_psiL=trq_fpsL/30.57
--Call the text
txt_set (txt_shp1, string.format("%02.01f", trq_psiL) )
txt_set (txt_shp2, string.format("%02.01f", trq_psiL) )
txt_set (txt_shp3, string.format("%02.01f", trq_psiL) )
-- Make the coloured text visible pertinent to tq psi value
visible(txt_shp1, trq_psiL < 40)
visible(txt_shp2, trq_psiL >= 40)
visible(txt_shp3, trq_psiL >= 50)
--do it all again for the right Engine
trq_fpsR=trq_nms[2] * 0.73756 --engine 2
--convert foot pounds to psi
trq_psiR=trq_fpsR/30.57
txt_set (txt_shp4, string.format("%02.01f", trq_psiR) )
txt_set (txt_shp5, string.format("%02.01f", trq_psiR) )
txt_set (txt_shp6, string.format("%02.01f", trq_psiR) )
visible(txt_shp4, trq_psiR < 40)
visible(txt_shp5, trq_psiR >= 40)
visible(txt_shp6, trq_psiR >= 50)
-- I use the prints in the AM console to validate what I should see on the gauge.
print(trq_psiL)
print(trq_psiR)
end
-- Data bus subscribe
xpl_dataref_subscribe("sim/flightmodel/engine/ENGN_TRQ", "FLOAT[8]", eng_torque)