zkv1000 / Nasal / softkeys.nas /
Newer Older
366 lines | 18.667kb
commit initial
Sébastien MARQUE authored on 2017-03-07
1
var softkeysClass = {
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
2
    new : func (device, node, role) {
commit initial
Sébastien MARQUE authored on 2017-03-07
3
        var m = { parents: [ softkeysClass ] };
4
        m.node = node;
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
5
        m.device = device;
adds the avaibility to have ...
Sébastien MARQUE authored on 2017-04-07
6
        m.role = substr(role, 0, 3);
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
7
        m.path = [];
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

            
20
        var path = keyMap[me.role];
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

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