zkv1000 / Nasal / softkeys.nas /
Newer Older
1286 lines | 67.695kb
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);
fix issue #8
Sébastien MARQUE authored on 2020-06-23
45
            me.device.display.updateSoftKeys();
commit initial
Sébastien MARQUE authored on 2017-03-07
46
        }
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
47
        elsif (key == 'BACK') {
48
            pop(me.path);
49
            me.device.display.updateSoftKeys();
commit initial
Sébastien MARQUE authored on 2017-03-07
50
        }
show the complete path menu ...
Sébastien MARQUE authored on 2017-03-20
51
        else {
52
            var list_path = '';
53
            foreach(var p; me.path) list_path ~= p ~ '/';
54
            print(me.device.role ~ ':' ~ list_path ~ key ~ ' : not yet implemented');
55
        }
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
56
    },
57

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

            
makes Vspeeds free and adapt...
Sébastien MARQUE authored on 2020-06-19
547
                            });
548
                            append(obj_infos, {
549
                                text: me.device.data[V ~ '-visible'] ? '   ON >' : '< OFF  ',
550
                                type: 'editable|immediate|end-of-line',
551
                                scrollgroup: scrollgroup,
552
                                _v: V,
553
                                choices: ['   ON >', '< OFF  '],
554
                                callback: func (id, selected) {
555
                                    var Vspeed = me.device.windows.state[id].objects[selected]._v;
556
                                    me.device.data[Vspeed ~ '-visible'] =
557
                                        me.device.windows.state[id].objects[selected].text
558
                                        ==
559
                                        me.device.windows.state[id].objects[selected].choices[0];
560
                                }
561
                            });
562
                            scrollgroup += 1;
563
                        }
564
                        append(obj_infos, {type: 'separator'});
make Vspeeds adaptable
Sébastien MARQUE authored on 2020-06-15
565
                    }
566
                    append(obj_infos,
TMR/REF window
Sébastien MARQUE authored on 2017-03-28
567
                            {text: 'MINIMUMS', type: 'normal'},
TMR/REF available
Sébastien MARQUE authored on 2017-04-10
568
                            {text: '   OFF   >', type: 'editable', choices: ['   OFF   >', '<  BARO  >','<TEMP COMP'], callback: func},
make Vspeeds adaptable
Sébastien MARQUE authored on 2020-06-15
569
                            {text: ' 1000FT', type: 'editable', format: '% 5iFT', factor: 100, callback: func}
570
                          );
571
                    me.device.windows.draw(
572
                        'TMR/REF',
makes Vspeeds free and adapt...
Sébastien MARQUE authored on 2020-06-19
573
                        {x: 720, y: 535, w: 300, l: 5, sep: scrollgroup ? 3 : 2},
make Vspeeds adaptable
Sébastien MARQUE authored on 2020-06-15
574
                        obj_infos,
makes Vspeeds free and adapt...
Sébastien MARQUE authored on 2020-06-19
575
                        scrollgroup > 2 ? { lines : 3, columns : 3 } : nil
TMR/REF window
Sébastien MARQUE authored on 2017-03-28
576
                    );
577
                    me.device.knobs.FmsInner = me.device.knobs.MenuSettings;
578
                    me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu;
TMR/REF available
Sébastien MARQUE authored on 2017-04-10
579
                    me.device.buttons.ENT = me.device.buttons.ValidateTMRREF;
580
                    me.device.buttons.FMS = me.device.buttons.ValidateTMRREF;
581
                    me.device.buttons.CLR = me.device.buttons.ClearTMRREF;
TMR/REF window
Sébastien MARQUE authored on 2017-03-28
582
                }
583
                else {
TMR/REF available
Sébastien MARQUE authored on 2017-04-10
584
                    me.device.buttons.ClearTMRREF();
TMR/REF window
Sébastien MARQUE authored on 2017-03-28
585
                }
586
            },
add PFD/NRST softkey
Sébastien MARQUE authored on 2020-05-16
587
            NRST: {
588
                _displayNearest: func (type, where) {
589
                    var id = 'PFD NRST';
590
                    me.device.display.updateSoftKeys();
591
                    me.device.windows.del(id);
592
                    var results = [];
593
                    var list = [];
594
                    if (type == 'apt') {
595
                        results = findAirportsWithinRange(100);
596
                    }
597
                    else {
598
                        results = findNavaidsWithinRange(100, type);
599
                    }
simplifies NRST code
Sébastien MARQUE authored on 2020-05-18
600
                    var norm_360 = func (a) return math.periodic(0, 360, a);
601
                    if    (where == 'OMNI')  var side = -1;
602
                    elsif (where == 'FRONT') var side = norm_360(data.hdg);
603
                    elsif (where == 'RIGHT') var side = norm_360(data.hdg + 90);
604
                    elsif (where == 'LEFT')  var side = norm_360(data.hdg - 90);
605
                    elsif (where == 'REAR')  var side = norm_360(data.hdg + 180);
606
                    foreach (var n; results) {
607
                        var (course, dist) = courseAndDistance(n);
608
                        if (side > -1) {
add PFD/NRST softkey
Sébastien MARQUE authored on 2020-05-16
609
                            var angle = 180 - abs(abs(course - side) - 180);
simplifies NRST code
Sébastien MARQUE authored on 2020-05-18
610
                            if (angle > 50)
611
                                continue;
add PFD/NRST softkey
Sébastien MARQUE authored on 2020-05-16
612
                        }
simplifies NRST code
Sébastien MARQUE authored on 2020-05-18
613
                        append(list, [n, course, dist]);
614
                        if (size(list) == 5)
615
                            break;
add PFD/NRST softkey
Sébastien MARQUE authored on 2020-05-16
616
                    }
617
                    var obj_infos = [
618
                        { text: sprintf('NEAREST %s (%s)', string.uc(type), where), type: 'title' },
619
                        { type: 'separator' }
620
                    ];
621
                    var firstEntry = 1;
622
                    foreach (var n; list) {
623
                        append(obj_infos, {
624
                            text: sprintf('%s (%s)', n[0].id, n[0].name),
625
                            type: (firstEntry ? 'selected' : 'editable') ~ '|end-of-line',
626
                            dto: n[0],
627
                        });
adds NAV freq if VOR selecte...
Sébastien MARQUE authored on 2020-05-18
628
                        if (type == 'vor') {
629
                            var idx = size(obj_infos) - 1;
630
                            obj_infos[idx]._freq = n[0].frequency;
631
                            obj_infos[idx].callback = func (id, selected) radios.getNode('nav-freq-mhz').setValue(me.device.windows.state[id].objects[selected]._freq / 100);
632
                        }
add PFD/NRST softkey
Sébastien MARQUE authored on 2020-05-16
633
                        append(obj_infos, {
634
                            text: sprintf('%s %03i° %3iNM', utf8.chstr(9658), n[1], n[2]),
635
                            type: 'normal|end-of-line'
636
                        });
637
                        firstEntry = 0;
638
                    }
639
                    me.device.knobs.FmsInner = me.device.knobs.NavigateMenu;
640
                    me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu;
641
                    me.device.buttons.ENT    = me.device.buttons.ValidateTMRREF;
642
                    me.device.buttons.CLR = func {
643
                        me.device.windows.del(id);
644
                        me.device.knobs.FmsOuter = func;
645
                        me.device.knobs.FmsInner = func;
fix MENU issue
Sébastien MARQUE authored on 2020-05-23
646
                        me.device.buttons.MENU = me.device.buttons.GlobalParams;
647
                        foreach (var b; ['ENT', 'CLR'])
add PFD/NRST softkey
Sébastien MARQUE authored on 2020-05-16
648
                            me.device.buttons[b] = func;
649
                    }
fix MENU issue
Sébastien MARQUE authored on 2020-05-23
650
                    me.device.buttons.MENU = func;
add PFD/NRST softkey
Sébastien MARQUE authored on 2020-05-16
651
                    me.device.windows.draw( id, {autogeom: 1}, obj_infos );
652
                },
adds NRST/COMMS
Sébastien MARQUE authored on 2020-05-18
653
                _displayNearestCOMM: func (where) {
654
                    var id = 'PFD NRST';
655
                    me.device.display.updateSoftKeys();
656
                    me.device.windows.del(id);
657
                    var results = [];
658
                    var ATIS_list = [];
659
                    var TRAFFIC_list = [];
660
                    var TWR_list = [];
661
                    results = findAirportsWithinRange(100);
662
                    var norm_360 = func (a) return math.periodic(0, 360, a);
663
                    if    (where == 'OMNI')  var side = -1;
664
                    elsif (where == 'FRONT') var side = norm_360(data.hdg);
665
                    elsif (where == 'RIGHT') var side = norm_360(data.hdg + 90);
666
                    elsif (where == 'LEFT')  var side = norm_360(data.hdg - 90);
667
                    elsif (where == 'REAR')  var side = norm_360(data.hdg + 180);
668
                    foreach (var r; results) {
669
                        var (course, dist) = courseAndDistance(r);
670
                        if (side > -1) {
671
                            var bearing = 180 - abs(abs(course - side) - 180);
672
                            if (bearing > 50)
673
                                continue;
674
                        }
675
                        foreach (var c; r.comms()) {
676
                            if (size(ATIS_list) < 4
677
                            and (string.match(c.ident, '*ATIS*') or string.match(c.ident, '*A[SW]OS*')))
678
                                append(ATIS_list, [r.id, c.frequency, course, dist]);
679

            
680
                            if (size(TWR_list) < 4
681
                            and string.match(c.ident, '*TWR*'))
682
                                append(TWR_list, [r.id, c.frequency, course, dist]);
683

            
684
                            if (size(TRAFFIC_list) < 4
685
                            and (string.match(c.ident, '*CTAF*') or string.match(c.ident, '*UNICOM*') or string.match(c.ident, '*MULTICOM*')))
686
                                append(TRAFFIC_list, [r.id, c.frequency, course, dist]);
687
                        }
688
                    }
689
                    var obj_infos = [];
690
                    firstEntry = 1;
691
                    if (size(ATIS_list) > 0) {
692
                        append(obj_infos, {text: 'ATIS', type: 'title'});
693
                        append(obj_infos, {type: 'separator'});
694
                        foreach (var atis; ATIS_list) {
695
                            append(obj_infos, {
696
                                text: atis[0],
697
                                _freq: atis[1],
698
                                type: firstEntry ? 'selected' : 'editable',
699
                                callback: func (id, selected) radios.getNode('comm-freq-mhz').setValue(me.device.windows.state[id].objects[selected]._freq),
700
                            });
701
                            append(obj_infos, {
702
                                text: sprintf(' (%.3fMHz) %3i° %2iNM', atis[1], atis[2], atis[3]),
703
                                type: 'normal|end-of-line'
704
                            });
705
                            firstEntry = 0;
706
                        }
707
                    }
708
                    if (size(TRAFFIC_list) > 0) {
709
                        append(obj_infos, {text: 'TRAFFIC', type: 'title'});
710
                        append(obj_infos, {type: 'separator'});
711
                        foreach (var traffic; TRAFFIC_list) {
712
                            append(obj_infos, {
713
                                text: traffic[0],
714
                                _freq: traffic[1],
715
                                type: firstEntry ? 'selected' : 'editable',
716
                                callback: func (id, selected) radios.getNode('comm-freq-mhz').setValue(me.device.windows.state[id].objects[selected]._freq),
717
                            });
718
                            append(obj_infos, {
719
                                text: sprintf(' (%.3fMHz) %3i° %2iNM', traffic[1], traffic[2], traffic[3]),
720
                                type: 'normal|end-of-line'
721
                            });
722
                            firstEntry = 0;
723
                        }
724
                    }
725
                    if (size(TWR_list) > 0) {
726
                        append(obj_infos, {text: 'TOWER', type: 'title'});
727
                        append(obj_infos, {type: 'separator'});
728
                        foreach (var tower; TWR_list) {
729
                            append(obj_infos, {
730
                                text: tower[0],
731
                                _freq: tower[1],
732
                                type: firstEntry ? 'selected' : 'editable',
733
                                callback: func (id, selected) radios.getNode('comm-freq-mhz').setValue(me.device.windows.state[id].objects[selected]._freq),
734
                            });
735
                            append(obj_infos, {
736
                                text: sprintf(' (%.3fMHz) %3i° %2iNM', tower[1], tower[2], tower[3]),
737
                                type: 'normal|end-of-line'
738
                            });
739
                            firstEntry = 0;
740
                        }
741
                    }
742
                    me.device.knobs.FmsInner = me.device.knobs.NavigateMenu;
743
                    me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu;
fix MENU issue
Sébastien MARQUE authored on 2020-05-23
744
                    me.device.buttons.MENU = func;
adds NRST/COMMS
Sébastien MARQUE authored on 2020-05-18
745
                    me.device.buttons.CLR = func {
746
                        me.device.windows.del(id);
747
                        me.device.knobs.FmsOuter = func;
748
                        me.device.knobs.FmsInner = func;
fix MENU issue
Sébastien MARQUE authored on 2020-05-23
749
                        me.device.buttons.MENU = me.device.buttons.GlobalParams;
750
                        foreach (var b; ['ENT', 'CLR'])
adds NRST/COMMS
Sébastien MARQUE authored on 2020-05-18
751
                            me.device.buttons[b] = func;
752
                    }
753
                    me.device.buttons.ENT    = me.device.buttons.ValidateTMRREF;
754
                    me.device.windows.draw( id, {autogeom: 1}, obj_infos );
755
                },
add PFD/NRST softkey
Sébastien MARQUE authored on 2020-05-16
756
############################################################################################################
757
# THIS CODE SHOULD REPLACE THE LINES BELOW (in new()), but it makes all call with the same args (apt, RIGHT)
758
############################################################################################################
759
#        if (m.device.role == 'PFD')
760
#            foreach (var dir; keyMap.PFD.NRST.texts) {
761
#                m.bindings.PFD.NRST[dir] = {};
762
#                foreach (var type; keyMap.PFD.NRST.OMNI.texts) {
763
#                    m.bindings.PFD.NRST[dir][type] = func {
764
#                        call(m.bindings.PFD.NRST._displayNearest, [string.lc(type), dir], m)
765
#                    };
766
#                }
767
#            }
768
############################################################################################################
769
                OMNI: {
770
                    APT: func { call(me.bindings.PFD.NRST._displayNearest, ['apt', 'OMNI'], me) },
771
                    VOR: func { call(me.bindings.PFD.NRST._displayNearest, ['vor', 'OMNI'], me) },
772
                    NDB: func { call(me.bindings.PFD.NRST._displayNearest, ['ndb', 'OMNI'], me) },
773
                    FIX: func { call(me.bindings.PFD.NRST._displayNearest, ['fix', 'OMNI'], me) },
adds NRST/COMMS
Sébastien MARQUE authored on 2020-05-18
774
                    COMM:func { call(me.bindings.PFD.NRST._displayNearestCOMM,    ['OMNI'], me) },
add PFD/NRST softkey
Sébastien MARQUE authored on 2020-05-16
775
                },
776
                FRONT: {
777
                    APT: func { call(me.bindings.PFD.NRST._displayNearest, ['apt', 'FRONT'], me) },
778
                    VOR: func { call(me.bindings.PFD.NRST._displayNearest, ['vor', 'FRONT'], me) },
779
                    NDB: func { call(me.bindings.PFD.NRST._displayNearest, ['ndb', 'FRONT'], me) },
780
                    FIX: func { call(me.bindings.PFD.NRST._displayNearest, ['fix', 'FRONT'], me) },
adds NRST/COMMS
Sébastien MARQUE authored on 2020-05-18
781
                    COMM:func { call(me.bindings.PFD.NRST._displayNearestCOMM,    ['FRONT'], me) },
add PFD/NRST softkey
Sébastien MARQUE authored on 2020-05-16
782
                },
783
                RIGHT: {
784
                    APT: func { call(me.bindings.PFD.NRST._displayNearest, ['apt', 'RIGHT'], me) },
785
                    VOR: func { call(me.bindings.PFD.NRST._displayNearest, ['vor', 'RIGHT'], me) },
786
                    NDB: func { call(me.bindings.PFD.NRST._displayNearest, ['ndb', 'RIGHT'], me) },
787
                    FIX: func { call(me.bindings.PFD.NRST._displayNearest, ['fix', 'RIGHT'], me) },
adds NRST/COMMS
Sébastien MARQUE authored on 2020-05-18
788
                    COMM:func { call(me.bindings.PFD.NRST._displayNearestCOMM,    ['RIGHT'], me) },
add PFD/NRST softkey
Sébastien MARQUE authored on 2020-05-16
789
                },
790
                REAR: {
791
                    APT: func { call(me.bindings.PFD.NRST._displayNearest, ['apt', 'REAR'], me) },
792
                    VOR: func { call(me.bindings.PFD.NRST._displayNearest, ['vor', 'REAR'], me) },
793
                    NDB: func { call(me.bindings.PFD.NRST._displayNearest, ['ndb', 'REAR'], me) },
794
                    FIX: func { call(me.bindings.PFD.NRST._displayNearest, ['fix', 'REAR'], me) },
adds NRST/COMMS
Sébastien MARQUE authored on 2020-05-18
795
                    COMM:func { call(me.bindings.PFD.NRST._displayNearestCOMM,    ['REAR'], me) },
add PFD/NRST softkey
Sébastien MARQUE authored on 2020-05-16
796
                },
797
                LEFT: {
798
                    APT: func { call(me.bindings.PFD.NRST._displayNearest, ['apt', 'LEFT'], me) },
799
                    VOR: func { call(me.bindings.PFD.NRST._displayNearest, ['vor', 'LEFT'], me) },
800
                    NDB: func { call(me.bindings.PFD.NRST._displayNearest, ['ndb', 'LEFT'], me) },
801
                    FIX: func { call(me.bindings.PFD.NRST._displayNearest, ['fix', 'LEFT'], me) },
adds NRST/COMMS
Sébastien MARQUE authored on 2020-05-18
802
                    COMM:func { call(me.bindings.PFD.NRST._displayNearestCOMM,    ['LEFT'], me) },
add PFD/NRST softkey
Sébastien MARQUE authored on 2020-05-16
803
                },
804
            },
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
805
        },
806
        MFD : {
807
            ENGINE: {
808
                FUEL: {
809
                    UNDO: func {
810
                        pop(me.path);
811
                        me.device.display.updateSoftKeys();
812
                    },
813
                    ENTER: func {
814
                        pop(me.path);
815
                        me.device.display.updateSoftKeys();
816
                    },
817
                },
818
                ENGINE: func {
819
                    me.path = [];
820
                    me.device.display.updateSoftKeys();
821
                },
822
            },
add missing exit to MFD/CHKL...
Sébastien MARQUE authored on 2017-03-20
823
            CHKLIST : {
add checklists management
Sébastien MARQUE authored on 2020-04-30
824
                _showCheckList: func (id, selected) {
825
                    var tabulate = func (l, r, t = 3, c = '.') {
826
                        var s = '';
827
                        for (var i = 0; i < (l - r) + t; i += 1) s ~= c;
828
                        return s;
829
                    }
830

            
831
                    var groupIndex     = me.device.windows.state[id].objects[selected].groupIndex;
832
                    var checklistIndex = me.device.windows.state[id].objects[selected].checklistIndex;
833

            
834
                    if (contains(me.device.windows.state[id].objects[selected], 'pageIndex'))
fix some issues with checkli...
Sébastien MARQUE authored on 2020-06-23
835
                        var pageIndex = me.device.windows.state[id].objects[selected].pageIndex;
add checklists management
Sébastien MARQUE authored on 2020-04-30
836
                    else
fix some issues with checkli...
Sébastien MARQUE authored on 2020-06-23
837
                        var pageIndex = -1;
add checklists management
Sébastien MARQUE authored on 2020-04-30
838

            
839
                    var title = '';
840
                    if (contains(me.device.windows.state[id].objects[selected], 'checklistTitle'))
fix some issues with checkli...
Sébastien MARQUE authored on 2020-06-23
841
                        var title = me.device.windows.state[id].objects[selected].checklistTitle;
add checklists management
Sébastien MARQUE authored on 2020-04-30
842
                    else
fix some issues with checkli...
Sébastien MARQUE authored on 2020-06-23
843
                        var title = me.device.windows.state[id].objects[selected].text;
add checklists management
Sébastien MARQUE authored on 2020-04-30
844

            
845
                    me.device.windows.del(id);
846

            
847
                    if (groupIndex < 0)
848
                         checklistNode = props.globals.getNode("/sim/checklists")
849
                                    .getChild('checklist', checklistIndex);
850
                    else
851
                         checklistNode = props.globals.getNode("/sim/checklists")
852
                                    .getChild("group", groupIndex)
853
                                    .getChild('checklist', checklistIndex);
854

            
855
                    var pages = checklistNode.getChildren('page');
fix some issues with checkli...
Sébastien MARQUE authored on 2020-06-23
856
                    if (size(pages) == 0)
857
                        append(pages, checklistNode);
add checklists management
Sébastien MARQUE authored on 2020-04-30
858

            
859
                    if (size(pages) and pageIndex == -1)
860
                        pageIndex = 0;
861

            
862
                    _previous_text = ' < PREVIOUS ';
863
                    _next_text     = ' NEXT > ';
864

            
865
                    var obj_infos = [];
866
                    var length = size(_previous_text ~ _next_text);
867
                    var length_cache = [];
868
                    if (size(pages))
869
                        checklistNode = pages[pageIndex];
870

            
871
                    append(obj_infos, {
872
                        text: sprintf('%s%s',
873
                                      title,
874
                                      size(pages) > 1 ? sprintf(' %d / %d',
875
                                                                pageIndex + 1,
876
                                                                size(pages)) : ''),
877
                        type: 'title'
878
                    });
879

            
880
                    append(obj_infos, {type: 'separator'});
881

            
882
                    forindex (var i; checklistNode.getChildren('item')) {
883
                        var l = size(checklistNode.getChild('item', i).getValue('name'));
884
                        if (checklistNode.getChild('item', i).getChild('value') != nil)
885
                            l += size(checklistNode.getChild('item', i).getValue('value'));
886
                        append(length_cache, l);
887
                        if (l > length)
888
                            length = l;
889
                    }
890

            
891
                    forindex (var i; checklistNode.getChildren('item')) {
892
                        var text = pages[pageIndex].getChild('item', i).getValue('name');
893
                        var item_val = '';
894
                        if (pages[pageIndex].getChild('item', i).getChild('value') != nil)
895
                            item_val = pages[pageIndex].getChild('item', i).getValue('value');
896
                        if (item_val != '')
897
                            text ~= tabulate(length, length_cache[i]);
898
                        text ~= item_val;
899

            
900
                        append(obj_infos, {
901
                            text: text,
902
                            groupIndex: groupIndex,
903
                            checklistIndex: checklistIndex,
904
                            pageIndex: pageIndex,
905
                            type: 'normal|end-of-line'
906
                        });
907
                    }
908

            
909
                    append(obj_infos, {type: 'separator'});
910

            
911
                    if (pageIndex and size(pages))
912
                        append(obj_infos, {
913
                                text: _previous_text,
914
                                groupIndex: groupIndex,
915
                                checklistIndex: checklistIndex,
916
                                pageIndex: pageIndex - 1,
917
                                checklistTitle: title,
918
                                type: (pageIndex + 1 < size(pages)) ? 'editable' : 'selected',
919
                                callback: func (id, selected) call(me.device.softkeys.bindings.MFD.CHKLIST._showCheckList, [id, selected], me)
920
                        });
921
                    else
922
                        append(obj_infos, {
923
                            text: tabulate(length, size(_next_text), 0, ' '),
924
                            type: 'normal'
925
                        });
926

            
927
                    if (pageIndex + 1 < size(pages)) {
928
                        if (pageIndex and size(pages))
929
                            append(obj_infos, {
930
                                text: tabulate(length, size(_previous_text ~ _next_text), 0, ' '),
931
                                type: 'normal',
932
                            });
933
                        append(obj_infos, {
934
                                text: _next_text,
935
                                groupIndex: groupIndex,
936
                                checklistIndex: checklistIndex,
937
                                pageIndex: pageIndex + 1,
938
                                checklistTitle: title,
939
                                type: 'selected|end-of-line',
940
                                callback: func (id, selected) call(me.device.softkeys.bindings.MFD.CHKLIST._showCheckList, [id, selected], me)
941
                        });
942
                    }
943

            
944
                    me.device.knobs.FmsInner = me.device.knobs.NavigateMenu;
945
                    me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu;
946
                    me.device.buttons.ENT    = me.device.buttons.ValidateTMRREF;
947
                    me.device.buttons.CLR = func {
948
                        me.device.windows.del(id);
fix some issues with checkli...
Sébastien MARQUE authored on 2020-06-23
949
                        me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group;
add checklists management
Sébastien MARQUE authored on 2020-04-30
950
                        me.device.knobs.FmsInner = func;
951
                        foreach (var b; ['ENT', 'CLR'])
952
                            me.device.buttons[b] = func;
953
                        me.device.buttons.MENU = func;
954
                    }
955
                    me.device.windows.draw( id, {autogeom: 1}, obj_infos );
956
                },
957
                LIST: func {
958
                    # nested function as checklist lists may be organized by group
959
                    var listChecklists = func (id, selected) {
960
                        var checklists = [];
961
                        var firstEntry = 1;
fix some issues with checkli...
Sébastien MARQUE authored on 2020-06-23
962
                        if (selected < 0) {
add checklists management
Sébastien MARQUE authored on 2020-04-30
963
                            checklists = props.globals.getNode("/sim/checklists")
964
                                            .getChildren('checklist');
fix some issues with checkli...
Sébastien MARQUE authored on 2020-06-23
965
                            var groupIndex = -1;
966
                        }
967
                        else {
968
                            var groupIndex = me.device.windows.state[id].objects[selected].groupIndex;
969
                            me.device.windows.del(id);
add checklists management
Sébastien MARQUE authored on 2020-04-30
970
                            checklists = props.globals.getNode("/sim/checklists")
971
                                            .getChild("group", groupIndex)
972
                                            .getChildren('checklist');
fix some issues with checkli...
Sébastien MARQUE authored on 2020-06-23
973
                        }
add checklists management
Sébastien MARQUE authored on 2020-04-30
974
                        var checklistsQty = size(checklists);
975
                        var obj_infos = [];
976

            
977
                        if (checklistsQty) {
978
                            forindex (var c; checklists) {
979
                                if (string.uc(checklists[c].getValue('title')) == 'EMERGENCY') {
980
                                    checklistsQty -= 1;
981
                                    continue;
982
                                }
983
                                var title = checklists[c].getValue('title');
984
                                append(obj_infos, {
985
                                    text: title,
986
                                    groupIndex: groupIndex,
987
                                    checklistIndex: c,
988
                                    checklistTitle: title,
989
                                    type: (firstEntry ? 'selected' : 'editable') ~ '|end-of-line',
990
                                    callback: func (id, selected) call(me.device.softkeys.bindings.MFD.CHKLIST._showCheckList, [id, selected], me)
991
                                });
992
                                if (checklistsQty == 1) { # see comments below for groups
993
                                    call(me.device.softkeys.bindings.MFD.CHKLIST._showCheckList, [groupIndex, 0], me);
994
                                    return;
995
                                }
996
                                elsif (checklistsQty == 0)
997
                                    return;
998
                                firstEntry = 0;
999
                            }
1000
                        }
1001

            
1002
                        id ~= ' CHECKLISTS';
1003
                        me.device.knobs.FmsInner = me.device.knobs.NavigateMenu;
1004
                        me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu;
1005
                        me.device.buttons.ENT    = me.device.buttons.ValidateTMRREF;
1006
                        me.device.buttons.CLR = func {
1007
                            me.device.windows.del(id);
fix some issues with checkli...
Sébastien MARQUE authored on 2020-06-23
1008
                            me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group;
add checklists management
Sébastien MARQUE authored on 2020-04-30
1009
                            me.device.knobs.FmsInner = func;
1010
                            foreach (var b; ['ENT', 'CLR'])
1011
                                me.device.buttons[b] = func;
1012
                            me.device.buttons.MENU = func;
1013
                        }
1014
                        me.device.windows.draw(id, {autogeom: 1}, obj_infos);
1015
                    }
1016

            
fix some issues with checkli...
Sébastien MARQUE authored on 2020-06-23
1017
                    foreach(var windowId; keys(me.device.windows.state))
add checklists management
Sébastien MARQUE authored on 2020-04-30
1018
                        me.device.windows.del(windowId);
1019

            
fix some issues with checkli...
Sébastien MARQUE authored on 2020-06-23
1020
                    var windowId = 'CHKLIST LIST';
add checklists management
Sébastien MARQUE authored on 2020-04-30
1021
                    var obj_infos = [];
1022
                    var firstEntry = 1;
1023
                    var groups = props.globals.getNode("/sim/checklists").getChildren("group");
1024
                    var groupsQty = size(groups);
1025

            
1026
                    if (groupsQty) {
1027
                        forindex (var g; groups) {
1028
                            # emergency checklists are listed in their own menu
1029
                            if (string.uc(groups[g].getValue('name')) == 'EMERGENCY') {
1030
                                groupsQty -= 1;
1031
                                continue;
1032
                            }
1033
                            # the key groupIndex isn't used by the display system
1034
                            # we use it to keep the information of group node's index
1035
                            append(obj_infos, {
1036
                                text: groups[g].getValue('name'),
1037
                                groupIndex: g,
1038
                                type: (firstEntry ? 'selected' : 'editable') ~ '|end-of-line',
1039
                                callback: func (id, selected) listChecklists(id, selected) });
1040
                            firstEntry = 0;
1041
                            # if there are only one group left, let display it directly
1042
                            if (groupsQty == 1) {
1043
                                listChecklists(windowId, 0);
1044
                                return;
1045
                            }
1046
                            elsif (groupsQty == 0) {
1047
                                return;
1048
                            }
1049
                        }
1050
                    }
1051
                    else {
1052
                        listChecklists(windowId, -1);
1053
                        return;
1054
                    }
1055

            
1056
                    me.device.knobs.FmsInner = me.device.knobs.NavigateMenu;
1057
                    me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu;
1058
                    me.device.buttons.ENT    = me.device.buttons.ValidateTMRREF;
1059
                    me.device.buttons.CLR = func {
1060
                        me.device.windows.del(windowId);
fix some issues with checkli...
Sébastien MARQUE authored on 2020-06-23
1061
                        me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group;
add checklists management
Sébastien MARQUE authored on 2020-04-30
1062
                        me.device.knobs.FmsInner = func;
1063
                        foreach (var b; ['ENT', 'CLR'])
1064
                            me.device.buttons[b] = func;
1065
                        me.device.buttons.MENU = func;
1066
                    }
1067
                    me.device.windows.draw(windowId, {autogeom: 1}, obj_infos);
1068
                },
1069
                EMERGCY: func {
1070
                    # nested function as checklist lists may be organized by group
1071
                    var listChecklists = func (groupIndex) {
1072
                        var checklists = [];
1073
                        var firstEntry = 1;
1074
                        if (groupIndex == -1)
1075
                            checklists = props.globals.getNode("/sim/checklists")
1076
                                            .getChildren('checklist');
1077
                        else
1078
                            checklists = props.globals.getNode("/sim/checklists")
1079
                                            .getChild("group", groupIndex)
1080
                                            .getChildren('checklist');
1081
                        var checklistsQty = size(checklists);
1082
                        var obj_infos = [];
1083
                        var firstEntry = 1;
1084

            
1085
                        if (checklistsQty) {
1086
                            forindex (var c; checklists) {
1087
                                if (groupIndex < 0 and string.uc(checklists[c].getValue('title')) != 'EMERGENCY') {
1088
                                    checklistsQty -= 1;
1089
                                    continue;
1090
                                }
1091
                                append(obj_infos, {
1092
                                    text: checklists[c].getValue('title'),
1093
                                    groupIndex: groupIndex,
1094
                                    checklistIndex: c,
1095
                                    type: (firstEntry ? 'selected' : 'editable') ~ '|end-of-line',
1096
                                    callback: func (id, selected) call(me.device.softkeys.bindings.MFD.CHKLIST._showCheckList, [id, selected], me)
1097
                                });
1098
                                firstEntry = 0;
1099
                            }
1100
                        }
1101
                        id = 'EMERGENCY CHECKLISTS';
1102
                        me.device.knobs.FmsInner = me.device.knobs.NavigateMenu;
1103
                        me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu;
1104
                        me.device.buttons.ENT    = me.device.buttons.ValidateTMRREF;
1105
                        me.device.buttons.CLR = func {
1106
                            me.device.windows.del(id);
fix some issues with checkli...
Sébastien MARQUE authored on 2020-06-23
1107
                            me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group;
add checklists management
Sébastien MARQUE authored on 2020-04-30
1108
                            me.device.knobs.FmsInner = func;
1109
                            foreach (var b; ['ENT', 'CLR'])
1110
                                me.device.buttons[b] = func;
1111
                            me.device.buttons.MENU = func;
1112
                        }
1113
                        me.device.windows.draw(id, {autogeom: 1}, obj_infos);
1114
                        if (checklistsQty == 1) { # see comments below for groups
1115
                            call(me.device.softkeys.bindings.MFD.CHKLIST._showCheckList, [groupIndex, 0], me);
1116
                            return;
1117
                        }
1118
                        elsif (checklistsQty == 0)
1119
                            call(me.device.buttons.CLR, [0], me);
1120
                            return;
1121
                    }
1122

            
1123
                    var windowId = 'CHKLIST EMERGCY';
1124
                    if (contains(me.device.windows.state, windowId))
1125
                        me.device.windows.del(windowId);
1126

            
1127
                    var groups = props.globals.getNode("/sim/checklists").getChildren("group");
1128

            
1129
                    var emergency_group_found = 0;
1130
                    if (size(groups)) {
1131
                        forindex (var g; groups) {
1132
                            # emergency checklists are listed in their own menu
1133
                            # we support only one emergency checklists group named EMERGENCY (case insensitive)
1134
                            if (string.uc(groups[g].getValue('name')) != 'EMERGENCY')
1135
                                continue;
1136
                            listChecklists(g);
1137
                            emergency_group_found = !emergency_group_found;
1138
                            break;
1139
                        }
1140
                    }
1141

            
1142
                    if (!emergency_group_found)
1143
                        listChecklists(-1);
1144
                },
add missing exit to MFD/CHKL...
Sébastien MARQUE authored on 2017-03-20
1145
                EXIT: func {
1146
                    me.path = [];
1147
                    me.device.display.updateSoftKeys();
1148
                },
1149
            },
add TCAS
Sébastien MARQUE authored on 2017-12-21
1150
            MAP: {
1151
                TRAFFIC: func {
improve the selection of dis...
Sébastien MARQUE authored on 2017-12-30
1152
                    call(me.bindings.PFD.INSET.declutter, ['MAPTRAFFIC', 'tcas', 0], me);
1153
                },
1154
                ROUTE: func {
1155
                    call(me.bindings.PFD.INSET.declutter, ['MAPROUTE', 'route', 1], me);
1156
                },
1157
                TERRAIN: func {
1158
                    call(me.bindings.PFD.INSET.declutter, ['MAPTERRAIN', 'tiles', 3], me);
1159
                },
topo display is now availabl...
Sébastien MARQUE authored on 2020-06-14
1160
                TOPO: func {
1161
                    call(me.bindings.PFD.INSET.declutter, ['MAPTOPO', 'topo', 7], me);
1162
                },
improve the selection of dis...
Sébastien MARQUE authored on 2017-12-30
1163
                NAVAIDS: {
1164
                    ALL: func {
1165
                        call(me.bindings.PFD.INSET.NAVAIDS.ALL, [ 'MAPNAVAIDS' ], me);
1166
                    },
1167
                    VOR: func {
1168
                        call(me.bindings.PFD.INSET.NAVAIDS.declutter, ['MAPNAVAIDSVOR', 'VOR', 2], me);
1169
                    },
1170
                    TACAN: func {
1171
                        call(me.bindings.PFD.INSET.NAVAIDS.declutter, ['MAPNAVAIDSTACAN', 'TACAN', 3], me);
1172
                    },
1173
                    NDB: func {
1174
                        call(me.bindings.PFD.INSET.NAVAIDS.declutter, ['MAPNAVAIDSNDB', 'NDB', 4], me);
1175
                    },
1176
                    DME: func {
1177
                        call(me.bindings.PFD.INSET.NAVAIDS.declutter, ['MAPNAVAIDSDME', 'DME', 5], me);
1178
                    },
1179
                    APT: func {
1180
                        call(me.bindings.PFD.INSET.NAVAIDS.declutter, ['MAPNAVAIDSAPT', 'airport', 6], me);
1181
                    },
add TCAS
Sébastien MARQUE authored on 2017-12-21
1182
                },
1183
            },
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
1184
        },
commit initial
Sébastien MARQUE authored on 2017-03-07
1185
    },
1186
};
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
1187

            
1188
var keyMap = {
vim folds
Sébastien MARQUE authored on 2017-12-21
1189
# softkeys map for PFD and MFD {{{1
1190
# PFD {{{2
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
1191
    PFD : {
1192
        first : 1,
1193
        texts : ['INSET', 'SENSOR', 'PFD', 'OBS', 'CDI', 'DME', 'XPDR', 'IDENT', 'TMR/REF', 'NRST' ],
1194
        INSET : {
removes traffic from PFD ins...
Sébastien MARQUE authored on 2020-06-14
1195
            texts : ['OFF', '', '', 'ROUTE', '', 'TERRAIN', 'NAVAIDS', 'METAR'],
improve the selection of dis...
Sébastien MARQUE authored on 2017-12-30
1196
            NAVAIDS : {
1197
                first : 2,
1198
                texts : ['VOR', 'TACAN', 'NDB', 'DME', 'APT', '', 'ALL'],
1199
            },
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
1200
        },
1201
        SENSOR : {
1202
            first : 2,
1203
            texts : [ 'ADC1', 'ADC2', '', 'AHRS1', 'AHRS2'],
1204
        },
1205
        PFD : {
1206
            texts : [ 'SYN VIS', 'DFLTS', 'AOA/WIND', 'DME', 'BRG1', 'HSI FMT', 'BRG2', '', 'ALT UNIT', 'STD BARO' ],
1207
            'SYN VIS' : {
1208
                texts : [ 'PATHWAY', 'SYN TERR', 'HR2NHDG', 'APTSIGNS', 'FPM'],
1209
            },
1210
            'AOA/WIND' : {
1211
                first : 4,
1212
                texts : ['AOA', 'WIND'],
1213
                AOA : {
1214
                    first : 5,
1215
                    texts : ['AOA ON', 'AOA AUTO'],
1216
                },
1217
                WIND : {
1218
                    first : 2,
1219
                    texts : ['OPTN1', 'OPTN2', '', 'OFF'],
1220
                },
1221
            },
1222
            'HSI FMT' : {
1223
                first : 6,
1224
                texts : ['360 HSI', 'ARC HSI'],
1225
            },
1226
            'ALT UNIT' : {
1227
                first : 5,
1228
                texts : ['METERS', '', 'IN', 'HPA'],
1229
            },
1230
        },
1231
        XPDR : {
1232
            first : 2,
1233
            texts : ['STBY', 'ON', 'ALT', '', 'VFR', 'CODE', 'IDENT'],
1234
            CODE : {
1235
                texts : ['0', '1', '2', '3', '4', '5', '6', '7', 'IDENT', 'BKSP'],
1236
            },
1237
        },
add PFD/NRST softkey
Sébastien MARQUE authored on 2020-05-16
1238
        NRST : {
1239
            first : 4,
1240
            texts : ['OMNI', 'REAR', 'FRONT', 'LEFT', 'RIGHT', 'RANGE'],
1241
            RANGE : {
1242
                first : 7,
1243
                texts : ['MIN', 'MAX' ],
1244
                MIN : { first: 3, texts : ['0NM',   '10NM',  '30NM',  '50NM'] },
fix typo
Sébastien MARQUE authored on 2020-06-11
1245
                MAX : { first: 3, texts : ['200NM', '150NM', '100NM', '50NM'] },
add PFD/NRST softkey
Sébastien MARQUE authored on 2020-05-16
1246
            },
adds NRST/COMMS
Sébastien MARQUE authored on 2020-05-18
1247
            OMNI : { texts: ['NDB', 'FIX', 'VOR', 'APT', '', '', '', '', '', 'COMM'] }, # that will be mirrored later
add PFD/NRST softkey
Sébastien MARQUE authored on 2020-05-16
1248
        },
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
1249
    },
vim folds
Sébastien MARQUE authored on 2017-12-21
1250
#}}}2
1251
# MFD {{{2
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
1252
    MFD : {
1253
        texts : ['ENGINE', '', 'MAP', '', '', '', '', '', '', 'DCLTR', 'SHW CHRT', 'CHKLIST'],
1254
        MAP : {
improve the selection of dis...
Sébastien MARQUE authored on 2017-12-30
1255
            texts : ['TRAFFIC', 'ROUTE', 'TOPO', 'TERRAIN', 'NAVAIDS', '','', '', '', '', 'BACK'],
1256
            NAVAIDS : {
1257
                first : 2,
1258
                texts : ['VOR', 'TACAN', 'NDB', 'DME', 'APT', '', 'ALL', '', '', 'BACK' ],
1259
            },
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
1260
        },
1261
        CHKLIST : {
add checklists management
Sébastien MARQUE authored on 2020-04-30
1262
            texts : ['ENGINE', '', '', '', 'LIST', 'DONE', '', '', '', '', 'EXIT', 'EMERGCY'],
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
1263
        },
1264
        ENGINE : {
1265
            texts : ['ENGINE', 'ANTI-ICE', '', 'DCLTR', '', 'ASSIST', '', '', '', '', 'FUEL'],
1266
            'ANTI-ICE' : {
1267
                texts : ['LEFT', 'AUTO', 'RIGHT', '', '', '', '', '', '', '', '', 'BACK'],
1268
            },
1269
            FUEL : {
1270
                first : 1,
1271
                texts : ['FULL', 'TABS', '', '', '', '', '', '', '', 'UNDO', 'ENTER'],
1272
            },
1273
        },
1274
    },
vim folds
Sébastien MARQUE authored on 2017-12-21
1275
#}}}2
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
1276
};
1277
if (data['stall-aoa'] == 9999)
1278
    keyMap.PFD.PFD['AOA/WIND'].texts = ['', 'WIND'];
add checklists management
Sébastien MARQUE authored on 2020-04-30
1279
if (props.globals.getNode('/sim/checklists') == nil) {
1280
    keyMap.MFD.texts[11] = '';
1281
    delete(keyMap.MFD, 'CHKLIST');
1282
}
add PFD/NRST softkey
Sébastien MARQUE authored on 2020-05-16
1283
foreach (var d; ['FRONT', 'REAR', 'LEFT', 'RIGHT']) {
1284
    keyMap.PFD.NRST[d] = keyMap.PFD.NRST.OMNI;
1285
}
vim folds
Sébastien MARQUE authored on 2017-12-21
1286
#}}}1