From acabed103fa47562fa9a4ba6a65ce4d333cc2322 Mon Sep 17 00:00:00 2001 From: Stuart Buchanan Date: Sat, 12 Jan 2019 21:23:27 +0000 Subject: [PATCH] FG1000: Local time display, ETE fix. --- .../FG1000/Nasal/Interfaces/GenericADCPublisher.nas | 2 ++ .../FG1000/Nasal/Interfaces/GenericFMSPublisher.nas | 2 +- .../Nasal/MFDPages/PFDInstruments/PFDInstruments.nas | 8 ++++++++ .../MFDPages/PFDInstruments/PFDInstrumentsController.nas | 6 ++++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/Interfaces/GenericADCPublisher.nas b/Aircraft/Instruments-3d/FG1000/Nasal/Interfaces/GenericADCPublisher.nas index b29531535..3aab36d2a 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/Interfaces/GenericADCPublisher.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/Interfaces/GenericADCPublisher.nas @@ -61,6 +61,8 @@ var GenericADCPublisher = obj.addPropMap("ADCOutsideAirTemperatureC", "/environment/temperature-degc"); obj.addPropMap("ADCWindHeadingDeg", "/environment/wind-from-heading-deg"); obj.addPropMap("ADCWindSpeedKt", "/environment/wind-speed-kt"); + obj.addPropMap("ADCTimeLocalSec", "/sim/time/local-day-seconds"); + obj.addPropMap("ADCTimeUTCSec", "/sim/time/utc/day-seconds"); return obj; }, }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/Interfaces/GenericFMSPublisher.nas b/Aircraft/Instruments-3d/FG1000/Nasal/Interfaces/GenericFMSPublisher.nas index 6d21b0a65..3ec137bbc 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/Interfaces/GenericFMSPublisher.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/Interfaces/GenericFMSPublisher.nas @@ -100,7 +100,7 @@ var GenericFMSPublisher = } gpsdata["FMSDistance"] = dst; - var spd = getprop("/instrumentation/gps/indicated-ground-speed-kt") or 1.0; + var spd = math.max(getprop("/instrumentation/gps/indicated-ground-speed-kt"), 20.0); var time_hrs = dst / spd; gpsdata["FMSEstimatedTimeEnroute"] = time_hrs; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/MFDPages/PFDInstruments/PFDInstruments.nas b/Aircraft/Instruments-3d/FG1000/Nasal/MFDPages/PFDInstruments/PFDInstruments.nas index 48d9c9c36..5c44b03f0 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/MFDPages/PFDInstruments/PFDInstruments.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/MFDPages/PFDInstruments/PFDInstruments.nas @@ -62,6 +62,7 @@ var PFDInstruments = "SelectedALT-text", "XPDR-DIGIT-3-text", "XPDR-DIGIT-2-text", "XPDR-DIGIT-1-text", "XPDR-DIGIT-0-text", "XPDR-MODE-text", + "TIME-text", ]); # Set clipping for the various tapes @@ -514,6 +515,13 @@ var PFDInstruments = me.setTextElement("OAT-text", sprintf((abs(oat) < 10) ? "%.1f %s" : "%i %s", oat, "°C")); }, + updateTime : func (time_sec) { + var sec = math.mod(time_sec, 60); + var mins = math.mod((time_sec - sec) / 60, 60); + var hours = math.mod((time_sec - mins - sec) / 3600, 12); + me.setTextElement("TIME-text", sprintf("%02d:%02d:%02d", hours, mins, sec)); + }, + updateHSI : func (hdg) { me.getElement("Rose").setRotation(-hdg * D2R); me.setTextElement("HDG-text", sprintf("%03u°", hdg)); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/MFDPages/PFDInstruments/PFDInstrumentsController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/MFDPages/PFDInstruments/PFDInstrumentsController.nas index ffe006c34..3db0c5ec0 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/MFDPages/PFDInstruments/PFDInstrumentsController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/MFDPages/PFDInstruments/PFDInstrumentsController.nas @@ -39,6 +39,7 @@ var PFDInstrumentsController = _selected_alt_ft : 0, _heading_magnetic_deg : 0, _mag_var : 0, + _time_sec : 0, _fp_active : 0, _fp_current_wp : 0, @@ -245,6 +246,11 @@ var PFDInstrumentsController = no_data: (data["ADCIndicatedAirspeed"] < 1.0) ); + if ((data["ADCTimeLocalSec"] != nil) and (me._time_sec != data["ADCTimeLocalSec"])) { + me._time_sec = data["ADCTimeLocalSec"]; + me.page.updateTime(me._time_sec); + } + return emesary.Transmitter.ReceiptStatus_OK; },