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