zkv1000 / Nasal / display.nas /
Newer Older
1276 lines | 48.132kb
comment on the folds
Sébastien MARQUE authored on 2017-03-13
1
# vim: set foldmethod=marker foldmarker={{{,}}} :
commit initial
Sébastien MARQUE authored on 2017-03-07
2
var displayClass = {
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
3
    new: func(device) {
add new vim folds
Sébastien MARQUE authored on 2017-03-15
4
# the contructor {{{
commit initial
Sébastien MARQUE authored on 2017-03-07
5
        var m = { parents: [ displayClass ] };
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
6

            
commit initial
Sébastien MARQUE authored on 2017-03-07
7
        m.display = canvas.new({
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
8
                "name"      : device.name,
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
9
                "size"      : [1280, 1280],
10
                "view"      : [1024, 768],
commit initial
Sébastien MARQUE authored on 2017-03-07
11
                "mipmapping": 1
12
        });
13
        m.display.addPlacement({
configurable display size, v...
Sébastien MARQUE authored on 2017-04-15
14
                "node": device.data['screen-object'] != nil ? device.data['screen-object'] : "Screen",
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
15
                "parent": device.name
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
16
            });
commit initial
Sébastien MARQUE authored on 2017-03-07
17
        m.display.setColorBackground(0,0,0);
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
18
        m.role = device.role;
pass device pointer to displ...
Sébastien MARQUE authored on 2017-03-14
19
        m.device = device;
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
20
        m.screenElements = {};
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
21
        m.screen = m.display
22
            .createGroup()
23
            .show();
commit initial
Sébastien MARQUE authored on 2017-03-07
24

            
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
25
        m.timers2 = {}; # tho old timer implementation use already a named timer hash
26
        # Softkeys revert to the previous level after 45 seconds of inactivity.
27
        m.softkeys_inactivity_delay = 45;
28

            
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
29
            var groups = {
animation VSI
Sébastien MARQUE authored on 2017-03-10
30
                show : [
makes header visible on MFD ...
Sébastien MARQUE authored on 2017-03-18
31
                    'Header',
commit initial
Sébastien MARQUE authored on 2017-03-07
32
                    'SoftKeysTexts', 
33
                    'COMM', 
34
                    'NAV', 
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
35
                    'nav-freq-switch',
36
                    'comm-freq-switch',
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
37
                ],
38
                text: [
39
                    'nav1-standby-freq', 'nav1-selected-freq', 'nav1-id',
40
                    'nav2-standby-freq', 'nav2-selected-freq', 'nav2-id',
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
41
                    'comm1-standby-freq', 'comm1-selected-freq',
42
                    'comm2-standby-freq', 'comm2-selected-freq',
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
43
                ],
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
44
                hide : [ 'Failures', 'NAV-COMM-Failures' ],
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
45
                clip: [ ],
46
            };
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
47

            
add softkeys colors
Sébastien MARQUE authored on 2017-03-21
48
            for (var k = 0; k < 12; k += 1) {
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
49
                append(groups.text, sprintf("SoftKey%02i-text", k));
add softkeys colors
Sébastien MARQUE authored on 2017-03-21
50
                append(groups.show, sprintf("SoftKey%02i-bg", k));
51
            }
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
52

            
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
53
            if (m.device.role == 'PFD') {
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
54
                append(groups.show,
adds some vim z-folds
Sébastien MARQUE authored on 2017-04-19
55
# {{{
commit initial
Sébastien MARQUE authored on 2017-03-07
56
                    'XPDR-TIME', 
AI disponible
Sébastien MARQUE authored on 2017-03-10
57
                    'FlightInstruments',
58
                    'Horizon',
AI disponible, avec bankPoin...
Sébastien MARQUE authored on 2017-03-10
59
                    'bankPointer',
animation VSI
Sébastien MARQUE authored on 2017-03-10
60
                    'VSI',
animation HSI
Sébastien MARQUE authored on 2017-03-11
61
                    'Rose',
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
62
                    'Heading-bug',
63
                    'PFD-Widgets',
trends animation
Sébastien MARQUE authored on 2017-03-13
64
                    'Trends',
65
                    'Airspeed-Trend-Indicator',
66
                    'Altitude-Trend-Indicator',
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
67
                    'OAT',
68
                    'IAS-bg',
69
                    'TAS',
70
                    'GSPD',
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
71
                    'BARO-bg',
adds slipskid animation
Sébastien MARQUE authored on 2017-03-24
72
                    'SlipSkid',
add V-speeds bugs
Sébastien MARQUE authored on 2017-04-04
73
                    'IAS-Vx', 'IAS-Vy', 'IAS-Vr', 'IAS-Vglide',
adds some vim z-folds
Sébastien MARQUE authored on 2017-04-19
74
# }}}
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
75
                );
76
                append(groups.hide,
adds some vim z-folds
Sébastien MARQUE authored on 2017-04-19
77
# {{{
adds EIS
Sébastien MARQUE authored on 2017-03-18
78
                    'EIS',
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
79
                    'CDI',
adds OMI to PFD
Sébastien MARQUE authored on 2017-03-23
80
                    'OMI', 'MarkerBG', 'MarkerText',
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
81
                    'VDI',
adds CDI
Sébastien MARQUE authored on 2017-03-18
82
                    'NAV1-pointer', 'NAV1-CDI', 'NAV1-FROM', 'NAV1-TO',
83
                    'NAV2-pointer', 'NAV2-CDI', 'NAV2-FROM', 'NAV2-TO',
84
                    'GPS-pointer', 'GPS-CDI', 'GPS-CTI', 'GPS-CTI-diamond', 'GPS-FROM', 'GPS-TO',
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
85
                    'BRG1-pointer',
86
                    'BRG2-pointer',
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
87
                    'SelectedHDG-bg',
88
                    'SelectedHDG-bgtext',
89
                    'SelectedHDG-text',
90
                    'SelectedCRS-bg',
91
                    'SelectedCRS-bgtext',
92
                    'SelectedCRS-text',
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
93
                    'SelectedALT', 'SelectedALT-bug', 'SelectedALT-bg', 'SelectedALT-symbol',
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
94
                    'TAS',
95
                    'GSPD',
96
                    'WindData',
97
                    'Reversionnary',
98
                    'Annunciation',
99
                    'Comparator',
100
                    'BRG1',
101
                    'BRG2',
102
                    'DME1',
makes map available for PFD ...
Sébastien MARQUE authored on 2017-04-19
103
                    'PFD-Map-bg',
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
104
                    'PFD-Multilines',
improves WindData display
Sébastien MARQUE authored on 2017-03-16
105
                    'WindData', 'WindData-OPTN1', 'WindData-OPTN2', 'WindData-OPTN1-HDG', 'WindData-OPTN2-symbol', 'WindData-OPTN2-headwind', 'WindData-OPTN2-crosswind', 'WindData-NODATA',
nicer AOA display
Sébastien MARQUE authored on 2017-04-16
106
                    'AOA', 'AOA-needle', 'AOA-text', 'AOA-approach',
adds some vim z-folds
Sébastien MARQUE authored on 2017-04-19
107
# }}}
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
108
                );
109
                append(groups.clip,
adds some vim z-folds
Sébastien MARQUE authored on 2017-04-19
110
# {{{
animation IAS
Sébastien MARQUE authored on 2017-03-10
111
                    'SpeedLint1',
animation ALT
Sébastien MARQUE authored on 2017-03-11
112
                    'SpeedTape',
113
                    'LintAlt',
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
114
                    'AltLint00011',
115
                    'PitchScale',
adds some vim z-folds
Sébastien MARQUE authored on 2017-04-19
116
# }}}
animation ALT
Sébastien MARQUE authored on 2017-03-11
117
                );
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
118
                append(groups.text,
adds some vim z-folds
Sébastien MARQUE authored on 2017-04-19
119
# {{{
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
120
                    'SelectedALT-text',
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
121
                    'TAS-text',
122
                    'GSPD-text',
anime time display
Sébastien MARQUE authored on 2017-03-13
123
                    'TIME-text',
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
124
                    'OAT-text',
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
125
                    'VSIText',
126
                    'Speed110',
127
                    'Alt11100',
128
                    'HDG-text',
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
129
                    'BARO-text',
adds CDI
Sébastien MARQUE authored on 2017-03-18
130
                    'CDI-SRC-text', 'CDI-GPS-ANN-text', 'CDI-GPS-XTK-text',
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
131
                    'BRG1-pointer', 'BRG1-SRC-text', 'BRG1-DST-text', 'BRG1-WPID-text',
132
                    'BRG2-pointer', 'BRG2-SRC-text', 'BRG2-DST-text', 'BRG2-WPID-text',
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
133
                    'WindData-OPTN1-HDG-text', 'WindData-OPTN1-SPD-text',
134
                    'WindData-OPTN2-crosswind-text', 'WindData-OPTN2-headwind-text',
adds transponder
Sébastien MARQUE authored on 2017-03-17
135
                    'XPDR-MODE-text', 'XPDR-DIGIT-3-text', 'XPDR-DIGIT-2-text', 'XPDR-DIGIT-1-text', 'XPDR-DIGIT-0-text',
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
136
                    'AltBigC', 'AltSmallC'
adds some vim z-folds
Sébastien MARQUE authored on 2017-04-19
137
# }}}
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
138
                );
139
                for (var place = 1; place <= 6; place +=1) {
140
                    append(groups.text,
141
                        'AltBigU' ~ place,
142
                        'AltSmallU' ~ place,
143
                        'AltBigD' ~ place,
144
                        'AltSmallD' ~ place
145
                    );
146
                }
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
147
                canvas.parsesvg(m.screen, data.zkv1000_reldir ~ 'Systems/PFD.svg');
animation ALT
Sébastien MARQUE authored on 2017-03-11
148
            }
adds EIS
Sébastien MARQUE authored on 2017-03-18
149
            else {
EIS now really specific to a...
Sébastien MARQUE authored on 2017-04-20
150
                var eis_file = getprop('/instrumentation/zkv1000/eis/type');
151
                if (eis_file == nil)
152
                    eis_file = getprop('/instrumentation/zkv1000/eis/file');
153

            
154
                if (eis_file != nil) {
155
                    if (find('/', eis_file) == -1)
156
                        eis_file = data.zkv1000_dir ~ 'Nasal/EIS/' ~ eis_file ~ '.nas';
157
                    elsif (split('/', eis_file)[0] == 'Aircraft') {
158
                        var path = split('/', eis_file);
159
                        if (getprop('/sim/fg-aircraft') != nil) {
160
                            eis_file = getprop('/sim/fg-aircraft');
161
                            for (var i = 1; i < size(path); i += 1)
162
                                eis_file ~= '/' ~ path[i];
163
                        }
164
                        else
165
                            eis_file = getprop('/sim/fg-root') ~ '/' ~ eis_file;
166
                    }
167
                }
168
                else
169
                    eis_file = data.zkv1000_dir ~ 'Nasal/EIS/none.nas';
170

            
171
                if (io.stat(eis_file) == nil
172
                and print(eis_file ~ ' not found'))
173
                    eis_file = data.zkv1000_dir ~ 'Nasal/EIS/none.nas';
174
                io.load_nasal(eis_file, 'zkv1000');
175

            
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
176
                if (contains(m.parents[0], 'showEIS'))
177
                    m.showEIS(groups);
adds EIS
Sébastien MARQUE authored on 2017-03-18
178
            }
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
179

            
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
180
            canvas.parsesvg(m.screen, data.zkv1000_reldir ~ 'Systems/softkeys.svg');
181
            canvas.parsesvg(m.screen, data.zkv1000_reldir ~ 'Systems/header-nav-comm.svg');
animation ALT
Sébastien MARQUE authored on 2017-03-11
182

            
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
183
            m.loadGroup(groups);
184

            
185
            if (m.device.role == 'PFD') {
186
                m.device.data.aoa = 0;
187
                m.device.data['aoa-auto'] = 0;
188
                m.device.data.mapclip = {
189
                    top: math.ceil(m.screenElements['PFD-Map-bg'].getTransformedBounds()[1]) - 1,
190
                    right: math.ceil(m.screenElements['PFD-Map-bg'].getTransformedBounds()[2]) - 1,
191
                    bottom: math.ceil(m.screenElements['PFD-Map-bg'].getTransformedBounds()[3]) - 1,
192
                    left: math.ceil(m.screenElements['PFD-Map-bg'].getTransformedBounds()[0]) - 1,
makes map available for PFD ...
Sébastien MARQUE authored on 2017-04-19
193
                };
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
194
            }
animation texts EIS + power ...
Sébastien MARQUE authored on 2017-03-19
195
            else {
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
196
                m.device.data.mapclip = {
197
                    top: math.ceil(m.screenElements['Header'].getTransformedBounds()[3]),
198
                    right: m.display.get('view[0]'),
199
                    bottom: math.ceil(m.screenElements['SoftKeysTexts'].getTransformedBounds()[1]),
200
                    left: contains(m.screenElements, 'EIS') ? math.ceil(m.screenElements['EIS'].getTransformedBounds()[2]) : 0,
set MFD map size relative to...
Sébastien MARQUE authored on 2017-04-18
201
                };
makes map available for PFD ...
Sébastien MARQUE authored on 2017-04-19
202
            }
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
203
        return m;
204
    },
205
#}}}
makes map available for PFD ...
Sébastien MARQUE authored on 2017-04-19
206

            
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
207
# timers stuff {{{
208
    timers : {},
209

            
210
    timerTrigger : func {
211
        var now = systime();
212
        foreach (var id; keys(me.timers)) {
213
            if (me.timers[id] < now) {
214
                me.screenElements[id].hide();
215
                delete(me.timers, id);
216
            }
commit initial
Sébastien MARQUE authored on 2017-03-07
217
        }
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
218
        settimer(func me.timerTrigger(), 1);
219
    },
220

            
221
    addTimer : func (duration, element) {
222
        if (typeof(element) == 'scalar')
223
            element = [ element ];
224
        var end = systime() + duration;
225
        foreach (var e; element)
226
            me.timers[e] = end;
commit initial
Sébastien MARQUE authored on 2017-03-07
227
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
228
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
229

            
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
230
    showInitProgress : func {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
231
#{{{
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
232
        if (me.device.role == 'PFD') {
233
            me.updateAI();
234
            me.updateVSI();
235
            me.updateIAS();
236
            me.updateALT();
237
            me.updateHSI();
238
            me.updateTIME();
239
            me.updateOAT();
240
            me.updateTAS();
241
            me.updateBRG();
242
            me.updateXPDR();
243
            me.updateBARO();
244
            me.updateOMI();
245
            me.timerTrigger();
246
            me.screen.show();
247
        }
248
        else {
249
            me.updateEIS();
250
            io.load_nasal(data.zkv1000_dir ~ 'Nasal/MFD.pages.nas', 'zkv1000');
251
            me['page selected'] = 0;
252
            me.device.data['page selection'] = [
253
# {{{
254
                {
255
                    name: 'MAP',
256
                    objects: [
257
                        {text: 'NAVIGATION MAP'},
258
                        {text: 'TRAFFIC MAP'},
259
                        {text: 'STORMSCOPE'},
260
                        {text: 'WEATHER DATA LINK'},
261
                        {text: 'TAWS-B'},
262
                    ],
263
                },
264
                {
265
                    name: 'WPT',
266
                    objects: [
267
                        {text: 'AIRPORT INFORMATION'},
268
                        {text: 'AIRPORT DIRECTORY'},
269
                        {text: 'DEPARTURE INFORMATION'},
270
                        {text: 'ARRIVAL INFORMATION'},
271
                        {text: 'APPROACH INFORMATION'},
272
                        {text: 'WEATHER INFORMATION'},
273
                        {text: 'INTERSECTION INFORMATION'},
274
                        {text: 'NDB INFORMATION'},
275
                        {text: 'VOR INFORMATION'},
276
                        {text: 'USER WAYPOINT INFORMATION'},
277
                    ],
278
                },
279
                {
280
                    name: 'AUX',
281
                    objects: [
282
                        {text: 'TRIP PLANNING'},
283
                        {text: 'UTILITY'},
284
                        {text: 'GPS STATUS'},
285
                        {text: 'SYSTEM SETUP'},
286
                    ],
287
                },
288
                {
289
                    name: 'FPL',
290
                    objects: [
291
                        {text: 'ACTIVE FLIGHT PLAN'},
292
                        {text: 'WIDE VIEW, NARROW VIEW'},
293
                        {text: 'FLIGHT PLAN CATALOG'},
294
                    ],
295
                },
296
                {
297
                    name: 'PROC',
298
                    objects: [
299
                        {text: 'DEPARTURE LOADING'},
300
                        {text: 'ARRIVAL LOADING'},
301
                        {text: 'APPROACH LOADING'},
302
                    ],
303
                },
304
                {
305
                    name: 'NRST',
306
                    objects: [
307
                        {text: 'NEAREST AIRPORTS'},
308
                        {text: 'NEAREST INTERSECTIONS'},
309
                        {text: 'NEAREST NDB'},
310
                        {text: 'NEAREST VOR'},
311
                        {text: 'NEAREST USER WAYPOINTS'},
312
                        {text: 'NEAREST FREQUENCIES'},
313
                        {text: 'NEAREST AIRSPACES'},
314
                    ],
315
                },
316
# }}}
317
            ];
318
            me.setMFDPages();
319
            me.device.buttons.MENU = me.device.buttons.MapMenu;
320
        }
commit initial
Sébastien MARQUE authored on 2017-03-07
321

            
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
322
        me.updateNAV({auto:'nav', tune: radios.getNode('nav-tune').getValue()});
323
        me.updateCOMM({auto:'comm', tune: radios.getNode('comm-tune').getValue()});
324
        me.softkeys_inactivity();
325
        me.updateSoftKeys();
commit initial
Sébastien MARQUE authored on 2017-03-07
326
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
327
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
328

            
some added comments
Sébastien MARQUE authored on 2017-03-18
329
    colors : {
330
# set of predefined colors {{{
331
        green : [0, 1, 0],
332
        white : [1, 1, 1],
333
        black : [0, 0, 0],
334
        lightblue : [0, 1, 1],
335
        darkblue : [0, 0, 1],
336
        red : [1, 0, 0],
adds CDI
Sébastien MARQUE authored on 2017-03-18
337
        magenta : [1, 0, 1],
some added comments
Sébastien MARQUE authored on 2017-03-18
338
    },
339
#}}}
340

            
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
341
    loadGroup : func (h) {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
342
#{{{
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
343
        if (typeof(h) != 'hash') {
344
            msg_dbg(sprintf("%s need a hash, but get a %s from %s",
345
                    caller(0)[0],
346
                    typeof(h),
347
                    caller(1)[0]));
348
            return;
commit initial
Sébastien MARQUE authored on 2017-03-07
349
        }
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
350
        var setMethod = func (e, t) {
351
            if (t == 'hide')
352
                me.screenElements[e].hide();
353
            elsif (t == 'show')
354
                me.screenElements[e].show();
AI disponible
Sébastien MARQUE authored on 2017-03-10
355
            elsif (t == 'rot' or t == 'trans') {
356
                if (! contains(me.screenElements[e], t))
357
                    me.screenElements[e][t] = me.screenElements[e].createTransform();
358
            }
359
            elsif (t == 'clip') {
360
                if (contains(me.clips, e))
361
                    me.screenElements[e].set("clip", me.clips[e]);
362
                else
printlog with adapted level ...
Sébastien MARQUE authored on 2017-03-20
363
                    printlog('warn', 'no defined clip for ' ~ e);
AI disponible
Sébastien MARQUE authored on 2017-03-10
364
            }
animation VSI
Sébastien MARQUE authored on 2017-03-10
365
            elsif (t == 'text') {
366
                if (contains(me.texts, e)) {
367
                    if (contains(me.texts[e], 'alignment'))
368
                        me.screenElements[e].setAlignment(me.texts[e].alignment);
369
                    if (contains(me.texts[e], 'default'))
370
                        me.screenElements[e].setText(me.texts[e].default);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
371
                    if (contains(me.texts[e], 'color'))
372
                        me.screenElements[e].setColor(me.texts[e].color);
adds CDI
Sébastien MARQUE authored on 2017-03-18
373
                    if (contains(me.texts[e], 'visible'))
374
                        me.screenElements[e].setVisible(me.texts[e].visible);
animation VSI
Sébastien MARQUE authored on 2017-03-10
375
                }
printlog with adapted level ...
Sébastien MARQUE authored on 2017-03-20
376
                else
377
                    printlog('debug', 'no text format for ' ~ e);
animation VSI
Sébastien MARQUE authored on 2017-03-10
378
            }
commit initial
Sébastien MARQUE authored on 2017-03-07
379
            else
printlog with adapted level ...
Sébastien MARQUE authored on 2017-03-20
380
                printlog('warn', 'unknown method ' ~ t);
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
381
        };
382
        foreach (var todo; keys(h)) {
383
            if (typeof(h[todo]) != 'vector') h[todo] = [ h[todo] ];
384
            foreach (var id; h[todo]) {
385
                if (! contains(me.screenElements, id)) {
386
                    me.screenElements[id] = me.screen.getElementById(id);
387
                    if (me.screenElements[id] != nil)
388
                        setMethod(id, todo);
389
                    else
printlog with adapted level ...
Sébastien MARQUE authored on 2017-03-20
390
                        printlog('warn', 'SVG ID ' ~ id ~ ' not found');
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
391
                }
392
                else
393
                    setMethod(id, todo);
394
            }
commit initial
Sébastien MARQUE authored on 2017-03-07
395
        }
396
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
397
#}}}
AI disponible
Sébastien MARQUE authored on 2017-03-10
398

            
399
    clips : {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
400
#{{{
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
401
        PitchScale   : "rect(70,664,370,256)",
402
        SpeedLint1   : "rect(252,226,318,204)",
403
        SpeedTape    : "rect(115,239,455,156)",
404
        LintAlt      : "rect(115,808,455,704)",
animation ALT
Sébastien MARQUE authored on 2017-03-11
405
        AltLint00011 : "rect(252,804,318,771)",
AI disponible
Sébastien MARQUE authored on 2017-03-10
406
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
407
#}}}
AI disponible
Sébastien MARQUE authored on 2017-03-10
408

            
animation VSI
Sébastien MARQUE authored on 2017-03-10
409
    texts : {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
410
#{{{
animation VSI
Sébastien MARQUE authored on 2017-03-10
411
        VSIText : {
412
            alignment: "right-bottom", default : num('0'),
413
        },
animation IAS
Sébastien MARQUE authored on 2017-03-10
414
        Speed110 : {
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
415
            alignment : 'left-bottom'
animation IAS
Sébastien MARQUE authored on 2017-03-10
416
        },
animation ALT (2)
Sébastien MARQUE authored on 2017-03-11
417
        Alt11100 : {
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
418
            alignment:'left-bottom'
animation ALT (2)
Sébastien MARQUE authored on 2017-03-11
419
        },
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
420
        "HDG-text" : {
421
            default: '---°'
422
        },
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
423
        'nav1-standby-freq' : {
424
            color: [0, 1, 1],
425
        },
426
        'nav1-id' : {
427
            default: ''
428
        },
429
        'nav2-id' : {
430
            default: ''
431
        },
adds CDI
Sébastien MARQUE authored on 2017-03-18
432
        'CDI-GPS-ANN-text' : {
433
            visible : 0
434
        },
435
        'CDI-GPS-XTK-text' : {
436
            visible : 0
437
        },
438
        'CDI-SRC-text' : {
439
            visible : 0
440
        },
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
441
        'BARO-text' : {
442
            alignment : 'left-bottom',
443
        }
some added comments
Sébastien MARQUE authored on 2017-03-18
444
#        'TAS-text' : {
445
#            alignment : 'right-bottom',
446
#        },
447
#        'GSPD-text' : {
448
#            alignment : 'right-bottom',
449
#        },
animation VSI
Sébastien MARQUE authored on 2017-03-10
450
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
451
#}}}
animation VSI
Sébastien MARQUE authored on 2017-03-10
452

            
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
453
    softkeys_inactivity : func {
454
# automagically back to previous level after some delay {{{
455
        me.timers2.softkeys_inactivity = maketimer (
456
            me.softkeys_inactivity_delay,
457
            func {
458
                pop(me.device.softkeys.path);
459
                me.updateSoftKeys();
460
            }, me);
461
        me.timers2.softkeys_inactivity.singleShot = 1;
462
    },
463
#}}}
464

            
add softkeys colors
Sébastien MARQUE authored on 2017-03-21
465
    setSoftKeyColor : func (n, active, alert = 0) {
466
# set colors for active softkeys {{{
467
        var sftk = sprintf('SoftKey%02i-', n);
468
        if (active) {
469
            var bg = alert ? 1 : 0.5;
470
            me.screenElements[sftk ~ 'bg']
471
                .setColorFill(bg,bg,bg);
472
            me.screenElements[sftk ~ 'text']
473
                .setColor(0,0,0);
474
        }
475
        else {
476
            me.screenElements[sftk ~ 'bg']
477
                .setColorFill(0,0,0);
478
            me.screenElements[sftk ~ 'text']
479
                .setColor(1,1,1);
480
        }
481
    },
482
#}}}
483

            
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
484
    updateSoftKeys : func {
485
# update SoftKeys boxes {{{
486
        # on PFD the last boxes are always BACK and ALERTS
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
487
        if (me.device.role == 'PFD') {
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
488
            me.screenElements[sprintf("SoftKey%02i-text", 11)]
489
                .setText('ALERTS');
490
            if (size(me.device.softkeys.path) != 0)
491
                me.screenElements[sprintf("SoftKey%02i-text", 10)]
492
                    .setText('BACK');
493
        }
494

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
495
        var path = keyMap[me.device.role];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
496
        var pathid = '';
497
        foreach (var p; me.device.softkeys.path) {
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
498
            path = path[p];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
499
            pathid ~= p;
500
        }
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
501

            
502
        # feeding with empty menus the first boxes
503
        var start = (contains(path, 'first')) ? path.first : 0;
504
        for (var k = 0; k < start; k+=1) {
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
505
            var sftk = sprintf("SoftKey%02i-", k);
506
            me.screenElements[sftk ~ 'text']
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
507
                .setText('');
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
508
            me.screenElements[sftk ~ 'bg']
509
                .setColorFill(0,0,0);
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
510
        }
511
        # filling with the content the next boxes
512
        forindex (var k; path.texts) {
513
            var i = k + start;
514
            me.screenElements[sprintf("SoftKey%02i-text", i)]
515
                .setText(path.texts[k]);
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
516
            me.setSoftKeyColor(i,
517
                    contains(me.device.softkeys.colored, pathid ~ path.texts[k]));
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
518
        }
519
        # feeding the last boxes with empty string
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
520
        var end = (me.device.role == 'PFD') ? 10 : 12;
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
521
        if (size(path.texts) + start < end) {
522
            start = size(path.texts) + start;
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
523
            for (var k = start; k < end; k += 1) {
524
                var sftk = sprintf("SoftKey%02i-", k);
525
                me.screenElements[sftk ~ 'text']
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
526
                    .setText('');
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
527
                me.screenElements[sftk ~ 'bg']
528
                    .setColorFill(0,0,0);
529
            }
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
530
        }
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
531

            
532
        if (size(me.device.softkeys.path))
533
            me.timers2.softkeys_inactivity.restart(me.softkeys_inactivity_delay);
534
        else
535
            me.timers2.softkeys_inactivity.stop();
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
536
    },
537
#}}}
538

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
539
    updateAI: func(){
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
540
#{{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
541
        var pitch = data.pitch;
542
        var roll = data.roll;
AI disponible
Sébastien MARQUE authored on 2017-03-10
543
        if (pitch > 80)
544
            pitch = 80;
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
545
        elsif (pitch < -80)
AI disponible
Sébastien MARQUE authored on 2017-03-10
546
            pitch = -80;
547
        me.screenElements.Horizon
fix AI animation
Sébastien MARQUE authored on 2017-03-19
548
            .setCenter(459, 282.8 - 6.849 * pitch)
AI disponible
Sébastien MARQUE authored on 2017-03-10
549
            .setRotation(-roll * D2R)
fix AI animation
Sébastien MARQUE authored on 2017-03-19
550
            .setTranslation(0, pitch * 6.849);
AI disponible, avec bankPoin...
Sébastien MARQUE authored on 2017-03-10
551
        me.screenElements.bankPointer
552
            .setRotation(-roll * D2R);
adds slipskid animation
Sébastien MARQUE authored on 2017-03-24
553
        me.screenElements['SlipSkid']
554
            .setTranslation(getprop("/instrumentation/slip-skid-ball/indicated-slip-skid") * 10, 0);
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
555
        settimer(func me.updateAI(), 0.1);
AI disponible
Sébastien MARQUE authored on 2017-03-10
556
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
557
#}}}
animation VSI
Sébastien MARQUE authored on 2017-03-10
558

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
559
    updateVSI: func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
560
# animate VSI {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
561
        var vsi = data.vsi;
animation VSI
Sébastien MARQUE authored on 2017-03-10
562
        me.screenElements.VSIText
563
            .setText(num(math.round(vsi, 10)));
564
        if (vsi > 4500)
565
            vsi = 4500;
566
        elsif (vsi < -4500)
567
            vsi = -4500;
568
        me.screenElements.VSI
569
            .setTranslation(0, vsi * -0.03465);
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
570
        settimer(func me.updateVSI(), 0.1);
animation VSI
Sébastien MARQUE authored on 2017-03-10
571
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
572
#}}}
animation IAS
Sébastien MARQUE authored on 2017-03-10
573

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
574
    updateIAS: func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
575
# animates the IAS lint (PFD) {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
576
        var ias = data.ias;
animation IAS
Sébastien MARQUE authored on 2017-03-10
577
        if (ias >= 10)
578
            me.screenElements.Speed110
579
                .setText(sprintf("% 2u",num(math.floor(ias/10))));
580
        else
581
            me.screenElements.Speed110
582
                .setText('');
583
        me.screenElements.SpeedLint1
584
            .setTranslation(0,(math.mod(ias,10) + (ias >= 10)*10) * 36);
585
        me.screenElements.SpeedTape
586
            .setTranslation(0,ias * 5.711);
put Vspeeds in common data s...
Sébastien MARQUE authored on 2017-04-11
587
        if (ias > data.Vne and ! me._ias_already_exceeded) { # easier than .getColorFill
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
588
            me._ias_already_exceeded = 1;
589
            me.screenElements['IAS-bg']
590
                .setColorFill(1,0,0);
591
        }
put Vspeeds in common data s...
Sébastien MARQUE authored on 2017-04-11
592
        elsif (ias < data.Vne and me._ias_already_exceeded) { # easier than .getColorFill
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
593
            me._ias_already_exceeded = 0;
594
            me.screenElements['IAS-bg']
595
                .setColorFill(0,0,0);
596
        }
add V-speeds bugs
Sébastien MARQUE authored on 2017-04-04
597
        foreach (var v; ['Vx', 'Vy', 'Vr', 'Vglide']) {
put Vspeeds in common data s...
Sébastien MARQUE authored on 2017-04-11
598
            if (me.device.data[v ~ '-visible'] and abs(data[v] - ias) < 30)
add V-speeds bugs
Sébastien MARQUE authored on 2017-04-04
599
                me.screenElements['IAS-' ~ v]
put Vspeeds in common data s...
Sébastien MARQUE authored on 2017-04-11
600
                    .setTranslation(0, (ias - data[v]) * 5.711)
add V-speeds bugs
Sébastien MARQUE authored on 2017-04-04
601
                    .show();
602
            else
603
                me.screenElements['IAS-' ~ v]
604
                    .hide();
605
        }
606

            
trends animation
Sébastien MARQUE authored on 2017-03-13
607
        var now = systime();
608
        # estimated speed in 6s
609
        var Sy = 6 * (ias - me._last_ias_kt) / (now - me._last_ias_s);
610
        if (abs(Sy) > 30)
611
            Sy = 30 * abs(Sy)/Sy; # = -30 or 30
612
        me.screenElements['Airspeed-Trend-Indicator']
613
            .setScale(1,Sy)
614
            .setTranslation(0, -284.5 * (Sy - 1));
615
        me._last_ias_kt = ias;
616
        me._last_ias_s = now;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
617
        settimer(func me.updateIAS(), 0.1);
animation IAS
Sébastien MARQUE authored on 2017-03-10
618
    },
trends animation
Sébastien MARQUE authored on 2017-03-13
619
    _last_ias_kt : 0,
620
    _last_ias_s : systime(),
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
621
    _ias_already_exceeded : 0,
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
622
#}}}
animation ALT
Sébastien MARQUE authored on 2017-03-11
623

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
624
    updateTAS: func {
625
# updates the True Airspeed and GroundSpeed indicators {{{
626
        me.screenElements['TAS-text']
627
            .setText(sprintf('%iKT', getprop('/instrumentation/airspeed-indicator/true-speed-kt')));
628
        me.screenElements['GSPD-text']
629
            .setText(sprintf('%iKT', getprop('/velocities/groundspeed-kt')));
630
        settimer(func me.updateTAS(), 0.5);
631
    },
632
#}}}
633

            
634
    updateALT: func () {
635
# animates the altitude lint (PFD) {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
636
        var alt = data.alt;
animation ALT
Sébastien MARQUE authored on 2017-03-11
637
        if (alt < 0)
638
            me.screenElements.Alt11100
639
                .setText(sprintf("% 3i",math.ceil(alt/100)));
640
        elsif (alt < 100)
641
            me.screenElements.Alt11100
642
                .setText('');
643
        else
644
            me.screenElements.Alt11100
645
                .setText(sprintf("% 3i",math.floor(alt/100)));
646
        me.screenElements.AltLint00011
647
            .setTranslation(0,math.fmod(alt,100) * 1.24);
648

            
649
        # From Farmin/G1000 http://wiki.flightgear.org/Project_Farmin/FG1000
650
        if (alt> -1000 and alt< 1000000) {
651
            var Offset10 = 0;
652
            var Offset100 = 0;
653
            var Offset1000 = 0;
654
            if (alt< 0) {
655
                var Ne = 1;
656
                var alt= -alt;
657
            }
658
            else
659
                var Ne = 0;
660

            
661
            var Alt10       = math.mod(alt,100);
662
            var Alt100      = int(math.mod(alt/100,10));
663
            var Alt1000     = int(math.mod(alt/1000,10));
664
            var Alt10000    = int(math.mod(alt/10000,10));
665
            var Alt20       = math.mod(Alt10,20)/20;
666
            if (Alt10 >= 80)
667
                var Alt100 += Alt20;
668

            
669
            if (Alt10 >= 80 and Alt100 >= 9)
670
                var Alt1000 += Alt20;
671

            
672
            if (Alt10 >= 80 and Alt100 >= 9 and Alt1000 >= 9)
673
                var Alt10000 += Alt20;
674

            
675
            if (alt> 100)
676
                var Offset10 = 100;
677

            
678
            if (alt> 1000)
679
                var Offset100 = 10;
680

            
681
            if (alt> 10000)
682
                var Offset1000 = 10;
683

            
684
            if (!Ne) {
685
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*0.57375);
686
                var altCentral = (int(alt/100)*100);
687
            }
688
            elsif (Ne) {
689
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*-0.57375);
690
                var altCentral = -(int(alt/100)*100);
691
            }
692
            me.screenElements["AltBigC"].setText("");
693
            me.screenElements["AltSmallC"].setText("");
694
            for (var place = 1; place <= 6; place += 1) {
695
                var altUP = altCentral + (place*100);
696
                var offset = -30.078;
697
                if (altUP < 0) {
698
                    var altUP = -altUP;
699
                    var prefix = "-";
700
                    var offset += 15.039;
701
                }
702
                else
703
                    var prefix = "";
704

            
705
                if (altUP == 0) {
706
                    var AltBigUP    = "";
707
                    var AltSmallUP  = "0";
708

            
709
                }
710
                elsif (math.mod(altUP,500) == 0 and altUP != 0) {
711
                    var AltBigUP    = sprintf(prefix~"%1d", altUP);
712
                    var AltSmallUP  = "";
713
                }
714
                elsif (altUP < 1000 and (math.mod(altUP,500))) {
715
                    var AltBigUP    = "";
716
                    var AltSmallUP  = sprintf(prefix~"%1d", int(math.mod(altUP,1000)));
717
                    var offset = -30.078;
718
                }
719
                elsif ((altUP < 10000) and (altUP >= 1000) and (math.mod(altUP,500))) {
720
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
721
                    var AltSmallUP  = sprintf("%1d", int(math.mod(altUP,1000)));
722
                    var offset += 15.039;
723
                }
724
                else {
725
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
726
                    var mod = int(math.mod(altUP,1000));
727
                    var AltSmallUP  = sprintf("%1d", mod);
728
                    var offset += 30.078;
729
                }
730

            
731
                me.screenElements["AltBigU"~place].setText(AltBigUP);
732
                me.screenElements["AltSmallU"~place].setText(AltSmallUP);
733
                me.screenElements["AltSmallU"~place].setTranslation(offset,0);
734
                var altDOWN = altCentral - (place*100);
735
                var offset = -30.078;
736
                if (altDOWN < 0) {
737
                    var altDOWN = -altDOWN;
738
                    var prefix = "-";
739
                    var offset += 15.039;
740
                }
741
                else
742
                    var prefix = "";
743

            
744
                if (altDOWN == 0) {
745
                    var AltBigDOWN  = "";
746
                    var AltSmallDOWN    = "0";
747
                }
748
                elsif (math.mod(altDOWN,500) == 0 and altDOWN != 0) {
749
                    var AltBigDOWN  = sprintf(prefix~"%1d", altDOWN);
750
                    var AltSmallDOWN    = "";
751
                }
752
                elsif (altDOWN < 1000 and (math.mod(altDOWN,500))) {
753
                    var AltBigDOWN  = "";
754
                    var AltSmallDOWN    = sprintf(prefix~"%1d", int(math.mod(altDOWN,1000)));
755
                    var offset = -30.078;
756
                }
757
                elsif ((altDOWN < 10000) and (altDOWN >= 1000) and (math.mod(altDOWN,500))) {
758
                    var AltBigDOWN  = sprintf(prefix~"%1d", int(altDOWN/1000));
759
                    var AltSmallDOWN    = sprintf("%1d", int(math.mod(altDOWN,1000)));
760
                    var offset += 15.039;
761
                }
762
                else {
763
                    var AltBigDOWN  = sprintf(prefix~"%1d", int(altDOWN/1000));
764
                    var mod = int(math.mod(altDOWN,1000));
765
                    var AltSmallDOWN    = sprintf("%1d", mod);
766
                    var offset += 30.078;
767
                }
768
                me.screenElements["AltBigD"~place].setText(AltBigDOWN);
769
                me.screenElements["AltSmallD"~place].setText(AltSmallDOWN);
770
                me.screenElements["AltSmallD"~place].setTranslation(offset,0);
771
            }
772
        }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
773
        me.updateSelectedALT();
trends animation
Sébastien MARQUE authored on 2017-03-13
774
        var now = systime();
775
        # altitude in 6s
776
        var Sy = .3 * (alt - me._last_alt_ft) / (now - me._last_alt_s); # scale = 1/20ft
777
        if (abs(Sy) > 15)
778
            Sy = 15 * abs(Sy)/Sy; # = -15 or 15
779
        me.screenElements['Altitude-Trend-Indicator']
780
            .setScale(1,Sy)
781
            .setTranslation(0, -284.5 * (Sy - 1));
782
        me._last_alt_ft = alt;
783
        me._last_alt_s = now;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
784
        settimer(func me.updateALT(), 0.2);
animation ALT
Sébastien MARQUE authored on 2017-03-11
785
    },
trends animation
Sébastien MARQUE authored on 2017-03-13
786
    _last_alt_ft : 0,
787
    _last_alt_s  : systime(),
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
788
#}}}
animation HSI
Sébastien MARQUE authored on 2017-03-11
789

            
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
790
    updateBARO : func () {
791
# update BARO widget {{{
792
        var fmt = me._baro_unit == 'inhg' ? '%.2f%s' : '%i%s';
793
        me.screenElements['BARO-text']
794
            .setText(sprintf(fmt,
795
                        getprop('/instrumentation/altimeter/setting-' ~ me._baro_unit),
796
                        me._baro_unit == 'inhg' ? 'in' : 'hPa')
797
                );
798
    },
799
    _baro_unit : 'inhg',
800
#}}}
801

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
802
    updateHSI : func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
803
# rotates the compass (PFD) {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
804
        var hdg = data.hdg;
animation HSI
Sébastien MARQUE authored on 2017-03-11
805
        me.screenElements.Rose
806
            .setRotation(-hdg * D2R);
807
        me.screenElements['HDG-text']
808
            .setText(sprintf("%03u°", hdg));
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
809
        settimer(func me.updateHSI(), 0.1);
animation HSI
Sébastien MARQUE authored on 2017-03-11
810
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
811
#}}}
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
812

            
removes unecessary listeners
Sébastien MARQUE authored on 2017-04-08
813
    updateHDG : func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
814
# moves the heading bug and display heading-deg for 3 seconds (PFD) {{{
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
815
        if (me.device.role == 'MFD')
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
816
            return;
removes unecessary listeners
Sébastien MARQUE authored on 2017-04-08
817
        var hdg = getprop('/instrumentation/zkv1000/afcs/heading-bug-deg');
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
818
        me.screenElements['Heading-bug']
819
            .setRotation(hdg * D2R);
820
        me.screenElements['SelectedHDG-bg']
821
            .show();
822
        me.screenElements['SelectedHDG-bgtext']
823
            .show();
824
        me.screenElements['SelectedHDG-text']
825
            .setText(sprintf('%03d°%s', hdg, ''))
826
            .show();
827
        me.addTimer(3, ['SelectedHDG-text', 'SelectedHDG-bgtext', 'SelectedHDG-bg']);
828
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
829
#}}}
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
830

            
adds CDI
Sébastien MARQUE authored on 2017-03-18
831
    updateCRS : func () {
anime CRS
Sébastien MARQUE authored on 2017-03-13
832
# TODO: update display for NAV/GPS/BRG courses {{{
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
833
        if (me.device.role == 'MFD')
anime CRS
Sébastien MARQUE authored on 2017-03-13
834
            return;
adds CDI
Sébastien MARQUE authored on 2017-03-18
835
        var source = getprop('/instrumentation/zkv1000/cdi/source');
836
        if (source == 'OFF')
837
            return;
838
        var crs = getprop('/instrumentation/zkv1000/cdi/course');
839
        if (crs == nil)
840
            return;
anime CRS
Sébastien MARQUE authored on 2017-03-13
841
        me.screenElements['SelectedCRS-bg']
842
            .show();
843
        me.screenElements['SelectedCRS-bgtext']
844
            .show();
845
        me.screenElements['SelectedCRS-text']
846
            .setText(sprintf('%03d°%s', crs, ''))
adds CDI
Sébastien MARQUE authored on 2017-03-18
847
            .setColor(source == 'GPS' ? me.colors.magenta : me.colors.green)
anime CRS
Sébastien MARQUE authored on 2017-03-13
848
            .show();
849
        me.addTimer(3, ['SelectedCRS-text', 'SelectedCRS-bgtext', 'SelectedCRS-bg']);
850
    },
851
#}}}
852

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
853
    updateSelectedALT : func {
854
# animation for altitude section, called via updatedALT {{{
creates flightdeck hash to p...
Sébastien MARQUE authored on 2017-04-07
855
        if (! me.screenElements['SelectedALT'].getVisible())
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
856
            return;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
857
        var selected_alt = getprop('/instrumentation/zkv1000/afcs/selected-alt-ft');
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
858
        var delta_alt = data.alt - selected_alt;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
859
        if (abs(delta_alt) > 300)
860
            delta_alt = 300 * abs(delta_alt)/delta_alt;
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
861
        me.screenElements['SelectedALT-symbol']
862
            .setVisible(abs(delta_alt) > 100);
863
        me.screenElements['SelectedALT-bg']
864
            .setVisible(abs(delta_alt) > 100);
865
        me.screenElements['SelectedALT-text']
866
            .setText(sprintf("%i", selected_alt))
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
867
            .setVisible(abs(delta_alt) > 100);
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
868
        me.screenElements['SelectedALT-bug']
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
869
            .setTranslation(0, delta_alt * 0.567); # 170/300 = 0.567
870
    },
871
#}}}
872

            
adds CDI
Sébastien MARQUE authored on 2017-03-18
873
    updateCDI : func {
874
# animation for CDI {{{
875
        var source = getprop('/instrumentation/zkv1000/cdi/source');
876
        if (source == 'OFF') {
877
            foreach (var s; ['GPS', 'NAV1', 'NAV2'])
878
                foreach (var t; ['pointer', 'CDI'])
879
                    me.screenElements[s ~ '-' ~ t].hide();
880
            me.screenElements['CDI-GPS-ANN-text'].hide();
881
            me.screenElements['CDI-GPS-XTK-text'].hide();
882
            me.screenElements['CDI-SRC-text'].hide();
883
            me.screenElements['CDI'].hide();
884
        }
885
        else {
886
            var course = getprop('/instrumentation/zkv1000/cdi/course');
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
887
            var rot = (course - data.hdg) * D2R;
adds CDI
Sébastien MARQUE authored on 2017-03-18
888
            me.screenElements['CDI']
makes the CDI available
Sébastien MARQUE authored on 2017-03-23
889
                .setRotation(rot)
adds CDI
Sébastien MARQUE authored on 2017-03-18
890
                .show();
891
            me.screenElements['GPS-CTI']
animates GPS-CTI
Sébastien MARQUE authored on 2017-03-24
892
                .setVisible(getprop('/instrumentation/gps/wp/wp[1]/valid'))
893
                .setRotation(getprop('/instrumentation/gps/wp/wp[1]/course-deviation-deg') * D2R);
adds CDI
Sébastien MARQUE authored on 2017-03-18
894
            me.screenElements['GPS-CTI-diamond']
animates GPS-CTI
Sébastien MARQUE authored on 2017-03-24
895
                .setVisible(getprop('/instrumentation/gps/wp/wp[1]/valid'))
896
                .setRotation(getprop('/instrumentation/gps/wp/wp[1]/course-deviation-deg') * D2R);
adds CDI
Sébastien MARQUE authored on 2017-03-18
897
            foreach (var s; ['GPS', 'NAV1', 'NAV2']) {
898
                me.screenElements[s ~ '-pointer']
899
                    .setRotation(rot)
900
                    .setVisible(source == s);
901
                me.screenElements[s ~ '-CDI']
902
                    .setVisible(source == s);
903
                foreach (var f; ['FROM', 'TO'])
904
                    me.screenElements[s ~ '-' ~ f]
makes the CDI available
Sébastien MARQUE authored on 2017-03-23
905
                        .setVisible(s == source and getprop('/instrumentation/zkv1000/cdi/' ~ f ~ '-flag'));
adds CDI
Sébastien MARQUE authored on 2017-03-18
906
                me.screenElements['CDI-SRC-text']
907
                    .setText(source)
908
                    .setColor(source == 'GPS' ? me.colors.magenta : me.colors.green)
909
                    .show();
910
            }
makes the CDI available
Sébastien MARQUE authored on 2017-03-23
911
            var deflection = getprop('/instrumentation/zkv1000/cdi/course-deflection');
912
            if (left(source, 3) == 'NAV')
913
                var scale = deflection / 4;
914
            else { # GPS
915
                # TODO: deviation depending of the flight phase
916
                # for now fixed 1 dot = 1 nm course error
917
                var abs_deflection = abs(deflection);
918
                me.screenElements['CDI-GPS-XTK-text']
919
                    .setText(sprintf('XTK %iNM', abs_deflection))
920
                    .setVisible(abs_deflection > 2.4);
921
                var scale = deflection / 2;
922
            }
923
            scale = (abs(scale) > 1.2) ? 1.2 : scale;
924
            me.screenElements[source ~ '-CDI']
925
                .setTranslation(65 * scale, 0);
926
            settimer(func me.updateCDI(), 0.3);
adds CDI
Sébastien MARQUE authored on 2017-03-18
927
        }
928
    },
929
#}}}
930

            
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
931
    _updateRadio: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
932
# common parts for NAV/LOC/COMM radios{{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
933
        # arg[0]._r = <comm|nav>
934
        if (contains(arg[0], "active")) {
935
            if (arg[0]['active'] == 'none') {
936
                me.screenElements[arg[0]._r ~ '1-selected-freq']
937
                    .setColor(1,1,1);
938
                me.screenElements[arg[0]._r ~ '2-selected-freq']
939
                    .setColor(1,1,1);
940
            }
941
            else {
942
                me.screenElements[arg[0]._r ~ arg[0]['active'] ~ '-selected-freq']
943
                    .setColor(0,1,0);
944
                me.screenElements[arg[0]._r ~ arg[0].inactive ~ '-selected-freq']
945
                    .setColor(1,1,1);
946
            }
947
        }
948
        if (contains(arg[0], 'tune')) {
949
            # n = 0 -> NAV1/COMM1
950
            # n = 1 -> NAV1/COMM2
951
            me.screenElements[arg[0]._r ~ '-freq-switch']
952
                .setTranslation(0, arg[0].tune * 25);
953
            me.screenElements[arg[0]._r ~ (arg[0].tune + 1) ~ '-standby-freq']
954
                .setColor(0,1,1);
955
            me.screenElements[arg[0]._r ~ ((arg[0].tune == 0) + 1) ~ '-standby-freq']
956
                .setColor(1,1,1);
957
        }
958
        if (contains(arg[0], 'refresh')) {
small stuff
Sébastien MARQUE authored on 2017-03-22
959
            # refresh only one line: NAV1/COMM1 or NAV2/COMM2
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
960
            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
961
            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-selected-freq']
962
                .setText(sprintf(fmt, getprop('/instrumentation/'
963
                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/selected-mhz')));
964
            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-standby-freq']
965
                .setText(sprintf(fmt, getprop('/instrumentation/'
966
                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/standby-mhz')));
967
        }
968
        if (contains(arg[0], 'set')) {
969
            # positionne la valeur modifiée, les listeners "trigguent" en permanence ces propriétés, donc exit
970
            var n = getprop('/instrumentation/zkv1000/radios/' ~ arg[0]._r ~ '-tune');
971
            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
972
            me.screenElements[arg[0]._r ~ (n + 1) ~ '-standby-freq']
fix freq display while setti...
Sébastien MARQUE authored on 2017-03-16
973
                .setText(sprintf(fmt, getprop('/instrumentation/' ~ arg[0]._r ~ '[' ~ n ~ ']/frequencies/standby-mhz')));
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
974
        }
975
        if (contains(arg[0], 'auto')) {
976
            # pour rafraichir automagiquement, toutes les deux secondes un refresh pour un NAV
977
            var radio = arg[0].auto;
978
            me._updateRadio({refresh: 1, _r: radio});
979
            settimer(func me._updateRadio({refresh: 2, _r: radio}), 1);
980
            settimer(func me._updateRadio({auto: radio}), 2);
981
        }
982
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
983
#}}}
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
984

            
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
985
    updateNAV : func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
986
# update NAV/LOC rodios display upper left (PFD/MFD){{{
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
987
        # made active via menu
988
        if (contains(arg[0], "active")) {
adds CDI
Sébastien MARQUE authored on 2017-03-18
989
            arg[0]._r = 'nav';
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
990
            if (arg[0]['active'] == 'none') {
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
991
                me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
992
                me.screenElements['nav1-id']
993
                    .setColor(1,1,1);
994
                me.screenElements['nav2-id']
995
                    .setColor(1,1,1);
996
                me.screenElements['NAV1-pointer']
997
                    .hide();
998
                me.screenElements['NAV2-pointer']
999
                    .hide();
1000
            }
1001
            else {
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1002
                arg[0].inactive = (arg[0]['active'] == 1) + 1;
1003
                me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1004
                me.screenElements['nav' ~ arg[0]['active'] ~ '-id']
1005
                    .setColor(0,1,0);
1006
                me.screenElements['NAV' ~ arg[0]['active'] ~ '-pointer']
1007
                    .show();
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1008
                me.screenElements['nav' ~ arg[0].inactive ~ '-id']
1009
                    .setColor(1,1,1);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1010
#                me.screenElements['HDI']
1011
#                    .setRotation();
1012
#                me.screenElements['NAV' ~ inactive ~ '-pointer']
1013
#                    .hide();
1014
#                foreach (var e; [ 'FROM', 'TO', 'CDI' ])
1015
#                    me.screenElements['NAV' ~ inactive ~ '-' ~ e]
1016
#                        .hide();
1017
            }
1018
        }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1019
        elsif (contains(arg[0], 'nav-id')) {
Correction swap NAV tuning
Sébastien MARQUE authored on 2017-03-12
1020
            # TODO: récupérer la valeur via les paramètres transmis du listener
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1021
            if (arg[0].val == nil)
1022
                arg[0].val = '';
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1023
            me.screenElements["nav" ~ arg[0]['nav-id'] ~ "-id"]
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1024
                    .setText(arg[0].val);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1025
        }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1026
        else {
1027
            arg[0]._r = 'nav';
1028
            me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1029
        }
1030
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
1031
#}}}
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1032

            
1033
    updateCOMM: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
1034
# update COMM radios display upper right (PFD/MFD){{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1035
        arg[0]._r = 'comm';
1036
        me._updateRadio(arg[0]);
1037
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
1038
#}}}
anime time display
Sébastien MARQUE authored on 2017-03-13
1039

            
1040
    updateTIME : func {
1041
# updates the displayed time botoom left {{{
1042
        me.screenElements['TIME-text']
1043
            .setText(getprop('/sim/time/gmt-string'));
1044
        settimer(func me.updateTIME(), 1);
1045
    },
1046
#}}}
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1047

            
adds transponder
Sébastien MARQUE authored on 2017-03-17
1048
    updateXPDR : func {
1049
# updates transponder display {{{
1050
        for (var d = 0; d < 4; d+=1)
1051
            me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
1052
                .setText(sprintf('%i', getprop('/instrumentation/transponder/inputs/digit[' ~ d ~ ']')));
1053
        var tuning = getprop('/instrumentation/zkv1000/radios/xpdr-tuning-digit');
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
1054
        var fms = getprop('/instrumentation/zkv1000/radios/xpdr-tuning-fms-method');
1055
        for (var d = 0; d < 4; d+=1)
1056
            me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
1057
                .setColor(1,1,1);
1058
        if (tuning != nil) {
1059
            me.screenElements['XPDR-DIGIT-' ~ tuning ~ '-text']
1060
                .setColor(0,1,1);
1061
            if (fms)
1062
                me.screenElements['XPDR-DIGIT-' ~ (tuning - 1) ~ '-text']
1063
                    .setColor(0,1,1);
1064
        }
adds transponder
Sébastien MARQUE authored on 2017-03-17
1065
        else {
1066
            if (getprop('/instrumentation/transponder/ident'))
1067
                var mode = 'IDENT';
1068
            else
1069
                var mode = getprop('/instrumentation/zkv1000/radio/xpdr-mode');
1070
            var wow = getprop('/gear/gear/wow');
1071
            if (! wow and mode != 'STBY')
1072
                var color = [0, 1, 0];
1073
            else
1074
                var color = [1, 1, 1];
1075
            for (var d = 0; d < 4; d+=1)
1076
                me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
1077
                    .setColor(color);
1078
            me.screenElements['XPDR-MODE-text']
1079
                .setColor(color)
1080
                .setText(mode);
1081
        }
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
1082
    },
adds transponder
Sébastien MARQUE authored on 2017-03-17
1083
#}}}
1084

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1085
    updateOAT : func {
1086
# update OAT display on normal and reversionnary modes (every 3s) {{{
1087
        var tmp = getprop('/environment/temperature-deg' ~ me._oat_unit);
1088
        me.screenElements['OAT-text']
1089
            .setText(sprintf((abs(tmp) < 10) ? "%.1f %s" : "%i %s", tmp, (me._oat_unit == 'c') ? '°C' : 'F'));
1090
        settimer(func me.updateOAT(), 3);
1091
    },
1092
    _oat_unit : 'c',
1093
#}}}
1094

            
1095
    updateWindData : func {
1096
# update the window text and arrows for OPTN1/2 {{{
1097
        if (me._winddata_optn == 0)
1098
            return;
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
1099
        if (data.ias < 30) {
improves WindData display
Sébastien MARQUE authored on 2017-03-16
1100
            me.screenElements['WindData-NODATA']
1101
                .hide();
1102
            var wind_hdg = getprop('/environment/wind-from-heading-deg');
1103
            var wind_spd = getprop('/environment/wind-speed-kt');
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
1104
            var alpha = wind_hdg - data.hdg;
improves WindData display
Sébastien MARQUE authored on 2017-03-16
1105
            if (me._winddata_optn == 1) {
1106
                me.screenElements['WindData-OPTN1-HDG']
1107
                    .setRotation((alpha + 180) * D2R)
1108
                    .show();
1109
                me.screenElements['WindData-OPTN1-HDG-text']
1110
                    .setText(sprintf("%03i°", wind_hdg))
1111
                    .show();
1112
                me.screenElements['WindData-OPTN1-SPD-text']
1113
                    .setText(int(wind_spd) ~ 'KT')
1114
                    .show();
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1115
            }
improves WindData display
Sébastien MARQUE authored on 2017-03-16
1116
            else { # me._winddata_optn == 2
1117
                alpha *= D2R;
1118
                var Vt = wind_spd * math.sin(alpha);
1119
                var Ve = wind_spd * math.cos(alpha);
1120
                if (Vt != 0) {
1121
                    me.screenElements['WindData-OPTN2-crosswind-text']
1122
                        .setText(sprintf('%i', abs(Vt)))
1123
                        .show();
1124
                    me.screenElements['WindData-OPTN2-crosswind']
1125
                        .setScale(-abs(Vt)/Vt, 1)
1126
                        .setTranslation(-35 * (abs(Vt)/Vt + 1), 0)
1127
                        .show();
1128
                }
1129
                if (Ve != 0) {
1130
                    me.screenElements['WindData-OPTN2-headwind-text']
1131
                        .setText(sprintf('%i', abs(Ve)))
1132
                        .show();
1133
                    me.screenElements['WindData-OPTN2-headwind']
1134
                        .setScale(1, abs(Ve)/Ve)
1135
                        .setTranslation(0, 515 * (1 - abs(Ve)/Ve))
1136
                        .show();
1137
                }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1138
            }
1139
        }
improves WindData display
Sébastien MARQUE authored on 2017-03-16
1140
        else {
1141
            foreach (var e; [
1142
                    'WindData-OPTN1-HDG',
1143
                    'WindData-OPTN1-HDG-text',
1144
                    'WindData-OPTN1-SPD-text',
1145
                    'WindData-OPTN2-crosswind-text',
1146
                    'WindData-OPTN2-crosswind',
1147
                    'WindData-OPTN2-headwind-text',
1148
                    'WindData-OPTN2-headwind'
1149
            ])
1150
                me.screenElements[e].hide();
1151
            me.screenElements['WindData-NODATA'].show();
1152
        }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1153
        settimer(func me.updateWindData(), 0.5);
1154
    },
1155
    _winddata_optn : 0,
1156
#}}}
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1157

            
adds AOA display
Sébastien MARQUE authored on 2017-04-15
1158
    updateAOA : func {
1159
# update Angle Of Attack {{{
1160
        if (me.device.data.aoa == 0)
1161
            return;
1162
        var color = [1,1,1];
1163
        var norm = data.aoa / data['stall-aoa'];
nicer AOA display
Sébastien MARQUE authored on 2017-04-16
1164
        me.screenElements['AOA-text']
1165
            .setText(sprintf('% .1f', norm));
adds AOA display
Sébastien MARQUE authored on 2017-04-15
1166
        if (norm > 1) norm = 1;
1167
        if (norm > 0.9)
1168
            color = [1,0,0];
1169
        elsif (norm > 0.7)
1170
            color = [1,1,0];
1171
        elsif (norm < 0) {
1172
            norm = 0;
1173
            color = [1,0,0];
1174
        }
1175
        me.screenElements['AOA-needle']
1176
            .setRotation(-norm * math.pi)
nicer AOA display
Sébastien MARQUE authored on 2017-04-16
1177
            .setColorFill(color);
1178
        me.screenElements['AOA-text']
adds AOA display
Sébastien MARQUE authored on 2017-04-15
1179
            .setColor(color);
1180
        settimer(func me.updateAOA(), 0.1);
1181
    },
1182
# }}}
1183

            
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1184
    updateBRG : func {
some added comments
Sébastien MARQUE authored on 2017-03-18
1185
# displays and update BRG1/2 {{{
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1186
        foreach (var brg; [1, 2]) {
1187
            var source = 'brg' ~ brg ~ '-source';
1188

            
1189
            var dev = radios.getNode(source).getValue();
1190
            var el  = 'BRG' ~ brg;
1191
            if (dev != 'OFF') {
1192
                var info = {
1193
                    pointer : nil,
1194
                    id : 'NO DATA',
1195
                    hdg : nil,
1196
                    dst : '--.-NM'
1197
                };
1198
                if (left(dev, 3) == 'NAV') {
1199
                    info.pointer = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/in-range');
1200
                    if (info.pointer) {
1201
                        info.id  = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/nav-id');
1202
                        info.hdg = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/heading-deg');
1203
                        info.dst = sprintf('%.1d', getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/nav-distance') / 1852); # m -> /1852
1204
                    }
1205
                }
1206
                elsif (dev == 'GPS') {
1207
                    info.pointer = props.getNode('/instrumentation/gps/wp').getChild('wp[1])');
1208
                    if (info.pointer) {
1209
                        info.id  = getprop('/instrumentation/gps/wp/wp[1]/ID');
1210
                        info.hdg = getprop('/instrumentation/gps/wp/wp[1]/bearing-mag-deg');
1211
                        info.dst = sprintf('%.1d', getprop('/instrumentation/gps/wp/wp[1]/distance-nm'));
1212
                    }
1213
                }
1214
                else { # there are 2 available ADF in FG, but instrument manage only 1
1215
                    info.pointer = getprop('/instrumentation/adf/in-range');
1216
                    if (info.pointer) {
1217
                        info.id  = getprop('/instrumentation/adf/ident');
1218
                        info.hdg = getprop('/instrumentation/adf/indicated-bearing-deg');
1219
                    }
1220
                }
1221

            
1222
                if (info.pointer)
1223
                    me.screenElements[el ~ '-pointer']
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
1224
                        .setRotation(-info.hdg - data.hdg * D2R)
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1225
                        .show();
1226
                else
1227
                    me.screenElements[el ~ '-pointer']
1228
                        .hide();
1229
                me.screenElements[el ~ '-SRC-text']
1230
                    .setText(dev);
1231
                me.screenElements[el ~ '-DST-text']
1232
                    .setText(info.dst);
1233
                me.screenElements[el ~ '-WPID-text']
1234
                    .setText(info.id);
1235
                me.screenElements['BRG' ~ brg]
1236
                    .show();
1237
            }
1238
            else {
1239
                me.screenElements['BRG' ~ brg]
1240
                    .hide();
1241
            }
1242
        }
colorize BRG1/2 when needed,...
Sébastien MARQUE authored on 2017-03-21
1243
        settimer(func me.updateBRG(), 0.5);
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1244
    },
some added comments
Sébastien MARQUE authored on 2017-03-18
1245
#}}}
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
1246

            
adds OMI to PFD
Sébastien MARQUE authored on 2017-03-23
1247
    updateOMI : func {
1248
# display marker baecon Outer, Middle, Inner {{{
1249
        var marker = nil;
1250
        foreach (var m; ['outer', 'middle', 'inner'])
1251
            if (getprop('/instrumentation/marker-beacon/' ~ m)) {
1252
                marker = m;
1253
                me.screenElements['OMI']
1254
                    .show();
1255
                break;
1256
            }
1257
        if (marker != nil) {
1258
            me.screenElements['MarkerText']
1259
                .setText(me._omi_data[marker].t)
1260
                .show();
1261
            me.screenElements['MarkerBG']
1262
                .setColorFill(me._omi_data[marker].bg)
1263
                .show();
1264
        }
1265
        else
1266
            me.screenElements['OMI']
1267
                .hide();
1268
        settimer(func me.updateOMI(), 1);
1269
    },
1270
    _omi_data : {
1271
        'outer':  {t: 'O', bg: [0,1,1]},
1272
        'middle': {t: 'M', bg: [1,1,1]},
1273
        'inner':  {t: 'I', bg: [1,1,0]},
1274
    },
1275
#}}}
animation texts EIS + power ...
Sébastien MARQUE authored on 2017-03-19
1276
};