zkv1000 / Nasal / softkeys.nas /
Newer Older
1337 lines | 70.04kb
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') {
fix navaids softkey display
Sébastien MARQUE authored on 2021-04-11
107
                        if (contains(me.colored, root_id ~ 'ALL')) {
improve the selection of dis...
Sébastien MARQUE authored on 2017-12-30
108
                            foreach (var n; [ 'ALL', 'VOR', 'DME', 'NDB', 'TACAN', 'APT' ])
109
                                delete(me.colored, root_id ~ n);
fix navaids softkey display
Sébastien MARQUE authored on 2021-04-11
110
                            delete(me.colored, root_id);
111
                        }
112
                        else {
improve the selection of dis...
Sébastien MARQUE authored on 2017-12-30
113
                            foreach (var n; [ 'ALL', 'VOR', 'DME', 'NDB', 'TACAN', 'APT' ])
114
                                me.colored[root_id ~ n] = 1;
fix navaids softkey display
Sébastien MARQUE authored on 2021-04-11
115
                            me.colored[root_id] = 1;
116
                        }
improve the selection of dis...
Sébastien MARQUE authored on 2017-12-30
117
                        me.device.display.updateSoftKeys();
118
                        foreach (var n; [ 'VOR', 'TACAN', 'NDB', 'DME' ])
119
                            me.device.map.layers.navaids._can[n]
120
                                .setVisible(contains(me.colored, root_id ~ n));
121
                        me.device.map.layers.navaids._can.airport
122
                            .setVisible(contains(me.colored, root_id ~ 'APT'));
123
                    },
124
                    VOR: func {
simplify navaids declutterin...
Sébastien MARQUE authored on 2021-04-12
125
                        call(me.bindings.PFD.INSET.NAVAIDS.declutter, [ 'VOR' ], me);
improve the selection of dis...
Sébastien MARQUE authored on 2017-12-30
126
                    },
127
                    TACAN: func {
simplify navaids declutterin...
Sébastien MARQUE authored on 2021-04-12
128
                        call(me.bindings.PFD.INSET.NAVAIDS.declutter, [ 'TACAN' ], me);
improve the selection of dis...
Sébastien MARQUE authored on 2017-12-30
129
                    },
130
                    NDB: func {
simplify navaids declutterin...
Sébastien MARQUE authored on 2021-04-12
131
                        call(me.bindings.PFD.INSET.NAVAIDS.declutter, [ 'NDB' ], me);
improve the selection of dis...
Sébastien MARQUE authored on 2017-12-30
132
                    },
133
                    DME: func {
simplify navaids declutterin...
Sébastien MARQUE authored on 2021-04-12
134
                        call(me.bindings.PFD.INSET.NAVAIDS.declutter, [ 'DME' ], me);
improve the selection of dis...
Sébastien MARQUE authored on 2017-12-30
135
                    },
136
                    APT: func {
simplify navaids declutterin...
Sébastien MARQUE authored on 2021-04-12
137
                        call(me.bindings.PFD.INSET.NAVAIDS.declutter, [ 'APT' ], me);
improve the selection of dis...
Sébastien MARQUE authored on 2017-12-30
138
                    },
simplify navaids declutterin...
Sébastien MARQUE authored on 2021-04-12
139
                    declutter: func (id) {
fix navaids softkey display
Sébastien MARQUE authored on 2021-04-11
140
                        var root_id = (me.device.role == 'PFD' ? 'INSET' : 'MAP') ~ 'NAVAIDS';
simplify navaids declutterin...
Sébastien MARQUE authored on 2021-04-12
141
                        if (contains(me.colored, root_id ~ id)) {
142
                            delete(me.colored, root_id ~ id);
fix navaids softkey display
Sébastien MARQUE authored on 2021-04-11
143
                            delete(me.colored, root_id ~ 'ALL');
improve the selection of dis...
Sébastien MARQUE authored on 2017-12-30
144
                        }
145
                        else
simplify navaids declutterin...
Sébastien MARQUE authored on 2021-04-12
146
                            me.colored[root_id ~ id] = 1;
fix navaids softkey display
Sébastien MARQUE authored on 2021-04-11
147

            
148
                        var active_navaids = 0;
149
                        foreach (var n; [ 'VOR', 'DME', 'NDB', 'TACAN', 'APT' ])
150
                            active_navaids += contains(me.colored, root_id ~ n);
151

            
152
                        if (active_navaids < 5)
153
                            delete(me.colored, root_id ~ 'ALL');
154
                        else
155
                            me.colored[root_id ~ 'ALL'] = 1;
156

            
157
                        if (active_navaids > 0)
158
                            me.colored[root_id] = 1;
159
                        else
160
                            delete(me.colored, root_id);
161

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

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

            
731
                            if (size(TWR_list) < 4
732
                            and string.match(c.ident, '*TWR*'))
733
                                append(TWR_list, [r.id, c.frequency, course, dist]);
734

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

            
882
                    var groupIndex     = me.device.windows.state[id].objects[selected].groupIndex;
883
                    var checklistIndex = me.device.windows.state[id].objects[selected].checklistIndex;
884

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

            
890
                    var title = '';
891
                    if (contains(me.device.windows.state[id].objects[selected], 'checklistTitle'))
fix some issues with checkli...
Sébastien MARQUE authored on 2020-06-23
892
                        var title = me.device.windows.state[id].objects[selected].checklistTitle;
add checklists management
Sébastien MARQUE authored on 2020-04-30
893
                    else
fix some issues with checkli...
Sébastien MARQUE authored on 2020-06-23
894
                        var title = me.device.windows.state[id].objects[selected].text;
add checklists management
Sébastien MARQUE authored on 2020-04-30
895

            
896
                    me.device.windows.del(id);
897

            
898
                    if (groupIndex < 0)
899
                         checklistNode = props.globals.getNode("/sim/checklists")
900
                                    .getChild('checklist', checklistIndex);
901
                    else
902
                         checklistNode = props.globals.getNode("/sim/checklists")
903
                                    .getChild("group", groupIndex)
904
                                    .getChild('checklist', checklistIndex);
905

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

            
910
                    if (size(pages) and pageIndex == -1)
911
                        pageIndex = 0;
912

            
913
                    _previous_text = ' < PREVIOUS ';
914
                    _next_text     = ' NEXT > ';
915

            
916
                    var obj_infos = [];
917
                    var length = size(_previous_text ~ _next_text);
918
                    var length_cache = [];
919
                    if (size(pages))
920
                        checklistNode = pages[pageIndex];
921

            
922
                    append(obj_infos, {
923
                        text: sprintf('%s%s',
924
                                      title,
925
                                      size(pages) > 1 ? sprintf(' %d / %d',
926
                                                                pageIndex + 1,
927
                                                                size(pages)) : ''),
928
                        type: 'title'
929
                    });
930

            
931
                    append(obj_infos, {type: 'separator'});
932

            
933
                    forindex (var i; checklistNode.getChildren('item')) {
934
                        var l = size(checklistNode.getChild('item', i).getValue('name'));
935
                        if (checklistNode.getChild('item', i).getChild('value') != nil)
936
                            l += size(checklistNode.getChild('item', i).getValue('value'));
937
                        append(length_cache, l);
938
                        if (l > length)
939
                            length = l;
940
                    }
941

            
942
                    forindex (var i; checklistNode.getChildren('item')) {
943
                        var text = pages[pageIndex].getChild('item', i).getValue('name');
944
                        var item_val = '';
945
                        if (pages[pageIndex].getChild('item', i).getChild('value') != nil)
946
                            item_val = pages[pageIndex].getChild('item', i).getValue('value');
947
                        if (item_val != '')
948
                            text ~= tabulate(length, length_cache[i]);
949
                        text ~= item_val;
950

            
951
                        append(obj_infos, {
952
                            text: text,
953
                            groupIndex: groupIndex,
954
                            checklistIndex: checklistIndex,
955
                            pageIndex: pageIndex,
956
                            type: 'normal|end-of-line'
957
                        });
958
                    }
959

            
960
                    append(obj_infos, {type: 'separator'});
961

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

            
978
                    if (pageIndex + 1 < size(pages)) {
979
                        if (pageIndex and size(pages))
980
                            append(obj_infos, {
981
                                text: tabulate(length, size(_previous_text ~ _next_text), 0, ' '),
982
                                type: 'normal',
983
                            });
984
                        append(obj_infos, {
985
                                text: _next_text,
986
                                groupIndex: groupIndex,
987
                                checklistIndex: checklistIndex,
988
                                pageIndex: pageIndex + 1,
989
                                checklistTitle: title,
990
                                type: 'selected|end-of-line',
991
                                callback: func (id, selected) call(me.device.softkeys.bindings.MFD.CHKLIST._showCheckList, [id, selected], me)
992
                        });
993
                    }
994

            
995
                    me.device.knobs.FmsInner = me.device.knobs.NavigateMenu;
996
                    me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu;
997
                    me.device.buttons.ENT    = me.device.buttons.ValidateTMRREF;
998
                    me.device.buttons.CLR = func {
999
                        me.device.windows.del(id);
fix some issues with checkli...
Sébastien MARQUE authored on 2020-06-23
1000
                        me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group;
add checklists management
Sébastien MARQUE authored on 2020-04-30
1001
                        me.device.knobs.FmsInner = func;
1002
                        foreach (var b; ['ENT', 'CLR'])
1003
                            me.device.buttons[b] = func;
1004
                        me.device.buttons.MENU = func;
1005
                    }
1006
                    me.device.windows.draw( id, {autogeom: 1}, obj_infos );
1007
                },
1008
                LIST: func {
1009
                    # nested function as checklist lists may be organized by group
1010
                    var listChecklists = func (id, selected) {
1011
                        var checklists = [];
1012
                        var firstEntry = 1;
fix some issues with checkli...
Sébastien MARQUE authored on 2020-06-23
1013
                        if (selected < 0) {
add checklists management
Sébastien MARQUE authored on 2020-04-30
1014
                            checklists = props.globals.getNode("/sim/checklists")
1015
                                            .getChildren('checklist');
fix some issues with checkli...
Sébastien MARQUE authored on 2020-06-23
1016
                            var groupIndex = -1;
1017
                        }
1018
                        else {
1019
                            var groupIndex = me.device.windows.state[id].objects[selected].groupIndex;
1020
                            me.device.windows.del(id);
add checklists management
Sébastien MARQUE authored on 2020-04-30
1021
                            checklists = props.globals.getNode("/sim/checklists")
1022
                                            .getChild("group", groupIndex)
1023
                                            .getChildren('checklist');
fix some issues with checkli...
Sébastien MARQUE authored on 2020-06-23
1024
                        }
add checklists management
Sébastien MARQUE authored on 2020-04-30
1025
                        var checklistsQty = size(checklists);
1026
                        var obj_infos = [];
1027

            
1028
                        if (checklistsQty) {
1029
                            forindex (var c; checklists) {
1030
                                if (string.uc(checklists[c].getValue('title')) == 'EMERGENCY') {
1031
                                    checklistsQty -= 1;
1032
                                    continue;
1033
                                }
1034
                                var title = checklists[c].getValue('title');
1035
                                append(obj_infos, {
1036
                                    text: title,
1037
                                    groupIndex: groupIndex,
1038
                                    checklistIndex: c,
1039
                                    checklistTitle: title,
1040
                                    type: (firstEntry ? 'selected' : 'editable') ~ '|end-of-line',
1041
                                    callback: func (id, selected) call(me.device.softkeys.bindings.MFD.CHKLIST._showCheckList, [id, selected], me)
1042
                                });
1043
                                if (checklistsQty == 1) { # see comments below for groups
1044
                                    call(me.device.softkeys.bindings.MFD.CHKLIST._showCheckList, [groupIndex, 0], me);
1045
                                    return;
1046
                                }
1047
                                elsif (checklistsQty == 0)
1048
                                    return;
1049
                                firstEntry = 0;
1050
                            }
1051
                        }
1052

            
1053
                        id ~= ' CHECKLISTS';
1054
                        me.device.knobs.FmsInner = me.device.knobs.NavigateMenu;
1055
                        me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu;
1056
                        me.device.buttons.ENT    = me.device.buttons.ValidateTMRREF;
1057
                        me.device.buttons.CLR = func {
1058
                            me.device.windows.del(id);
fix some issues with checkli...
Sébastien MARQUE authored on 2020-06-23
1059
                            me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group;
add checklists management
Sébastien MARQUE authored on 2020-04-30
1060
                            me.device.knobs.FmsInner = func;
1061
                            foreach (var b; ['ENT', 'CLR'])
1062
                                me.device.buttons[b] = func;
1063
                            me.device.buttons.MENU = func;
1064
                        }
1065
                        me.device.windows.draw(id, {autogeom: 1}, obj_infos);
1066
                    }
1067

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

            
fix some issues with checkli...
Sébastien MARQUE authored on 2020-06-23
1071
                    var windowId = 'CHKLIST LIST';
add checklists management
Sébastien MARQUE authored on 2020-04-30
1072
                    var obj_infos = [];
1073
                    var firstEntry = 1;
1074
                    var groups = props.globals.getNode("/sim/checklists").getChildren("group");
1075
                    var groupsQty = size(groups);
1076

            
1077
                    if (groupsQty) {
1078
                        forindex (var g; groups) {
1079
                            # emergency checklists are listed in their own menu
1080
                            if (string.uc(groups[g].getValue('name')) == 'EMERGENCY') {
1081
                                groupsQty -= 1;
1082
                                continue;
1083
                            }
1084
                            # the key groupIndex isn't used by the display system
1085
                            # we use it to keep the information of group node's index
1086
                            append(obj_infos, {
1087
                                text: groups[g].getValue('name'),
1088
                                groupIndex: g,
1089
                                type: (firstEntry ? 'selected' : 'editable') ~ '|end-of-line',
1090
                                callback: func (id, selected) listChecklists(id, selected) });
1091
                            firstEntry = 0;
1092
                            # if there are only one group left, let display it directly
1093
                            if (groupsQty == 1) {
1094
                                listChecklists(windowId, 0);
1095
                                return;
1096
                            }
1097
                            elsif (groupsQty == 0) {
1098
                                return;
1099
                            }
1100
                        }
1101
                    }
1102
                    else {
1103
                        listChecklists(windowId, -1);
1104
                        return;
1105
                    }
1106

            
1107
                    me.device.knobs.FmsInner = me.device.knobs.NavigateMenu;
1108
                    me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu;
1109
                    me.device.buttons.ENT    = me.device.buttons.ValidateTMRREF;
1110
                    me.device.buttons.CLR = func {
1111
                        me.device.windows.del(windowId);
fix some issues with checkli...
Sébastien MARQUE authored on 2020-06-23
1112
                        me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group;
add checklists management
Sébastien MARQUE authored on 2020-04-30
1113
                        me.device.knobs.FmsInner = func;
1114
                        foreach (var b; ['ENT', 'CLR'])
1115
                            me.device.buttons[b] = func;
1116
                        me.device.buttons.MENU = func;
1117
                    }
1118
                    me.device.windows.draw(windowId, {autogeom: 1}, obj_infos);
1119
                },
1120
                EMERGCY: func {
1121
                    # nested function as checklist lists may be organized by group
1122
                    var listChecklists = func (groupIndex) {
1123
                        var checklists = [];
1124
                        var firstEntry = 1;
1125
                        if (groupIndex == -1)
1126
                            checklists = props.globals.getNode("/sim/checklists")
1127
                                            .getChildren('checklist');
1128
                        else
1129
                            checklists = props.globals.getNode("/sim/checklists")
1130
                                            .getChild("group", groupIndex)
1131
                                            .getChildren('checklist');
1132
                        var checklistsQty = size(checklists);
1133
                        var obj_infos = [];
1134
                        var firstEntry = 1;
1135

            
1136
                        if (checklistsQty) {
1137
                            forindex (var c; checklists) {
1138
                                if (groupIndex < 0 and string.uc(checklists[c].getValue('title')) != 'EMERGENCY') {
1139
                                    checklistsQty -= 1;
1140
                                    continue;
1141
                                }
1142
                                append(obj_infos, {
1143
                                    text: checklists[c].getValue('title'),
1144
                                    groupIndex: groupIndex,
1145
                                    checklistIndex: c,
1146
                                    type: (firstEntry ? 'selected' : 'editable') ~ '|end-of-line',
1147
                                    callback: func (id, selected) call(me.device.softkeys.bindings.MFD.CHKLIST._showCheckList, [id, selected], me)
1148
                                });
1149
                                firstEntry = 0;
1150
                            }
1151
                        }
1152
                        id = 'EMERGENCY CHECKLISTS';
1153
                        me.device.knobs.FmsInner = me.device.knobs.NavigateMenu;
1154
                        me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu;
1155
                        me.device.buttons.ENT    = me.device.buttons.ValidateTMRREF;
1156
                        me.device.buttons.CLR = func {
1157
                            me.device.windows.del(id);
fix some issues with checkli...
Sébastien MARQUE authored on 2020-06-23
1158
                            me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group;
add checklists management
Sébastien MARQUE authored on 2020-04-30
1159
                            me.device.knobs.FmsInner = func;
1160
                            foreach (var b; ['ENT', 'CLR'])
1161
                                me.device.buttons[b] = func;
1162
                            me.device.buttons.MENU = func;
1163
                        }
1164
                        me.device.windows.draw(id, {autogeom: 1}, obj_infos);
1165
                        if (checklistsQty == 1) { # see comments below for groups
1166
                            call(me.device.softkeys.bindings.MFD.CHKLIST._showCheckList, [groupIndex, 0], me);
1167
                            return;
1168
                        }
1169
                        elsif (checklistsQty == 0)
1170
                            call(me.device.buttons.CLR, [0], me);
1171
                            return;
1172
                    }
1173

            
1174
                    var windowId = 'CHKLIST EMERGCY';
1175
                    if (contains(me.device.windows.state, windowId))
1176
                        me.device.windows.del(windowId);
1177

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

            
1180
                    var emergency_group_found = 0;
1181
                    if (size(groups)) {
1182
                        forindex (var g; groups) {
1183
                            # emergency checklists are listed in their own menu
1184
                            # we support only one emergency checklists group named EMERGENCY (case insensitive)
1185
                            if (string.uc(groups[g].getValue('name')) != 'EMERGENCY')
1186
                                continue;
1187
                            listChecklists(g);
1188
                            emergency_group_found = !emergency_group_found;
1189
                            break;
1190
                        }
1191
                    }
1192

            
1193
                    if (!emergency_group_found)
1194
                        listChecklists(-1);
1195
                },
add missing exit to MFD/CHKL...
Sébastien MARQUE authored on 2017-03-20
1196
                EXIT: func {
1197
                    me.path = [];
1198
                    me.device.display.updateSoftKeys();
1199
                },
1200
            },
add TCAS
Sébastien MARQUE authored on 2017-12-21
1201
            MAP: {
1202
                TRAFFIC: func {
improve the selection of dis...
Sébastien MARQUE authored on 2017-12-30
1203
                    call(me.bindings.PFD.INSET.declutter, ['MAPTRAFFIC', 'tcas', 0], me);
1204
                },
1205
                ROUTE: func {
1206
                    call(me.bindings.PFD.INSET.declutter, ['MAPROUTE', 'route', 1], me);
1207
                },
1208
                TERRAIN: func {
1209
                    call(me.bindings.PFD.INSET.declutter, ['MAPTERRAIN', 'tiles', 3], me);
1210
                },
topo display is now availabl...
Sébastien MARQUE authored on 2020-06-14
1211
                TOPO: func {
1212
                    call(me.bindings.PFD.INSET.declutter, ['MAPTOPO', 'topo', 7], me);
1213
                },
improve the selection of dis...
Sébastien MARQUE authored on 2017-12-30
1214
                NAVAIDS: {
1215
                    ALL: func {
1216
                        call(me.bindings.PFD.INSET.NAVAIDS.ALL, [ 'MAPNAVAIDS' ], me);
1217
                    },
1218
                    VOR: func {
simplify navaids declutterin...
Sébastien MARQUE authored on 2021-04-12
1219
                        call(me.bindings.PFD.INSET.NAVAIDS.declutter, [ 'VOR' ], me);
improve the selection of dis...
Sébastien MARQUE authored on 2017-12-30
1220
                    },
1221
                    TACAN: func {
simplify navaids declutterin...
Sébastien MARQUE authored on 2021-04-12
1222
                        call(me.bindings.PFD.INSET.NAVAIDS.declutter, [ 'TACAN' ], me);
improve the selection of dis...
Sébastien MARQUE authored on 2017-12-30
1223
                    },
1224
                    NDB: func {
simplify navaids declutterin...
Sébastien MARQUE authored on 2021-04-12
1225
                        call(me.bindings.PFD.INSET.NAVAIDS.declutter, [ 'NDB' ], me);
improve the selection of dis...
Sébastien MARQUE authored on 2017-12-30
1226
                    },
1227
                    DME: func {
simplify navaids declutterin...
Sébastien MARQUE authored on 2021-04-12
1228
                        call(me.bindings.PFD.INSET.NAVAIDS.declutter, [ 'DME' ], me);
improve the selection of dis...
Sébastien MARQUE authored on 2017-12-30
1229
                    },
1230
                    APT: func {
simplify navaids declutterin...
Sébastien MARQUE authored on 2021-04-12
1231
                        call(me.bindings.PFD.INSET.NAVAIDS.declutter, ['APT' ], me);
improve the selection of dis...
Sébastien MARQUE authored on 2017-12-30
1232
                    },
add TCAS
Sébastien MARQUE authored on 2017-12-21
1233
                },
1234
            },
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
1235
        },
commit initial
Sébastien MARQUE authored on 2017-03-07
1236
    },
1237
};
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
1238

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