zkv1000 / Nasal / buttons.nas /
Newer Older
421 lines | 20.396kb
commit initial
Sébastien MARQUE authored on 2017-03-07
1
var buttonsClass = {
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: [ buttonsClass ] };
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
4
        m.device = device;
commit initial
Sébastien MARQUE authored on 2017-03-07
5
        return m;
6
    },
7

            
8
    PAN : func (xdir = 0, ydir = 0) {
9
    },
10

            
11
    AsSwitchNAV : func {
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
12
        var n = radios.getValue('nav-tune');
commit initial
Sébastien MARQUE authored on 2017-03-07
13
        var tmp = getprop('/instrumentation/nav[' ~ n ~ ']/frequencies/selected-mhz');
14
        setprop('/instrumentation/nav[' ~ n ~ ']/frequencies/selected-mhz', getprop('/instrumentation/nav[' ~ n ~ ']/frequencies/standby-mhz'));
15
        setprop('/instrumentation/nav[' ~ n ~ ']/frequencies/standby-mhz', tmp);
creates flightdeck hash to p...
Sébastien MARQUE authored on 2017-04-07
16
        foreach (var c; keys(flightdeck))
17
            if (contains(flightdeck[c], 'display'))
18
                flightdeck[c].display.updateNAV({refresh: n+1});
commit initial
Sébastien MARQUE authored on 2017-03-07
19
    },
20

            
ajout de l'animation des bou...
Sébastien MARQUE authored on 2017-03-08
21
    AsSwitchCOM : func (x) {
commit initial
Sébastien MARQUE authored on 2017-03-07
22
        if (x) {
ajout de l'animation des bou...
Sébastien MARQUE authored on 2017-03-08
23
            me.AsSwitchCOM_pushed = getprop('/sim/time/elapsed-sec');
commit initial
Sébastien MARQUE authored on 2017-03-07
24
        }
ajout de l'animation des bou...
Sébastien MARQUE authored on 2017-03-08
25
        else {
26
            var pressed = getprop('/sim/time/elapsed-sec') - me.AsSwitchCOM_pushed;
27
            if (pressed > 2) {
28
                setprop('/instrumentation/comm/frequencies/selected-mhz', 121.500);
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
29
                radios.setValue('comm1-selected', 1);
30
                radios.setValue('comm2-selected', 0);
fix COMM display standby fre...
Sébastien MARQUE authored on 2017-04-09
31
                foreach (var d; keys(flightdeck))
32
                    if (contains(flightdeck[d], 'display')) {
33
                        flightdeck[d].display.updateCOMM({refresh: 1});
34
                        flightdeck[d].display.updateCOMM({refresh: 2});
35
                    }
ajout de l'animation des bou...
Sébastien MARQUE authored on 2017-03-08
36
            }
37
            else {
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
38
                var c = radios.getValue('comm-tune');
ajout de l'animation des bou...
Sébastien MARQUE authored on 2017-03-08
39
                var tmp = getprop('/instrumentation/comm[' ~ c ~ ']/frequencies/selected-mhz');
40
                setprop('/instrumentation/comm[' ~ c ~ ']/frequencies/selected-mhz', getprop('/instrumentation/comm[' ~ c ~ ']/frequencies/standby-mhz'));
41
                setprop('/instrumentation/comm[' ~ c ~ ']/frequencies/standby-mhz', tmp);
fix COMM display standby fre...
Sébastien MARQUE authored on 2017-04-09
42
                foreach (var d; keys(flightdeck))
43
                    if (contains(flightdeck[d], 'display'))
44
                        flightdeck[d].display.updateCOMM({refresh: c+1});
ajout de l'animation des bou...
Sébastien MARQUE authored on 2017-03-08
45
            }
commit initial
Sébastien MARQUE authored on 2017-03-07
46
        }
47
    },
48

            
ajout de l'animation des bou...
Sébastien MARQUE authored on 2017-03-08
49
    ALT : func () {
50
        var alt = getprop('instrumentation/altimeter/indicated-altitude-ft');
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
51
        afcs.setIntValue('selected-alt-ft', math.round(alt, 10));
commit initial
Sébastien MARQUE authored on 2017-03-07
52
    },
53

            
TMR/REF available
Sébastien MARQUE authored on 2017-04-10
54
    ValidateTMRREF : func (a = 0) {
55
        if (a)
56
            return;
57
        var (id, selected) = split('-', me.device.windows.selected);
58
        var state = me.device.windows.state[id];
59
        selected += state.scroll.offset;
60
        if (contains(state.objects[selected], 'callback'))
61
            call(state.objects[selected].callback, [id, selected], me);
62
    },
63

            
64
    ClearTMRREF : func (a = 0) {
65
        if (a)
66
            return;
67
        me.device.windows.del();
68
        me.device.data.TMRtimer = nil;
69
        me.device.knobs.FmsInner = func;
70
        me.device.knobs.FmsOuter = func;
71
        me.device.buttons.ENT = func;
72
        me.device.buttons.FMS = func;
73
        me.device.buttons.CLR = func;
74
    },
75

            
fix MFD page selection syste...
Sébastien MARQUE authored on 2017-04-13
76
    MFD_page_wrapper : func (id, selected) {
77
        var s = me.device.data[id][me.device.display['page selected']];
78
        var group = s.name;
79
        var subpage = s.objects[selected].text;
80

            
81
        foreach (var k; keys(me.device.windows.window))
allows only implemented MFD ...
Sébastien MARQUE authored on 2017-06-02
82
            if (find(id, k) == 0) {
83
                me.device.windows.del(id);
84
                break;
85
            }
86
        call(me.device.display.MFD[group][subpage], [], me);
fix MFD page selection syste...
Sébastien MARQUE authored on 2017-04-13
87
    },
88

            
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
89
    MapMenu : func (a = 0) {
90
        if (a == 1)
91
            return;
92
        var menu_label = 'MAP MENU';
93
        if (!contains(me.device.windows.window, menu_label ~ '-bg')) {
94
            var level_min = 13;
95
            var level_max = 7;
selection of map display by ...
Sébastien MARQUE authored on 2020-06-14
96
            var range_from_level = func (l) {
97
                var r = (me.device.display.display.get('view[1]') / 2 * 84.53 * math.cos(data.lat) / math.pow(2, l)) * units.distance.from_nm;
98
                return sprintf('% 3u%s', math.round(r, r > 10 ? 5 : 1), units.distance.from_nm == 1 ? 'NM' : 'km');
99
            }
100
            var ranges = [ sprintf('  %s >', range_from_level(level_max)) ];
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
101
            for (var i = level_max + 1; i <= level_min; i += 1)
selection of map display by ...
Sébastien MARQUE authored on 2020-06-14
102
                append(ranges, sprintf(i < level_min ? '< %s >' : '< %s  ', range_from_level(i)));
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
103
            var orientation = [ '  NORTH UP >', '<  TRK UP  >' ];
104
            if (getprop('/instrumentation/gps/route-distance-nm') != nil)
105
                append(orientation, '<  DTK UP  >');
106
            append(orientation, '<  HDG UP   ');
107
            me.device.windows.draw(
108
                    menu_label,
109
                    {x: 720, y: 100, w: 300, l:3, sep: 1},
110
                    [
111
                        {text: menu_label, type: 'title'},
112
                        {type: 'separator'},
selection of map display by ...
Sébastien MARQUE authored on 2020-06-14
113
                        {text: 'RANGE: ', type: 'normal'},
114
                        {text: ranges[me.device.data.zoom - level_max],
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
115
                         type: 'selected|end-of-line',
selection of map display by ...
Sébastien MARQUE authored on 2020-06-14
116
                         choices: ranges,
117
                         level_max: level_max,
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
118
                         callback: func (id, selected) {
selection of map display by ...
Sébastien MARQUE authored on 2020-06-14
119
                             me.device.data.zoom = vecindex(me.device.windows.state[id].objects[selected].choices,
120
                                                            me.device.windows.state[id].objects[selected].text)
121
                                                   + me.device.windows.state[id].objects[selected].level_max;
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
122
                             me.device.map.changeZoom();
123
                             me.device.map.update();
124
                         }
125
                        },
126
                        {text: 'ORIENTATION', type: 'normal'},
127
                        {text: (func foreach (var o; orientation) if (find(me.device.data.orientation.text, o) > -1) return o;)(),
128
                         type: 'editable|end-of-line',
129
                         choices: orientation,
130
                         callback: func (id, selected) {
131
                             var o = me.device.windows.state[id].objects[selected].text;
132
                             o = substr(o, 2);
133
                             o = substr(o, 0, size(o) - 2);
134
                             o = string.trim(o);
135
                             me.device.data.orientation.text = o;
136
                             me.device.map.update();
137
                         }
138
                        },
139
                    ]
140
                );
141
            me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu;
142
            me.device.knobs.FmsInner = me.device.knobs.MenuSettings;
143
            me.device.buttons.CLR = me.device.buttons.MapMenu;
144
            me.device.buttons.ENT = me.device.buttons.ValidateTMRREF;
145
        }
146
        else {
147
            me.device.buttons.ENT = func;
148
            me.device.buttons.CLR = func;
149
            me.device.knobs.FmsInner = func;
150
            me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group;
151
            me.device.windows.del(menu_label);
152
        }
153
    },
154

            
add brightness and lights co...
Sébastien MARQUE authored on 2020-04-27
155
    GlobalParams: func (a) {
156
        if (a == 1)
157
            return;
158
        var windowId = 'GLOBAL SETTINGS';
159
        var obj_infos = [
160
            {text: 'DISPLAY', type: 'title'},
161
            {type: 'separator'},
162
            {text: 'Brightness: ', type: 'normal'},
creates settings management
Sébastien MARQUE authored on 2020-05-16
163
            {text: sprintf( '% 3u %%', zkv.getValue('display-brightness-norm') * 100 / 0.7),
add brightness and lights co...
Sébastien MARQUE authored on 2020-04-27
164
                type: 'selected immediate end-of-line',
creates settings management
Sébastien MARQUE authored on 2020-05-16
165
                format: ' % 3u %% ',
add brightness and lights co...
Sébastien MARQUE authored on 2020-04-27
166
                range: {max: 100, min: 0},
167
                callback: func (id, selected) {
168
                    var b = num(string.trim(me.device.windows.state[id].objects[selected].text, 0, func (c) c == `%` or c == ` `));
169
                    zkv.setDoubleValue('display-brightness-norm', b * 0.7 / 100);
170
                },
171
            },
creates settings management
Sébastien MARQUE authored on 2020-05-16
172
            {text: 'Light    : ', type: 'normal'},
add brightness and lights co...
Sébastien MARQUE authored on 2020-04-27
173
            {text: '  0 >',
174
                type: 'editable|immediate|end-of-line',
creates settings management
Sébastien MARQUE authored on 2020-05-16
175
                choices: ['  0 >', '< 1 >', '< 2 >', '< 3  '],
add brightness and lights co...
Sébastien MARQUE authored on 2020-04-27
176
                callback: func (id, selected) {
creates settings management
Sébastien MARQUE authored on 2020-05-16
177
                    var l = num(string.trim(me.device.windows.state[id].objects[selected].text, 0, func (c) c == ` ` or c == `<` or c == `>`));
178
                    zkv.setDoubleValue('lightmap', l * 3);
add brightness and lights co...
Sébastien MARQUE authored on 2020-04-27
179
                }
creates settings management
Sébastien MARQUE authored on 2020-05-16
180
            },
181
            {text: 'UNITS', type: 'title'},
182
            {type: 'separator'},
settings with scrollable con...
Sébastien MARQUE authored on 2020-06-15
183
            {text: 'Pressure  :', type: 'normal', scrollgroup: 0},
settings now have effect
Sébastien MARQUE authored on 2020-06-12
184
            {text: data.settings.units.pressure == 'inhg' ? '  inHg >' : '<  hPa  ',
creates settings management
Sébastien MARQUE authored on 2020-05-16
185
                type: 'editable|end-of-line',
186
                choices: [ '  inHg >', '<  hPa  '],
settings with scrollable con...
Sébastien MARQUE authored on 2020-06-15
187
                scrollgroup: 0,
creates settings management
Sébastien MARQUE authored on 2020-05-16
188
                callback: func (id, selected) {
189
                    var u = string.trim(me.device.windows.state[id].objects[selected].text, 0, func (c) c == ` ` or c == `<` or c == `>`);
190
                    if (u == 'inHg')
191
                        data.settings.units.pressure = 'inhg';
192
                    else
193
                        data.settings.units.pressure = 'hpa';
adds settings storage and re...
Sébastien MARQUE authored on 2020-06-17
194
                    zkv.getNode('save/pressure', 1).setValue(data.settings.units.pressure);
settings now have effect
Sébastien MARQUE authored on 2020-06-12
195
                    me.device.display.updateBARO();
creates settings management
Sébastien MARQUE authored on 2020-05-16
196
                }
197
            },
settings with scrollable con...
Sébastien MARQUE authored on 2020-06-15
198
            {text: 'Altitude  :', type: 'normal', scrollgroup: 1},
settings now have effect
Sébastien MARQUE authored on 2020-06-12
199
            {text: units.altitude.from_ft == 1 ? '   feet  >' : '< meters  ',
creates settings management
Sébastien MARQUE authored on 2020-05-16
200
                type: 'editable|end-of-line',
201
                choices: [ '   feet  >', '< meters  ' ],
settings with scrollable con...
Sébastien MARQUE authored on 2020-06-15
202
                scrollgroup: 1,
creates settings management
Sébastien MARQUE authored on 2020-05-16
203
                callback: func (id, selected) {
204
                    var u = string.trim(me.device.windows.state[id].objects[selected].text, 0, func (c) c == ` ` or c == `<` or c == `>`);
settings now have effect
Sébastien MARQUE authored on 2020-06-12
205
                    if (u == 'feet') {
creates settings management
Sébastien MARQUE authored on 2020-05-16
206
                        data.settings.units.altitude = 'ft';
settings now have effect
Sébastien MARQUE authored on 2020-06-12
207
                        units.altitude.from_ft = 1;
208
                        units.altitude.from_m  = M2FT;
209
                    }
210
                    else {
creates settings management
Sébastien MARQUE authored on 2020-05-16
211
                        data.settings.units.altitude = 'm';
settings now have effect
Sébastien MARQUE authored on 2020-06-12
212
                        units.altitude.from_ft = FT2M;
213
                        units.altitude.from_m  = 1;
214
                    }
adds settings storage and re...
Sébastien MARQUE authored on 2020-06-17
215
                    foreach (var from; keys(units.altitude))
216
                        zkv.getNode('save/altitude', 1).setDoubleValue(from, units.altitude[from]);
217

            
settings now have effect
Sébastien MARQUE authored on 2020-06-12
218
                }
219
            },
settings with scrollable con...
Sébastien MARQUE authored on 2020-06-15
220
            {text: 'Distance  :', type: 'normal', scrollgroup: 2},
settings now have effect
Sébastien MARQUE authored on 2020-06-12
221
            {text: units.distance.from_nm == 1 ? '  NM >' : '< km  ',
222
                type: 'editable|end-of-line',
223
                choices: ['  NM >', '< km  '],
settings with scrollable con...
Sébastien MARQUE authored on 2020-06-15
224
                scrollgroup: 2,
settings now have effect
Sébastien MARQUE authored on 2020-06-12
225
                callback: func (id, selected) {
226
                    var u = string.trim(me.device.windows.state[id].objects[selected].text, 0, func (c) c == ` ` or c == `<` or c == `>`);
227
                    if (u == 'NM') {
228
                        data.settings.units.distance = 'nm';
229
                        units.distance.from_nm = 1;
230
                        units.distance.from_m  = M2NM * 1000;
231
                    }
232
                    else {
233
                        data.settings.units.distance = 'km';
234
                        units.distance.from_nm = NM2M / 1000;
235
                        units.distance.from_m  = 0.001;
236
                    }
adds settings storage and re...
Sébastien MARQUE authored on 2020-06-17
237
                    foreach (var from; keys(units.distance))
238
                        zkv.getNode('save/distance', 1).setDoubleValue(from, units.distance[from]);
creates settings management
Sébastien MARQUE authored on 2020-05-16
239
                }
240
            },
settings with scrollable con...
Sébastien MARQUE authored on 2020-06-15
241
            {text: 'Speed     :', type: 'normal', scrollgroup: 3},
settings now have effect
Sébastien MARQUE authored on 2020-06-12
242
            {text: units.speed.from_kt == 1 ? '  knots  >' : '<  km/h   ',
creates settings management
Sébastien MARQUE authored on 2020-05-16
243
                type: 'editable|end-of-line',
244
                choices: [ '  knots  >', '<  km/h   ' ],
settings with scrollable con...
Sébastien MARQUE authored on 2020-06-15
245
                scrollgroup: 3,
creates settings management
Sébastien MARQUE authored on 2020-05-16
246
                callback: func (id, selected) {
247
                    var u = string.trim(me.device.windows.state[id].objects[selected].text, 0, func (c) c == ` ` or c == `<` or c == `>`);
settings now have effect
Sébastien MARQUE authored on 2020-06-12
248
                    if (u == 'knots') {
creates settings management
Sébastien MARQUE authored on 2020-05-16
249
                        data.settings.units.altitude = 'kt';
settings now have effect
Sébastien MARQUE authored on 2020-06-12
250
                        units.speed.from_kt  = 1;
251
                        units.speed.from_kmh = MPS2KT / 3.6;
252
                    }
253
                    else {
creates settings management
Sébastien MARQUE authored on 2020-05-16
254
                        data.settings.units.altitude = 'kmh';
settings now have effect
Sébastien MARQUE authored on 2020-06-12
255
                        units.speed.from_kt  = KT2MPS * 3.6;
256
                        units.speed.from_kmh = 1;
257
                    }
adds settings storage and re...
Sébastien MARQUE authored on 2020-06-17
258
                    foreach (var from; keys(units.speed))
259
                        zkv.getNode('save/speed', 1).setDoubleValue(from, units.speed[from]);
settings now have effect
Sébastien MARQUE authored on 2020-06-12
260
                    foreach (var v; ['Vx', 'Vy', 'Vr', 'Vglide', 'Vne']) {
261
                        var speed = alerts.getValue(v) * units.speed.from_kt;
262
                        data[v] = speed != nil ? speed : 9999;
263
                    }
creates settings management
Sébastien MARQUE authored on 2020-05-16
264
                }
265
            },
settings with scrollable con...
Sébastien MARQUE authored on 2020-06-15
266
            {text: 'Vert. Spd :', type: 'normal', scrollgroup: 4},
settings now have effect
Sébastien MARQUE authored on 2020-06-12
267
            {text: units.vspeed.from_fpm == 1 ? '  ft/min >' : '<  m/min  ',
creates settings management
Sébastien MARQUE authored on 2020-05-16
268
                type: 'editable|end-of-line',
269
                choices: [ '  ft/min >', '<  m/min  ' ],
settings with scrollable con...
Sébastien MARQUE authored on 2020-06-15
270
                scrollgroup: 4,
creates settings management
Sébastien MARQUE authored on 2020-05-16
271
                callback: func (id, selected) {
272
                    var u = string.trim(me.device.windows.state[id].objects[selected].text, 0, func (c) c == ` ` or c == `<` or c == `>`);
settings now have effect
Sébastien MARQUE authored on 2020-06-12
273
                    if (u == 'ft/min') {
creates settings management
Sébastien MARQUE authored on 2020-05-16
274
                        data.settings.units.altitude = 'fpm';
settings now have effect
Sébastien MARQUE authored on 2020-06-12
275
                        units.vspeed.from_fpm = 1;
276
                        units.vspeed.from_mpm = M2FT;
277
                    }
278
                    else {
creates settings management
Sébastien MARQUE authored on 2020-05-16
279
                        data.settings.units.altitude = 'mpm';
settings now have effect
Sébastien MARQUE authored on 2020-06-12
280
                        units.vspeed.from_fpm = FT2M;
281
                        units.vspeed.from_mpm = 1;
282
                    }
adds settings storage and re...
Sébastien MARQUE authored on 2020-06-17
283
                    foreach (var from; keys(units.vspeed))
284
                        zkv.getNode('save/vspeed', 1).setDoubleValue(from, units.vspeed[from]);
creates settings management
Sébastien MARQUE authored on 2020-05-16
285
                }
286
            },
adds temperature units setti...
Sébastien MARQUE authored on 2020-06-15
287
            {text: 'Temperat. :', type: 'normal', scrollgroup: 5},
288
            {text: units.temperature.from_C(0) ? '  F >' : '< °C  ',
289
                type: 'editable|end-of-line',
290
                choices: [ '  F >', '< °C  ' ],
291
                scrollgroup: 5,
292
                callback: func (id, selected) {
293
                    var u = string.trim(me.device.windows.state[id].objects[selected].text, 0, func (c) c == ` ` or c == `<` or c == `>`);
294
                    if (u == '°C') {
295
                        units.temperature.from_C = func (c) return c;
296
                        units.temperature.from_F = func (f) return (f - 32) / 1.8;
adds settings storage and re...
Sébastien MARQUE authored on 2020-06-17
297
                        zkv.getNode('save/temperature', 1).setValue('from_C', 'units.temperature.from_C = func (c) return c;');
298
                        zkv.getNode('save/temperature', 1).setValue('from_F', 'units.temperature.from_F = func (f) return (f - 32) / 1.8;');
adds temperature units setti...
Sébastien MARQUE authored on 2020-06-15
299
                    }
300
                    else {
301
                        units.temperature.from_C = func (c) return c * 1.8 + 32;
302
                        units.temperature.from_F = func (f) return f;
adds settings storage and re...
Sébastien MARQUE authored on 2020-06-17
303
                        zkv.getNode('save/temperature', 1).setValue('from_C', 'units.temperature.from_C = func (c) return c * 1.8 + 32;');
304
                        zkv.getNode('save/temperature', 1).setValue('from_F', 'units.temperature.from_F = func (f) return f;');
adds temperature units setti...
Sébastien MARQUE authored on 2020-06-15
305
                    }
306
                }
307
            },
adds time display setting
Sébastien MARQUE authored on 2020-06-11
308
            {type: 'separator'},
309
            {text: 'TIME REF: ', type: 'normal'},
310
            {text: data.settings.time.actual,
311
                type: 'editable|end-of-line',
312
                choices: [ '  GMT >', '< LCL >', '< UTC >', '< RL   ' ],
313
                callback: func (id, selected) {
314
                    data.settings.time.actual = me.device.windows.state[id].objects[selected].text;
315
                    data.settings.time.label = string.trim(me.device.windows.state[id].objects[selected].text, 0, func (c) c == ` ` or c == `<` or c == `>`);
316
                }
317
            },
add brightness and lights co...
Sébastien MARQUE authored on 2020-04-27
318
        ];
settings with scrollable con...
Sébastien MARQUE authored on 2020-06-15
319
        me.device.windows.draw( windowId, {autogeom: 1}, obj_infos, {lines: 3, columns: 2});
add brightness and lights co...
Sébastien MARQUE authored on 2020-04-27
320
        me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu;
321
        me.device.knobs.FmsInner = me.device.knobs.MenuSettings;
adds settings storage and re...
Sébastien MARQUE authored on 2020-06-17
322
        me.device.buttons.ENT = func (a = 0) {
323
            if (a) return;
324
            me.device.buttons.ValidateTMRREF();
325
            var settings_file = getprop('/sim/fg-home') ~'/aircraft-data/zkv1000.xml';
326
            if (io.stat(settings_file) != nil)
327
                fgcommand('loadxml', props.Node.new({ filename: settings_file, targetnode: zkv.getNode('_save', 1).getPath() }));
328
            props.copy(zkv.getNode('save'), zkv.getNode('_save/' ~ getprop('/sim/aircraft'), 1), 1);
329
        }
add brightness and lights co...
Sébastien MARQUE authored on 2020-04-27
330
        me.device.buttons.CLR = func {
331
            me.device.windows.del(windowId);
332
            me.device.knobs.FmsOuter = func;
333
            me.device.knobs.FmsInner = func;
334
            foreach (var b; ['ENT', 'CLR'])
335
                me.device.buttons[b] = func;
336
            me.device.buttons.MENU = me.device.buttons.GlobalParams;
adds settings storage and re...
Sébastien MARQUE authored on 2020-06-17
337
            if (zkv.getNode('save') != nil) {
338
                fgcommand('savexml', props.Node.new({ filename: getprop('/sim/fg-home') ~'/aircraft-data/zkv1000.xml',
339
                      sourcenode: zkv.getNode('_save').getPath() }));
340
                zkv.getNode('_save').remove();
341
                zkv.getNode('save').remove();
342
            }
add brightness and lights co...
Sébastien MARQUE authored on 2020-04-27
343
        }
344
        me.device.buttons.MENU = me.device.buttons.CLR;
345
    },
346

            
handle DTO button
Sébastien MARQUE authored on 2020-05-16
347
    DirectTo : func (a) {
348
        if (a) return;
349
        if (me.device.windows.selected == nil) return;
350
        var (id, selected) = split('-', me.device.windows.selected);
351
        var state = me.device.windows.state[id];
352
        selected += state.scroll.offset;
353
        var scratch = props.globals.getNode('/instrumentation/gps/scratch');
354
        if (contains(state.objects[selected], 'dto')) {
355
            scratch.setValue('longitude-deg', state.objects[selected].dto.lon);
356
            scratch.setValue('latitude-deg', state.objects[selected].dto.lat);
357
            scratch.setValue('ident', state.objects[selected].dto.id);
358
            scratch.setValue('altitude-ft', data.alt);
359
            setprop('/instrumentation/gps/command', 'direct');
360
        }
361
    },
362

            
adds FPL button
Sébastien MARQUE authored on 2020-06-11
363
    FPL : func (a) {
364
        if (a or data.fpSize == 0 or me.device.windows.selected != '')
365
            return;
366
        var windowId = 'FLIGHTPLAN LIST';
367
        var flightplan = props.globals.getNode('/autopilot/route-manager');
368
        var route = flightplan.getNode('route');
369
        var obj_infos = [];
370
        var firstEntry = 1;
371
        var current = flightplan.getValue('current-wp');
372
        for (var i = current; i <= data.fpSize; i += 1) {
373
            var wp = route.getChild('wp', i);
374
            append(obj_infos, {
375
                type: (firstEntry ? 'selected' : 'editable'),
376
                text: sprintf('#%2d %-10s', data.fpSize - i, wp.getValue('id')),
377
                scrollgroup: i - current,
378
                dto: {
379
                    lon: wp.getValue('lon'),
380
                    lat: wp.getValue('lat'),
381
                    id:  wp.getValue('id')
382
                },
383
            });
384
            append(obj_infos, {
385
                type: 'normal|end-of-line',
386
                scrollgroup: i - current,
387
                text: sprintf(' %3dNM %3d°',
388
                              math.round(wp.getValue('leg-distance-nm')),
389
                              math.round(wp.getValue('leg-bearing-true-deg')))
390
            });
391
            firstEntry = 0;
392
        }
393
        me.device.windows.draw(windowId, obj_infos, {lines: 6, columns: 2});
394
        me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu;
395
        me.device.knobs.FmsInner = me.device.knobs.NavigateMenu;
396
        me.device.buttons.ENT = func;
397
        me.device.buttons.MENU = func;
398
        me.device.buttons.CLR = func {
399
            me.device.windows.del(windowId);
400
            if (me.device.role == 'PFD') {
401
                me.device.knobs.FmsOuter = func;
402
                me.device.knobs.FmsInner = func;
403
                me.device.buttons.MENU   = me.device.buttons.GlobalParams;
404
            }
405
            else {
406
                me.device.knobs.FmsInner = func;
407
                me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group;
408
                me.device.buttons.MENU   = me.device.buttons.MapMenu;
409
            }
410
            foreach (var b; ['ENT', 'CLR'])
411
                me.device.buttons[b] = func;
412
        }
413
        me.device.buttons.MENU = me.device.buttons.CLR;
414
    },
415

            
commit initial
Sébastien MARQUE authored on 2017-03-07
416
    MENU : void,
417
    PROC : void,
418
    CLR : void,
419
    ENT : void,
420
    FMS : void,
421
};