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

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

            
714
                            if (size(TWR_list) < 4
715
                            and string.match(c.ident, '*TWR*'))
716
                                append(TWR_list, [r.id, c.frequency, course, dist]);
717

            
718
                            if (size(TRAFFIC_list) < 4
719
                            and (string.match(c.ident, '*CTAF*') or string.match(c.ident, '*UNICOM*') or string.match(c.ident, '*MULTICOM*')))
720
                                append(TRAFFIC_list, [r.id, c.frequency, course, dist]);
721
                        }
722
                    }
723
                    var obj_infos = [];
724
                    firstEntry = 1;
725
                    if (size(ATIS_list) > 0) {
726
                        append(obj_infos, {text: 'ATIS', type: 'title'});
727
                        append(obj_infos, {type: 'separator'});
728
                        foreach (var atis; ATIS_list) {
729
                            append(obj_infos, {
730
                                text: atis[0],
731
                                _freq: atis[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', atis[1], atis[2], atis[3]),
737
                                type: 'normal|end-of-line'
738
                            });
739
                            firstEntry = 0;
740
                        }
741
                    }
742
                    if (size(TRAFFIC_list) > 0) {
743
                        append(obj_infos, {text: 'TRAFFIC', type: 'title'});
744
                        append(obj_infos, {type: 'separator'});
745
                        foreach (var traffic; TRAFFIC_list) {
746
                            append(obj_infos, {
747
                                text: traffic[0],
748
                                _freq: traffic[1],
749
                                type: firstEntry ? 'selected' : 'editable',
750
                                callback: func (id, selected) radios.getNode('comm-freq-mhz').setValue(me.device.windows.state[id].objects[selected]._freq),
751
                            });
752
                            append(obj_infos, {
753
                                text: sprintf(' (%.3fMHz) %3i° %2iNM', traffic[1], traffic[2], traffic[3]),
754
                                type: 'normal|end-of-line'
755
                            });
756
                            firstEntry = 0;
757
                        }
758
                    }
759
                    if (size(TWR_list) > 0) {
760
                        append(obj_infos, {text: 'TOWER', type: 'title'});
761
                        append(obj_infos, {type: 'separator'});
762
                        foreach (var tower; TWR_list) {
763
                            append(obj_infos, {
764
                                text: tower[0],
765
                                _freq: tower[1],
766
                                type: firstEntry ? 'selected' : 'editable',
767
                                callback: func (id, selected) radios.getNode('comm-freq-mhz').setValue(me.device.windows.state[id].objects[selected]._freq),
768
                            });
769
                            append(obj_infos, {
770
                                text: sprintf(' (%.3fMHz) %3i° %2iNM', tower[1], tower[2], tower[3]),
771
                                type: 'normal|end-of-line'
772
                            });
773
                            firstEntry = 0;
774
                        }
775
                    }
776
                    me.device.knobs.FmsInner = me.device.knobs.NavigateMenu;
777
                    me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu;
fix MENU issue
Sébastien MARQUE authored on 2020-05-23
778
                    me.device.buttons.MENU = func;
adds NRST/COMMS
Sébastien MARQUE authored on 2020-05-18
779
                    me.device.buttons.CLR = func {
780
                        me.device.windows.del(id);
781
                        me.device.knobs.FmsOuter = func;
782
                        me.device.knobs.FmsInner = func;
fix MENU issue
Sébastien MARQUE authored on 2020-05-23
783
                        me.device.buttons.MENU = me.device.buttons.GlobalParams;
784
                        foreach (var b; ['ENT', 'CLR'])
adds NRST/COMMS
Sébastien MARQUE authored on 2020-05-18
785
                            me.device.buttons[b] = func;
786
                    }
787
                    me.device.buttons.ENT    = me.device.buttons.ValidateTMRREF;
788
                    me.device.windows.draw( id, {autogeom: 1}, obj_infos );
789
                },
add PFD/NRST softkey
Sébastien MARQUE authored on 2020-05-16
790
############################################################################################################
791
# THIS CODE SHOULD REPLACE THE LINES BELOW (in new()), but it makes all call with the same args (apt, RIGHT)
792
############################################################################################################
793
#        if (m.device.role == 'PFD')
794
#            foreach (var dir; keyMap.PFD.NRST.texts) {
795
#                m.bindings.PFD.NRST[dir] = {};
796
#                foreach (var type; keyMap.PFD.NRST.OMNI.texts) {
797
#                    m.bindings.PFD.NRST[dir][type] = func {
798
#                        call(m.bindings.PFD.NRST._displayNearest, [string.lc(type), dir], m)
799
#                    };
800
#                }
801
#            }
802
############################################################################################################
803
                OMNI: {
804
                    APT: func { call(me.bindings.PFD.NRST._displayNearest, ['apt', 'OMNI'], me) },
805
                    VOR: func { call(me.bindings.PFD.NRST._displayNearest, ['vor', 'OMNI'], me) },
806
                    NDB: func { call(me.bindings.PFD.NRST._displayNearest, ['ndb', 'OMNI'], me) },
807
                    FIX: func { call(me.bindings.PFD.NRST._displayNearest, ['fix', 'OMNI'], me) },
adds NRST/COMMS
Sébastien MARQUE authored on 2020-05-18
808
                    COMM:func { call(me.bindings.PFD.NRST._displayNearestCOMM,    ['OMNI'], me) },
add PFD/NRST softkey
Sébastien MARQUE authored on 2020-05-16
809
                },
810
                FRONT: {
811
                    APT: func { call(me.bindings.PFD.NRST._displayNearest, ['apt', 'FRONT'], me) },
812
                    VOR: func { call(me.bindings.PFD.NRST._displayNearest, ['vor', 'FRONT'], me) },
813
                    NDB: func { call(me.bindings.PFD.NRST._displayNearest, ['ndb', 'FRONT'], me) },
814
                    FIX: func { call(me.bindings.PFD.NRST._displayNearest, ['fix', 'FRONT'], me) },
adds NRST/COMMS
Sébastien MARQUE authored on 2020-05-18
815
                    COMM:func { call(me.bindings.PFD.NRST._displayNearestCOMM,    ['FRONT'], me) },
add PFD/NRST softkey
Sébastien MARQUE authored on 2020-05-16
816
                },
817
                RIGHT: {
818
                    APT: func { call(me.bindings.PFD.NRST._displayNearest, ['apt', 'RIGHT'], me) },
819
                    VOR: func { call(me.bindings.PFD.NRST._displayNearest, ['vor', 'RIGHT'], me) },
820
                    NDB: func { call(me.bindings.PFD.NRST._displayNearest, ['ndb', 'RIGHT'], me) },
821
                    FIX: func { call(me.bindings.PFD.NRST._displayNearest, ['fix', 'RIGHT'], me) },
adds NRST/COMMS
Sébastien MARQUE authored on 2020-05-18
822
                    COMM:func { call(me.bindings.PFD.NRST._displayNearestCOMM,    ['RIGHT'], me) },
add PFD/NRST softkey
Sébastien MARQUE authored on 2020-05-16
823
                },
824
                REAR: {
825
                    APT: func { call(me.bindings.PFD.NRST._displayNearest, ['apt', 'REAR'], me) },
826
                    VOR: func { call(me.bindings.PFD.NRST._displayNearest, ['vor', 'REAR'], me) },
827
                    NDB: func { call(me.bindings.PFD.NRST._displayNearest, ['ndb', 'REAR'], me) },
828
                    FIX: func { call(me.bindings.PFD.NRST._displayNearest, ['fix', 'REAR'], me) },
adds NRST/COMMS
Sébastien MARQUE authored on 2020-05-18
829
                    COMM:func { call(me.bindings.PFD.NRST._displayNearestCOMM,    ['REAR'], me) },
add PFD/NRST softkey
Sébastien MARQUE authored on 2020-05-16
830
                },
831
                LEFT: {
832
                    APT: func { call(me.bindings.PFD.NRST._displayNearest, ['apt', 'LEFT'], me) },
833
                    VOR: func { call(me.bindings.PFD.NRST._displayNearest, ['vor', 'LEFT'], me) },
834
                    NDB: func { call(me.bindings.PFD.NRST._displayNearest, ['ndb', 'LEFT'], me) },
835
                    FIX: func { call(me.bindings.PFD.NRST._displayNearest, ['fix', 'LEFT'], me) },
adds NRST/COMMS
Sébastien MARQUE authored on 2020-05-18
836
                    COMM:func { call(me.bindings.PFD.NRST._displayNearestCOMM,    ['LEFT'], me) },
add PFD/NRST softkey
Sébastien MARQUE authored on 2020-05-16
837
                },
838
            },
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
839
        },
840
        MFD : {
841
            ENGINE: {
842
                FUEL: {
843
                    UNDO: func {
844
                        pop(me.path);
845
                        me.device.display.updateSoftKeys();
846
                    },
847
                    ENTER: func {
848
                        pop(me.path);
849
                        me.device.display.updateSoftKeys();
850
                    },
851
                },
852
                ENGINE: func {
853
                    me.path = [];
854
                    me.device.display.updateSoftKeys();
855
                },
856
            },
add missing exit to MFD/CHKL...
Sébastien MARQUE authored on 2017-03-20
857
            CHKLIST : {
add checklists management
Sébastien MARQUE authored on 2020-04-30
858
                _showCheckList: func (id, selected) {
859
                    var tabulate = func (l, r, t = 3, c = '.') {
860
                        var s = '';
861
                        for (var i = 0; i < (l - r) + t; i += 1) s ~= c;
862
                        return s;
863
                    }
864

            
865
                    var groupIndex     = me.device.windows.state[id].objects[selected].groupIndex;
866
                    var checklistIndex = me.device.windows.state[id].objects[selected].checklistIndex;
867

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

            
873
                    var title = '';
874
                    if (contains(me.device.windows.state[id].objects[selected], 'checklistTitle'))
fix some issues with checkli...
Sébastien MARQUE authored on 2020-06-23
875
                        var title = me.device.windows.state[id].objects[selected].checklistTitle;
add checklists management
Sébastien MARQUE authored on 2020-04-30
876
                    else
fix some issues with checkli...
Sébastien MARQUE authored on 2020-06-23
877
                        var title = me.device.windows.state[id].objects[selected].text;
add checklists management
Sébastien MARQUE authored on 2020-04-30
878

            
879
                    me.device.windows.del(id);
880

            
881
                    if (groupIndex < 0)
882
                         checklistNode = props.globals.getNode("/sim/checklists")
883
                                    .getChild('checklist', checklistIndex);
884
                    else
885
                         checklistNode = props.globals.getNode("/sim/checklists")
886
                                    .getChild("group", groupIndex)
887
                                    .getChild('checklist', checklistIndex);
888

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

            
893
                    if (size(pages) and pageIndex == -1)
894
                        pageIndex = 0;
895

            
896
                    _previous_text = ' < PREVIOUS ';
897
                    _next_text     = ' NEXT > ';
898

            
899
                    var obj_infos = [];
900
                    var length = size(_previous_text ~ _next_text);
901
                    var length_cache = [];
902
                    if (size(pages))
903
                        checklistNode = pages[pageIndex];
904

            
905
                    append(obj_infos, {
906
                        text: sprintf('%s%s',
907
                                      title,
908
                                      size(pages) > 1 ? sprintf(' %d / %d',
909
                                                                pageIndex + 1,
910
                                                                size(pages)) : ''),
911
                        type: 'title'
912
                    });
913

            
914
                    append(obj_infos, {type: 'separator'});
915

            
916
                    forindex (var i; checklistNode.getChildren('item')) {
917
                        var l = size(checklistNode.getChild('item', i).getValue('name'));
918
                        if (checklistNode.getChild('item', i).getChild('value') != nil)
919
                            l += size(checklistNode.getChild('item', i).getValue('value'));
920
                        append(length_cache, l);
921
                        if (l > length)
922
                            length = l;
923
                    }
924

            
925
                    forindex (var i; checklistNode.getChildren('item')) {
926
                        var text = pages[pageIndex].getChild('item', i).getValue('name');
927
                        var item_val = '';
928
                        if (pages[pageIndex].getChild('item', i).getChild('value') != nil)
929
                            item_val = pages[pageIndex].getChild('item', i).getValue('value');
930
                        if (item_val != '')
931
                            text ~= tabulate(length, length_cache[i]);
932
                        text ~= item_val;
933

            
934
                        append(obj_infos, {
935
                            text: text,
936
                            groupIndex: groupIndex,
937
                            checklistIndex: checklistIndex,
938
                            pageIndex: pageIndex,
939
                            type: 'normal|end-of-line'
940
                        });
941
                    }
942

            
943
                    append(obj_infos, {type: 'separator'});
944

            
945
                    if (pageIndex and size(pages))
946
                        append(obj_infos, {
947
                                text: _previous_text,
948
                                groupIndex: groupIndex,
949
                                checklistIndex: checklistIndex,
950
                                pageIndex: pageIndex - 1,
951
                                checklistTitle: title,
952
                                type: (pageIndex + 1 < size(pages)) ? 'editable' : 'selected',
953
                                callback: func (id, selected) call(me.device.softkeys.bindings.MFD.CHKLIST._showCheckList, [id, selected], me)
954
                        });
955
                    else
956
                        append(obj_infos, {
957
                            text: tabulate(length, size(_next_text), 0, ' '),
958
                            type: 'normal'
959
                        });
960

            
961
                    if (pageIndex + 1 < size(pages)) {
962
                        if (pageIndex and size(pages))
963
                            append(obj_infos, {
964
                                text: tabulate(length, size(_previous_text ~ _next_text), 0, ' '),
965
                                type: 'normal',
966
                            });
967
                        append(obj_infos, {
968
                                text: _next_text,
969
                                groupIndex: groupIndex,
970
                                checklistIndex: checklistIndex,
971
                                pageIndex: pageIndex + 1,
972
                                checklistTitle: title,
973
                                type: 'selected|end-of-line',
974
                                callback: func (id, selected) call(me.device.softkeys.bindings.MFD.CHKLIST._showCheckList, [id, selected], me)
975
                        });
976
                    }
977

            
978
                    me.device.knobs.FmsInner = me.device.knobs.NavigateMenu;
979
                    me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu;
980
                    me.device.buttons.ENT    = me.device.buttons.ValidateTMRREF;
981
                    me.device.buttons.CLR = func {
982
                        me.device.windows.del(id);
fix some issues with checkli...
Sébastien MARQUE authored on 2020-06-23
983
                        me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group;
add checklists management
Sébastien MARQUE authored on 2020-04-30
984
                        me.device.knobs.FmsInner = func;
985
                        foreach (var b; ['ENT', 'CLR'])
986
                            me.device.buttons[b] = func;
987
                        me.device.buttons.MENU = func;
988
                    }
989
                    me.device.windows.draw( id, {autogeom: 1}, obj_infos );
990
                },
991
                LIST: func {
992
                    # nested function as checklist lists may be organized by group
993
                    var listChecklists = func (id, selected) {
994
                        var checklists = [];
995
                        var firstEntry = 1;
fix some issues with checkli...
Sébastien MARQUE authored on 2020-06-23
996
                        if (selected < 0) {
add checklists management
Sébastien MARQUE authored on 2020-04-30
997
                            checklists = props.globals.getNode("/sim/checklists")
998
                                            .getChildren('checklist');
fix some issues with checkli...
Sébastien MARQUE authored on 2020-06-23
999
                            var groupIndex = -1;
1000
                        }
1001
                        else {
1002
                            var groupIndex = me.device.windows.state[id].objects[selected].groupIndex;
1003
                            me.device.windows.del(id);
add checklists management
Sébastien MARQUE authored on 2020-04-30
1004
                            checklists = props.globals.getNode("/sim/checklists")
1005
                                            .getChild("group", groupIndex)
1006
                                            .getChildren('checklist');
fix some issues with checkli...
Sébastien MARQUE authored on 2020-06-23
1007
                        }
add checklists management
Sébastien MARQUE authored on 2020-04-30
1008
                        var checklistsQty = size(checklists);
1009
                        var obj_infos = [];
1010

            
1011
                        if (checklistsQty) {
1012
                            forindex (var c; checklists) {
1013
                                if (string.uc(checklists[c].getValue('title')) == 'EMERGENCY') {
1014
                                    checklistsQty -= 1;
1015
                                    continue;
1016
                                }
1017
                                var title = checklists[c].getValue('title');
1018
                                append(obj_infos, {
1019
                                    text: title,
1020
                                    groupIndex: groupIndex,
1021
                                    checklistIndex: c,
1022
                                    checklistTitle: title,
1023
                                    type: (firstEntry ? 'selected' : 'editable') ~ '|end-of-line',
1024
                                    callback: func (id, selected) call(me.device.softkeys.bindings.MFD.CHKLIST._showCheckList, [id, selected], me)
1025
                                });
1026
                                if (checklistsQty == 1) { # see comments below for groups
1027
                                    call(me.device.softkeys.bindings.MFD.CHKLIST._showCheckList, [groupIndex, 0], me);
1028
                                    return;
1029
                                }
1030
                                elsif (checklistsQty == 0)
1031
                                    return;
1032
                                firstEntry = 0;
1033
                            }
1034
                        }
1035

            
1036
                        id ~= ' CHECKLISTS';
1037
                        me.device.knobs.FmsInner = me.device.knobs.NavigateMenu;
1038
                        me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu;
1039
                        me.device.buttons.ENT    = me.device.buttons.ValidateTMRREF;
1040
                        me.device.buttons.CLR = func {
1041
                            me.device.windows.del(id);
fix some issues with checkli...
Sébastien MARQUE authored on 2020-06-23
1042
                            me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group;
add checklists management
Sébastien MARQUE authored on 2020-04-30
1043
                            me.device.knobs.FmsInner = func;
1044
                            foreach (var b; ['ENT', 'CLR'])
1045
                                me.device.buttons[b] = func;
1046
                            me.device.buttons.MENU = func;
1047
                        }
1048
                        me.device.windows.draw(id, {autogeom: 1}, obj_infos);
1049
                    }
1050

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

            
fix some issues with checkli...
Sébastien MARQUE authored on 2020-06-23
1054
                    var windowId = 'CHKLIST LIST';
add checklists management
Sébastien MARQUE authored on 2020-04-30
1055
                    var obj_infos = [];
1056
                    var firstEntry = 1;
1057
                    var groups = props.globals.getNode("/sim/checklists").getChildren("group");
1058
                    var groupsQty = size(groups);
1059

            
1060
                    if (groupsQty) {
1061
                        forindex (var g; groups) {
1062
                            # emergency checklists are listed in their own menu
1063
                            if (string.uc(groups[g].getValue('name')) == 'EMERGENCY') {
1064
                                groupsQty -= 1;
1065
                                continue;
1066
                            }
1067
                            # the key groupIndex isn't used by the display system
1068
                            # we use it to keep the information of group node's index
1069
                            append(obj_infos, {
1070
                                text: groups[g].getValue('name'),
1071
                                groupIndex: g,
1072
                                type: (firstEntry ? 'selected' : 'editable') ~ '|end-of-line',
1073
                                callback: func (id, selected) listChecklists(id, selected) });
1074
                            firstEntry = 0;
1075
                            # if there are only one group left, let display it directly
1076
                            if (groupsQty == 1) {
1077
                                listChecklists(windowId, 0);
1078
                                return;
1079
                            }
1080
                            elsif (groupsQty == 0) {
1081
                                return;
1082
                            }
1083
                        }
1084
                    }
1085
                    else {
1086
                        listChecklists(windowId, -1);
1087
                        return;
1088
                    }
1089

            
1090
                    me.device.knobs.FmsInner = me.device.knobs.NavigateMenu;
1091
                    me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu;
1092
                    me.device.buttons.ENT    = me.device.buttons.ValidateTMRREF;
1093
                    me.device.buttons.CLR = func {
1094
                        me.device.windows.del(windowId);
fix some issues with checkli...
Sébastien MARQUE authored on 2020-06-23
1095
                        me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group;
add checklists management
Sébastien MARQUE authored on 2020-04-30
1096
                        me.device.knobs.FmsInner = func;
1097
                        foreach (var b; ['ENT', 'CLR'])
1098
                            me.device.buttons[b] = func;
1099
                        me.device.buttons.MENU = func;
1100
                    }
1101
                    me.device.windows.draw(windowId, {autogeom: 1}, obj_infos);
1102
                },
1103
                EMERGCY: func {
1104
                    # nested function as checklist lists may be organized by group
1105
                    var listChecklists = func (groupIndex) {
1106
                        var checklists = [];
1107
                        var firstEntry = 1;
1108
                        if (groupIndex == -1)
1109
                            checklists = props.globals.getNode("/sim/checklists")
1110
                                            .getChildren('checklist');
1111
                        else
1112
                            checklists = props.globals.getNode("/sim/checklists")
1113
                                            .getChild("group", groupIndex)
1114
                                            .getChildren('checklist');
1115
                        var checklistsQty = size(checklists);
1116
                        var obj_infos = [];
1117
                        var firstEntry = 1;
1118

            
1119
                        if (checklistsQty) {
1120
                            forindex (var c; checklists) {
1121
                                if (groupIndex < 0 and string.uc(checklists[c].getValue('title')) != 'EMERGENCY') {
1122
                                    checklistsQty -= 1;
1123
                                    continue;
1124
                                }
1125
                                append(obj_infos, {
1126
                                    text: checklists[c].getValue('title'),
1127
                                    groupIndex: groupIndex,
1128
                                    checklistIndex: c,
1129
                                    type: (firstEntry ? 'selected' : 'editable') ~ '|end-of-line',
1130
                                    callback: func (id, selected) call(me.device.softkeys.bindings.MFD.CHKLIST._showCheckList, [id, selected], me)
1131
                                });
1132
                                firstEntry = 0;
1133
                            }
1134
                        }
1135
                        id = 'EMERGENCY CHECKLISTS';
1136
                        me.device.knobs.FmsInner = me.device.knobs.NavigateMenu;
1137
                        me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu;
1138
                        me.device.buttons.ENT    = me.device.buttons.ValidateTMRREF;
1139
                        me.device.buttons.CLR = func {
1140
                            me.device.windows.del(id);
fix some issues with checkli...
Sébastien MARQUE authored on 2020-06-23
1141
                            me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group;
add checklists management
Sébastien MARQUE authored on 2020-04-30
1142
                            me.device.knobs.FmsInner = func;
1143
                            foreach (var b; ['ENT', 'CLR'])
1144
                                me.device.buttons[b] = func;
1145
                            me.device.buttons.MENU = func;
1146
                        }
1147
                        me.device.windows.draw(id, {autogeom: 1}, obj_infos);
1148
                        if (checklistsQty == 1) { # see comments below for groups
1149
                            call(me.device.softkeys.bindings.MFD.CHKLIST._showCheckList, [groupIndex, 0], me);
1150
                            return;
1151
                        }
1152
                        elsif (checklistsQty == 0)
1153
                            call(me.device.buttons.CLR, [0], me);
1154
                            return;
1155
                    }
1156

            
1157
                    var windowId = 'CHKLIST EMERGCY';
1158
                    if (contains(me.device.windows.state, windowId))
1159
                        me.device.windows.del(windowId);
1160

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

            
1163
                    var emergency_group_found = 0;
1164
                    if (size(groups)) {
1165
                        forindex (var g; groups) {
1166
                            # emergency checklists are listed in their own menu
1167
                            # we support only one emergency checklists group named EMERGENCY (case insensitive)
1168
                            if (string.uc(groups[g].getValue('name')) != 'EMERGENCY')
1169
                                continue;
1170
                            listChecklists(g);
1171
                            emergency_group_found = !emergency_group_found;
1172
                            break;
1173
                        }
1174
                    }
1175

            
1176
                    if (!emergency_group_found)
1177
                        listChecklists(-1);
1178
                },
add missing exit to MFD/CHKL...
Sébastien MARQUE authored on 2017-03-20
1179
                EXIT: func {
1180
                    me.path = [];
1181
                    me.device.display.updateSoftKeys();
1182
                },
1183
            },
add TCAS
Sébastien MARQUE authored on 2017-12-21
1184
            MAP: {
1185
                TRAFFIC: func {
improve the selection of dis...
Sébastien MARQUE authored on 2017-12-30
1186
                    call(me.bindings.PFD.INSET.declutter, ['MAPTRAFFIC', 'tcas', 0], me);
1187
                },
1188
                ROUTE: func {
1189
                    call(me.bindings.PFD.INSET.declutter, ['MAPROUTE', 'route', 1], me);
1190
                },
1191
                TERRAIN: func {
1192
                    call(me.bindings.PFD.INSET.declutter, ['MAPTERRAIN', 'tiles', 3], me);
1193
                },
topo display is now availabl...
Sébastien MARQUE authored on 2020-06-14
1194
                TOPO: func {
1195
                    call(me.bindings.PFD.INSET.declutter, ['MAPTOPO', 'topo', 7], me);
1196
                },
improve the selection of dis...
Sébastien MARQUE authored on 2017-12-30
1197
                NAVAIDS: {
1198
                    ALL: func {
1199
                        call(me.bindings.PFD.INSET.NAVAIDS.ALL, [ 'MAPNAVAIDS' ], me);
1200
                    },
1201
                    VOR: func {
1202
                        call(me.bindings.PFD.INSET.NAVAIDS.declutter, ['MAPNAVAIDSVOR', 'VOR', 2], me);
1203
                    },
1204
                    TACAN: func {
1205
                        call(me.bindings.PFD.INSET.NAVAIDS.declutter, ['MAPNAVAIDSTACAN', 'TACAN', 3], me);
1206
                    },
1207
                    NDB: func {
1208
                        call(me.bindings.PFD.INSET.NAVAIDS.declutter, ['MAPNAVAIDSNDB', 'NDB', 4], me);
1209
                    },
1210
                    DME: func {
1211
                        call(me.bindings.PFD.INSET.NAVAIDS.declutter, ['MAPNAVAIDSDME', 'DME', 5], me);
1212
                    },
1213
                    APT: func {
1214
                        call(me.bindings.PFD.INSET.NAVAIDS.declutter, ['MAPNAVAIDSAPT', 'airport', 6], me);
1215
                    },
add TCAS
Sébastien MARQUE authored on 2017-12-21
1216
                },
1217
            },
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
1218
        },
commit initial
Sébastien MARQUE authored on 2017-03-07
1219
    },
1220
};
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
1221

            
1222
var keyMap = {
vim folds
Sébastien MARQUE authored on 2017-12-21
1223
# softkeys map for PFD and MFD {{{1
1224
# PFD {{{2
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
1225
    PFD : {
1226
        first : 1,
1227
        texts : ['INSET', 'SENSOR', 'PFD', 'OBS', 'CDI', 'DME', 'XPDR', 'IDENT', 'TMR/REF', 'NRST' ],
1228
        INSET : {
removes traffic from PFD ins...
Sébastien MARQUE authored on 2020-06-14
1229
            texts : ['OFF', '', '', 'ROUTE', '', 'TERRAIN', 'NAVAIDS', 'METAR'],
improve the selection of dis...
Sébastien MARQUE authored on 2017-12-30
1230
            NAVAIDS : {
1231
                first : 2,
1232
                texts : ['VOR', 'TACAN', 'NDB', 'DME', 'APT', '', 'ALL'],
1233
            },
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
1234
        },
1235
        SENSOR : {
1236
            first : 2,
1237
            texts : [ 'ADC1', 'ADC2', '', 'AHRS1', 'AHRS2'],
1238
        },
1239
        PFD : {
1240
            texts : [ 'SYN VIS', 'DFLTS', 'AOA/WIND', 'DME', 'BRG1', 'HSI FMT', 'BRG2', '', 'ALT UNIT', 'STD BARO' ],
1241
            'SYN VIS' : {
1242
                texts : [ 'PATHWAY', 'SYN TERR', 'HR2NHDG', 'APTSIGNS', 'FPM'],
1243
            },
1244
            'AOA/WIND' : {
1245
                first : 4,
1246
                texts : ['AOA', 'WIND'],
1247
                AOA : {
1248
                    first : 5,
1249
                    texts : ['AOA ON', 'AOA AUTO'],
1250
                },
1251
                WIND : {
1252
                    first : 2,
1253
                    texts : ['OPTN1', 'OPTN2', '', 'OFF'],
1254
                },
1255
            },
1256
            'HSI FMT' : {
1257
                first : 6,
1258
                texts : ['360 HSI', 'ARC HSI'],
1259
            },
1260
            'ALT UNIT' : {
1261
                first : 5,
1262
                texts : ['METERS', '', 'IN', 'HPA'],
1263
            },
1264
        },
1265
        XPDR : {
1266
            first : 2,
1267
            texts : ['STBY', 'ON', 'ALT', '', 'VFR', 'CODE', 'IDENT'],
1268
            CODE : {
1269
                texts : ['0', '1', '2', '3', '4', '5', '6', '7', 'IDENT', 'BKSP'],
1270
            },
1271
        },
add PFD/NRST softkey
Sébastien MARQUE authored on 2020-05-16
1272
        NRST : {
1273
            first : 4,
1274
            texts : ['OMNI', 'REAR', 'FRONT', 'LEFT', 'RIGHT', 'RANGE'],
1275
            RANGE : {
1276
                first : 7,
1277
                texts : ['MIN', 'MAX' ],
1278
                MIN : { first: 3, texts : ['0NM',   '10NM',  '30NM',  '50NM'] },
fix typo
Sébastien MARQUE authored on 2020-06-11
1279
                MAX : { first: 3, texts : ['200NM', '150NM', '100NM', '50NM'] },
add PFD/NRST softkey
Sébastien MARQUE authored on 2020-05-16
1280
            },
adds NRST/COMMS
Sébastien MARQUE authored on 2020-05-18
1281
            OMNI : { texts: ['NDB', 'FIX', 'VOR', 'APT', '', '', '', '', '', 'COMM'] }, # that will be mirrored later
add PFD/NRST softkey
Sébastien MARQUE authored on 2020-05-16
1282
        },
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
1283
    },
vim folds
Sébastien MARQUE authored on 2017-12-21
1284
#}}}2
1285
# MFD {{{2
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
1286
    MFD : {
1287
        texts : ['ENGINE', '', 'MAP', '', '', '', '', '', '', 'DCLTR', 'SHW CHRT', 'CHKLIST'],
1288
        MAP : {
improve the selection of dis...
Sébastien MARQUE authored on 2017-12-30
1289
            texts : ['TRAFFIC', 'ROUTE', 'TOPO', 'TERRAIN', 'NAVAIDS', '','', '', '', '', 'BACK'],
1290
            NAVAIDS : {
1291
                first : 2,
1292
                texts : ['VOR', 'TACAN', 'NDB', 'DME', 'APT', '', 'ALL', '', '', 'BACK' ],
1293
            },
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
1294
        },
1295
        CHKLIST : {
add checklists management
Sébastien MARQUE authored on 2020-04-30
1296
            texts : ['ENGINE', '', '', '', 'LIST', 'DONE', '', '', '', '', 'EXIT', 'EMERGCY'],
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
1297
        },
1298
        ENGINE : {
1299
            texts : ['ENGINE', 'ANTI-ICE', '', 'DCLTR', '', 'ASSIST', '', '', '', '', 'FUEL'],
1300
            'ANTI-ICE' : {
1301
                texts : ['LEFT', 'AUTO', 'RIGHT', '', '', '', '', '', '', '', '', 'BACK'],
1302
            },
1303
            FUEL : {
1304
                first : 1,
1305
                texts : ['FULL', 'TABS', '', '', '', '', '', '', '', 'UNDO', 'ENTER'],
1306
            },
1307
        },
1308
    },
vim folds
Sébastien MARQUE authored on 2017-12-21
1309
#}}}2
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
1310
};
1311
if (data['stall-aoa'] == 9999)
1312
    keyMap.PFD.PFD['AOA/WIND'].texts = ['', 'WIND'];
add checklists management
Sébastien MARQUE authored on 2020-04-30
1313
if (props.globals.getNode('/sim/checklists') == nil) {
1314
    keyMap.MFD.texts[11] = '';
1315
    delete(keyMap.MFD, 'CHKLIST');
1316
}
add PFD/NRST softkey
Sébastien MARQUE authored on 2020-05-16
1317
foreach (var d; ['FRONT', 'REAR', 'LEFT', 'RIGHT']) {
1318
    keyMap.PFD.NRST[d] = keyMap.PFD.NRST.OMNI;
1319
}
vim folds
Sébastien MARQUE authored on 2017-12-21
1320
#}}}1