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

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

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

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

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

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

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

            
502
var keyMap = {
503
# softkeys map for PFD and MFD {{{
504
    PFD : {
505
        first : 1,
506
        texts : ['INSET', 'SENSOR', 'PFD', 'OBS', 'CDI', 'DME', 'XPDR', 'IDENT', 'TMR/REF', 'NRST' ],
507
        INSET : {
508
            texts : ['OFF', 'DCLTR', 'WXLGND', 'TRAFFIC', 'TOPO', 'TERRAIN', 'STRMSCP', 'NEXRAD-C', 'XM LTNG', 'METAR'],
509
        },
510
        SENSOR : {
511
            first : 2,
512
            texts : [ 'ADC1', 'ADC2', '', 'AHRS1', 'AHRS2'],
513
        },
514
        PFD : {
515
            texts : [ 'SYN VIS', 'DFLTS', 'AOA/WIND', 'DME', 'BRG1', 'HSI FMT', 'BRG2', '', 'ALT UNIT', 'STD BARO' ],
516
            'SYN VIS' : {
517
                texts : [ 'PATHWAY', 'SYN TERR', 'HR2NHDG', 'APTSIGNS', 'FPM'],
518
            },
519
            'AOA/WIND' : {
520
                first : 4,
521
                texts : ['AOA', 'WIND'],
522
                AOA : {
523
                    first : 5,
524
                    texts : ['AOA ON', 'AOA AUTO'],
525
                },
526
                WIND : {
527
                    first : 2,
528
                    texts : ['OPTN1', 'OPTN2', '', 'OFF'],
529
                },
530
            },
531
            'HSI FMT' : {
532
                first : 6,
533
                texts : ['360 HSI', 'ARC HSI'],
534
            },
535
            'ALT UNIT' : {
536
                first : 5,
537
                texts : ['METERS', '', 'IN', 'HPA'],
538
            },
539
        },
540
        XPDR : {
541
            first : 2,
542
            texts : ['STBY', 'ON', 'ALT', '', 'VFR', 'CODE', 'IDENT'],
543
            CODE : {
544
                texts : ['0', '1', '2', '3', '4', '5', '6', '7', 'IDENT', 'BKSP'],
545
            },
546
        },
547
    },
548
    MFD : {
549
        texts : ['ENGINE', '', 'MAP', '', '', '', '', '', '', 'DCLTR', 'SHW CHRT', 'CHKLIST'],
550
        MAP : {
551
            texts: ['TRAFFIC', 'PROFILE', 'TOPO', 'TERRAIN', 'AIRWAYS', 'STRMSCP','NEXRAD-C', 'XM LTNG', 'METAR', 'LEGEND', 'BACK'],
552
        },
553
        CHKLIST : {
554
            texts : ['ENGINE', '', '', '', '', 'DONE', '', '', '', '', 'EXIT', 'EMERGCY'],
555
        },
556
        ENGINE : {
557
            texts : ['ENGINE', 'ANTI-ICE', '', 'DCLTR', '', 'ASSIST', '', '', '', '', 'FUEL'],
558
            'ANTI-ICE' : {
559
                texts : ['LEFT', 'AUTO', 'RIGHT', '', '', '', '', '', '', '', '', 'BACK'],
560
            },
561
            FUEL : {
562
                first : 1,
563
                texts : ['FULL', 'TABS', '', '', '', '', '', '', '', 'UNDO', 'ENTER'],
564
            },
565
        },
566
    },
567
};
568
if (data['stall-aoa'] == 9999)
569
    keyMap.PFD.PFD['AOA/WIND'].texts = ['', 'WIND'];
570
#}}}