zkv1000 / Nasal / softkeys.nas /
Newer Older
364 lines | 18.609kb
commit initial
Sébastien MARQUE authored on 2017-03-07
1
var softkeysClass = {
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
2
    new : func (device) {
commit initial
Sébastien MARQUE authored on 2017-03-07
3
        var m = { parents: [ softkeysClass ] };
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
4
        m.device = device;
5
        m.path = [];
commit initial
Sébastien MARQUE authored on 2017-03-07
6
        return m;
7
    },
8

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

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

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

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

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

            
55
    bindings : {
56
        PFD : {
57
            INSET: {
58
                OFF: func {
59
                    pop(me.path);
60
                    me.device.display.updateSoftKeys();
61
                },
62
            },
63
            PFD: {
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
64
                'AOA/WIND' : {
65
                    WIND : {
66
                        OPTN1 : func {
67
                            me.device.display._winddata_optn = 1;
68
                            me.device.display.screenElements['WindData'].show();
69
                            me.device.display.screenElements['WindData-OPTN1'].show();
70
                            me.device.display.screenElements['WindData-OPTN1-HDG'].show();
71
                            me.device.display.screenElements['WindData-OPTN2'].hide();
72
                            me.device.display.updateWindData();
73
                        },
74
                        OPTN2 : func {
75
                            me.device.display._winddata_optn = 2;
76
                            me.device.display.screenElements['WindData'].show();
77
                            me.device.display.screenElements['WindData-OPTN1'].hide();
78
                            me.device.display.screenElements['WindData-OPTN2'].show();
79
                            me.device.display.screenElements['WindData-OPTN2-symbol'].show();
80
                            me.device.display.screenElements['WindData-OPTN2-headwind'].show();
81
                            me.device.display.screenElements['WindData-OPTN2-crosswind'].show();
82
                            me.device.display.updateWindData();
83
                        },
84
                        OFF : func {
85
                            me.device.display._winddata_optn = 0;
86
                            me.device.display.screenElements['WindData'].hide();
87
                            me.device.display.screenElements['WindData-OPTN1'].hide();
88
                            me.device.display.screenElements['WindData-OPTN2'].hide();
89
                        },
90
                    },
91
                },
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
92
                BRG1 : func (brg = 1){
93
                    var source = 'brg' ~ brg ~ '-source';
94
                    var list = ['NAV' ~ brg, 'GPS', 'ADF', 'OFF'];
95
                    var index = std.Vector
96
                                   .new(list)
97
                                   .index(radios.getNode(source).getValue());
98
                    var next = (index == size(list) -1) ?  0 : index + 1;
99
                    radios.getNode(source).setValue(list[next]);
100
                },
101
                BRG2 : func {
102
                    call(me.bindings.PFD.PFD.BRG1, [ 2 ], me);
103
                },
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
104
                'STD BARO' : func {
105
                    setprop('/instrumentation/altimeter/setting-inhg', 29.92);
106
                    me.device.display.updateBARO();
107
                    pop(me.path);
108
                    me.device.display.updateSoftKeys();
109
                },
110
                IN :  func {
111
                    me.device.display._baro_unit = 'inhg';
112
                    me.device.display.updateBARO();
113
                },
114
                HPA : func {
115
                    me.device.display._baro_unit = 'hpa';
116
                    me.device.display.updateBARO();
117
                },
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
118
            },
119
            XPDR: {
adds transponder
Sébastien MARQUE authored on 2017-03-17
120
                STBY : func {
121
                    setprop('/instrumentation/transponder/ident', 0);
122
                    setprop('/instrumentation/transponder/knob-mode', 1);
123
                    setprop('/instrumentation/zkv1000/radio/xpdr-mode', 'STBY');
124
                    me.device.display.updateXPDR();
125
                },
126
                ON : func {
127
                    setprop('/instrumentation/transponder/ident', 1);
128
                    setprop('/instrumentation/transponder/knob-mode', 4);
129
                    setprop('/instrumentation/zkv1000/radio/xpdr-mode', 'ON');
130
                    me.device.display.updateXPDR();
131
                },
132
                ALT : func {
133
                    setprop('/instrumentation/transponder/ident', 1);
134
                    setprop('/instrumentation/transponder/knob-mode', 5);
135
                    setprop('/instrumentation/zkv1000/radio/xpdr-mode', 'ALT');
136
                    me.device.display.updateXPDR();
137
                },
138
                VFR : func {
139
                    setprop('/instrumentation/transponder/id-code', '1200');
140
                    me.device.display.updateXPDR();
141
                },
142
                IDENT : func {
143
                    call(me.bindings.PFD.IDENT, [], me);
144
                },
145
                CODE : {
146
                    '0' : func (n = 0) {
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
147
                        if (getprop('/instrumentation/zkv1000/radios/xpdr-tuning-fms-method'))
148
                            return;
149
                        me.device.display.timers2.softkeys_inactivity.stop();
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
150
                        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
151
                        # disable FMS knob entering method
152
                        me.device.knobs.FmsInner = void;
153
                        # When entering the code, the next softkey in sequence
154
                        # must be pressed within 10 seconds, or the entry is cancelled
155
                        # and restored to the previous code
156
                        if (!contains(me.bindings.PFD.XPDR.CODE, 'on_change_inactivity')) {
157
                            me.bindings.PFD.XPDR.CODE.on_change_inactivity = maketimer(10,
158
                                func {
159
                                    setprop('/instrumentation/zkv1000/radios/xpdr-tuning-digit', 3);
160
                                    me.device.knobs.FmsInner = me.device.knobs.XPDRCodeSetDigits;
161
                                    me.device.knobs.FmsOuter = me.device.knobs.XPDRCodeNextDigits;
162
                                    call(me.bindings.PFD.XPDR.CODE.restore, [], me);
163
                                });
164
                            me.bindings.PFD.XPDR.CODE.on_change_inactivity.singleShot = 1;
165
                            me.bindings.PFD.XPDR.CODE.on_change_inactivity.start();
166
                        }
167
                        else
168
                            me.bindings.PFD.XPDR.CODE.on_change_inactivity.restart(10);
adds transponder
Sébastien MARQUE authored on 2017-03-17
169
                        var tuning = radios.getNode('xpdr-tuning-digit');
170
                        var d = tuning.getValue();
171
                        setprop('/instrumentation/transponder/inputs/digit[' ~ d ~ ']', n);
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
172
                        if (d == 1) {
173
                            if (!contains(me.bindings.PFD.XPDR.CODE, 'on_change_auto_validation'))
174
                                me.bindings.PFD.XPDR.CODE.on_change_auto_validation = maketimer(5,
175
                                    func call(me.bindings.PFD.IDENT, [], me));
176
                            me.bindings.PFD.XPDR.CODE.on_change_auto_validation.singleShot = 1;
177
                            me.bindings.PFD.XPDR.CODE.on_change_auto_validation.start();
178
                        }
179
                        else {
180
                            d -= 1;
181
                            tuning.setValue(d);
182
                        }
adds transponder
Sébastien MARQUE authored on 2017-03-17
183
                        me.device.display.updateXPDR();
184
                    },
185
                    '1' : func {
186
                        call(me.bindings.PFD.XPDR.CODE['0'], [ 1 ], me);
187
                    },
188
                    '2' : func {
189
                        call(me.bindings.PFD.XPDR.CODE['0'], [ 2 ], me);
190
                    },
191
                    '3' : func {
192
                        call(me.bindings.PFD.XPDR.CODE['0'], [ 3 ], me);
193
                    },
194
                    '4' : func {
195
                        call(me.bindings.PFD.XPDR.CODE['0'], [ 4 ], me);
196
                    },
197
                    '5' : func {
198
                        call(me.bindings.PFD.XPDR.CODE['0'], [ 5 ], me);
199
                    },
200
                    '6' : func {
201
                        call(me.bindings.PFD.XPDR.CODE['0'], [ 6 ], me);
202
                    },
203
                    '7' : func {
204
                        call(me.bindings.PFD.XPDR.CODE['0'], [ 7 ], me);
205
                    },
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
206
                    IDENT: func {
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
207
                        me.bindings.PFD.XPDR.CODE.inactivity.restart(me.device.display.softkeys_inactivity_delay);
208
                        me.device.display.timers2.softkeys_inactivity.restart(me.device.display.softkeys_inactivity_delay);
adds transponder
Sébastien MARQUE authored on 2017-03-17
209
                        call(me.bindings.PFD.IDENT, [], me);
210
                    },
211
                    BKSP: func {
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
212
                        if (getprop('/instrumentation/zkv1000/radios/xpdr-tuning-fms-method'))
213
                            return;
214
                        if (contains(me.bindings.PFD.XPDR.CODE, 'on_change_inactivity'))
215
                            me.bindings.PFD.XPDR.CODE.on_change_inactivity.restart(10);
216
                        if (contains(me.bindings.PFD.XPDR.CODE, 'on_change_auto_validation'))
217
                                me.bindings.PFD.XPDR.CODE.on_change_auto_validation.stop();
adds transponder
Sébastien MARQUE authored on 2017-03-17
218
                        var tuning = radios.getNode('xpdr-tuning-digit');
219
                        var d = tuning.getValue();
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
220
                        if (d < 3) {
221
                            d += 1;
222
                            tuning.setValue(d);
223
                        }
adds transponder
Sébastien MARQUE authored on 2017-03-17
224
                        me.device.display.updateXPDR();
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
225
                    },
adds transponder
Sébastien MARQUE authored on 2017-03-17
226
                    BACK : func (inactive = 0) {
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
227
                        call(me.bindings.PFD.XPDR.CODE.restore, [], me);
adds transponder
Sébastien MARQUE authored on 2017-03-17
228
                        pop(me.path);
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
229
                        call(me.bindings.PFD.XPDR.CODE.exit, [me.path], me);
230
                    },
231
                    restore : func {
232
                        setprop('/instrumentation/transponder/id-code',
233
                            sprintf('%s', getprop('/instrumentation/zkv1000/radios/xpdr-backup-code')));
234
                        me.device.display.updateXPDR();
adds transponder
Sébastien MARQUE authored on 2017-03-17
235
                    },
236
                    exit : func (p) {
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
237
                        if (contains(me.bindings.PFD.XPDR.CODE, 'inactivity')) # does not exists if IDENT pressed from top-level
238
                            me.bindings.PFD.XPDR.CODE.inactivity.stop();
adds transponder
Sébastien MARQUE authored on 2017-03-17
239
                        radios.removeChild('xpdr-tuning-digit', 0);
240
                        radios.removeChild('xpdr-backup-code', 0);
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
241
                        radios.removeChild('xpdr-tuning-fms-method', 0);
adds transponder
Sébastien MARQUE authored on 2017-03-17
242
                        me.path = p;
243
                        me.device.display.updateXPDR();
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
244
                        me.device.display.updateSoftKeys();
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
245
                        me.device.knobs.FmsInner = void;
246
                        me.device.knobs.FmsOuter = void;
247
                        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
248
                    },
adds transponder
Sébastien MARQUE authored on 2017-03-17
249
                    hook : func {
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
250
                        # this level has its own timer as we may need to revert changes, and got different timers
251
                        me.device.display.timers2.softkeys_inactivity.stop();
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
252
                        me.bindings.PFD.XPDR.CODE.inactivity = maketimer(
253
                            me.device.display.softkeys_inactivity_delay,
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
254
                            func call(me.bindings.PFD.XPDR.CODE.BACK, [], me));
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
255
                        me.bindings.PFD.XPDR.CODE.inactivity.singleShot = 1;
256
                        me.bindings.PFD.XPDR.CODE.inactivity.start();
adds transponder
Sébastien MARQUE authored on 2017-03-17
257
                        var tuning = getprop('/instrument/zkv1000/radios/xpdr-tuning-digit');
258
                        if (tuning == nil) {
259
                            radios.getNode('xpdr-tuning-digit', 1).setValue(3);
260
                            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
261
                            radios.getNode('xpdr-tuning-fms-method', 1).setValue(0);
adds transponder
Sébastien MARQUE authored on 2017-03-17
262
                            me.device.display.updateXPDR();
263
                        }
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
264
                        me.device.knobs.FmsInner = me.device.knobs.XPDRCodeSetDigits;
265
                        me.device.knobs.FmsOuter = me.device.knobs.XPDRCodeNextDigits;
adds transponder
Sébastien MARQUE authored on 2017-03-17
266
                    },
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
267
                },
adds transponder
Sébastien MARQUE authored on 2017-03-17
268
            },
269
            IDENT : func {
270
                if (getprop('/instrumentation/zkv1000/radio/xpdr-mode') == 'STBY')
271
                    return;
272
                setprop('/instrumentation/transponder/ident', 1);
273
                me.bindings.PFD.XPDR.ident = maketimer(18,
274
                        func {
275
                            setprop('/instrumentation/transponder/ident', 0);
276
                            me.device.display.updateXPDR();
277
                        });
278
                me.bindings.PFD.XPDR.ident.singleShot = 1;
279
                me.bindings.PFD.XPDR.ident.start();
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
280
                call(me.bindings.PFD.XPDR.CODE.exit, [], me);
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
281
            },
adds CDI
Sébastien MARQUE authored on 2017-03-18
282
            CDI : func {
283
                var list = ['OFF'];
284
                if (getprop('/instrumentation/gps/route-distance-nm') != nil)
285
                    append(list, 'GPS');
286
                if (getprop('/instrumentation/nav/in-range') != nil)
287
                    append(list, 'NAV1');
288
                if (getprop('/instrumentation/nav[1]/in-range') != nil)
289
                    append(list, 'NAV2');
290
                var index = std.Vector
291
                               .new(list)
292
                               .index(cdi.getNode('source').getValue());
293
                var next = (index == size(list) -1) ?  0 : index + 1;
294
                cdi.getNode('source').setValue(list[next]);
295
                CDIfromSOURCE(list[next]);
296
                me.device.display.updateCDI();
297
            },
TMR/REF window
Sébastien MARQUE authored on 2017-03-28
298
            'TMR/REF' : func {
299
                if (!contains(me.device.windows.state, 'TMR/REF')) {
300
                    me.device.windows.draw(
301
                        'TMR/REF',
302
                        {x: 720, y: 535, w: 300, l: 5, sep: 3},
TMR/REF window adaptation
Sébastien MARQUE authored on 2017-04-02
303
                        [ # objects infos
TMR/REF window
Sébastien MARQUE authored on 2017-03-28
304
                            {text: 'REFERENCES', type: 'title'},
305
                            {type: 'separator'},
306
                            {text: 'TIMER', type: 'normal'},
307
                            {text: '00:00:00', type: 'selected|time', },
application of windows with ...
Sébastien MARQUE authored on 2017-04-04
308
                            {text: '  UP >', type: 'editable', choices: ['  UP >', '<DOWN '], callback: func},
TMR/REF window adaptation
Sébastien MARQUE authored on 2017-04-02
309
                            {text: 'START?', type: 'editable|end-of-line|choices', choices: ['START?', 'RESET?', 'STOP?'], callback: func},
TMR/REF window
Sébastien MARQUE authored on 2017-03-28
310
                            {type: 'separator'},
application of windows with ...
Sébastien MARQUE authored on 2017-04-04
311
                            {text: sprintf('Vx     % 3iKT', alerts.getNode('Vx').getValue()), type: 'normal', scrollgroup:0},
312
                            {text: '   ON >', type: 'editable|end-of-line', choices: ['   ON >', '< OFF  '], scrollgroup:0, callback: func},
313
                            {text: sprintf('Vy     % 3iKT', alerts.getNode('Vy').getValue()), type: 'normal', scrollgroup:1},
314
                            {text: '   ON >', type: 'editable|end-of-line', choices: ['   ON >', '< OFF  '], scrollgroup:1, callback: func},
315
                            {text: sprintf('Vr     % 3iKT', alerts.getNode('Vr').getValue()), type: 'normal', scrollgroup:2},
316
                            {text: '   ON >', type: 'editable|end-of-line', choices: ['   ON >', '< OFF  '], scrollgroup:2, callback: func},
317
                            {text: sprintf('Vglide % 3iKT', alerts.getNode('Vglide').getValue()), type: 'normal', scrollgroup:3},
318
                            {text: '   ON >', type: 'editable|end-of-line', choices: ['   ON >', '< OFF  '], scrollgroup:3, callback: func},
TMR/REF window
Sébastien MARQUE authored on 2017-03-28
319
                            {type: 'separator'},
320
                            {text: 'MINIMUMS', type: 'normal'},
TMR/REF window adaptation
Sébastien MARQUE authored on 2017-04-02
321
                            {text: '  BARO >', type: 'editable', choices: ['  BARO >','< TST1 >','< TST2  '], callback: func},
322
                            {text: ' 1000FT', type: 'editable', format: '% 5iFT', factor: 100, callback: func},
323
                        ],
324
                        { # scrolling info, see menu.nas
325
                            lines : 3,
326
                            columns : 2,
327
                        }
TMR/REF window
Sébastien MARQUE authored on 2017-03-28
328
                    );
329
                    me.device.knobs.FmsInner = me.device.knobs.MenuSettings;
330
                    me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu;
331
                }
332
                else {
333
                    me.device.knobs.FmsInner = func;
334
                    me.device.knobs.FmsOuter = func;
335
                    me.device.windows.del();
336
                }
337
            },
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
338
        },
339
        MFD : {
340
            ENGINE: {
341
                FUEL: {
342
                    UNDO: func {
343
                        pop(me.path);
344
                        me.device.display.updateSoftKeys();
345
                    },
346
                    ENTER: func {
347
                        pop(me.path);
348
                        me.device.display.updateSoftKeys();
349
                    },
350
                },
351
                ENGINE: func {
352
                    me.path = [];
353
                    me.device.display.updateSoftKeys();
354
                },
355
            },
add missing exit to MFD/CHKL...
Sébastien MARQUE authored on 2017-03-20
356
            CHKLIST : {
357
                EXIT: func {
358
                    me.path = [];
359
                    me.device.display.updateSoftKeys();
360
                },
361
            },
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
362
        },
commit initial
Sébastien MARQUE authored on 2017-03-07
363
    },
364
};