Showing 1 changed files with 51 additions and 27 deletions
+51 -27
Nasal/softkeys.nas
... ...
@@ -459,11 +459,6 @@ var softkeysClass = {
459 459
             },
460 460
             'TMR/REF' : func {
461 461
                 if (!contains(me.device.windows.state, 'TMR/REF')) {
462
-                    var Vspeed_visiblity = func (id, selected, Vspeed)
463
-                        me.device.data[Vspeed ~ '-visible'] =
464
-                            me.device.windows.state[id].objects[selected].text
465
-                            ==
466
-                            me.device.windows.state[id].objects[selected].choices[0];
467 462
                     var GenericTimer = func (id, selected) {
468 463
                         var action = me.device.windows.state[id].objects[selected].text;
469 464
                         if (action == 'START?') {
... ...
@@ -513,10 +508,7 @@ var softkeysClass = {
513 508
                             .setText(action);
514 509
                         me.device.windows.state[id].objects[selected].text = action;
515 510
                     };
516
-                    me.device.windows.draw(
517
-                        'TMR/REF',
518
-                        {x: 720, y: 535, w: 300, l: 5, sep: 3},
519
-                        [ # objects infos
511
+                    var obj_infos = [ # objects infos
520 512
                             {text: 'REFERENCES', type: 'title'},
521 513
                             {type: 'separator'},
522 514
                             {text: 'TIMER', type: 'normal'},
... ...
@@ -524,27 +516,59 @@ var softkeysClass = {
524 516
                             {text: '  UP >', type: 'editable', choices: ['  UP >', '<DOWN ']},
525 517
                             {text: 'START?', type: 'editable|end-of-line', callback: func (id, selected) GenericTimer(id, selected)},
526 518
                             {type: 'separator'},
527
-                            {text: sprintf('Vx     %3iKT',
528
-                                            alerts.getNode('Vx') != nil ? alerts.getValue('Vx') : 0), type: 'normal', scrollgroup:0},
529
-                            {text: me.device.data['Vx-visible'] ? '   ON >' : '< OFF  ', type: 'editable|immediate|end-of-line', choices: ['   ON >', '< OFF  '], scrollgroup:0, callback: func (id, selected) Vspeed_visiblity(id, selected, 'Vx')},
530
-                            {text: sprintf('Vy     %3iKT',
531
-                                            alerts.getNode('Vy') != nil ? alerts.getValue('Vy') : 0), type: 'normal', scrollgroup:1},
532
-                            {text: me.device.data['Vy-visible'] ? '   ON >' : '< OFF  ', type: 'editable|immediate|end-of-line', choices: ['   ON >', '< OFF  '], scrollgroup:1, callback: func (id, selected) Vspeed_visiblity(id, selected, 'Vy')},
533
-                            {text: sprintf('Vr     %3iKT',
534
-                                            alerts.getNode('Vr') != nil ? alerts.getValue('Vr') : 0), type: 'normal', scrollgroup:2},
535
-                            {text: me.device.data['Vr-visible'] ? '   ON >' : '< OFF  ', type: 'editable|immediate|end-of-line', choices: ['   ON >', '< OFF  '], scrollgroup:2, callback: func (id, selected) Vspeed_visiblity(id, selected, 'Vr')},
536
-                            {text: sprintf('Vglide %3iKT',
537
-                                            alerts.getNode('Vglide') != nil ? alerts.getValue('Vglide') : 0), type: 'normal', scrollgroup:3},
538
-                            {text: me.device.data['Vglide-visible'] ? '   ON >' : '< OFF  ', type: 'editable|immediate|end-of-line', choices: ['   ON >', '< OFF  '], scrollgroup:3, callback: func (id, selected) Vspeed_visiblity(id, selected, 'Vglide')},
519
+                    ];
520
+                    var scrollgroup = 0;
521
+                    foreach (var V; ['x', 'y', 'r', 'glide']) {
522
+                        V = 'V' ~ V;
523
+                        var speed = alerts.getNode(V) != nil ? alerts.getValue(V) * units.speed.from_kt : 0;
524
+                        append(obj_infos, {
525
+                            text: sprintf('%-7s', V),
526
+                            type: 'normal',
527
+                            scrollgroup: scrollgroup
528
+                        });
529
+                        append(obj_infos, {
530
+                            text: sprintf('%3i%s',
531
+                                alerts.getNode(V) != nil ? alerts.getValue(V) * units.speed.from_kt : 0,
532
+                                units.speed.from_kt == 1 ? 'KT' : 'km/h'),
533
+                            type: 'editable|immediate',
534
+                            scrollgroup: scrollgroup,
535
+                            range: {min: 0, max: 999},
536
+                            format: '%3i' ~ (units.speed.from_kt == 1 ? 'KT' : 'km/h'),
537
+                            _v: V,
538
+                            callback: func (id, selected,) {
539
+                                string.scanf(string.trim(me.device.windows.state[id].objects[selected].text, -1),
540
+                                             '%3u' ~ (units.speed.from_kt == 1 ? 'KT' : 'km/h'), var r = []);
541
+                                data[me.device.windows.state[id].objects[selected]._v] = r[0];
542
+                            }
543
+
544
+                        });
545
+                        append(obj_infos, {
546
+                            text: me.device.data[V ~ '-visible'] ? '   ON >' : '< OFF  ',
547
+                            type: 'editable|immediate|end-of-line',
548
+                            scrollgroup: scrollgroup,
549
+                            _v: V,
550
+                            choices: ['   ON >', '< OFF  '],
551
+                            callback: func (id, selected) {
552
+                                var Vspeed = me.device.windows.state[id].objects[selected]._v;
553
+                                me.device.data[Vspeed ~ '-visible'] =
554
+                                    me.device.windows.state[id].objects[selected].text
555
+                                    ==
556
+                                    me.device.windows.state[id].objects[selected].choices[0];
557
+                            }
558
+                        });
559
+                        scrollgroup += 1;
560
+                    }
561
+                    append(obj_infos,
539 562
                             {type: 'separator'},
540 563
                             {text: 'MINIMUMS', type: 'normal'},
541 564
                             {text: '   OFF   >', type: 'editable', choices: ['   OFF   >', '<  BARO  >','<TEMP COMP'], callback: func},
542
-                            {text: ' 1000FT', type: 'editable', format: '% 5iFT', factor: 100, callback: func},
543
-                        ],
544
-                        { # scrolling info, see menu.nas
545
-                            lines : 3,
546
-                            columns : 2,
547
-                        }
565
+                            {text: ' 1000FT', type: 'editable', format: '% 5iFT', factor: 100, callback: func}
566
+                          );
567
+                    me.device.windows.draw(
568
+                        'TMR/REF',
569
+                        {x: 720, y: 535, w: 300, l: 5, sep: 3},
570
+                        obj_infos,
571
+                        { lines : 3, columns : 3 }
548 572
                     );
549 573
                     me.device.knobs.FmsInner = me.device.knobs.MenuSettings;
550 574
                     me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu;