Free to modify and enhance for everyone
very easy to add data in the script, no need to calculate where the data will be displayed, all needed gap between lines are pre inserted
Code: Select all
-- RALLYE 150 ST FLIGHT DATA TOOL
-- enjxp_SimPassion 08/05/2019 v0.0.2
-- Default Size = 330 x 1080
img_plate = img_add_fullscreen("150ST_Plate_BG.png")
local lbl_ft_sz = 25
local ft_sz = 25
local ms_ft_sz = 20
txt_style0 = "font:inconsolata_bold.ttf ; size:30px; color: #FFFFFF; background_color: #4977FF; halign: center; valign: center;"
txt_style1 = "font:digital-7-mono.ttf; size:"..ft_sz.."px; color:#303030; halign:right; valign:center; background_color:#222222;"
txt_style2 = "font:digital-7-mono.ttf; size:"..ft_sz.."px; color:#00CC00; halign:right; valign:center;"
txt_style3 = "font:MS33558.ttf; size:"..ms_ft_sz.."px; color:#FFFFFF; halign:center; valign:center;"
txt_style4 = "font:Arimo-Bold.ttf; size:40px; color:#FFFFFF; halign:center; valign:center;"
txt_style5 = "font:inconsolata_bold.ttf ; size:"..lbl_ft_sz.."px; color: #FFFFFF; background_color: #00CC00; halign: center; valign: center;"
txt_style6 = "font:digital-7-mono.ttf; size:25px; color:#00CC00; halign:center; valign:center;"
txt_style7 = "font:digital-7-mono.ttf; size:15px; color:#00CC00; halign:center; valign:center;"
txt_style8 = "font:digital-7-mono.ttf; size:"..ft_sz.."px; color:#303030; halign:center; valign:center; background_color:#00CC00;"
txt_style9 = "font:digital-7-mono.ttf; size:"..ft_sz.."px; color:#303030; halign:center; valign:center; background_color:#CC6600;"
txt_style10 = "font:digital-7-mono.ttf; size:"..ft_sz.."px; color:#00CC00; halign:center; valign:center;"
function CoordBearing(lat1,lon1,lat2,lon2,magvar)
lat1 = math.rad(lat1)
lon1 = math.rad(lon1)
lat2 = math.rad(lat2)
lon2 = math.rad(lon2)
theta=math.atan(math.sin(lon2-lon1)*math.cos(lat2),math.cos(lat1)*math.sin(lat2)-math.sin(lat1)*math.cos(lat2)*math.cos(lon2-lon1))
brng = math.rad(theta) * 180 / math.pi
brng = (math.deg(brng)+magvar) % 360
return brng
end
function CoordDistance(latitude1, longitude1, latitude2, longitude2)
return 6371 * math.acos(math.sin(latitude1) * math.sin(latitude2) + math.cos(latitude1) * math.cos(latitude2) * math.cos(longitude2 - longitude1))
end
lig = 0 -- We start here
lib0 = txt_add("FLIGHT DATA", txt_style0, 0, lig, 330, 30) -- Main title
lig = lig + 30
lib1 = txt_add("SPEED", txt_style5, 0, lig, 330, lbl_ft_sz) -- a section is followed by a jump of 25px
lig = lig + 25
txt_lbl_tas = txt_add("TAS", txt_style3, 3, lig, 100, ft_sz)
txt_unt_tas = txt_add("KT", txt_style3, 235, lig, 50, ft_sz)
txt_tas_off = txt_add("0000 ", txt_style1,110, lig, 125, ft_sz)
txt_tas = txt_add("", txt_style2, 110, lig, 125, ft_sz)
lig = lig + 28 -- And data is followed by a jump of 28px
txt_lbl_ias = txt_add("IAS", txt_style3, 3, lig, 100, ft_sz)
txt_unt_ias = txt_add("KT", txt_style3, 235, lig, 50, ft_sz)
txt_ias_off = txt_add("0000 ", txt_style1,110, lig, 125, ft_sz)
txt_ias = txt_add("", txt_style2, 110, lig, 125, ft_sz)
lig = lig + 28
txt_lbl_grdspd = txt_add("GRNDSPD", txt_style3, 3, lig, 100, ft_sz)
txt_unt_grdspd = txt_add("KT", txt_style3, 235, lig, 50, ft_sz)
txt_grdspd_off = txt_add("0000 ", txt_style1,110, lig, 125, ft_sz)
txt_grdspd = txt_add("", txt_style2, 110, lig, 125, ft_sz)
lig = lig + 28
txt_lbl_rpm = txt_add("RPM", txt_style3, 3, lig, 100, ft_sz)
txt_unt_rpm = txt_add("RND/MN", txt_style3, 235, lig, 90, ft_sz)
txt_rpm_off = txt_add("0000 ", txt_style1,110, lig, 125, ft_sz)
txt_rpm = txt_add("", txt_style2, 110, lig, 125, ft_sz)
-- As a sample Copy and insert somewhere these 7 following lines and edit, when wanting a new section with already one data to be customized
-- Warning !!! Be aware to also customize variables which should exist only once
--=====================================================================
lig = lig + 28
lib1 = txt_add("HEADING", txt_style5, 0, lig, 330, lbl_ft_sz)
lig = lig + 25
txt_lbl_brg = txt_add("BRG", txt_style3, 3, lig, 100, ft_sz)
txt_unt_brg = txt_add("DEG", txt_style3, 235, lig, 60, ft_sz)
txt_brg_off = txt_add("000 ", txt_style1, 110, lig, 125, ft_sz)
txt_brg = txt_add("", txt_style2, 110, lig, 125, ft_sz)
--=====================================================================
lig = lig + 28
txt_lbl_hdg = txt_add("HDG", txt_style3, 3, lig, 100, ft_sz)
txt_unt_hdg = txt_add("DEG", txt_style3, 235, lig, 60, ft_sz)
txt_hdg_off = txt_add("000 ", txt_style1, 110, lig, 125, ft_sz)
txt_hdg = txt_add("", txt_style2, 110, lig, 125, ft_sz)
-- When needing one data or a few more, copy these 5 following lines, insert at the end of an existing last data within a section and edit data
--=====================================================================
lig = lig + 28
txt_lbl_crs1 = txt_add("CRS1", txt_style3, 3, lig, 100, ft_sz)
txt_unt_crs1 = txt_add("DEG", txt_style3, 235, lig, 60, ft_sz)
txt_crs1_off = txt_add("000 ", txt_style1, 110, lig, 125, ft_sz)
txt_crs1 = txt_add("", txt_style2, 110, lig, 125, ft_sz)
--=====================================================================
lig = lig + 28
lib1 = txt_add("ALTITUDE", txt_style5, 0, lig, 330, lbl_ft_sz)
lig = lig + 25
txt_lbl_alt = txt_add("ALT", txt_style3, 3, lig, 100, ft_sz)
txt_unt_alt = txt_add("FT", txt_style3, 235, lig, 50, ft_sz)
txt_alt_off = txt_add("00000 ", txt_style1,110, lig, 125, ft_sz)
txt_alt = txt_add("", txt_style2, 110, lig, 125, ft_sz)
lig = lig + 28
txt_lbl_vvi = txt_add("VVI", txt_style3, 3, lig, 100, ft_sz)
txt_unt_vvi = txt_add("FT/MN", txt_style3, 235, lig, 100, ft_sz)
txt_vvi_off = txt_add("00000 ", txt_style1,110, lig, 125, ft_sz)
txt_vvi = txt_add("", txt_style2, 110, lig, 125, ft_sz)
lig = lig + 28
txt_lbl_apvvi = txt_add("APVVI", txt_style3, 3, lig, 100, ft_sz)
txt_unt_apvvi = txt_add("FT/MN", txt_style3, 235, lig, 100, ft_sz)
txt_apvvi_off = txt_add("00000 ", txt_style1,110, lig, 125, ft_sz)
txt_apvvi = txt_add("", txt_style2, 110, lig, 125, ft_sz)
lig = lig + 28
lib1 = txt_add("FUEL", txt_style5, 0, lig, 330, lbl_ft_sz)
lig = lig + 25
txt_lbl_tnk1 = txt_add("TANK1", txt_style3, 3, lig, 100, ft_sz)
txt_unt_tnk1 = txt_add("KG", txt_style3, 235, lig, 50, ft_sz)
txt_tnk1_off = txt_add("0000 ", txt_style1, 110, lig, 125, ft_sz)
txt_tnk1 = txt_add("", txt_style2, 110, lig, 125, ft_sz)
lig = lig + 28
txt_lbl_tnk2 = txt_add("TANK2", txt_style3, 3, lig, 100, ft_sz)
txt_unt_tnk2 = txt_add("KG", txt_style3, 235, lig, 50, ft_sz)
txt_tnk2_off = txt_add("0000 ", txt_style1, 110, lig, 125, ft_sz)
txt_tnk2 = txt_add("", txt_style2, 110, lig, 125, ft_sz)
lig = lig + 28
txt_lbl_tnk3 = txt_add("TANK3", txt_style3, 3, lig, 100, ft_sz)
txt_unt_tnk3 = txt_add("KG", txt_style3, 235, lig, 50, ft_sz)
txt_tnk3_off = txt_add("0000 ", txt_style1, 110, lig, 125, ft_sz)
txt_tnk3 = txt_add("", txt_style2, 110, lig, 125, ft_sz)
lig = lig + 28
txt_lbl_tnk4 = txt_add("TANK4", txt_style3, 3, lig, 100, ft_sz)
txt_unt_tnk4 = txt_add("KG", txt_style3, 235, lig, 50, ft_sz)
txt_tnk4_off = txt_add("0000 ", txt_style1, 110, lig, 125, ft_sz)
txt_tnk4 = txt_add("", txt_style2, 110, lig, 125, ft_sz)
lig = lig + 28
txt_lbl_tnk5 = txt_add("TANK5", txt_style3, 3, lig, 100, ft_sz)
txt_unt_tnk5 = txt_add("KG", txt_style3, 235, lig, 50, ft_sz)
txt_tnk5_off = txt_add("0000 ", txt_style1, 110, lig, 125, ft_sz)
txt_tnk5 = txt_add("", txt_style2, 110, lig, 125, ft_sz)
lig = lig + 28
txt_lbl_tnk6 = txt_add("TANK6", txt_style3, 3, lig, 100, ft_sz)
txt_unt_tnk6 = txt_add("KG", txt_style3, 235, lig, 50, ft_sz)
txt_tnk6_off = txt_add("0000 ", txt_style1, 110, lig, 125, ft_sz)
txt_tnk6 = txt_add("", txt_style2, 110, lig, 125, ft_sz)
lig = lig + 28
txt_lbl_tnk7 = txt_add("TANK7", txt_style3, 3, lig, 100, ft_sz)
txt_unt_tnk7 = txt_add("KG", txt_style3, 235, lig, 50, ft_sz)
txt_tnk7_off = txt_add("0000 ", txt_style1, 110, lig, 125, ft_sz)
txt_tnk7 = txt_add("", txt_style2, 110, lig, 125, ft_sz)
lig = lig + 28
txt_lbl_tnk8 = txt_add("TANK8", txt_style3, 3, lig, 100, ft_sz)
txt_unt_tnk8 = txt_add("KG", txt_style3, 235, lig, 50, ft_sz)
txt_tnk8_off = txt_add("0000 ", txt_style1, 110, lig, 125, ft_sz)
txt_tnk8 = txt_add("", txt_style2, 110, lig, 125, ft_sz)
lig = lig + 28
txt_lbl_tnk9 = txt_add("TANK9", txt_style3, 3, lig, 100, ft_sz)
txt_unt_tnk9 = txt_add("KG", txt_style3, 235, lig, 50, ft_sz)
txt_tnk9_off = txt_add("0000 ", txt_style1, 110, lig, 125, ft_sz)
txt_tnk9 = txt_add("", txt_style2, 110, lig, 125, ft_sz)
lig = lig + 28
lib1 = txt_add("NEAREST", txt_style5, 0, lig, 330, lbl_ft_sz)
lig = lig + 25
txt_lbl_airp = txt_add("AIRP", txt_style3, 3, lig, 65, ft_sz)
txt_airp_off = txt_add("", txt_style1, 110, lig, 125, ft_sz)
txt_airp_icao = txt_add("", txt_style6, 110, lig, 125, ft_sz)
txt_airp_brng = txt_add("", txt_style3, 275, lig, 50, ft_sz)
lig = lig + 28
txt_lbl_vor = txt_add("VOR", txt_style3, 3, lig, 65, ft_sz)
txt_vor_off = txt_add("", txt_style1, 70, lig, 190, ft_sz)
txt_vor_icao = txt_add("", txt_style7, 70, lig, 190, ft_sz)
txt_vor_brng = txt_add("", txt_style3, 275, lig, 50, ft_sz)
lig = lig + 28
txt_lbl_ndb = txt_add("NDB", txt_style3, 3, lig, 65, ft_sz)
txt_ndb_off = txt_add("", txt_style1, 70, lig, 190, ft_sz)
txt_ndb_icao = txt_add("", txt_style7, 70, lig, 190, ft_sz)
txt_ndb_brng = txt_add("", txt_style3, 275, lig, 50, ft_sz)
lig = lig + 28
lib1 = txt_add("FLIGHT CONTROLS", txt_style5, 0, lig, 330, lbl_ft_sz)
lig = lig + 25
txt_lbl_flaps = txt_add("FLAPS", txt_style3, 3, lig, 100, ft_sz)
txt_unt_flaps = txt_add("PRCT", txt_style3, 235, lig, 70, ft_sz)
txt_flaps_off = txt_add("", txt_style1, 110, lig, 125, ft_sz)
txt_flaps = txt_add("", txt_style10, 110, lig, 125, ft_sz)
lig = lig + 28
txt_lbl_gears = txt_add("GEARS", txt_style3, 3, lig, 100, ft_sz)
txt_gears = txt_add("", txt_style8, 110, lig, 125, ft_sz)
-- Add new variable for new data inserted
function compute_display_leds( tas,
ias,
grdspd,
bearing,
heading,
course1,
altitude,
vvi,
apvvi,
fueltanks,
aircraft_latitude,
aircraft_longitude,
magvar,
flaps,
gears,
rpm
)
-- insert txt_set statement at the proper place below to handle newly added data
airp_nav_items = nav_get_nearest("AIRP", aircraft_latitude, aircraft_longitude, 1)
airp_icao = airp_nav_items[1]["NAME"]
airport_latitude = airp_nav_items[1]["LATITUDE"]
airport_longitude = airp_nav_items[1]["LONGITUDE"]
nrst_airp_brng = CoordBearing(aircraft_latitude,aircraft_longitude,airport_latitude,airport_longitude,magvar)
txt_set(txt_airp_icao,airp_icao)
txt_set(txt_airp_brng,math.floor(nrst_airp_brng))
vor_nav_items = nav_get_nearest("VOR", aircraft_latitude, aircraft_longitude, 1)
vor_icao = vor_nav_items[1]["NAME"]
vor_latitude = vor_nav_items[1]["LATITUDE"]
vor_longitude = vor_nav_items[1]["LONGITUDE"]
nrst_vor_brng = CoordBearing(aircraft_latitude,aircraft_longitude,vor_latitude,vor_longitude,magvar)
txt_set(txt_vor_icao,vor_icao)
txt_set(txt_vor_brng,math.floor(nrst_vor_brng))
ndb_nav_items = nav_get_nearest("NDB", aircraft_latitude, aircraft_longitude, 1)
ndb_icao = ndb_nav_items[1]["NAME"]
ndb_latitude = ndb_nav_items[1]["LATITUDE"]
ndb_longitude = ndb_nav_items[1]["LONGITUDE"]
nrst_ndb_brng = CoordBearing(aircraft_latitude,aircraft_longitude,ndb_latitude,ndb_longitude,magvar)
txt_set(txt_ndb_icao,ndb_icao)
txt_set(txt_ndb_brng,math.floor(nrst_ndb_brng))
txt_set(txt_tas,math.floor(tas).." ")
txt_set(txt_ias,math.floor(ias).." ")
txt_set(txt_grdspd,math.floor(grdspd).." ")
txt_set(txt_brg,math.floor(bearing).." ")
txt_set(txt_hdg,math.floor(heading).." ")
txt_set(txt_crs1,math.floor(course1).." ")
txt_set(txt_alt,math.floor(altitude).." ")
txt_set(txt_vvi,math.floor(vvi).." ")
txt_set(txt_apvvi,math.floor(apvvi).." ")
txt_set(txt_tnk1,math.floor(fueltanks[1]).." ")
txt_set(txt_tnk2,math.floor(fueltanks[2]).." ")
txt_set(txt_tnk3,math.floor(fueltanks[3]).." ")
txt_set(txt_tnk4,math.floor(fueltanks[4]).." ")
txt_set(txt_tnk5,math.floor(fueltanks[5]).." ")
txt_set(txt_tnk6,math.floor(fueltanks[6]).." ")
txt_set(txt_tnk7,math.floor(fueltanks[7]).." ")
txt_set(txt_tnk8,math.floor(fueltanks[8]).." ")
txt_set(txt_tnk9,math.floor(fueltanks[9]).." ")
txt_set(txt_flaps,math.floor(flaps*100).." ")
if gears == 0 then
txt_style(txt_gears,txt_style8)
elseif gears == 1 then
txt_style(txt_gears,txt_style9)
end
txt_set(txt_rpm,math.floor(rpm[1]).." ")
end
-- Add related Dataref to be available for the new data in the callback
xpl_dataref_subscribe( "sim/cockpit2/gauges/indicators/true_airspeed_kts_pilot", "FLOAT",
"sim/flightmodel/position/indicated_airspeed", "FLOAT",
"sim/cockpit2/radios/indicators/gps_dme_speed_kts", "FLOAT",
"sim/cockpit2/gauges/indicators/heading_vacuum_deg_mag_pilot", "FLOAT",
"sim/cockpit2/autopilot/heading_dial_deg_mag_pilot", "FLOAT",
"sim/cockpit/radios/nav1_obs_degm", "FLOAT",
"sim/cockpit2/gauges/indicators/altitude_ft_pilot", "FLOAT",
"sim/cockpit2/gauges/indicators/vvi_fpm_pilot", "FLOAT",
"sim/cockpit2/autopilot/vvi_dial_fpm", "FLOAT",
"sim/cockpit2/fuel/fuel_quantity", "FLOAT[9]",
"sim/flightmodel/position/latitude", "FLOAT",
"sim/flightmodel/position/longitude", "FLOAT",
"sim/flightmodel/position/magnetic_variation", "FLOAT",
"sim/cockpit2/controls/flap_ratio", "FLOAT",
"sim/cockpit2/annunciators/gear_unsafe", "INT",
"sim/cockpit2/engine/indicators/engine_speed_rpm", "FLOAT[8]",
compute_display_leds)
[EDIT] Indeed, no support on this, it's on eachone taste, doing, trying and seeing
Good playing with this tool, hope it could be of some help while debugging
there's also some ready made functions related to navigation and already some samples in it
I've just noticed to get some AM CTD when having too much datarefs reading while at the same time using the navigation feature "nav_get_nearest", not related to the instrument itself though
Just comment out these lines if you don't want to use navigation data :
Code: Select all
-- airp_nav_items = nav_get_nearest("AIRP", aircraft_latitude, aircraft_longitude, 1)
-- airp_icao = airp_nav_items[1]["NAME"]
-- airport_latitude = airp_nav_items[1]["LATITUDE"]
-- airport_longitude = airp_nav_items[1]["LONGITUDE"]
-- nrst_airp_brng = CoordBearing(aircraft_latitude,aircraft_longitude,airport_latitude,airport_longitude,magvar)
-- txt_set(txt_airp_icao,airp_icao)
-- txt_set(txt_airp_brng,math.floor(nrst_airp_brng))
-- vor_nav_items = nav_get_nearest("VOR", aircraft_latitude, aircraft_longitude, 1)
-- vor_icao = vor_nav_items[1]["NAME"]
-- vor_latitude = vor_nav_items[1]["LATITUDE"]
-- vor_longitude = vor_nav_items[1]["LONGITUDE"]
-- nrst_vor_brng = CoordBearing(aircraft_latitude,aircraft_longitude,vor_latitude,vor_longitude,magvar)
-- txt_set(txt_vor_icao,vor_icao)
-- txt_set(txt_vor_brng,math.floor(nrst_vor_brng))
-- ndb_nav_items = nav_get_nearest("NDB", aircraft_latitude, aircraft_longitude, 1)
-- ndb_icao = ndb_nav_items[1]["NAME"]
-- ndb_latitude = ndb_nav_items[1]["LATITUDE"]
-- ndb_longitude = ndb_nav_items[1]["LONGITUDE"]
-- nrst_ndb_brng = CoordBearing(aircraft_latitude,aircraft_longitude,ndb_latitude,ndb_longitude,magvar)
-- txt_set(txt_ndb_icao,ndb_icao)
-- txt_set(txt_ndb_brng,math.floor(nrst_ndb_brng))