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

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

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

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

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

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

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

            
519
var keyMap = {
vim folds
Sébastien MARQUE authored on 2017-12-21
520
# softkeys map for PFD and MFD {{{1
521
# PFD {{{2
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
522
    PFD : {
523
        first : 1,
524
        texts : ['INSET', 'SENSOR', 'PFD', 'OBS', 'CDI', 'DME', 'XPDR', 'IDENT', 'TMR/REF', 'NRST' ],
525
        INSET : {
526
            texts : ['OFF', 'DCLTR', 'WXLGND', 'TRAFFIC', 'TOPO', 'TERRAIN', 'STRMSCP', 'NEXRAD-C', 'XM LTNG', 'METAR'],
527
        },
528
        SENSOR : {
529
            first : 2,
530
            texts : [ 'ADC1', 'ADC2', '', 'AHRS1', 'AHRS2'],
531
        },
532
        PFD : {
533
            texts : [ 'SYN VIS', 'DFLTS', 'AOA/WIND', 'DME', 'BRG1', 'HSI FMT', 'BRG2', '', 'ALT UNIT', 'STD BARO' ],
534
            'SYN VIS' : {
535
                texts : [ 'PATHWAY', 'SYN TERR', 'HR2NHDG', 'APTSIGNS', 'FPM'],
536
            },
537
            'AOA/WIND' : {
538
                first : 4,
539
                texts : ['AOA', 'WIND'],
540
                AOA : {
541
                    first : 5,
542
                    texts : ['AOA ON', 'AOA AUTO'],
543
                },
544
                WIND : {
545
                    first : 2,
546
                    texts : ['OPTN1', 'OPTN2', '', 'OFF'],
547
                },
548
            },
549
            'HSI FMT' : {
550
                first : 6,
551
                texts : ['360 HSI', 'ARC HSI'],
552
            },
553
            'ALT UNIT' : {
554
                first : 5,
555
                texts : ['METERS', '', 'IN', 'HPA'],
556
            },
557
        },
558
        XPDR : {
559
            first : 2,
560
            texts : ['STBY', 'ON', 'ALT', '', 'VFR', 'CODE', 'IDENT'],
561
            CODE : {
562
                texts : ['0', '1', '2', '3', '4', '5', '6', '7', 'IDENT', 'BKSP'],
563
            },
564
        },
565
    },
vim folds
Sébastien MARQUE authored on 2017-12-21
566
#}}}2
567
# MFD {{{2
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
568
    MFD : {
569
        texts : ['ENGINE', '', 'MAP', '', '', '', '', '', '', 'DCLTR', 'SHW CHRT', 'CHKLIST'],
570
        MAP : {
571
            texts: ['TRAFFIC', 'PROFILE', 'TOPO', 'TERRAIN', 'AIRWAYS', 'STRMSCP','NEXRAD-C', 'XM LTNG', 'METAR', 'LEGEND', 'BACK'],
572
        },
573
        CHKLIST : {
574
            texts : ['ENGINE', '', '', '', '', 'DONE', '', '', '', '', 'EXIT', 'EMERGCY'],
575
        },
576
        ENGINE : {
577
            texts : ['ENGINE', 'ANTI-ICE', '', 'DCLTR', '', 'ASSIST', '', '', '', '', 'FUEL'],
578
            'ANTI-ICE' : {
579
                texts : ['LEFT', 'AUTO', 'RIGHT', '', '', '', '', '', '', '', '', 'BACK'],
580
            },
581
            FUEL : {
582
                first : 1,
583
                texts : ['FULL', 'TABS', '', '', '', '', '', '', '', 'UNDO', 'ENTER'],
584
            },
585
        },
586
    },
vim folds
Sébastien MARQUE authored on 2017-12-21
587
#}}}2
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
588
};
589
if (data['stall-aoa'] == 9999)
590
    keyMap.PFD.PFD['AOA/WIND'].texts = ['', 'WIND'];
vim folds
Sébastien MARQUE authored on 2017-12-21
591
#}}}1