Showing 2 changed files with 55 additions and 31 deletions
+33 -22
Nasal/display.nas
... ...
@@ -139,7 +139,7 @@ var displayClass = {
139 139
                     'BRG1',
140 140
                     'BRG2',
141 141
                     'DME1',
142
-                    'PFD-Map',
142
+                    'PFD-Map-bg',
143 143
                     'PFD-Multilines',
144 144
                     'WindData', 'WindData-OPTN1', 'WindData-OPTN2', 'WindData-OPTN1-HDG', 'WindData-OPTN2-symbol', 'WindData-OPTN2-headwind', 'WindData-OPTN2-crosswind', 'WindData-NODATA',
145 145
                     'AOA', 'AOA-needle', 'AOA-text', 'AOA-approach',
... ...
@@ -213,21 +213,19 @@ var displayClass = {
213 213
                 me.updateBARO();
214 214
                 me.updateOMI();
215 215
                 me.timerTrigger();
216
+                me.device.data.mapclip = {
217
+                    top: math.ceil(me.screenElements['PFD-Map-bg'].getTransformedBounds()[1]) - 1,
218
+                    right: math.ceil(me.screenElements['PFD-Map-bg'].getTransformedBounds()[2]) - 1,
219
+                    bottom: math.ceil(me.screenElements['PFD-Map-bg'].getTransformedBounds()[3]) - 1,
220
+                    left: math.ceil(me.screenElements['PFD-Map-bg'].getTransformedBounds()[0]) - 1,
221
+                };
222
+                me.device.data.mapsize = [
223
+                    me.device.data.mapclip.right - me.device.data.mapclip.left,
224
+                    me.device.data.mapclip.bottom - me.device.data.mapclip.top,
225
+                ];
216 226
             }
217 227
             else {
218 228
                 me.updateEIS();
219
-                me.device.timers.map = maketimer(1, me, func {
220
-                        me.MFDMapTiles.updateTiles();
221
-                        me.MFDMapNavaids.update();
222
-                        var gspd = getprop('/velocities/groundspeed-kt');
223
-                        if (gspd != 0)
224
-                            var next = (me.device.data['range-nm']/(gspd/3600))/(me.display.get('view[1]')/2);
225
-                        else
226
-                            var next = 10;
227
-                        if (next > 10)
228
-                            next = 10;
229
-                        me.device.timers.map.restart(next);
230
-                    });
231 229
                 me.device.data.mapclip = {
232 230
                     top: math.ceil(me.screenElements['Header'].getTransformedBounds()[3]),
233 231
                     right: me.display.get('view[0]'),
... ...
@@ -238,15 +236,6 @@ var displayClass = {
238 236
                     me.device.data.mapclip.right - me.device.data.mapclip.left,
239 237
                     me.device.data.mapclip.bottom - me.device.data.mapclip.top,
240 238
                 ];
241
-                me.device.timers.map.singleShot = 1;
242
-                me.device.data.zoom = 10;
243
-                me.MFDMapTiles = MapTiles.new(me.device);
244
-                me.MFDMapTiles.changeZoom(0);
245
-                me.MFDMapNavaids = PositionedLayer.new(me.device);
246
-                me.MFDMapNavaids.setVisible(1);
247
-                me.MFDMapNavaids.update();
248
-                me.MFDMapTiles.initialize_grid();
249
-                me.device.timers.map.start();
250 239
                 io.load_nasal(data.zkv1000_dir ~ 'Nasal/MFD.pages.nas', 'zkv1000');
251 240
                 me['page selected'] = 0;
252 241
                 me.device.data['page selection'] = [
... ...
@@ -317,6 +306,28 @@ var displayClass = {
317 306
                 ];
318 307
                 me.setMFDPages();
319 308
             }
309
+            me.device.data.zoom = 10;
310
+            me.MapTiles = MapTiles.new(me.device);
311
+            me.MapNavaids = PositionedLayer.new(me.device);
312
+            if (! contains(data.timers, 'map')) {
313
+                data.timers.map = maketimer(1, me, func {
314
+                        foreach (var d; keys(flightdeck)) {
315
+                            flightdeck[d].display.MapTiles.update();
316
+                            flightdeck[d].display.MapNavaids.update();
317
+                        }
318
+                        var gspd = getprop('/velocities/groundspeed-kt');
319
+                        if (gspd != 0)
320
+                            var next = (me.device.data['range-nm']/(gspd/3600))/(me.display.get('view[1]')/2);
321
+                        else
322
+                            var next = 10;
323
+                        if (next > 10)
324
+                            next = 10;
325
+                        data.timers.map.restart(next);
326
+                    });
327
+                data.timers.map.singleShot = 1;
328
+                data.timers.map.start();
329
+            }
330
+
320 331
             me.updateNAV({auto:'nav', tune: radios.getNode('nav-tune').getValue()});
321 332
             me.updateCOMM({auto:'comm', tune: radios.getNode('comm-tune').getValue()});
322 333
             me.softkeys_inactivity();
+22 -9
Nasal/map.nas
... ...
@@ -18,6 +18,7 @@ var MapTiles = {
18 18
             (m.num_tiles[0] - 1) / 2,
19 19
             (m.num_tiles[1] - 1) / 2
20 20
         ];
21
+        m.visibility = m.device.role == 'MFD';
21 22
         m.group = m.display.createGroup()
22 23
             .setCenter(
23 24
                     m.device.data.mapsize[0] / 2 + m.device.data.mapclip.left,
... ...
@@ -33,10 +34,13 @@ var MapTiles = {
33 34
                         ~ m.device.data.mapclip.right ~','
34 35
                         ~ m.device.data.mapclip.bottom ~','
35 36
                         ~ m.device.data.mapclip.left ~')'
36
-                );
37
+                )
38
+            .setVisible(m.visibility);
37 39
         m.tiles = setsize([], m.num_tiles[0]);
38 40
         m.last_tile = [-1,-1];
39 41
         m.last_type = data['tiles-type'];
42
+        m.changeZoom(0);
43
+        m.initialize_grid();
40 44
         return m;
41 45
     },
42 46
 
... ...
@@ -46,6 +50,13 @@ var MapTiles = {
46 50
         me.device.data['range-nm'] = me.display.get('view[1]') / 2 * 84.53 * math.cos(data.lat) / math.pow(2, me.device.data.zoom);
47 51
     },
48 52
 
53
+    setVisible : func (v) {
54
+        if (v != me.visibility) {
55
+            me.visibility = v;
56
+            me.group.setVisible(v);
57
+        }
58
+    },
59
+
49 60
 # initialize the map by setting up a grid of raster images
50 61
     initialize_grid : func {
51 62
         for(var x = 0; x < me.num_tiles[0]; x += 1) {
... ...
@@ -56,7 +67,9 @@ var MapTiles = {
56 67
     },
57 68
 
58 69
 # this is the callback that will be regularly called by the timer to update the map
59
-    updateTiles : func {
70
+    update : func {
71
+         if (! me.visibility)
72
+             return;
60 73
 #        me.group.setRotation(-data.hdg * D2R);
61 74
 
62 75
         var n = math.pow(2, me.device.data.zoom);
... ...
@@ -453,6 +466,8 @@ var PositionedLayer = {
453 466
 
454 467
         m._model = nil;
455 468
         m.device = device;
469
+        m._visibility = m.device.role == 'MFD';
470
+
456 471
         var display = m.device.display.display;
457 472
         m._group = display.createGroup().createChild('map', 'MFD map')
458 473
             .set('clip',
... ...
@@ -460,14 +475,14 @@ var PositionedLayer = {
460 475
                         ~ m.device.data.mapclip.top ~','
461 476
                         ~ m.device.data.mapclip.right ~','
462 477
                         ~ m.device.data.mapclip.bottom ~','
463
-                        ~ m.device.data.mapclip.left ~')');
464
-        m._group
478
+                        ~ m.device.data.mapclip.left ~')')
465 479
             .setTranslation(
466 480
                     m.device.data.mapsize[0] / 2 + m.device.data.mapclip.left,
467 481
                     m.device.data.mapsize[1] / 2 + m.device.data.mapclip.top
468
-                );
469
-        m._group._node.getNode('range', 1)
470
-            .setDoubleValue(13.5); # TODO find a far less esoteric way to get range value
482
+                )
483
+            .setVisible(m._visibility);
484
+            m._group._node
485
+                .getNode('range', 1).setDoubleValue(13.5); # TODO find a far less esoteric way to get range value
471 486
 
472 487
         m._can = {};
473 488
         m._cache = {};
... ...
@@ -499,8 +514,6 @@ var PositionedLayer = {
499 514
 
500 515
         m._results = nil;
501 516
 
502
-        m._visibility = 0;
503
-
504 517
         return m;
505 518
     },
506 519
     update : func {