Showing 1 changed files with 36 additions and 3 deletions
+36 -3
Nasal/display.nas
... ...
@@ -287,14 +287,47 @@ var displayClass = {
287 287
             GS:  [func return sprintf('%3iKT', getprop('/velocities/groundspeed-kt')), 'Ground Speed'],
288 288
             TRK: [func return sprintf('%03i°', getprop('/orientation/track-deg')), 'Track'],
289 289
             TAS: [func return sprintf('%i', getprop('/instrumentation/airspeed-indicator/true-speed-kt')), 'True Air Speed'],
290
-            FOB: [func { return sprintf('%3ilbs', getprop('/consumables/fuel/total-fuel-lbs')); }, 'Fuel on Board'],
290
+            FOB: [func return sprintf('%3ilbs', getprop('/consumables/fuel/total-fuel-lbs')), 'Fuel on Board'],
291
+            XTK: [func {
292
+                var source = cdi.getValue('source');
293
+                if (source == 'NAV1')
294
+                    var xtk = sprintf('/instrumentation/nav[0]/crosstrack-error-m');
295
+                elsif (source == 'GPS')
296
+                    var xtk = sprintf('/instrumentation/gps/wp/wp[1]/course-error-nm');
297
+                return ' ---NM'
298
+            }, 'Crosstrack Error'],
299
+            MSA: [func {
300
+                data._msa_spd        = getprop('/velocities/groundspeed-kt');
301
+                data._msa_track      = getprop('/orientation/track-deg');
302
+                if (! contains(data.timers, 'MSA_geodinfo')) {
303
+                    data._msa_alt         = -1;
304
+                    data._msa_point       = 1;
305
+                    data._msa_alt_intern  = 0;
306
+                    data.timers.MSA_geodinfo = maketimer(0, func {
307
+                        var geo = greatCircleMove(
308
+                                data._msa_track,
309
+                                (data._msa_spd / 12) / 10 * data._msa_point);
310
+                        var (alt, _) = geodinfo(geo.lat, geo.lon, 10000);
311
+                        if (data._msa_alt_intern < alt) data._msa_alt_intern = alt;
312
+                        data._msa_point += 1;
313
+                        if (data._msa_point > 10) {
314
+                            data._msa_alt         = math.round((1000 + data._msa_alt_intern * M2FT) / 100) * 100;
315
+                            data._msa_point       = 0;
316
+                            data._msa_alt_intern  = 0;
317
+                        }
318
+                        else
319
+                            data.timers.MSA_geodinfo.restart(0);
320
+                    });
321
+                    data.timers.MSA_geodinfo.singleShot = 1;
322
+                }
323
+                data.timers.MSA_geodinfo.start();
324
+                return data._msa_alt == -1 ? '-----ft' : sprintf('%5ift', data._msa_alt);
325
+            }, 'Minimum Safe Altitude'],
291 326
 #            BRG: [func return '---°', 'Bearing'],
292 327
 #            ESA: [func return '-----', 'Enroute Safe Altitude'],
293 328
 #            ISA: [func return '-----', 'ISA Relative Temperature'],
294
-#            MSA: [func return '----ft', 'Minimum Safe Altitude'],
295 329
 #            TKE: [func return ' ---°', 'Track Angle Error'],
296 330
 #            VSR: [func return ' ----', 'Vertical Speed Required'],
297
-#            XTK: [func return ' ---NM', 'Crosstrack Error'],
298 331
 # }}}
299 332
         };
300 333
         if (m.device.role == 'PFD')