zkv1000 / Nasal / buttons.nas /
Newer Older
445 lines | 21.695kb
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]);
makes Vspeeds free and adapt...
Sébastien MARQUE authored on 2020-06-19
260
                    foreach (var v; keys(data.Vspeeds))
261
                        data.Vspeeds[v] *= units.speed.from_kt;
creates settings management
Sébastien MARQUE authored on 2020-05-16
262
                }
263
            },
settings with scrollable con...
Sébastien MARQUE authored on 2020-06-15
264
            {text: 'Vert. Spd :', type: 'normal', scrollgroup: 4},
settings now have effect
Sébastien MARQUE authored on 2020-06-12
265
            {text: units.vspeed.from_fpm == 1 ? '  ft/min >' : '<  m/min  ',
creates settings management
Sébastien MARQUE authored on 2020-05-16
266
                type: 'editable|end-of-line',
267
                choices: [ '  ft/min >', '<  m/min  ' ],
settings with scrollable con...
Sébastien MARQUE authored on 2020-06-15
268
                scrollgroup: 4,
creates settings management
Sébastien MARQUE authored on 2020-05-16
269
                callback: func (id, selected) {
270
                    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
271
                    if (u == 'ft/min') {
creates settings management
Sébastien MARQUE authored on 2020-05-16
272
                        data.settings.units.altitude = 'fpm';
settings now have effect
Sébastien MARQUE authored on 2020-06-12
273
                        units.vspeed.from_fpm = 1;
274
                        units.vspeed.from_mpm = M2FT;
275
                    }
276
                    else {
creates settings management
Sébastien MARQUE authored on 2020-05-16
277
                        data.settings.units.altitude = 'mpm';
settings now have effect
Sébastien MARQUE authored on 2020-06-12
278
                        units.vspeed.from_fpm = FT2M;
279
                        units.vspeed.from_mpm = 1;
280
                    }
adds settings storage and re...
Sébastien MARQUE authored on 2020-06-17
281
                    foreach (var from; keys(units.vspeed))
282
                        zkv.getNode('save/vspeed', 1).setDoubleValue(from, units.vspeed[from]);
creates settings management
Sébastien MARQUE authored on 2020-05-16
283
                }
284
            },
adds temperature units setti...
Sébastien MARQUE authored on 2020-06-15
285
            {text: 'Temperat. :', type: 'normal', scrollgroup: 5},
286
            {text: units.temperature.from_C(0) ? '  F >' : '< °C  ',
287
                type: 'editable|end-of-line',
288
                choices: [ '  F >', '< °C  ' ],
289
                scrollgroup: 5,
290
                callback: func (id, selected) {
291
                    var u = string.trim(me.device.windows.state[id].objects[selected].text, 0, func (c) c == ` ` or c == `<` or c == `>`);
292
                    if (u == '°C') {
293
                        units.temperature.from_C = func (c) return c;
294
                        units.temperature.from_F = func (f) return (f - 32) / 1.8;
adds settings storage and re...
Sébastien MARQUE authored on 2020-06-17
295
                        zkv.getNode('save/temperature', 1).setValue('from_C', 'units.temperature.from_C = func (c) return c;');
296
                        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
297
                    }
298
                    else {
299
                        units.temperature.from_C = func (c) return c * 1.8 + 32;
300
                        units.temperature.from_F = func (f) return f;
adds settings storage and re...
Sébastien MARQUE authored on 2020-06-17
301
                        zkv.getNode('save/temperature', 1).setValue('from_C', 'units.temperature.from_C = func (c) return c * 1.8 + 32;');
302
                        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
303
                    }
304
                }
305
            },
adds volume settings
Sébastien MARQUE authored on 2020-06-18
306
            {text: 'Volume    :', type: 'normal', scrollgroup: 6},
typo
Sébastien MARQUE authored on 2020-06-18
307
            {text: units.volume.from_l == 1 ? '   l  >' : (units.volume.from_gal == 1 ?  '< gal  ' : '<  m3 >'),
adds volume settings
Sébastien MARQUE authored on 2020-06-18
308
                type: 'editable|end-of-line',
309
                choices: ['   l  >', '<  m3 >', '< gal  '],
310
                scrollgroup: 6,
311
                callback: func (id, selected) {
312
                    var u = string.trim(me.device.windows.state[id].objects[selected].text, 0, func (c) c == ` ` or c == `<` or c == `>`);
313
                    if (u == 'l') {
314
                        units.volume.from_l   = 1;
315
                        units.volume.from_gal = 3.78541178;
316
                        units.volume.from_m3  = 1000;
317
                    }
318
                    elsif (u == 'm3') {
319
                        units.volume.from_l   = 0.001;
320
                        units.volume.from_gal = 1 / 0.26417 / 1000;
321
                        units.volume.from_m3  = 1;
322
                    }
323
                    else {
324
                        units.volume.from_l   = 0.26417;
325
                        units.volume.from_gal = 1;
326
                        units.volume.from_m3  = units.volume.from_l / 1000;
327
                    }
328
                    foreach (var from; keys(units.volume))
329
                        zkv.getNode('save/volume', 1).setDoubleValue(from, units.volume[from]);
330
                }
331
            },
adds time display setting
Sébastien MARQUE authored on 2020-06-11
332
            {type: 'separator'},
333
            {text: 'TIME REF: ', type: 'normal'},
334
            {text: data.settings.time.actual,
335
                type: 'editable|end-of-line',
336
                choices: [ '  GMT >', '< LCL >', '< UTC >', '< RL   ' ],
337
                callback: func (id, selected) {
338
                    data.settings.time.actual = me.device.windows.state[id].objects[selected].text;
339
                    data.settings.time.label = string.trim(me.device.windows.state[id].objects[selected].text, 0, func (c) c == ` ` or c == `<` or c == `>`);
340
                }
341
            },
add brightness and lights co...
Sébastien MARQUE authored on 2020-04-27
342
        ];
settings with scrollable con...
Sébastien MARQUE authored on 2020-06-15
343
        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
344
        me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu;
345
        me.device.knobs.FmsInner = me.device.knobs.MenuSettings;
adds settings storage and re...
Sébastien MARQUE authored on 2020-06-17
346
        me.device.buttons.ENT = func (a = 0) {
347
            if (a) return;
348
            me.device.buttons.ValidateTMRREF();
349
            var settings_file = getprop('/sim/fg-home') ~'/aircraft-data/zkv1000.xml';
loads settings only if not a...
Sébastien MARQUE authored on 2020-06-18
350
            if (zkv.getNode('_save') == nil and io.stat(settings_file) != nil)
adds settings storage and re...
Sébastien MARQUE authored on 2020-06-17
351
                fgcommand('loadxml', props.Node.new({ filename: settings_file, targetnode: zkv.getNode('_save', 1).getPath() }));
352
            props.copy(zkv.getNode('save'), zkv.getNode('_save/' ~ getprop('/sim/aircraft'), 1), 1);
353
        }
add brightness and lights co...
Sébastien MARQUE authored on 2020-04-27
354
        me.device.buttons.CLR = func {
355
            me.device.windows.del(windowId);
356
            me.device.knobs.FmsOuter = func;
357
            me.device.knobs.FmsInner = func;
358
            foreach (var b; ['ENT', 'CLR'])
359
                me.device.buttons[b] = func;
360
            me.device.buttons.MENU = me.device.buttons.GlobalParams;
adds settings storage and re...
Sébastien MARQUE authored on 2020-06-17
361
            if (zkv.getNode('save') != nil) {
362
                fgcommand('savexml', props.Node.new({ filename: getprop('/sim/fg-home') ~'/aircraft-data/zkv1000.xml',
363
                      sourcenode: zkv.getNode('_save').getPath() }));
364
                zkv.getNode('_save').remove();
365
                zkv.getNode('save').remove();
366
            }
add brightness and lights co...
Sébastien MARQUE authored on 2020-04-27
367
        }
368
        me.device.buttons.MENU = me.device.buttons.CLR;
369
    },
370

            
handle DTO button
Sébastien MARQUE authored on 2020-05-16
371
    DirectTo : func (a) {
372
        if (a) return;
373
        if (me.device.windows.selected == nil) return;
374
        var (id, selected) = split('-', me.device.windows.selected);
375
        var state = me.device.windows.state[id];
376
        selected += state.scroll.offset;
377
        var scratch = props.globals.getNode('/instrumentation/gps/scratch');
378
        if (contains(state.objects[selected], 'dto')) {
379
            scratch.setValue('longitude-deg', state.objects[selected].dto.lon);
380
            scratch.setValue('latitude-deg', state.objects[selected].dto.lat);
381
            scratch.setValue('ident', state.objects[selected].dto.id);
382
            scratch.setValue('altitude-ft', data.alt);
383
            setprop('/instrumentation/gps/command', 'direct');
384
        }
385
    },
386

            
adds FPL button
Sébastien MARQUE authored on 2020-06-11
387
    FPL : func (a) {
388
        if (a or data.fpSize == 0 or me.device.windows.selected != '')
389
            return;
390
        var windowId = 'FLIGHTPLAN LIST';
391
        var flightplan = props.globals.getNode('/autopilot/route-manager');
392
        var route = flightplan.getNode('route');
393
        var obj_infos = [];
394
        var firstEntry = 1;
395
        var current = flightplan.getValue('current-wp');
396
        for (var i = current; i <= data.fpSize; i += 1) {
397
            var wp = route.getChild('wp', i);
398
            append(obj_infos, {
399
                type: (firstEntry ? 'selected' : 'editable'),
400
                text: sprintf('#%2d %-10s', data.fpSize - i, wp.getValue('id')),
401
                scrollgroup: i - current,
402
                dto: {
403
                    lon: wp.getValue('lon'),
404
                    lat: wp.getValue('lat'),
405
                    id:  wp.getValue('id')
406
                },
407
            });
408
            append(obj_infos, {
409
                type: 'normal|end-of-line',
410
                scrollgroup: i - current,
411
                text: sprintf(' %3dNM %3d°',
412
                              math.round(wp.getValue('leg-distance-nm')),
413
                              math.round(wp.getValue('leg-bearing-true-deg')))
414
            });
415
            firstEntry = 0;
416
        }
417
        me.device.windows.draw(windowId, obj_infos, {lines: 6, columns: 2});
418
        me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu;
419
        me.device.knobs.FmsInner = me.device.knobs.NavigateMenu;
420
        me.device.buttons.ENT = func;
421
        me.device.buttons.MENU = func;
422
        me.device.buttons.CLR = func {
423
            me.device.windows.del(windowId);
424
            if (me.device.role == 'PFD') {
425
                me.device.knobs.FmsOuter = func;
426
                me.device.knobs.FmsInner = func;
427
                me.device.buttons.MENU   = me.device.buttons.GlobalParams;
428
            }
429
            else {
430
                me.device.knobs.FmsInner = func;
431
                me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group;
432
                me.device.buttons.MENU   = me.device.buttons.MapMenu;
433
            }
434
            foreach (var b; ['ENT', 'CLR'])
435
                me.device.buttons[b] = func;
436
        }
437
        me.device.buttons.MENU = me.device.buttons.CLR;
438
    },
439

            
commit initial
Sébastien MARQUE authored on 2017-03-07
440
    MENU : void,
441
    PROC : void,
442
    CLR : void,
443
    ENT : void,
444
    FMS : void,
445
};