zkv1000 / Nasal / softkeys.nas /
Newer Older
491 lines | 27.151kb
commit initial
Sébastien MARQUE authored on 2017-03-07
1
var softkeysClass = {
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
2
    new : func (device) {
commit initial
Sébastien MARQUE authored on 2017-03-07
3
        var m = { parents: [ softkeysClass ] };
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
4
        m.device = device;
5
        m.path = [];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
6
        m.colored = {};
commit initial
Sébastien MARQUE authored on 2017-03-07
7
        return m;
8
    },
9

            
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
10
    SoftKey : func (n, a) {
11
        # released key not yet managed
12
        if (a == 1)
13
            return;
14

            
15
        var key = me.device.display.screenElements[sprintf("SoftKey%02i-text",n)].get('text');
16
        if (key == '' or key == nil)
17
            return;
18

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
19
        var path = keyMap[me.device.role];
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
20
        foreach(var p; me.path) {
21
            if (contains(path, p))
22
                path = path[p];
23
            else
24
                break;
commit initial
Sébastien MARQUE authored on 2017-03-07
25
        }
26

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
27
        var bindings = me.bindings[me.device.role];
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
28
        foreach(var p; me.path) {
29
            if (contains(bindings, p))
30
                bindings = bindings[p];
31
            else
32
                break;
commit initial
Sébastien MARQUE authored on 2017-03-07
33
        }
34

            
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
35
        if (contains(path, key)) {
36
            append(me.path, key);
fix issue with some menus
Sébastien MARQUE authored on 2017-03-20
37
            if (contains(bindings, key))
38
                if (contains(bindings[key], 'hook'))
39
                    call(bindings[key].hook, [], me);
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
40
            me.device.display.updateSoftKeys();
commit initial
Sébastien MARQUE authored on 2017-03-07
41
        }
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
42
        elsif (contains(bindings, key)) {
43
            call(bindings[key], [], me);
commit initial
Sébastien MARQUE authored on 2017-03-07
44
        }
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
45
        elsif (key == 'BACK') {
46
            pop(me.path);
47
            me.device.display.updateSoftKeys();
commit initial
Sébastien MARQUE authored on 2017-03-07
48
        }
show the complete path menu ...
Sébastien MARQUE authored on 2017-03-20
49
        else {
50
            var list_path = '';
51
            foreach(var p; me.path) list_path ~= p ~ '/';
52
            print(me.device.role ~ ':' ~ list_path ~ key ~ ' : not yet implemented');
53
        }
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
54
    },
55

            
56
    bindings : {
57
        PFD : {
58
            INSET: {
59
                OFF: func {
60
                    pop(me.path);
61
                    me.device.display.updateSoftKeys();
62
                },
63
            },
64
            PFD: {
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
65
                'AOA/WIND' : {
adds AOA display
Sébastien MARQUE authored on 2017-04-15
66
                    AOA : {
67
                        'AOA ON' : func {
68
                            if (me.device.data['aoa-auto'])
69
                                return;
70
                            me.device.data.aoa = ! me.device.data.aoa;
nicer AOA display
Sébastien MARQUE authored on 2017-04-16
71
                            foreach (var e; ['AOA', 'AOA-needle', 'AOA-text'])
72
                                me.device.display.screenElements[e]
73
                                    .setVisible(me.device.data.aoa);
74
                            me.device.display.screenElements['AOA-approach']
75
                                .setVisible(me.device.data.aoa and contains(data, 'approach-aoa'));
adds AOA display
Sébastien MARQUE authored on 2017-04-15
76
                            me.device.display.updateAOA();
77
                            me.device.display.setSoftKeyColor(5 ,me.device.data.aoa);
78
                            if (me.device.data.aoa)
79
                                me.colored['PFDAOA/WINDAOAAOA ON'] = 1;
80
                            else
81
                                delete(me.colored, 'PFDAOA/WINDAOAAOA ON');
82
                        },
83
                        'AOA AUTO' : func {
84
                            if (me.device.data.aoa)
85
                                return;
86
                            me.device.data['aoa-auto'] = ! me.device.data['aoa-auto'];
87
                            me.device.display.setSoftKeyColor(6 ,me.device.data['aoa-auto']);
88
                            if (me.device.data['aoa-auto']) {
89
                                me.colored['PFDAOA/WINDAOAAOA AUTO'] = 1;
90
                                if (!contains(me.device.timers, 'aoa'))
91
                                    me.device.timers.aoa = maketimer(1,
92
                                            func {
93
                                                var v = getprop('/gear/gear/position-norm') == 1
94
                                                    and getprop('/surfaces-positions/flap-pos-norm') != 0;
nicer AOA display
Sébastien MARQUE authored on 2017-04-16
95
                                                foreach (var e; ['AOA', 'AOA-needle', 'AOA-text'])
96
                                                    me.device.display.screenElements[e]
97
                                                        .setVisible(v);
98
                                                me.device.display.screenElements['AOA-approach']
99
                                                    .setVisible(v and contains(data, 'approach-aoa'));
adds AOA display
Sébastien MARQUE authored on 2017-04-15
100
                                            }, me);
101
                                me.device.timers.aoa.start();
102
                            }
103
                            else {
104
                                delete(me.colored, 'PFDAOA/WINDAOAAOA AUTO');
105
                                me.device.timers.aoa.stop();
106
                                me.device.data.aoa = 0;
107
                                me.device.display.screenElements['AOA']
108
                                    .hide();
109
                            }
110
                        },
nicer AOA display
Sébastien MARQUE authored on 2017-04-16
111
                        hook : func {
112
                            if (contains(data,'approach-aoa'))
113
                                me.device.display.screenElements['AOA-approach']
114
                                    .setRotation(-data['approach-aoa']/data['stall-aoa']*math.pi);
115
                        },
adds AOA display
Sébastien MARQUE authored on 2017-04-15
116
                    },
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
117
                    WIND : {
118
                        OPTN1 : func {
119
                            me.device.display._winddata_optn = 1;
120
                            me.device.display.screenElements['WindData'].show();
121
                            me.device.display.screenElements['WindData-OPTN1'].show();
122
                            me.device.display.screenElements['WindData-OPTN1-HDG'].show();
123
                            me.device.display.screenElements['WindData-OPTN2'].hide();
124
                            me.device.display.updateWindData();
uses the new coloration for ...
Sébastien MARQUE authored on 2017-04-15
125
                            me.device.display.setSoftKeyColor(2, 1);
126
                            me.colored['PFDAOA/WINDWINDOPTN1'] = 1;
127
                            me.device.display.setSoftKeyColor(3, 0);
128
                            delete(me.colored, 'PFDAOA/WINDWINDOPTN2');
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
129
                        },
130
                        OPTN2 : func {
131
                            me.device.display._winddata_optn = 2;
132
                            me.device.display.screenElements['WindData'].show();
133
                            me.device.display.screenElements['WindData-OPTN1'].hide();
134
                            me.device.display.screenElements['WindData-OPTN2'].show();
135
                            me.device.display.screenElements['WindData-OPTN2-symbol'].show();
136
                            me.device.display.screenElements['WindData-OPTN2-headwind'].show();
137
                            me.device.display.screenElements['WindData-OPTN2-crosswind'].show();
138
                            me.device.display.updateWindData();
uses the new coloration for ...
Sébastien MARQUE authored on 2017-04-15
139
                            me.device.display.setSoftKeyColor(2, 0);
140
                            delete(me.colored, 'PFDAOA/WINDWINDOPTN1');
141
                            me.device.display.setSoftKeyColor(3, 1);
142
                            me.colored['PFDAOA/WINDWINDOPTN2'] = 1;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
143
                        },
144
                        OFF : func {
145
                            me.device.display._winddata_optn = 0;
146
                            me.device.display.screenElements['WindData'].hide();
147
                            me.device.display.screenElements['WindData-OPTN1'].hide();
148
                            me.device.display.screenElements['WindData-OPTN2'].hide();
uses the new coloration for ...
Sébastien MARQUE authored on 2017-04-15
149
                            me.device.display.setSoftKeyColor(2, 0);
150
                            delete(me.colored, 'PFDAOA/WINDWINDOPTN1');
151
                            me.device.display.setSoftKeyColor(3, 0);
152
                            delete(me.colored, 'PFDAOA/WINDWINDOPTN2');
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
153
                        },
154
                    },
155
                },
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
156
                BRG1 : func (brg = 1){
157
                    var source = 'brg' ~ brg ~ '-source';
158
                    var list = ['NAV' ~ brg, 'GPS', 'ADF', 'OFF'];
159
                    var index = std.Vector
160
                                   .new(list)
161
                                   .index(radios.getNode(source).getValue());
162
                    var next = (index == size(list) -1) ?  0 : index + 1;
163
                    radios.getNode(source).setValue(list[next]);
uses the new coloration for ...
Sébastien MARQUE authored on 2017-04-15
164
                    if (list[next] != 'OFF') {
165
                        me.device.display.setSoftKeyColor(brg == 1 ? 4 : 6, 1);
166
                        me.colored['PFDBRG' ~ brg] = 1;
167
                    }
168
                    else {
169
                        me.device.display.setSoftKeyColor(brg == 1 ? 4 : 6, 0);
170
                        delete(me.colored, 'PFDBRG' ~ brg);
171
                    }
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
172
                },
173
                BRG2 : func {
174
                    call(me.bindings.PFD.PFD.BRG1, [ 2 ], me);
175
                },
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
176
                'STD BARO' : func {
177
                    setprop('/instrumentation/altimeter/setting-inhg', 29.92);
178
                    me.device.display.updateBARO();
179
                    pop(me.path);
180
                    me.device.display.updateSoftKeys();
181
                },
182
                IN :  func {
183
                    me.device.display._baro_unit = 'inhg';
184
                    me.device.display.updateBARO();
185
                },
186
                HPA : func {
187
                    me.device.display._baro_unit = 'hpa';
188
                    me.device.display.updateBARO();
189
                },
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
190
            },
191
            XPDR: {
adds transponder
Sébastien MARQUE authored on 2017-03-17
192
                STBY : func {
193
                    setprop('/instrumentation/transponder/ident', 0);
194
                    setprop('/instrumentation/transponder/knob-mode', 1);
195
                    setprop('/instrumentation/zkv1000/radio/xpdr-mode', 'STBY');
196
                    me.device.display.updateXPDR();
197
                },
198
                ON : func {
199
                    setprop('/instrumentation/transponder/ident', 1);
200
                    setprop('/instrumentation/transponder/knob-mode', 4);
201
                    setprop('/instrumentation/zkv1000/radio/xpdr-mode', 'ON');
202
                    me.device.display.updateXPDR();
203
                },
204
                ALT : func {
205
                    setprop('/instrumentation/transponder/ident', 1);
206
                    setprop('/instrumentation/transponder/knob-mode', 5);
207
                    setprop('/instrumentation/zkv1000/radio/xpdr-mode', 'ALT');
208
                    me.device.display.updateXPDR();
209
                },
210
                VFR : func {
211
                    setprop('/instrumentation/transponder/id-code', '1200');
212
                    me.device.display.updateXPDR();
213
                },
214
                IDENT : func {
215
                    call(me.bindings.PFD.IDENT, [], me);
216
                },
217
                CODE : {
218
                    '0' : func (n = 0) {
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
219
                        if (getprop('/instrumentation/zkv1000/radios/xpdr-tuning-fms-method'))
220
                            return;
221
                        me.device.display.timers2.softkeys_inactivity.stop();
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
222
                        me.bindings.PFD.XPDR.CODE.inactivity.restart(me.device.display.softkeys_inactivity_delay);
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
223
                        # disable FMS knob entering method
224
                        me.device.knobs.FmsInner = void;
225
                        # When entering the code, the next softkey in sequence
226
                        # must be pressed within 10 seconds, or the entry is cancelled
227
                        # and restored to the previous code
228
                        if (!contains(me.bindings.PFD.XPDR.CODE, 'on_change_inactivity')) {
229
                            me.bindings.PFD.XPDR.CODE.on_change_inactivity = maketimer(10,
230
                                func {
231
                                    setprop('/instrumentation/zkv1000/radios/xpdr-tuning-digit', 3);
232
                                    me.device.knobs.FmsInner = me.device.knobs.XPDRCodeSetDigits;
233
                                    me.device.knobs.FmsOuter = me.device.knobs.XPDRCodeNextDigits;
234
                                    call(me.bindings.PFD.XPDR.CODE.restore, [], me);
235
                                });
236
                            me.bindings.PFD.XPDR.CODE.on_change_inactivity.singleShot = 1;
237
                            me.bindings.PFD.XPDR.CODE.on_change_inactivity.start();
238
                        }
239
                        else
240
                            me.bindings.PFD.XPDR.CODE.on_change_inactivity.restart(10);
adds transponder
Sébastien MARQUE authored on 2017-03-17
241
                        var tuning = radios.getNode('xpdr-tuning-digit');
242
                        var d = tuning.getValue();
243
                        setprop('/instrumentation/transponder/inputs/digit[' ~ d ~ ']', n);
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
244
                        if (d == 1) {
245
                            if (!contains(me.bindings.PFD.XPDR.CODE, 'on_change_auto_validation'))
246
                                me.bindings.PFD.XPDR.CODE.on_change_auto_validation = maketimer(5,
247
                                    func call(me.bindings.PFD.IDENT, [], me));
248
                            me.bindings.PFD.XPDR.CODE.on_change_auto_validation.singleShot = 1;
249
                            me.bindings.PFD.XPDR.CODE.on_change_auto_validation.start();
250
                        }
251
                        else {
252
                            d -= 1;
253
                            tuning.setValue(d);
254
                        }
adds transponder
Sébastien MARQUE authored on 2017-03-17
255
                        me.device.display.updateXPDR();
256
                    },
257
                    '1' : func {
258
                        call(me.bindings.PFD.XPDR.CODE['0'], [ 1 ], me);
259
                    },
260
                    '2' : func {
261
                        call(me.bindings.PFD.XPDR.CODE['0'], [ 2 ], me);
262
                    },
263
                    '3' : func {
264
                        call(me.bindings.PFD.XPDR.CODE['0'], [ 3 ], me);
265
                    },
266
                    '4' : func {
267
                        call(me.bindings.PFD.XPDR.CODE['0'], [ 4 ], me);
268
                    },
269
                    '5' : func {
270
                        call(me.bindings.PFD.XPDR.CODE['0'], [ 5 ], me);
271
                    },
272
                    '6' : func {
273
                        call(me.bindings.PFD.XPDR.CODE['0'], [ 6 ], me);
274
                    },
275
                    '7' : func {
276
                        call(me.bindings.PFD.XPDR.CODE['0'], [ 7 ], me);
277
                    },
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
278
                    IDENT: func {
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
279
                        me.bindings.PFD.XPDR.CODE.inactivity.restart(me.device.display.softkeys_inactivity_delay);
280
                        me.device.display.timers2.softkeys_inactivity.restart(me.device.display.softkeys_inactivity_delay);
adds transponder
Sébastien MARQUE authored on 2017-03-17
281
                        call(me.bindings.PFD.IDENT, [], me);
282
                    },
283
                    BKSP: func {
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
284
                        if (getprop('/instrumentation/zkv1000/radios/xpdr-tuning-fms-method'))
285
                            return;
286
                        if (contains(me.bindings.PFD.XPDR.CODE, 'on_change_inactivity'))
287
                            me.bindings.PFD.XPDR.CODE.on_change_inactivity.restart(10);
288
                        if (contains(me.bindings.PFD.XPDR.CODE, 'on_change_auto_validation'))
289
                                me.bindings.PFD.XPDR.CODE.on_change_auto_validation.stop();
adds transponder
Sébastien MARQUE authored on 2017-03-17
290
                        var tuning = radios.getNode('xpdr-tuning-digit');
291
                        var d = tuning.getValue();
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
292
                        if (d < 3) {
293
                            d += 1;
294
                            tuning.setValue(d);
295
                        }
adds transponder
Sébastien MARQUE authored on 2017-03-17
296
                        me.device.display.updateXPDR();
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
297
                    },
adds transponder
Sébastien MARQUE authored on 2017-03-17
298
                    BACK : func (inactive = 0) {
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
299
                        call(me.bindings.PFD.XPDR.CODE.restore, [], me);
adds transponder
Sébastien MARQUE authored on 2017-03-17
300
                        pop(me.path);
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
301
                        call(me.bindings.PFD.XPDR.CODE.exit, [me.path], me);
302
                    },
303
                    restore : func {
304
                        setprop('/instrumentation/transponder/id-code',
305
                            sprintf('%s', getprop('/instrumentation/zkv1000/radios/xpdr-backup-code')));
306
                        me.device.display.updateXPDR();
adds transponder
Sébastien MARQUE authored on 2017-03-17
307
                    },
308
                    exit : func (p) {
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
309
                        if (contains(me.bindings.PFD.XPDR.CODE, 'inactivity')) # does not exists if IDENT pressed from top-level
310
                            me.bindings.PFD.XPDR.CODE.inactivity.stop();
adds transponder
Sébastien MARQUE authored on 2017-03-17
311
                        radios.removeChild('xpdr-tuning-digit', 0);
312
                        radios.removeChild('xpdr-backup-code', 0);
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
313
                        radios.removeChild('xpdr-tuning-fms-method', 0);
adds transponder
Sébastien MARQUE authored on 2017-03-17
314
                        me.path = p;
315
                        me.device.display.updateXPDR();
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
316
                        me.device.display.updateSoftKeys();
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
317
                        me.device.knobs.FmsInner = void;
318
                        me.device.knobs.FmsOuter = void;
319
                        me.device.display.timers2.softkeys_inactivity.restart(me.device.display.softkeys_inactivity_delay);
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
320
                    },
adds transponder
Sébastien MARQUE authored on 2017-03-17
321
                    hook : func {
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
322
                        # this level has its own timer as we may need to revert changes, and got different timers
323
                        me.device.display.timers2.softkeys_inactivity.stop();
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
324
                        me.bindings.PFD.XPDR.CODE.inactivity = maketimer(
325
                            me.device.display.softkeys_inactivity_delay,
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
326
                            func call(me.bindings.PFD.XPDR.CODE.BACK, [], me));
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
327
                        me.bindings.PFD.XPDR.CODE.inactivity.singleShot = 1;
328
                        me.bindings.PFD.XPDR.CODE.inactivity.start();
adds transponder
Sébastien MARQUE authored on 2017-03-17
329
                        var tuning = getprop('/instrument/zkv1000/radios/xpdr-tuning-digit');
330
                        if (tuning == nil) {
331
                            radios.getNode('xpdr-tuning-digit', 1).setValue(3);
332
                            radios.getNode('xpdr-backup-code', 1).setValue(getprop('/instrumentation/transponder/id-code'));
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
333
                            radios.getNode('xpdr-tuning-fms-method', 1).setValue(0);
adds transponder
Sébastien MARQUE authored on 2017-03-17
334
                            me.device.display.updateXPDR();
335
                        }
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
336
                        me.device.knobs.FmsInner = me.device.knobs.XPDRCodeSetDigits;
337
                        me.device.knobs.FmsOuter = me.device.knobs.XPDRCodeNextDigits;
adds transponder
Sébastien MARQUE authored on 2017-03-17
338
                    },
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
339
                },
adds transponder
Sébastien MARQUE authored on 2017-03-17
340
            },
341
            IDENT : func {
342
                if (getprop('/instrumentation/zkv1000/radio/xpdr-mode') == 'STBY')
343
                    return;
344
                setprop('/instrumentation/transponder/ident', 1);
345
                me.bindings.PFD.XPDR.ident = maketimer(18,
346
                        func {
347
                            setprop('/instrumentation/transponder/ident', 0);
348
                            me.device.display.updateXPDR();
349
                        });
350
                me.bindings.PFD.XPDR.ident.singleShot = 1;
351
                me.bindings.PFD.XPDR.ident.start();
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
352
                call(me.bindings.PFD.XPDR.CODE.exit, [], me);
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
353
            },
adds CDI
Sébastien MARQUE authored on 2017-03-18
354
            CDI : func {
355
                var list = ['OFF'];
356
                if (getprop('/instrumentation/gps/route-distance-nm') != nil)
357
                    append(list, 'GPS');
358
                if (getprop('/instrumentation/nav/in-range') != nil)
359
                    append(list, 'NAV1');
360
                if (getprop('/instrumentation/nav[1]/in-range') != nil)
361
                    append(list, 'NAV2');
362
                var index = std.Vector
363
                               .new(list)
364
                               .index(cdi.getNode('source').getValue());
365
                var next = (index == size(list) -1) ?  0 : index + 1;
366
                cdi.getNode('source').setValue(list[next]);
367
                CDIfromSOURCE(list[next]);
368
                me.device.display.updateCDI();
369
            },
TMR/REF window
Sébastien MARQUE authored on 2017-03-28
370
            'TMR/REF' : func {
371
                if (!contains(me.device.windows.state, 'TMR/REF')) {
TMR/REF available
Sébastien MARQUE authored on 2017-04-10
372
                    var Vspeed_visiblity = func (id, selected, Vspeed)
373
                        me.device.data[Vspeed ~ '-visible'] =
374
                            me.device.windows.state[id].objects[selected].text
375
                            ==
376
                            me.device.windows.state[id].objects[selected].choices[0];
377
                    var GenericTimer = func (id, selected) {
378
                        var action = me.device.windows.state[id].objects[selected].text;
379
                        if (action == 'START?') {
380
                            me.device.data.TMRrevert = 0;
381
                            me.device.data.TMRlast = getprop('/sim/time/elapsed-sec') - 1;
382
                            me.device.data.TMRreset = me.device.windows.state[id].objects[selected - 2].text;
383
                            me.device.data.TMRtimer = maketimer(1, func {
384
                                    var (hh, mm, ss) = split(':',
385
                                            me.device.windows.state[id].objects[selected - 2].text);
386
                                    var direction = -1;
387
                                    if ((me.device.windows.state[id].objects[selected - 1].text
388
                                            ==
389
                                        me.device.windows.state[id].objects[selected - 1].choices[0])
390
                                    or me.device.data.TMRrevert)
391
                                        direction = 1;
392
                                    var now = getprop('/sim/time/elapsed-sec');
393
                                    var dt = int(now - me.device.data.TMRlast) * direction;
394
                                    me.device.data.TMRlast = now;
395
                                    var val = HMS(hh, mm, ss, dt);
396
                                    me.device.windows.state[id].objects[selected - 2].text = val;
397
                                    me.device.windows.window[id ~ '-' ~ (selected -2)]
398
                                        .setText(val);
399
                                    if (val == '00:00:00' and direction == -1)
400
                                        me.device.data.TMRrevert = 1;
401
                                }, me);
402
                            me.device.data.TMRtimer.start();
403
                            action = 'STOP?';
404
                        }
405
                        elsif (action == 'STOP?') {
406
                            me.device.data.TMRtimer.stop();
407
                            action = 'RESET?';
408
                        }
409
                        elsif (action == 'RESET?') {
410
                            action = 'START?';
411
                            if ((me.device.windows.state[id].objects[selected - 1].text
412
                                        ==
413
                                me.device.windows.state[id].objects[selected - 1].choices[1])
414
                            and !me.device.data.TMRrevert)
415
                                var val = me.device.data.TMRreset;
416
                            else
417
                                var val = '00:00:00';
418
                            me.device.windows.state[id].objects[selected - 2].text = val;
419
                            me.device.windows.window[id ~ '-' ~ (selected -2)]
420
                                .setText(val);
421
                        }
422
                        me.device.windows.window[me.device.windows.selected]
423
                            .setText(action);
424
                        me.device.windows.state[id].objects[selected].text = action;
425
                    };
TMR/REF window
Sébastien MARQUE authored on 2017-03-28
426
                    me.device.windows.draw(
427
                        'TMR/REF',
428
                        {x: 720, y: 535, w: 300, l: 5, sep: 3},
TMR/REF window adaptation
Sébastien MARQUE authored on 2017-04-02
429
                        [ # objects infos
TMR/REF window
Sébastien MARQUE authored on 2017-03-28
430
                            {text: 'REFERENCES', type: 'title'},
431
                            {type: 'separator'},
432
                            {text: 'TIMER', type: 'normal'},
433
                            {text: '00:00:00', type: 'selected|time', },
TMR/REF available
Sébastien MARQUE authored on 2017-04-10
434
                            {text: '  UP >', type: 'editable', choices: ['  UP >', '<DOWN ']},
435
                            {text: 'START?', type: 'editable|end-of-line', callback: func (id, selected) GenericTimer(id, selected)},
TMR/REF window
Sébastien MARQUE authored on 2017-03-28
436
                            {type: 'separator'},
TMR/REF available
Sébastien MARQUE authored on 2017-04-10
437
                            {text: sprintf('Vx     %3iKT', alerts.getNode('Vx').getValue()), type: 'normal', scrollgroup:0},
438
                            {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')},
439
                            {text: sprintf('Vy     %3iKT', alerts.getNode('Vy').getValue()), type: 'normal', scrollgroup:1},
440
                            {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')},
441
                            {text: sprintf('Vr     %3iKT', alerts.getNode('Vr').getValue()), type: 'normal', scrollgroup:2},
442
                            {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')},
443
                            {text: sprintf('Vglide %3iKT', alerts.getNode('Vglide').getValue()), type: 'normal', scrollgroup:3},
444
                            {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')},
TMR/REF window
Sébastien MARQUE authored on 2017-03-28
445
                            {type: 'separator'},
446
                            {text: 'MINIMUMS', type: 'normal'},
TMR/REF available
Sébastien MARQUE authored on 2017-04-10
447
                            {text: '   OFF   >', type: 'editable', choices: ['   OFF   >', '<  BARO  >','<TEMP COMP'], callback: func},
TMR/REF window adaptation
Sébastien MARQUE authored on 2017-04-02
448
                            {text: ' 1000FT', type: 'editable', format: '% 5iFT', factor: 100, callback: func},
449
                        ],
450
                        { # scrolling info, see menu.nas
451
                            lines : 3,
452
                            columns : 2,
453
                        }
TMR/REF window
Sébastien MARQUE authored on 2017-03-28
454
                    );
455
                    me.device.knobs.FmsInner = me.device.knobs.MenuSettings;
456
                    me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu;
TMR/REF available
Sébastien MARQUE authored on 2017-04-10
457
                    me.device.buttons.ENT = me.device.buttons.ValidateTMRREF;
458
                    me.device.buttons.FMS = me.device.buttons.ValidateTMRREF;
459
                    me.device.buttons.CLR = me.device.buttons.ClearTMRREF;
TMR/REF window
Sébastien MARQUE authored on 2017-03-28
460
                }
461
                else {
TMR/REF available
Sébastien MARQUE authored on 2017-04-10
462
                    me.device.buttons.ClearTMRREF();
TMR/REF window
Sébastien MARQUE authored on 2017-03-28
463
                }
464
            },
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
465
        },
466
        MFD : {
467
            ENGINE: {
468
                FUEL: {
469
                    UNDO: func {
470
                        pop(me.path);
471
                        me.device.display.updateSoftKeys();
472
                    },
473
                    ENTER: func {
474
                        pop(me.path);
475
                        me.device.display.updateSoftKeys();
476
                    },
477
                },
478
                ENGINE: func {
479
                    me.path = [];
480
                    me.device.display.updateSoftKeys();
481
                },
482
            },
add missing exit to MFD/CHKL...
Sébastien MARQUE authored on 2017-03-20
483
            CHKLIST : {
484
                EXIT: func {
485
                    me.path = [];
486
                    me.device.display.updateSoftKeys();
487
                },
488
            },
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
489
        },
commit initial
Sébastien MARQUE authored on 2017-03-07
490
    },
491
};