Showing 4 changed files with 84 additions and 90 deletions
+78 -48
Nasal/display.nas
... ...
@@ -39,13 +39,16 @@ var displayClass = {
39 39
                     'SoftKeysTexts', 
40 40
                     'COMM', 
41 41
                     'NAV', 
42
+                    'nav-freq-switch',
43
+                    'comm-freq-switch',
42 44
                 ],
43
-                hide : [ ],
44 45
                 text: [
45 46
                     'nav1-standby-freq', 'nav1-selected-freq', 'nav1-id',
46 47
                     'nav2-standby-freq', 'nav2-selected-freq', 'nav2-id',
47
-                    'nav-freq-switch',
48
+                    'comm1-standby-freq', 'comm1-selected-freq',
49
+                    'comm2-standby-freq', 'comm2-selected-freq',
48 50
                 ],
51
+                hide : [ ],
49 52
                 clip: [ ],
50 53
             };
51 54
             if (me.role == 'PFD') {
... ...
@@ -99,7 +102,8 @@ var displayClass = {
99 102
                 me.updateALT(getprop('instrumentation/altimeter/indicated-altitude-ft'));
100 103
                 me.updateHSI(getprop('orientation/heading-deg'));
101 104
             }
102
-            me.updateNAV({refresh:1, auto:1});
105
+            me._updateRadio({auto:'nav'});
106
+            me._updateRadio({auto:'comm'});
103 107
             me.progress.removeAllChildren();
104 108
             me.progress = nil;
105 109
             me.showInitProgress = nil;
... ...
@@ -402,37 +406,85 @@ var displayClass = {
402 406
         settimer(func me.updateHSI(getprop('orientation/heading-deg')), 0.1);
403 407
     },
404 408
 
409
+    _updateRadio: func {
410
+        # arg[0]._r = <comm|nav>
411
+        if (contains(arg[0], "active")) {
412
+            if (arg[0]['active'] == 'none') {
413
+                me.screenElements[arg[0]._r ~ '1-selected-freq']
414
+                    .setColor(1,1,1);
415
+                me.screenElements[arg[0]._r ~ '2-selected-freq']
416
+                    .setColor(1,1,1);
417
+            }
418
+            else {
419
+                me.screenElements[arg[0]._r ~ arg[0]['active'] ~ '-selected-freq']
420
+                    .setColor(0,1,0);
421
+                me.screenElements[arg[0]._r ~ arg[0].inactive ~ '-selected-freq']
422
+                    .setColor(1,1,1);
423
+            }
424
+        }
425
+        if (contains(arg[0], 'tune')) {
426
+            # n = 0 -> NAV1/COMM1
427
+            # n = 1 -> NAV1/COMM2
428
+            me.screenElements[arg[0]._r ~ '-freq-switch']
429
+                .setTranslation(0, arg[0].tune * 25);
430
+            me.screenElements[arg[0]._r ~ (arg[0].tune + 1) ~ '-standby-freq']
431
+                .setColor(0,1,1);
432
+            me.screenElements[arg[0]._r ~ ((arg[0].tune == 0) + 1) ~ '-standby-freq']
433
+                .setColor(1,1,1);
434
+        }
435
+        if (contains(arg[0], 'refresh')) {
436
+            # rafraichi une seule ligne NAV1/COMM1 ou NAV2/COMM2
437
+            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
438
+            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-selected-freq']
439
+                .setText(sprintf(fmt, getprop('/instrumentation/'
440
+                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/selected-mhz')));
441
+            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-standby-freq']
442
+                .setText(sprintf(fmt, getprop('/instrumentation/'
443
+                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/standby-mhz')));
444
+        }
445
+        if (contains(arg[0], 'set')) {
446
+            # positionne la valeur modifiée, les listeners "trigguent" en permanence ces propriétés, donc exit
447
+            var n = getprop('/instrumentation/zkv1000/radios/' ~ arg[0]._r ~ '-tune');
448
+            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
449
+            me.screenElements[arg[0]._r ~ (n + 1) ~ '-standby-freq']
450
+                .setText(getprop('/instrumentation/' ~ arg[0]._r ~ '[' ~ n ~ ']/frequencies/standby-mhz'));
451
+        }
452
+        if (contains(arg[0], 'auto')) {
453
+            # pour rafraichir automagiquement, toutes les deux secondes un refresh pour un NAV
454
+            var radio = arg[0].auto;
455
+            me._updateRadio({refresh: 1, _r: radio});
456
+            settimer(func me._updateRadio({refresh: 2, _r: radio}), 1);
457
+            settimer(func me._updateRadio({auto: radio}), 2);
458
+        }
459
+    },
460
+
405 461
     updateNAV : func {
406 462
         # made active via menu
407 463
         if (contains(arg[0], "active")) {
408 464
             if (arg[0]['active'] == 'none') {
465
+                arg[0]._r = 'nav';
466
+                me._updateRadio(arg[0]);
409 467
                 me.screenElements['nav1-id']
410 468
                     .setColor(1,1,1);
411
-                me.screenElements['nav1-selected-freq']
412
-                    .setColor(1,1,1);
413 469
                 me.screenElements['nav2-id']
414 470
                     .setColor(1,1,1);
415
-                me.screenElements['nav2-selected-freq']
416
-                    .setColor(1,1,1);
417 471
                 me.screenElements['NAV1-pointer']
418 472
                     .hide();
419 473
                 me.screenElements['NAV2-pointer']
420 474
                     .hide();
421 475
             }
422 476
             else {
423
-                var inactive = (arg[0]['active'] == 1) + 1;
477
+                arg[0]._r = 'nav';
478
+                arg[0].inactive = (arg[0]['active'] == 1) + 1;
479
+                me._updateRadio(arg[0]);
424 480
                 me.screenElements['nav' ~ arg[0]['active'] ~ '-id']
425 481
                     .setColor(0,1,0);
426
-                me.screenElements['nav' ~ arg[0]['active'] ~ '-selected-freq']
427
-                    .setColor(0,1,0);
428 482
                 me.screenElements['NAV' ~ arg[0]['active'] ~ '-pointer']
429 483
                     .show();
484
+                me.screenElements['nav' ~ arg[0].inactive ~ '-id']
485
+                    .setColor(1,1,1);
430 486
 #                me.screenElements['HDI']
431 487
 #                    .setRotation();
432
-                me.screenElements['nav' ~ inactive ~ '-id']
433
-                    .setColor(1,1,1);
434
-                me.screenElements['nav' ~ inactive ~ '-selected-freq']
435
-                    .setColor(1,1,1);
436 488
 #                me.screenElements['NAV' ~ inactive ~ '-pointer']
437 489
 #                    .hide();
438 490
 #                foreach (var e; [ 'FROM', 'TO', 'CDI' ])
... ...
@@ -440,43 +492,21 @@ var displayClass = {
440 492
 #                        .hide();
441 493
             }
442 494
         }
443
-        if (contains(arg[0], 'tune')) {
444
-            var n = getprop('/instrumentation/zkv1000/radios/nav-tune');
445
-            # n = 0 -> NAV1
446
-            # n = 1 -> NAV2
447
-            me.screenElements['nav-freq-switch']
448
-                .setTranslation(0, n * 25);
449
-            me.screenElements['nav' ~ (n + 1) ~ '-standby-freq']
450
-                .setColor(0,1,1);
451
-            me.screenElements['nav' ~ ((n == 0) + 1) ~ '-standby-freq']
452
-                .setColor(1,1,1);
453
-        }
454
-        if (contains(arg[0], 'nav-id')) {
495
+        elsif (contains(arg[0], 'nav-id')) {
455 496
             # TODO: récupérer la valeur via les paramètres transmis du listener
456
-            var navid = getprop('/instrumentation/nav[' ~ (arg[0]['nav-id'] - 1) ~ ']/nav-id');
457
-            if (navid == nil)
458
-                navid = '';
497
+            if (arg[0].val == nil)
498
+                arg[0].val = '';
459 499
             me.screenElements["nav" ~ arg[0]['nav-id'] ~ "-id"]
460
-                    .setText(navid); # veut pas exister au début...
461
-        }
462
-        if (contains(arg[0], 'refresh')) {
463
-            # rafraichi une seule ligne NAV1 ou NAV2
464
-            me.screenElements['nav' ~ arg[0].refresh ~ '-selected-freq']
465
-                .setText(getprop('/instrumentation/nav[' ~ (arg[0].refresh - 1) ~ ']/frequencies/selected-mhz-fmt'));
466
-            me.screenElements['nav' ~ arg[0].refresh ~ '-standby-freq']
467
-                .setText(getprop('/instrumentation/nav[' ~ (arg[0].refresh - 1) ~ ']/frequencies/standby-mhz-fmt'));
468
-        }
469
-        if (contains(arg[0], 'set')) {
470
-            # positionne la valeur modifiée, les listeners "trigguent" en permanence ces propriétés, donc exit
471
-            var n = getprop('/instrumentation/zkv1000/radios/nav-tune');
472
-            me.screenElements['nav' ~ (n + 1) ~ '-standby-freq']
473
-                .setText(getprop('/instrumentation/nav[' ~ n ~ ']/frequencies/standby-mhz-fmt'));
500
+                    .setText(arg[0].val);
474 501
         }
475
-        if (contains(arg[0], 'auto')) {
476
-            # pour rafraichir automagiquement, toutes les deux secondes un refresh pour un NAV
477
-            me.updateNAV({refresh: 1});
478
-            settimer(func me.updateNAV({refresh: 2}), 1);
479
-            settimer(func me.updateNAV({auto:1}),     2);
502
+        else {
503
+            arg[0]._r = 'nav';
504
+            me._updateRadio(arg[0]);
480 505
         }
481 506
     },
507
+
508
+    updateCOMM: func {
509
+        arg[0]._r = 'comm';
510
+        me._updateRadio(arg[0]);
511
+    },
482 512
 };
+2 -40
Systems/screen.svg
... ...
@@ -6718,28 +6718,12 @@
6718 6718
      id="COMM"
6719 6719
      inkscape:label="COMM"
6720 6720
      style="display:inline">
6721
-    <rect
6722
-       y="4.5491962"
6723
-       x="760.00391"
6724
-       height="22.948854"
6725
-       width="86.902672"
6726
-       id="comm1-selected-tuning"
6727
-       style="display:inline;fill:none;fill-opacity:0;stroke:#9bd8d9;stroke-width:1.09732676;stroke-opacity:1"
6728
-       inkscape:label="comm1-selected-tuning" />
6729
-    <rect
6730
-       y="4.5455642"
6731
-       x="870.99341"
6732
-       height="22.952444"
6733
-       width="86.902588"
6734
-       id="comm1-standby-tuning"
6735
-       style="display:inline;fill:none;fill-opacity:0;stroke:#9bd8d9;stroke-width:1.09741211;stroke-opacity:1"
6736
-       inkscape:label="comm1-standby-tuning" />
6737 6721
     <path
6738 6722
        inkscape:connector-curvature="0"
6739
-       id="comm1-switch"
6723
+       id="comm-freq-switch"
6740 6724
        d="m 853.98671,12.608238 -3.99804,3.998045 -6.2e-4,1.008425 3.99805,3.998055 -0.004,-2 -0.99547,-0.995475 v -1.00391 l 12.00453,-6.2e-4 -0.0202,2.015015 -0.97708,-0.01901 -0.005,2.00143 3.99938,-3.99938 -10e-4,-0.998665 -4.0025,-4.001955 0.004,1.999995 0.99805,0.99805 -0.004,1 h -11.99609 l 0.006,-0.99743 0.99608,-0.99609 z"
6741 6725
        style="display:inline;fill:#9bd8d9;fill-opacity:1;stroke:#9bd8d9;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1"
6742
-       inkscape:label="comm1-switch" />
6726
+       inkscape:label="comm-freq-switch" />
6743 6727
     <text
6744 6728
        transform="scale(0.85708105,1.1667508)"
6745 6729
        id="comm1-standby-freq"
... ...
@@ -6766,28 +6750,6 @@
6766 6750
          x="937.43207"
6767 6751
          id="tspan4111-8-3"
6768 6752
          sodipodi:role="line">123.456</tspan></text>
6769
-    <rect
6770
-       y="28.549196"
6771
-       x="760.00391"
6772
-       height="22.948854"
6773
-       width="86.902672"
6774
-       id="comm2-selected-tuning"
6775
-       style="display:inline;fill:none;fill-opacity:0;stroke:#9bd8d9;stroke-width:1.09732676;stroke-opacity:1"
6776
-       inkscape:label="comm2-selected-tuning" />
6777
-    <rect
6778
-       y="28.545565"
6779
-       x="870.99341"
6780
-       height="22.952444"
6781
-       width="86.902588"
6782
-       id="comm2-standby-tuning"
6783
-       style="display:inline;fill:none;fill-opacity:0;stroke:#9bd8d9;stroke-width:1.09741211;stroke-opacity:1"
6784
-       inkscape:label="comm2-standby-tuning" />
6785
-    <path
6786
-       inkscape:connector-curvature="0"
6787
-       id="comm2-switch"
6788
-       d="m 853.98342,35.605668 -3.99804,3.998045 -6.2e-4,1.008425 3.99805,3.998055 -0.004,-2 -0.99547,-0.995475 v -1.00391 l 12.00453,-6.2e-4 -0.0202,2.015015 -0.97708,-0.01901 -0.005,2.00143 3.99938,-3.99938 -10e-4,-0.998665 -4.0025,-4.001955 0.004,1.999995 0.99805,0.99805 -0.004,1 h -11.99609 l 0.006,-0.99743 0.99608,-0.99609 z"
6789
-       style="display:inline;fill:#9bd8d9;fill-opacity:1;stroke:#9bd8d9;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1"
6790
-       inkscape:label="comm2-switch" />
6791 6753
     <text
6792 6754
        transform="scale(0.85708105,1.1667508)"
6793 6755
        id="comm2-standby-freq"
+2 -1
mfd.xml
... ...
@@ -420,12 +420,13 @@
420 420
           <property>/instrumentation/zkv1000/device[1]/status</property>
421 421
         </condition>
422 422
         <command>property-toggle</command>
423
-        <property>/intrumentation/zkv1000/radios/comm-selected</property>
423
+        <property>/instrumentation/zkv1000/radios/comm-tune</property>
424 424
       </binding>
425 425
     </action>
426 426
   </animation>
427 427
   <animation>
428 428
     <type>knob</type>
429
+    <object-name>ComInner</object-name>
429 430
     <action>
430 431
       <binding>
431 432
         <condition>
+2 -1
pfd.xml
... ...
@@ -431,12 +431,13 @@
431 431
           <property>/instrumentation/zkv1000/device[0]/status</property>
432 432
         </condition>
433 433
         <command>property-toggle</command>
434
-        <property>/intrumentation/zkv1000/radios/comm-selected</property>
434
+        <property>/instrumentation/zkv1000/radios/comm-tune</property>
435 435
       </binding>
436 436
     </action>
437 437
   </animation>
438 438
   <animation>
439 439
     <type>knob</type>
440
+    <object-name>ComInner</object-name>
440 441
     <action>
441 442
       <binding>
442 443
         <condition>