zkv1000 / Nasal / display.nas /
Newer Older
1477 lines | 58.005kb
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

            
replace settimer by maketime...
Sébastien MARQUE authored on 2020-05-06
25
        m.timers = {};
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
26
        # Softkeys revert to the previous level after 45 seconds of inactivity.
27
        m.softkeys_inactivity_delay = 45;
28

            
cosmetics
Sébastien MARQUE authored on 2020-05-12
29
        var groups = {
30
            show : [
31
                'Header',
32
                'SoftKeysTexts',
33
                'COMM',
34
                'NAV',
35
                'nav-freq-switch',
36
                'comm-freq-switch',
37
            ],
38
            text: [
39
                'nav1-standby-freq', 'nav1-selected-freq', 'nav1-id',
40
                'nav2-standby-freq', 'nav2-selected-freq', 'nav2-id',
41
                'comm1-standby-freq', 'comm1-selected-freq',
42
                'comm2-standby-freq', 'comm2-selected-freq',
43
            ],
44
            hide : [ 'Failures', 'NAV-COMM-Failures' ],
45
            clip: [ ],
46
        };
47

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

            
cosmetics
Sébastien MARQUE authored on 2020-05-12
53
        if (m.device.role == 'PFD') {
54
            append(groups.show,
adds some vim z-folds
Sébastien MARQUE authored on 2017-04-19
55
# {{{
cosmetics
Sébastien MARQUE authored on 2020-05-12
56
                'XPDR-TIME',
57
                'FlightInstruments',
58
                'Horizon',
59
                'bankPointer',
60
                'VSI',
61
                'Rose',
62
                'Heading-bug',
63
                'PFD-Widgets',
64
                'Trends',
65
                'Airspeed-Trend-Indicator',
66
                'Altitude-Trend-Indicator',
67
                'OAT',
68
                'IAS-bg',
69
                'TAS',
70
                'GSPD',
71
                'BARO-bg',
72
                'SlipSkid',
73
                'IAS-Vx', 'IAS-Vy', 'IAS-Vr', 'IAS-Vglide',
adds ILS glideslope
Sébastien MARQUE authored on 2020-06-09
74
                'VDI', 'GS-ILS', 'VDI-scale',
adds some vim z-folds
Sébastien MARQUE authored on 2017-04-19
75
# }}}
cosmetics
Sébastien MARQUE authored on 2020-05-12
76
            );
77
            append(groups.hide,
adds some vim z-folds
Sébastien MARQUE authored on 2017-04-19
78
# {{{
cosmetics
Sébastien MARQUE authored on 2020-05-12
79
                'EIS',
80
                'CDI',
81
                'OMI', 'MarkerBG', 'MarkerText',
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',
85
                'BRG1-pointer',
86
                'BRG2-pointer',
87
                'SelectedHDG-bg',
88
                'SelectedHDG-bgtext',
89
                'SelectedHDG-text',
90
                'SelectedCRS-bg',
91
                'SelectedCRS-bgtext',
92
                'SelectedCRS-text',
93
                'SelectedALT', 'SelectedALT-bug', 'SelectedALT-bg', 'SelectedALT-symbol',
94
                'TAS',
95
                'GSPD',
96
                'WindData',
97
                'Reversionnary',
98
                'Annunciation',
99
                'Comparator',
100
                'BRG1',
101
                'BRG2',
102
                'DME1',
103
                'PFD-Map-bg',
104
                'PFD-Multilines',
105
                'MapOrientation',
106
                'WindData', 'WindData-OPTN1', 'WindData-OPTN2', 'WindData-OPTN1-HDG', 'WindData-OPTN2-symbol', 'WindData-OPTN2-headwind', 'WindData-OPTN2-crosswind', 'WindData-NODATA',
107
                'AOA', 'AOA-needle', 'AOA-text', 'AOA-approach',
108
                'MFD-navbox',
109
                'Traffic',
adds ILS glideslope
Sébastien MARQUE authored on 2020-06-09
110
                'VDI-type-bg',
adds some vim z-folds
Sébastien MARQUE authored on 2017-04-19
111
# }}}
cosmetics
Sébastien MARQUE authored on 2020-05-12
112
            );
113
            append(groups.clip,
adds some vim z-folds
Sébastien MARQUE authored on 2017-04-19
114
# {{{
cosmetics
Sébastien MARQUE authored on 2020-05-12
115
                'SpeedLint1',
116
                'SpeedTape',
117
                'LintAlt',
118
                'AltLint00011',
119
                'PitchScale',
adds some vim z-folds
Sébastien MARQUE authored on 2017-04-19
120
# }}}
cosmetics
Sébastien MARQUE authored on 2020-05-12
121
            );
122
            append(groups.text,
adds some vim z-folds
Sébastien MARQUE authored on 2017-04-19
123
# {{{
cosmetics
Sébastien MARQUE authored on 2020-05-12
124
                'SelectedALT-text',
125
                'TAS-text',
126
                'GSPD-text',
adds time display setting
Sébastien MARQUE authored on 2020-06-11
127
                'TIME-text', 'TIME-REF-text',
cosmetics
Sébastien MARQUE authored on 2020-05-12
128
                'OAT-text',
129
                'VSIText',
130
                'Speed110',
131
                'Alt11100',
132
                'HDG-text',
133
                'BARO-text',
134
                'CDI-SRC-text', 'CDI-GPS-ANN-text', 'CDI-GPS-XTK-text',
135
                'BRG1-pointer', 'BRG1-SRC-text', 'BRG1-DST-text', 'BRG1-WPID-text',
136
                'BRG2-pointer', 'BRG2-SRC-text', 'BRG2-DST-text', 'BRG2-WPID-text',
137
                'WindData-OPTN1-HDG-text', 'WindData-OPTN1-SPD-text',
138
                'WindData-OPTN2-crosswind-text', 'WindData-OPTN2-headwind-text',
139
                'XPDR-MODE-text', 'XPDR-DIGIT-3-text', 'XPDR-DIGIT-2-text', 'XPDR-DIGIT-1-text', 'XPDR-DIGIT-0-text',
140
                'ETE', 'ETE-text', 'DIS', 'DIS-text', 'LEG-text',
141
                'LATMOD-Armed-text', 'LATMOD-Active-text',
142
                'AP-Status-text', 'YD-Status-text',
143
                'VERMOD-Active-text', 'VERMOD-Armed-text', 'VERMOD-Reference-text',
144
                'AltBigC', 'AltSmallC'
adds some vim z-folds
Sébastien MARQUE authored on 2017-04-19
145
# }}}
cosmetics
Sébastien MARQUE authored on 2020-05-12
146
            );
147
            for (var place = 1; place <= 6; place +=1) {
148
                append(groups.text,
149
                    'AltBigU' ~ place,
150
                    'AltSmallU' ~ place,
151
                    'AltBigD' ~ place,
152
                    'AltSmallD' ~ place
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
153
                );
animation ALT
Sébastien MARQUE authored on 2017-03-11
154
            }
cosmetics
Sébastien MARQUE authored on 2020-05-12
155
            canvas.parsesvg(m.screen, data.zkv1000_reldir ~ 'Models/PFD.svg');
156
        }
157
        else {
158
            var eis_file = eis.getValue('type');
159
            if (eis_file == nil)
160
                eis_file = eis.getValue('file');
161

            
162
            if (eis_file != nil) {
163
                if (find('/', eis_file) == -1)
164
                    eis_file = data.zkv1000_dir ~ 'Nasal/EIS/' ~ eis_file ~ '.nas';
165
                elsif (split('/', eis_file)[0] == 'Aircraft') {
166
                    var path = split('/', eis_file);
167
                    if (getprop('/sim/fg-aircraft') != nil) {
168
                        eis_file = getprop('/sim/fg-aircraft');
169
                        for (var i = 1; i < size(path); i += 1)
170
                            eis_file ~= '/' ~ path[i];
EIS now really specific to a...
Sébastien MARQUE authored on 2017-04-20
171
                    }
cosmetics
Sébastien MARQUE authored on 2020-05-12
172
                    else
173
                        eis_file = getprop('/sim/fg-root') ~ '/' ~ eis_file;
EIS now really specific to a...
Sébastien MARQUE authored on 2017-04-20
174
                }
cosmetics
Sébastien MARQUE authored on 2020-05-12
175
            }
176
            else
177
                eis_file = data.zkv1000_dir ~ 'Nasal/EIS/none.nas';
EIS now really specific to a...
Sébastien MARQUE authored on 2017-04-20
178

            
cosmetics
Sébastien MARQUE authored on 2020-05-12
179
            if (io.stat(eis_file) == nil
180
            and print(eis_file ~ ' not found'))
181
                eis_file = data.zkv1000_dir ~ 'Nasal/EIS/none.nas';
182
            io.load_nasal(eis_file, 'zkv1000');
EIS now really specific to a...
Sébastien MARQUE authored on 2017-04-20
183

            
cosmetics
Sébastien MARQUE authored on 2020-05-12
184
            if (contains(m.parents[0], 'showEIS'))
185
                m.showEIS(groups);
add navigation infos on head...
Sébastien MARQUE authored on 2017-05-24
186

            
cosmetics
Sébastien MARQUE authored on 2020-05-12
187
            append(groups.hide, 'PFD-navbox');
188
            for (var i=1; i <= 4; i+=1)
189
                foreach (var t; ['ID', 'VAL'])
190
                    append(groups.text, 'DATA-FIELD' ~ i ~ '-' ~ t ~ '-text');
191
        }
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
192

            
cosmetics
Sébastien MARQUE authored on 2020-05-12
193
        canvas.parsesvg(m.screen, data.zkv1000_reldir ~ 'Models/softkeys.svg');
194
        canvas.parsesvg(m.screen, data.zkv1000_reldir ~ 'Models/header-nav-comm.svg');
animation ALT
Sébastien MARQUE authored on 2017-03-11
195

            
cosmetics
Sébastien MARQUE authored on 2020-05-12
196
        m.loadGroup(groups);
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
197

            
cosmetics
Sébastien MARQUE authored on 2020-05-12
198
        if (m.device.role == 'PFD') {
199
            m.device.data.aoa = 0;
200
            m.device.data['aoa-auto'] = 0;
201
            m.device.data.mapclip = {
202
                top: math.ceil(m.screenElements['PFD-Map-bg'].getTransformedBounds()[1]) - 1,
203
                right: math.ceil(m.screenElements['PFD-Map-bg'].getTransformedBounds()[2]) - 1,
204
                bottom: math.ceil(m.screenElements['PFD-Map-bg'].getTransformedBounds()[3]) - 1,
205
                left: math.ceil(m.screenElements['PFD-Map-bg'].getTransformedBounds()[0]) - 1,
206
            };
207
        }
208
        else {
209
            m.device.data.mapclip = {
210
                top: math.ceil(m.screenElements['Header'].getTransformedBounds()[3]),
211
                right: m.display.get('view[0]'),
212
                bottom: math.ceil(m.screenElements['SoftKeysTexts'].getTransformedBounds()[1]),
213
                left: contains(m.screenElements, 'EIS') ? math.ceil(m.screenElements['EIS'].getTransformedBounds()[2]) : 0,
214
            };
215
        }
navigation box content
Sébastien MARQUE authored on 2020-05-12
216

            
217
        m.navbox = {
218
# {{{ the data to show info in navbox
219
            DTK: [func {
220
                var dtk = getprop('/instrumentation/gps/wp/wp[1]/desired-course-deg');
221
                if (dtk == nil)
222
                    return '---°';
223
                else
224
                    return sprintf('%03i°', dtk);
225
            }, 'Desired Track'],
226
            ETE: [func {
227
                if (data.fpSize == 0) return '--:--';
228
                var eta = getprop('/autopilot/route-manager/wp/eta');
229
                return sprintf('%5s', eta != nil ? eta : '--:--');
230
            }, 'Estimated Time Enroute'],
231
            TDR: [func {
232
                if (data.fpSize == 0) return '---NM';
233
                var dist = getprop('/autopilot/route-manager/distance-remaining-nm');
234
                if (dist != nil)
235
                    return sprintf(dist < 100 ? '%2.1fNM' : '%3iNM', dist);
236
                else
237
                    return '---NM';
238
            }, 'Total Distance Remaining'],
239
            DIS: [func {
240
                if (data.fpSize == 0) return '---NM';
241
                var dist = getprop('/autopilot/route-manager/wp/dist');
242
                if (dist != nil)
243
                    return sprintf(dist < 100 ? '%2.1fNM' : '%3iNM', dist);
244
                else
245
                    return '---NM';
246
            }, 'Distance remaining'],
247
            LEG: [func {
248
                if (data.fpSize == 0) return '';
249
                var route = m.device.map.layers.route;
250
                var wp = route.flightPlan[route.currentLeg.index];
251
                return sprintf(' %s %s %s', wp[0].name, utf8.chstr(9658), wp[1].name);
252
            }, ''], # not listed in MFD menu, on PFD only the leg is shown not the item
253
            LDG: [func {
254
                var eteSeconds = getprop('/autopilot/route-manager/ete');
255
                var eteHours = math.floor(eteSeconds / 3600);
256
                var eteMinutes = int((eteSeconds - (eteHours * 3600)) / 60);
257
                return sprintf(eteHours > 99 ? '--:--' : '%02i:%02i', eteHours, eteMinutes);
258
            }, 'ETA at Final Destination'],
259
            END: [func {
260
                var total_fuel = getprop('/consumables/fuel/total-fuel-gals');
261
                var gs = getprop('/velocities/groundspeed-kt');
262
                var consumption = 0;
263
                foreach(var engine; props.globals.getNode('/engines').getChildren('engine')) {
264
                    var ec = engine.getValue('fuel-flow-gph');
265
                    consumption += ec != nil ? ec : 0;
266
                }
267
                if (consumption > 0 and gs > 0)
268
                    return sprintf('%3iNM', (total_fuel * gs) / consumption);
269
                else
270
                    return '---NM';
271
            }, 'Endurance'],
272
            ETA: [func {
273
                var eteSeconds = getprop('/autopilot/route-manager/ete');
change way of time display
Sébastien MARQUE authored on 2020-06-12
274
                string.scanf(data.time, '%02u:%02u:%02u', var eta = []);
275

            
navigation box content
Sébastien MARQUE authored on 2020-05-12
276
                var eteHours = math.floor(eteSeconds / 3600);
change way of time display
Sébastien MARQUE authored on 2020-06-12
277
                if (eteHours > 24)
navigation box content
Sébastien MARQUE authored on 2020-05-12
278
                    return '--:--';
change way of time display
Sébastien MARQUE authored on 2020-06-12
279
                eta[1] += int((eteSeconds - (eteHours * 3600)) / 60);
280
                if (eta[1] > 59) {
281
                    eta[1] -= 60;
282
                    eta[0] += 1;
navigation box content
Sébastien MARQUE authored on 2020-05-12
283
                }
change way of time display
Sébastien MARQUE authored on 2020-06-12
284
                eta[0] += eteHours;
285
                if (eta[0] > 23)
286
                    eta[0] -= 24;
287
                return sprintf('%02i:%02i', eta[0], eta[1]);
navigation box content
Sébastien MARQUE authored on 2020-05-12
288
            }, 'Estimated Time of Arrival'],
289
            GS:  [func return sprintf('%3iKT', getprop('/velocities/groundspeed-kt')), 'Ground Speed'],
290
            TRK: [func return sprintf('%03i°', getprop('/orientation/track-deg')), 'Track'],
291
            TAS: [func return sprintf('%i', getprop('/instrumentation/airspeed-indicator/true-speed-kt')), 'True Air Speed'],
adds MSA and XTK navbox info...
Sébastien MARQUE authored on 2020-05-22
292
            FOB: [func return sprintf('%3ilbs', getprop('/consumables/fuel/total-fuel-lbs')), 'Fuel on Board'],
293
            XTK: [func {
fix XTK display
Sébastien MARQUE authored on 2020-05-23
294
                var xtk = nil;
adds MSA and XTK navbox info...
Sébastien MARQUE authored on 2020-05-22
295
                var source = cdi.getValue('source');
296
                if (source == 'NAV1')
fix XTK display
Sébastien MARQUE authored on 2020-05-23
297
                    var xtk = abs(getprop('/instrumentation/nav[0]/crosstrack-error-m')) * M2NM;
298
                elsif (source == 'NAV2')
299
                    var xtk = abs(getprop('/instrumentation/nav[1]/crosstrack-error-m')) * M2NM;
adds MSA and XTK navbox info...
Sébastien MARQUE authored on 2020-05-22
300
                elsif (source == 'GPS')
fix XTK display
Sébastien MARQUE authored on 2020-05-23
301
                    var xtk = abs(getprop('/instrumentation/gps/wp/wp[1]/course-error-nm'));
302

            
303
                if (xtk == nil)
304
                    return ' ---NM';
305
                elsif (xtk > 99.9)
306
                    return ' ++.+NM';
307
                else
308
                    return sprintf('%2.1fNM', xtk);
adds MSA and XTK navbox info...
Sébastien MARQUE authored on 2020-05-22
309
            }, 'Crosstrack Error'],
310
            MSA: [func {
311
                data._msa_spd        = getprop('/velocities/groundspeed-kt');
312
                data._msa_track      = getprop('/orientation/track-deg');
313
                if (! contains(data.timers, 'MSA_geodinfo')) {
314
                    data._msa_alt         = -1;
315
                    data._msa_point       = 1;
316
                    data._msa_alt_intern  = 0;
317
                    data.timers.MSA_geodinfo = maketimer(0, func {
318
                        var geo = greatCircleMove(
319
                                data._msa_track,
320
                                (data._msa_spd / 12) / 10 * data._msa_point);
fix MSA display
Sébastien MARQUE authored on 2020-05-23
321
                        var _geodinfo = geodinfo(geo.lat, geo.lon, 10000);
322
                        if (_geodinfo != nil)
323
                            if (data._msa_alt_intern < _geodinfo[0]) data._msa_alt_intern = _geodinfo[0];
adds MSA and XTK navbox info...
Sébastien MARQUE authored on 2020-05-22
324
                        data._msa_point += 1;
325
                        if (data._msa_point > 10) {
326
                            data._msa_alt         = math.round((1000 + data._msa_alt_intern * M2FT) / 100) * 100;
327
                            data._msa_point       = 0;
328
                            data._msa_alt_intern  = 0;
fix MSA display
Sébastien MARQUE authored on 2020-05-23
329
                            data.timers.MSA_geodinfo.stop();
adds MSA and XTK navbox info...
Sébastien MARQUE authored on 2020-05-22
330
                        }
331
                    });
332
                }
333
                data.timers.MSA_geodinfo.start();
334
                return data._msa_alt == -1 ? '-----ft' : sprintf('%5ift', data._msa_alt);
335
            }, 'Minimum Safe Altitude'],
navigation box content
Sébastien MARQUE authored on 2020-05-12
336
#            BRG: [func return '---°', 'Bearing'],
337
#            ESA: [func return '-----', 'Enroute Safe Altitude'],
338
#            ISA: [func return '-----', 'ISA Relative Temperature'],
339
#            TKE: [func return ' ---°', 'Track Angle Error'],
340
#            VSR: [func return ' ----', 'Vertical Speed Required'],
341
# }}}
342
        };
343
        if (m.device.role == 'PFD')
344
            foreach (var item; keys(m.navbox))
345
                if (item != 'LEG' and item != 'DIS' and item != 'ETE')
346
                    delete(m.navbox, item);
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
347
        return m;
348
    },
349
#}}}
makes map available for PFD ...
Sébastien MARQUE authored on 2017-04-19
350

            
replace settimer by maketime...
Sébastien MARQUE authored on 2020-05-06
351
    off: func {
poweroff improved
Sébastien MARQUE authored on 2020-05-16
352
        me.parents[0]._updateRadio = func; # because of the settimers...
353
        me.parents[0].updateEIS = func;
354
        foreach(var timer; keys(me.timers)) {
355
            me.timers[timer].stop();
356
            delete(me.timers, timer);
replace settimer by maketime...
Sébastien MARQUE authored on 2020-05-06
357
        }
poweroff improved
Sébastien MARQUE authored on 2020-05-16
358
        foreach (var e; keys(me.screenElements)) {
359
            if (typeof(me.screenElements[e]) != 'nil')
360
                me.screenElements[e].hide();
361
            delete(me.screenElements, e);
362
        }
363
        foreach (var e; keys(me.screenElements)) {
364
            if (typeof(me.screenElements[e]) != 'nil')
365
                me.screenElements[e].hide();
366
            delete(me.screenElements, e);
367
        }
368
        foreach (var e; keys(me.screenElements)) {
369
            if (typeof(me.screenElements[e]) != 'nil')
370
                me.screenElements[e].hide();
371
            delete(me.screenElements, e);
372
        }
373
        me.screen.setVisible(0);
374
        settimer(func {
375
                me.screen.removeAllChildren();
376
                me.screen.del();
377
                me.display.del();
378
        }, 0.1);
replace settimer by maketime...
Sébastien MARQUE authored on 2020-05-06
379
    },
380

            
381
# temporary Widget Display for HDG and CRS modification {{{
382

            
383
    temporaryWidgetDisplay : {},
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
384

            
385
    timerTrigger : func {
386
        var now = systime();
replace settimer by maketime...
Sébastien MARQUE authored on 2020-05-06
387
        foreach (var id; keys(me.temporaryWidgetDisplay)) {
388
            if (me.temporaryWidgetDisplay[id] < now) {
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
389
                me.screenElements[id].hide();
replace settimer by maketime...
Sébastien MARQUE authored on 2020-05-06
390
                delete(me.temporaryWidgetDisplay, id);
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
391
            }
commit initial
Sébastien MARQUE authored on 2017-03-07
392
        }
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
393
    },
394

            
395
    addTimer : func (duration, element) {
396
        if (typeof(element) == 'scalar')
397
            element = [ element ];
398
        var end = systime() + duration;
399
        foreach (var e; element)
replace settimer by maketime...
Sébastien MARQUE authored on 2020-05-06
400
            me.temporaryWidgetDisplay[e] = end;
commit initial
Sébastien MARQUE authored on 2017-03-07
401
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
402
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
403

            
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
404
    showInitProgress : func {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
405
#{{{
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
406
        if (me.device.role == 'PFD') {
replace settimer by maketime...
Sébastien MARQUE authored on 2020-05-06
407
            me.timers.updateAI     = maketimer(0.1, me, me.updateAI     );
408
            me.timers.updateVSI    = maketimer(0.1, me, me.updateVSI    );
409
            me.timers.updateIAS    = maketimer(0.1, me, me.updateIAS    );
410
            me.timers.updateALT    = maketimer(0.2, me, me.updateALT    );
411
            me.timers.updateHSI    = maketimer(0.2, me, me.updateHSI    );
412
            me.timers.updateTIME   = maketimer(1.0, me, me.updateTIME   );
413
            me.timers.updateOAT    = maketimer(3.0, me, me.updateOAT    );
414
            me.timers.updateTAS    = maketimer(0.5, me, me.updateTAS    );
415
            me.timers.updateBRG    = maketimer(0.5, me, me.updateBRG    );
416
            me.timers.updateXPDR   = maketimer(0,   me, me.updateXPDR   ); me.timers.updateXPDR.singleShot=1;
417
            me.timers.updateBARO   = maketimer(0,   me, me.updateBARO   ); me.timers.updateBARO.singleShot=1;
418
            me.timers.updateOMI    = maketimer(1.0, me, me.updateOMI    );
419
            me.timers.timerTrigger = maketimer(1.0, me, me.timerTrigger );
settimers to maketimer conti...
Sébastien MARQUE authored on 2020-05-13
420
            me.timers.updateAOA    = maketimer(0.1, me, me.updateAOA    );    me.timers.updateAOA.singleShot=1;
421
            me.timers.updateCDI    = maketimer(0.3, me, me.updateCDI    );    me.timers.updateCDI.singleShot=1;
422
            me.timers.updateWindData = maketimer(0.5, me, me.updateWindData); me.timers.updateWindData.singleShot=1;
replace settimer by maketime...
Sébastien MARQUE authored on 2020-05-06
423

            
heading bug set at power on
Sébastien MARQUE authored on 2020-05-30
424
            me.screenElements['Heading-bug'].setRotation(int(afcs.getValue('heading-bug-deg')) * D2R);
425

            
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
426
            me.screen.show();
add brightness and lights co...
Sébastien MARQUE authored on 2020-04-27
427
            me.device.buttons.MENU = me.device.buttons.GlobalParams;
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
428
        }
429
        else {
430
            me.updateEIS();
431
            io.load_nasal(data.zkv1000_dir ~ 'Nasal/MFD.pages.nas', 'zkv1000');
432
            me['page selected'] = 0;
433
            me.setMFDPages();
434
            me.device.buttons.MENU = me.device.buttons.MapMenu;
435
        }
commit initial
Sébastien MARQUE authored on 2017-03-07
436

            
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
437
        me.updateNAV({auto:'nav', tune: radios.getNode('nav-tune').getValue()});
438
        me.updateCOMM({auto:'comm', tune: radios.getNode('comm-tune').getValue()});
439
        me.softkeys_inactivity();
440
        me.updateSoftKeys();
replace settimer by maketime...
Sébastien MARQUE authored on 2020-05-06
441
        me.timers.updateNavigationBox = maketimer(me.device.role == 'MFD' ? 0.6 : 0.3, me, me.updateNavigationBox);
442

            
443
        foreach (var timer; keys(me.timers))
444
            me.timers[timer].start();
adds ILS glideslope
Sébastien MARQUE authored on 2020-06-09
445

            
446
        me.timers.updateGS = maketimer(0.2, me, me.updateGS);
commit initial
Sébastien MARQUE authored on 2017-03-07
447
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
448
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
449

            
some added comments
Sébastien MARQUE authored on 2017-03-18
450
    colors : {
451
# set of predefined colors {{{
452
        green : [0, 1, 0],
453
        white : [1, 1, 1],
454
        black : [0, 0, 0],
455
        lightblue : [0, 1, 1],
456
        darkblue : [0, 0, 1],
457
        red : [1, 0, 0],
adds CDI
Sébastien MARQUE authored on 2017-03-18
458
        magenta : [1, 0, 1],
add yellow predefined color
Sébastien MARQUE authored on 2020-05-11
459
        yellow : [1, 1, 0],
some added comments
Sébastien MARQUE authored on 2017-03-18
460
    },
461
#}}}
462

            
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
463
    loadGroup : func (h) {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
464
#{{{
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
465
        if (typeof(h) != 'hash') {
466
            msg_dbg(sprintf("%s need a hash, but get a %s from %s",
467
                    caller(0)[0],
468
                    typeof(h),
469
                    caller(1)[0]));
470
            return;
commit initial
Sébastien MARQUE authored on 2017-03-07
471
        }
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
472
        var setMethod = func (e, t) {
473
            if (t == 'hide')
474
                me.screenElements[e].hide();
475
            elsif (t == 'show')
476
                me.screenElements[e].show();
AI disponible
Sébastien MARQUE authored on 2017-03-10
477
            elsif (t == 'rot' or t == 'trans') {
478
                if (! contains(me.screenElements[e], t))
479
                    me.screenElements[e][t] = me.screenElements[e].createTransform();
480
            }
481
            elsif (t == 'clip') {
482
                if (contains(me.clips, e))
483
                    me.screenElements[e].set("clip", me.clips[e]);
484
                else
printlog deprecated + consta...
Sébastien MARQUE authored on 2020-04-24
485
                    logprint(LOG_WARN, 'no defined clip for ' ~ e);
AI disponible
Sébastien MARQUE authored on 2017-03-10
486
            }
animation VSI
Sébastien MARQUE authored on 2017-03-10
487
            elsif (t == 'text') {
488
                if (contains(me.texts, e)) {
489
                    if (contains(me.texts[e], 'alignment'))
490
                        me.screenElements[e].setAlignment(me.texts[e].alignment);
491
                    if (contains(me.texts[e], 'default'))
492
                        me.screenElements[e].setText(me.texts[e].default);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
493
                    if (contains(me.texts[e], 'color'))
494
                        me.screenElements[e].setColor(me.texts[e].color);
adds CDI
Sébastien MARQUE authored on 2017-03-18
495
                    if (contains(me.texts[e], 'visible'))
496
                        me.screenElements[e].setVisible(me.texts[e].visible);
animation VSI
Sébastien MARQUE authored on 2017-03-10
497
                }
printlog with adapted level ...
Sébastien MARQUE authored on 2017-03-20
498
                else
printlog deprecated + consta...
Sébastien MARQUE authored on 2020-04-24
499
                    logprint(LOG_DEBUG, 'no text format for ' ~ e);
animation VSI
Sébastien MARQUE authored on 2017-03-10
500
            }
commit initial
Sébastien MARQUE authored on 2017-03-07
501
            else
printlog deprecated + consta...
Sébastien MARQUE authored on 2020-04-24
502
                logprint(LOG_WARN, 'unknown method ' ~ t);
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
503
        };
504
        foreach (var todo; keys(h)) {
505
            if (typeof(h[todo]) != 'vector') h[todo] = [ h[todo] ];
506
            foreach (var id; h[todo]) {
507
                if (! contains(me.screenElements, id)) {
508
                    me.screenElements[id] = me.screen.getElementById(id);
509
                    if (me.screenElements[id] != nil)
510
                        setMethod(id, todo);
511
                    else
printlog deprecated + consta...
Sébastien MARQUE authored on 2020-04-24
512
                        logprint(LOG_WARN, 'SVG ID ' ~ id ~ ' not found');
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
513
                }
514
                else
515
                    setMethod(id, todo);
516
            }
commit initial
Sébastien MARQUE authored on 2017-03-07
517
        }
518
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
519
#}}}
AI disponible
Sébastien MARQUE authored on 2017-03-10
520

            
521
    clips : {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
522
#{{{
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
523
        PitchScale   : "rect(70,664,370,256)",
524
        SpeedLint1   : "rect(252,226,318,204)",
525
        SpeedTape    : "rect(115,239,455,156)",
526
        LintAlt      : "rect(115,808,455,704)",
animation ALT
Sébastien MARQUE authored on 2017-03-11
527
        AltLint00011 : "rect(252,804,318,771)",
AI disponible
Sébastien MARQUE authored on 2017-03-10
528
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
529
#}}}
AI disponible
Sébastien MARQUE authored on 2017-03-10
530

            
animation VSI
Sébastien MARQUE authored on 2017-03-10
531
    texts : {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
532
#{{{
animation VSI
Sébastien MARQUE authored on 2017-03-10
533
        VSIText : {
534
            alignment: "right-bottom", default : num('0'),
535
        },
animation IAS
Sébastien MARQUE authored on 2017-03-10
536
        Speed110 : {
correct speed and altitude t...
Sébastien MARQUE authored on 2020-05-08
537
            alignment : 'right-bottom'
animation IAS
Sébastien MARQUE authored on 2017-03-10
538
        },
animation ALT (2)
Sébastien MARQUE authored on 2017-03-11
539
        Alt11100 : {
correct speed and altitude t...
Sébastien MARQUE authored on 2020-05-08
540
            alignment:'right-bottom'
animation ALT (2)
Sébastien MARQUE authored on 2017-03-11
541
        },
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
542
        "HDG-text" : {
543
            default: '---°'
544
        },
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
545
        'nav1-standby-freq' : {
546
            color: [0, 1, 1],
547
        },
548
        'nav1-id' : {
549
            default: ''
550
        },
551
        'nav2-id' : {
552
            default: ''
553
        },
adds CDI
Sébastien MARQUE authored on 2017-03-18
554
        'CDI-GPS-ANN-text' : {
555
            visible : 0
556
        },
557
        'CDI-GPS-XTK-text' : {
558
            visible : 0
559
        },
560
        'CDI-SRC-text' : {
561
            visible : 0
562
        },
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
563
        'BARO-text' : {
564
            alignment : 'left-bottom',
improve route info display
Sébastien MARQUE authored on 2020-05-03
565
        },
566
        'LEG-text' : {
567
            alignment : 'center-center',
568
        },
some added comments
Sébastien MARQUE authored on 2017-03-18
569
#        'TAS-text' : {
570
#            alignment : 'right-bottom',
571
#        },
572
#        'GSPD-text' : {
573
#            alignment : 'right-bottom',
574
#        },
animation VSI
Sébastien MARQUE authored on 2017-03-10
575
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
576
#}}}
animation VSI
Sébastien MARQUE authored on 2017-03-10
577

            
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
578
    softkeys_inactivity : func {
579
# automagically back to previous level after some delay {{{
old timers2 removed
Sébastien MARQUE authored on 2020-05-15
580
        me.timers.softkeys_inactivity = maketimer (
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
581
            me.softkeys_inactivity_delay,
582
            func {
583
                pop(me.device.softkeys.path);
584
                me.updateSoftKeys();
585
            }, me);
old timers2 removed
Sébastien MARQUE authored on 2020-05-15
586
        me.timers.softkeys_inactivity.singleShot = 1;
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
587
    },
588
#}}}
589

            
softkey is implemented by de...
Sébastien MARQUE authored on 2017-12-21
590
    setSoftKeyColor : func (n, active, implemented = 1, alert = 0) {
add softkeys colors
Sébastien MARQUE authored on 2017-03-21
591
# set colors for active softkeys {{{
592
        var sftk = sprintf('SoftKey%02i-', n);
593
        if (active) {
594
            var bg = alert ? 1 : 0.5;
595
            me.screenElements[sftk ~ 'bg']
596
                .setColorFill(bg,bg,bg);
597
            me.screenElements[sftk ~ 'text']
598
                .setColor(0,0,0);
599
        }
600
        else {
not yet implemented softkeys...
Sébastien MARQUE authored on 2017-06-08
601
            var tc = implemented ? 1 : 0.5;
add softkeys colors
Sébastien MARQUE authored on 2017-03-21
602
            me.screenElements[sftk ~ 'bg']
603
                .setColorFill(0,0,0);
604
            me.screenElements[sftk ~ 'text']
not yet implemented softkeys...
Sébastien MARQUE authored on 2017-06-08
605
                .setColor(tc,tc,tc);
add softkeys colors
Sébastien MARQUE authored on 2017-03-21
606
        }
607
    },
608
#}}}
609

            
navigation box content
Sébastien MARQUE authored on 2020-05-12
610
    updateNavigationBox : func {
add navigation infos on head...
Sébastien MARQUE authored on 2017-05-24
611
# update Navigation Box on MFD and PFD header {{{
612
        var route = me.device.map.layers.route;
navigation box content
Sébastien MARQUE authored on 2020-05-12
613
        data.fpSize = size(route.flightPlan);
add navigation infos on head...
Sébastien MARQUE authored on 2017-05-24
614
        if (me.device.role == 'MFD') {
615
            for (var i=1; i<=4; i+=1)
616
                me.screenElements['DATA-FIELD' ~ i ~ '-VAL-text']
617
                    .setText(
MFD navbox always available
Sébastien MARQUE authored on 2020-05-20
618
                        me.navbox[me.screenElements['DATA-FIELD' ~ i ~ '-ID-text'].get('text')][0]()
add navigation infos on head...
Sébastien MARQUE authored on 2017-05-24
619
                    );
620
        }
621
        else { # PFD
MFD navbox always available
Sébastien MARQUE authored on 2020-05-20
622
            var enroute = getprop('/autopilot/route-manager/current-wp') > -1;
improve route info display
Sébastien MARQUE authored on 2020-05-03
623
            me.screenElements['ETE'].setVisible(enroute);
624
            me.screenElements['DIS'].setVisible(enroute);
navigation box content
Sébastien MARQUE authored on 2020-05-12
625
            me.screenElements['ETE-text'].setVisible(enroute).setText(me.navbox.ETE[0]());
626
            me.screenElements['DIS-text'].setVisible(enroute).setText(me.navbox.DIS[0]());
627
            me.screenElements['LEG-text'].setVisible(enroute).setText(me.navbox.LEG[0]());
add navigation infos on head...
Sébastien MARQUE authored on 2017-05-24
628
        }
629
    },
630
#}}}
631

            
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
632
    updateSoftKeys : func {
633
# update SoftKeys boxes {{{
634
        # on PFD the last boxes are always BACK and ALERTS
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
635
        if (me.device.role == 'PFD') {
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
636
            me.screenElements[sprintf("SoftKey%02i-text", 11)]
637
                .setText('ALERTS');
638
            if (size(me.device.softkeys.path) != 0)
639
                me.screenElements[sprintf("SoftKey%02i-text", 10)]
not yet implemented softkeys...
Sébastien MARQUE authored on 2017-06-08
640
                    .setText('BACK')
641
                    .setColor(1,1,1);
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
642
        }
643

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
644
        var path = keyMap[me.device.role];
not yet implemented softkeys...
Sébastien MARQUE authored on 2017-06-08
645
        var bindings = me.device.softkeys.bindings[me.device.role];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
646
        var pathid = '';
647
        foreach (var p; me.device.softkeys.path) {
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
648
            path = path[p];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
649
            pathid ~= p;
not yet implemented softkeys...
Sébastien MARQUE authored on 2017-06-08
650
            if (contains(bindings, p))
651
                bindings = bindings[p];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
652
        }
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
653

            
654
        # feeding with empty menus the first boxes
655
        var start = (contains(path, 'first')) ? path.first : 0;
656
        for (var k = 0; k < start; k+=1) {
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
657
            var sftk = sprintf("SoftKey%02i-", k);
658
            me.screenElements[sftk ~ 'text']
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
659
                .setText('');
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
660
            me.screenElements[sftk ~ 'bg']
661
                .setColorFill(0,0,0);
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
662
        }
663
        # filling with the content the next boxes
664
        forindex (var k; path.texts) {
665
            var i = k + start;
666
            me.screenElements[sprintf("SoftKey%02i-text", i)]
667
                .setText(path.texts[k]);
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
668
            me.setSoftKeyColor(i,
not yet implemented softkeys...
Sébastien MARQUE authored on 2017-06-08
669
                    contains(me.device.softkeys.colored, pathid ~ path.texts[k]),
670
                    contains(bindings, path.texts[k]));
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
671
        }
672
        # feeding the last boxes with empty string
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
673
        var end = (me.device.role == 'PFD') ? 10 : 12;
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
674
        if (size(path.texts) + start < end) {
675
            start = size(path.texts) + start;
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
676
            for (var k = start; k < end; k += 1) {
677
                var sftk = sprintf("SoftKey%02i-", k);
678
                me.screenElements[sftk ~ 'text']
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
679
                    .setText('');
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
680
                me.screenElements[sftk ~ 'bg']
681
                    .setColorFill(0,0,0);
682
            }
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
683
        }
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
684

            
685
        if (size(me.device.softkeys.path))
old timers2 removed
Sébastien MARQUE authored on 2020-05-15
686
            me.timers.softkeys_inactivity.restart(me.softkeys_inactivity_delay);
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
687
        else
old timers2 removed
Sébastien MARQUE authored on 2020-05-15
688
            me.timers.softkeys_inactivity.stop();
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
689
    },
690
#}}}
691

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
692
    updateAI: func(){
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
693
#{{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
694
        var pitch = data.pitch;
695
        var roll = data.roll;
AI disponible
Sébastien MARQUE authored on 2017-03-10
696
        if (pitch > 80)
697
            pitch = 80;
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
698
        elsif (pitch < -80)
AI disponible
Sébastien MARQUE authored on 2017-03-10
699
            pitch = -80;
700
        me.screenElements.Horizon
fix AI animation
Sébastien MARQUE authored on 2017-03-19
701
            .setCenter(459, 282.8 - 6.849 * pitch)
AI disponible
Sébastien MARQUE authored on 2017-03-10
702
            .setRotation(-roll * D2R)
fix AI animation
Sébastien MARQUE authored on 2017-03-19
703
            .setTranslation(0, pitch * 6.849);
AI disponible, avec bankPoin...
Sébastien MARQUE authored on 2017-03-10
704
        me.screenElements.bankPointer
705
            .setRotation(-roll * D2R);
adds slipskid animation
Sébastien MARQUE authored on 2017-03-24
706
        me.screenElements['SlipSkid']
707
            .setTranslation(getprop("/instrumentation/slip-skid-ball/indicated-slip-skid") * 10, 0);
add TCAS
Sébastien MARQUE authored on 2017-12-21
708
        me.screenElements['Traffic']
traffic alert and display
Sébastien MARQUE authored on 2020-06-08
709
            .setVisible(data.tcas_level > 1);
AI disponible
Sébastien MARQUE authored on 2017-03-10
710
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
711
#}}}
animation VSI
Sébastien MARQUE authored on 2017-03-10
712

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
713
    updateVSI: func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
714
# animate VSI {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
715
        var vsi = data.vsi;
animation VSI
Sébastien MARQUE authored on 2017-03-10
716
        me.screenElements.VSIText
717
            .setText(num(math.round(vsi, 10)));
718
        if (vsi > 4500)
719
            vsi = 4500;
720
        elsif (vsi < -4500)
721
            vsi = -4500;
722
        me.screenElements.VSI
723
            .setTranslation(0, vsi * -0.03465);
724
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
725
#}}}
animation IAS
Sébastien MARQUE authored on 2017-03-10
726

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
727
    updateIAS: func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
728
# animates the IAS lint (PFD) {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
729
        var ias = data.ias;
animation IAS
Sébastien MARQUE authored on 2017-03-10
730
        if (ias >= 10)
731
            me.screenElements.Speed110
732
                .setText(sprintf("% 2u",num(math.floor(ias/10))));
733
        else
734
            me.screenElements.Speed110
735
                .setText('');
736
        me.screenElements.SpeedLint1
737
            .setTranslation(0,(math.mod(ias,10) + (ias >= 10)*10) * 36);
738
        me.screenElements.SpeedTape
739
            .setTranslation(0,ias * 5.711);
put Vspeeds in common data s...
Sébastien MARQUE authored on 2017-04-11
740
        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
741
            me._ias_already_exceeded = 1;
742
            me.screenElements['IAS-bg']
743
                .setColorFill(1,0,0);
744
        }
put Vspeeds in common data s...
Sébastien MARQUE authored on 2017-04-11
745
        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
746
            me._ias_already_exceeded = 0;
747
            me.screenElements['IAS-bg']
748
                .setColorFill(0,0,0);
749
        }
add V-speeds bugs
Sébastien MARQUE authored on 2017-04-04
750
        foreach (var v; ['Vx', 'Vy', 'Vr', 'Vglide']) {
put Vspeeds in common data s...
Sébastien MARQUE authored on 2017-04-11
751
            if (me.device.data[v ~ '-visible'] and abs(data[v] - ias) < 30)
add V-speeds bugs
Sébastien MARQUE authored on 2017-04-04
752
                me.screenElements['IAS-' ~ v]
put Vspeeds in common data s...
Sébastien MARQUE authored on 2017-04-11
753
                    .setTranslation(0, (ias - data[v]) * 5.711)
add V-speeds bugs
Sébastien MARQUE authored on 2017-04-04
754
                    .show();
755
            else
756
                me.screenElements['IAS-' ~ v]
757
                    .hide();
758
        }
759

            
improve trends vor ALT and I...
Sébastien MARQUE authored on 2020-04-30
760
        var Sy = 0;
761
        for (var i = 8; i >= 0; i -= 1)
762
            me._last_ias_Sy[i+1] = me._last_ias_Sy[i];
trends animation
Sébastien MARQUE authored on 2017-03-13
763
        var now = systime();
764
        # estimated speed in 6s
improve trends vor ALT and I...
Sébastien MARQUE authored on 2020-04-30
765
        me._last_ias_Sy[0] = 6 * (ias - me._last_ias_kt) / (now - me._last_ias_s);
766
        foreach (var _Sy; me._last_ias_Sy)
767
            Sy += _Sy;
768
        Sy /= 10;
trends animation
Sébastien MARQUE authored on 2017-03-13
769
        if (abs(Sy) > 30)
770
            Sy = 30 * abs(Sy)/Sy; # = -30 or 30
771
        me.screenElements['Airspeed-Trend-Indicator']
772
            .setScale(1,Sy)
773
            .setTranslation(0, -284.5 * (Sy - 1));
774
        me._last_ias_kt = ias;
775
        me._last_ias_s = now;
animation IAS
Sébastien MARQUE authored on 2017-03-10
776
    },
trends animation
Sébastien MARQUE authored on 2017-03-13
777
    _last_ias_kt : 0,
778
    _last_ias_s : systime(),
improve trends vor ALT and I...
Sébastien MARQUE authored on 2020-04-30
779
    _last_ias_Sy : [0,0,0,0,0,0,0,0,0,0],
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
780
    _ias_already_exceeded : 0,
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
781
#}}}
animation ALT
Sébastien MARQUE authored on 2017-03-11
782

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
783
    updateTAS: func {
784
# updates the True Airspeed and GroundSpeed indicators {{{
785
        me.screenElements['TAS-text']
786
            .setText(sprintf('%iKT', getprop('/instrumentation/airspeed-indicator/true-speed-kt')));
787
        me.screenElements['GSPD-text']
788
            .setText(sprintf('%iKT', getprop('/velocities/groundspeed-kt')));
789
    },
790
#}}}
791

            
792
    updateALT: func () {
793
# animates the altitude lint (PFD) {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
794
        var alt = data.alt;
animation ALT
Sébastien MARQUE authored on 2017-03-11
795
        if (alt < 0)
796
            me.screenElements.Alt11100
fix altitude indicator
Sébastien MARQUE authored on 2020-05-03
797
                .setText(sprintf("%3d",math.ceil(alt/100)));
animation ALT
Sébastien MARQUE authored on 2017-03-11
798
        elsif (alt < 100)
799
            me.screenElements.Alt11100
800
                .setText('');
801
        else
802
            me.screenElements.Alt11100
fix altitude indicator
Sébastien MARQUE authored on 2020-05-03
803
                .setText(sprintf("%3i",math.floor(alt/100)));
animation ALT
Sébastien MARQUE authored on 2017-03-11
804
        me.screenElements.AltLint00011
805
            .setTranslation(0,math.fmod(alt,100) * 1.24);
806

            
807
        # From Farmin/G1000 http://wiki.flightgear.org/Project_Farmin/FG1000
808
        if (alt> -1000 and alt< 1000000) {
809
            var Offset10 = 0;
810
            var Offset100 = 0;
811
            var Offset1000 = 0;
812
            if (alt< 0) {
813
                var Ne = 1;
814
                var alt= -alt;
815
            }
816
            else
817
                var Ne = 0;
818

            
819
            var Alt10       = math.mod(alt,100);
820
            var Alt100      = int(math.mod(alt/100,10));
821
            var Alt1000     = int(math.mod(alt/1000,10));
822
            var Alt10000    = int(math.mod(alt/10000,10));
823
            var Alt20       = math.mod(Alt10,20)/20;
824
            if (Alt10 >= 80)
825
                var Alt100 += Alt20;
826

            
827
            if (Alt10 >= 80 and Alt100 >= 9)
828
                var Alt1000 += Alt20;
829

            
830
            if (Alt10 >= 80 and Alt100 >= 9 and Alt1000 >= 9)
831
                var Alt10000 += Alt20;
832

            
833
            if (alt> 100)
834
                var Offset10 = 100;
835

            
836
            if (alt> 1000)
837
                var Offset100 = 10;
838

            
839
            if (alt> 10000)
840
                var Offset1000 = 10;
841

            
842
            if (!Ne) {
843
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*0.57375);
844
                var altCentral = (int(alt/100)*100);
845
            }
846
            elsif (Ne) {
847
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*-0.57375);
848
                var altCentral = -(int(alt/100)*100);
849
            }
850
            me.screenElements["AltBigC"].setText("");
851
            me.screenElements["AltSmallC"].setText("");
852
            for (var place = 1; place <= 6; place += 1) {
853
                var altUP = altCentral + (place*100);
854
                var offset = -30.078;
855
                if (altUP < 0) {
856
                    var altUP = -altUP;
857
                    var prefix = "-";
858
                    var offset += 15.039;
859
                }
860
                else
861
                    var prefix = "";
862

            
863
                if (altUP == 0) {
864
                    var AltBigUP    = "";
865
                    var AltSmallUP  = "0";
866

            
867
                }
868
                elsif (math.mod(altUP,500) == 0 and altUP != 0) {
869
                    var AltBigUP    = sprintf(prefix~"%1d", altUP);
870
                    var AltSmallUP  = "";
871
                }
872
                elsif (altUP < 1000 and (math.mod(altUP,500))) {
873
                    var AltBigUP    = "";
874
                    var AltSmallUP  = sprintf(prefix~"%1d", int(math.mod(altUP,1000)));
875
                    var offset = -30.078;
876
                }
877
                elsif ((altUP < 10000) and (altUP >= 1000) and (math.mod(altUP,500))) {
878
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
879
                    var AltSmallUP  = sprintf("%1d", int(math.mod(altUP,1000)));
880
                    var offset += 15.039;
881
                }
882
                else {
883
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
884
                    var mod = int(math.mod(altUP,1000));
885
                    var AltSmallUP  = sprintf("%1d", mod);
886
                    var offset += 30.078;
887
                }
888

            
889
                me.screenElements["AltBigU"~place].setText(AltBigUP);
890
                me.screenElements["AltSmallU"~place].setText(AltSmallUP);
891
                me.screenElements["AltSmallU"~place].setTranslation(offset,0);
892
                var altDOWN = altCentral - (place*100);
893
                var offset = -30.078;
894
                if (altDOWN < 0) {
895
                    var altDOWN = -altDOWN;
896
                    var prefix = "-";
897
                    var offset += 15.039;
898
                }
899
                else
900
                    var prefix = "";
901

            
902
                if (altDOWN == 0) {
903
                    var AltBigDOWN  = "";
904
                    var AltSmallDOWN    = "0";
905
                }
906
                elsif (math.mod(altDOWN,500) == 0 and altDOWN != 0) {
907
                    var AltBigDOWN  = sprintf(prefix~"%1d", altDOWN);
908
                    var AltSmallDOWN    = "";
909
                }
910
                elsif (altDOWN < 1000 and (math.mod(altDOWN,500))) {
911
                    var AltBigDOWN  = "";
912
                    var AltSmallDOWN    = sprintf(prefix~"%1d", int(math.mod(altDOWN,1000)));
913
                    var offset = -30.078;
914
                }
915
                elsif ((altDOWN < 10000) and (altDOWN >= 1000) and (math.mod(altDOWN,500))) {
916
                    var AltBigDOWN  = sprintf(prefix~"%1d", int(altDOWN/1000));
917
                    var AltSmallDOWN    = sprintf("%1d", int(math.mod(altDOWN,1000)));
918
                    var offset += 15.039;
919
                }
920
                else {
921
                    var AltBigDOWN  = sprintf(prefix~"%1d", int(altDOWN/1000));
922
                    var mod = int(math.mod(altDOWN,1000));
923
                    var AltSmallDOWN    = sprintf("%1d", mod);
924
                    var offset += 30.078;
925
                }
926
                me.screenElements["AltBigD"~place].setText(AltBigDOWN);
927
                me.screenElements["AltSmallD"~place].setText(AltSmallDOWN);
928
                me.screenElements["AltSmallD"~place].setTranslation(offset,0);
929
            }
930
        }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
931
        me.updateSelectedALT();
improve trends vor ALT and I...
Sébastien MARQUE authored on 2020-04-30
932
        var Sy = 0;
933
        for (var i = 8; i >= 0; i -= 1)
934
            me._last_alt_Sy[i+1] = me._last_alt_Sy[i];
trends animation
Sébastien MARQUE authored on 2017-03-13
935
        var now = systime();
936
        # altitude in 6s
improve trends vor ALT and I...
Sébastien MARQUE authored on 2020-04-30
937
        me._last_alt_Sy[0] = .3 * (alt - me._last_alt_ft) / (now - me._last_alt_s); # scale = 1/20ft
938
        foreach (var _Sy; me._last_alt_Sy)
939
            Sy += _Sy;
940
        Sy /= 10;
trends animation
Sébastien MARQUE authored on 2017-03-13
941
        if (abs(Sy) > 15)
942
            Sy = 15 * abs(Sy)/Sy; # = -15 or 15
943
        me.screenElements['Altitude-Trend-Indicator']
944
            .setScale(1,Sy)
945
            .setTranslation(0, -284.5 * (Sy - 1));
946
        me._last_alt_ft = alt;
947
        me._last_alt_s = now;
animation ALT
Sébastien MARQUE authored on 2017-03-11
948
    },
trends animation
Sébastien MARQUE authored on 2017-03-13
949
    _last_alt_ft : 0,
improve trends vor ALT and I...
Sébastien MARQUE authored on 2020-04-30
950
    _last_alt_Sy : [0,0,0,0,0,0,0,0,0,0],
trends animation
Sébastien MARQUE authored on 2017-03-13
951
    _last_alt_s  : systime(),
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
952
#}}}
animation HSI
Sébastien MARQUE authored on 2017-03-11
953

            
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
954
    updateBARO : func () {
955
# update BARO widget {{{
956
        var fmt = me._baro_unit == 'inhg' ? '%.2f%s' : '%i%s';
957
        me.screenElements['BARO-text']
958
            .setText(sprintf(fmt,
959
                        getprop('/instrumentation/altimeter/setting-' ~ me._baro_unit),
960
                        me._baro_unit == 'inhg' ? 'in' : 'hPa')
961
                );
962
    },
963
    _baro_unit : 'inhg',
964
#}}}
965

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
966
    updateHSI : func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
967
# rotates the compass (PFD) {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
968
        var hdg = data.hdg;
animation HSI
Sébastien MARQUE authored on 2017-03-11
969
        me.screenElements.Rose
970
            .setRotation(-hdg * D2R);
971
        me.screenElements['HDG-text']
972
            .setText(sprintf("%03u°", hdg));
973
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
974
#}}}
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
975

            
removes unecessary listeners
Sébastien MARQUE authored on 2017-04-08
976
    updateHDG : func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
977
# moves the heading bug and display heading-deg for 3 seconds (PFD) {{{
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
978
        if (me.device.role == 'MFD')
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
979
            return;
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
980
        var hdg = afcs.getValue('heading-bug-deg');
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
981
        me.screenElements['Heading-bug']
982
            .setRotation(hdg * D2R);
983
        me.screenElements['SelectedHDG-bg']
984
            .show();
985
        me.screenElements['SelectedHDG-bgtext']
986
            .show();
987
        me.screenElements['SelectedHDG-text']
988
            .setText(sprintf('%03d°%s', hdg, ''))
989
            .show();
990
        me.addTimer(3, ['SelectedHDG-text', 'SelectedHDG-bgtext', 'SelectedHDG-bg']);
991
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
992
#}}}
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
993

            
adds CDI
Sébastien MARQUE authored on 2017-03-18
994
    updateCRS : func () {
anime CRS
Sébastien MARQUE authored on 2017-03-13
995
# TODO: update display for NAV/GPS/BRG courses {{{
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
996
        if (me.device.role == 'MFD')
anime CRS
Sébastien MARQUE authored on 2017-03-13
997
            return;
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
998
        var source = cdi.getValue('source');
adds CDI
Sébastien MARQUE authored on 2017-03-18
999
        if (source == 'OFF')
1000
            return;
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
1001
        var crs = cdi.getValue('course');
adds CDI
Sébastien MARQUE authored on 2017-03-18
1002
        if (crs == nil)
1003
            return;
anime CRS
Sébastien MARQUE authored on 2017-03-13
1004
        me.screenElements['SelectedCRS-bg']
1005
            .show();
1006
        me.screenElements['SelectedCRS-bgtext']
1007
            .show();
1008
        me.screenElements['SelectedCRS-text']
1009
            .setText(sprintf('%03d°%s', crs, ''))
adds CDI
Sébastien MARQUE authored on 2017-03-18
1010
            .setColor(source == 'GPS' ? me.colors.magenta : me.colors.green)
anime CRS
Sébastien MARQUE authored on 2017-03-13
1011
            .show();
1012
        me.addTimer(3, ['SelectedCRS-text', 'SelectedCRS-bgtext', 'SelectedCRS-bg']);
1013
    },
1014
#}}}
1015

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1016
    updateSelectedALT : func {
1017
# animation for altitude section, called via updatedALT {{{
creates flightdeck hash to p...
Sébastien MARQUE authored on 2017-04-07
1018
        if (! me.screenElements['SelectedALT'].getVisible())
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
1019
            return;
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
1020
        var selected_alt = afcs.getValue('selected-alt-ft');
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
1021
        var delta_alt = data.alt - selected_alt;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1022
        if (abs(delta_alt) > 300)
1023
            delta_alt = 300 * abs(delta_alt)/delta_alt;
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
1024
        me.screenElements['SelectedALT-symbol']
1025
            .setVisible(abs(delta_alt) > 100);
1026
        me.screenElements['SelectedALT-bg']
1027
            .setVisible(abs(delta_alt) > 100);
1028
        me.screenElements['SelectedALT-text']
1029
            .setText(sprintf("%i", selected_alt))
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1030
            .setVisible(abs(delta_alt) > 100);
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
1031
        me.screenElements['SelectedALT-bug']
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1032
            .setTranslation(0, delta_alt * 0.567); # 170/300 = 0.567
1033
    },
1034
#}}}
1035

            
adds CDI
Sébastien MARQUE authored on 2017-03-18
1036
    updateCDI : func {
1037
# animation for CDI {{{
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
1038
        var source = cdi.getValue('source');
adds CDI
Sébastien MARQUE authored on 2017-03-18
1039
        if (source == 'OFF') {
1040
            foreach (var s; ['GPS', 'NAV1', 'NAV2'])
1041
                foreach (var t; ['pointer', 'CDI'])
1042
                    me.screenElements[s ~ '-' ~ t].hide();
1043
            me.screenElements['CDI-GPS-ANN-text'].hide();
1044
            me.screenElements['CDI-GPS-XTK-text'].hide();
1045
            me.screenElements['CDI-SRC-text'].hide();
1046
            me.screenElements['CDI'].hide();
1047
        }
1048
        else {
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
1049
            var course = cdi.getValue('course');
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
1050
            var rot = (course - data.hdg) * D2R;
adds CDI
Sébastien MARQUE authored on 2017-03-18
1051
            me.screenElements['CDI']
makes the CDI available
Sébastien MARQUE authored on 2017-03-23
1052
                .setRotation(rot)
adds CDI
Sébastien MARQUE authored on 2017-03-18
1053
                .show();
1054
            me.screenElements['GPS-CTI']
animates GPS-CTI
Sébastien MARQUE authored on 2017-03-24
1055
                .setVisible(getprop('/instrumentation/gps/wp/wp[1]/valid'))
1056
                .setRotation(getprop('/instrumentation/gps/wp/wp[1]/course-deviation-deg') * D2R);
adds CDI
Sébastien MARQUE authored on 2017-03-18
1057
            me.screenElements['GPS-CTI-diamond']
animates GPS-CTI
Sébastien MARQUE authored on 2017-03-24
1058
                .setVisible(getprop('/instrumentation/gps/wp/wp[1]/valid'))
1059
                .setRotation(getprop('/instrumentation/gps/wp/wp[1]/course-deviation-deg') * D2R);
adds CDI
Sébastien MARQUE authored on 2017-03-18
1060
            foreach (var s; ['GPS', 'NAV1', 'NAV2']) {
1061
                me.screenElements[s ~ '-pointer']
1062
                    .setRotation(rot)
1063
                    .setVisible(source == s);
1064
                me.screenElements[s ~ '-CDI']
1065
                    .setVisible(source == s);
1066
                foreach (var f; ['FROM', 'TO'])
1067
                    me.screenElements[s ~ '-' ~ f]
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
1068
                        .setVisible(s == source and cdi.getValue(f ~ '-flag'));
adds CDI
Sébastien MARQUE authored on 2017-03-18
1069
                me.screenElements['CDI-SRC-text']
1070
                    .setText(source)
1071
                    .setColor(source == 'GPS' ? me.colors.magenta : me.colors.green)
1072
                    .show();
1073
            }
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
1074
            var deflection = cdi.getValue('course-deflection');
warning on CDI for NAV not i...
Sébastien MARQUE authored on 2020-05-30
1075
            if (left(source, 3) == 'NAV') {
makes the CDI available
Sébastien MARQUE authored on 2017-03-23
1076
                var scale = deflection / 4;
fix range warning on CDI
Sébastien MARQUE authored on 2020-06-03
1077
                if (cdi.getValue('in-range') == 0)
warning on CDI for NAV not i...
Sébastien MARQUE authored on 2020-05-30
1078
                    me.screenElements['CDI-GPS-XTK-text']
1079
                        .setColor(me.colors.green)
1080
                        .setText('RANGE')
1081
                        .setVisible(!me.screenElements['CDI-GPS-XTK-text'].getVisible());
1082
                else
1083
                    me.screenElements['CDI-GPS-XTK-text']
1084
                        .hide();
adds ILS glideslope
Sébastien MARQUE authored on 2020-06-09
1085
                if (source == 'NAV1' and getprop('/instrumentation/nav/nav-loc')) {
1086
                    me.screenElements['CDI-GPS-ANN-text']
1087
                        .setColor(me.colors.green)
1088
                        .setText('LOC')
1089
                        .show();
1090
                    cdi.setValue('course', int(getprop('/instrumentation/nav/radials/target-radial-deg')));
1091
                }
1092
                else
1093
                    me.screenElements['CDI-GPS-ANN-text'].hide();
warning on CDI for NAV not i...
Sébastien MARQUE authored on 2020-05-30
1094
            }
makes the CDI available
Sébastien MARQUE authored on 2017-03-23
1095
            else { # GPS
1096
                # TODO: deviation depending of the flight phase
1097
                # for now fixed 1 dot = 1 nm course error
GFC700 GPS helper
Sébastien MARQUE authored on 2020-05-18
1098
                var abs_deflection_max = 2.4;
1099
                if (me.screenElements['LATMOD-Armed-text'].getText() == 'GPS')
1100
                    abs_deflection_max = 0.5;
adds GPS OBS mode
Sébastien MARQUE authored on 2020-05-30
1101
                if (getprop('/instrumentation/gps/mode') == 'obs') {
1102
                    abs_deflection_max = 0.1;
1103
                    me.screenElements['CDI-GPS-ANN-text']
adds ILS glideslope
Sébastien MARQUE authored on 2020-06-09
1104
                        .setColor(me.colors.magenta)
adds GPS OBS mode
Sébastien MARQUE authored on 2020-05-30
1105
                        .setText('OBS')
1106
                        .show();
1107
                }
1108
                else
1109
                    me.screenElements['CDI-GPS-ANN-text'].hide();
makes the CDI available
Sébastien MARQUE authored on 2017-03-23
1110
                var abs_deflection = abs(deflection);
1111
                me.screenElements['CDI-GPS-XTK-text']
fix issue with GPS/CDI
Sébastien MARQUE authored on 2020-05-28
1112
                    .setText(sprintf((abs_deflection < 1 ? 'XTK %.1fNM' : 'XTK %iNM'), abs_deflection))
warning on CDI for NAV not i...
Sébastien MARQUE authored on 2020-05-30
1113
                    .setColor(me.colors.magenta)
GFC700 GPS helper
Sébastien MARQUE authored on 2020-05-18
1114
                    .setVisible(abs_deflection > abs_deflection_max);
makes the CDI available
Sébastien MARQUE authored on 2017-03-23
1115
                var scale = deflection / 2;
1116
            }
fix bug with max cource devi...
Sébastien MARQUE authored on 2020-05-30
1117
            scale = (abs(scale) > 1.2) ? 1.2 * scale / abs(scale) : scale;
makes the CDI available
Sébastien MARQUE authored on 2017-03-23
1118
            me.screenElements[source ~ '-CDI']
1119
                .setTranslation(65 * scale, 0);
settimers to maketimer conti...
Sébastien MARQUE authored on 2020-05-13
1120
            me.timers.updateCDI.start();
adds CDI
Sébastien MARQUE authored on 2017-03-18
1121
        }
1122
    },
1123
#}}}
1124

            
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1125
    _updateRadio: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
1126
# common parts for NAV/LOC/COMM radios{{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1127
        # arg[0]._r = <comm|nav>
1128
        if (contains(arg[0], "active")) {
1129
            if (arg[0]['active'] == 'none') {
1130
                me.screenElements[arg[0]._r ~ '1-selected-freq']
1131
                    .setColor(1,1,1);
1132
                me.screenElements[arg[0]._r ~ '2-selected-freq']
1133
                    .setColor(1,1,1);
1134
            }
1135
            else {
1136
                me.screenElements[arg[0]._r ~ arg[0]['active'] ~ '-selected-freq']
1137
                    .setColor(0,1,0);
1138
                me.screenElements[arg[0]._r ~ arg[0].inactive ~ '-selected-freq']
1139
                    .setColor(1,1,1);
1140
            }
1141
        }
1142
        if (contains(arg[0], 'tune')) {
1143
            # n = 0 -> NAV1/COMM1
1144
            # n = 1 -> NAV1/COMM2
1145
            me.screenElements[arg[0]._r ~ '-freq-switch']
1146
                .setTranslation(0, arg[0].tune * 25);
1147
            me.screenElements[arg[0]._r ~ (arg[0].tune + 1) ~ '-standby-freq']
1148
                .setColor(0,1,1);
1149
            me.screenElements[arg[0]._r ~ ((arg[0].tune == 0) + 1) ~ '-standby-freq']
1150
                .setColor(1,1,1);
1151
        }
1152
        if (contains(arg[0], 'refresh')) {
small stuff
Sébastien MARQUE authored on 2017-03-22
1153
            # refresh only one line: NAV1/COMM1 or NAV2/COMM2
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1154
            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
1155
            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-selected-freq']
1156
                .setText(sprintf(fmt, getprop('/instrumentation/'
1157
                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/selected-mhz')));
1158
            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-standby-freq']
1159
                .setText(sprintf(fmt, getprop('/instrumentation/'
1160
                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/standby-mhz')));
1161
        }
1162
        if (contains(arg[0], 'set')) {
1163
            # positionne la valeur modifiée, les listeners "trigguent" en permanence ces propriétés, donc exit
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
1164
            var n = radios.getValue(arg[0]._r ~ '-tune');
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1165
            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
1166
            me.screenElements[arg[0]._r ~ (n + 1) ~ '-standby-freq']
fix freq display while setti...
Sébastien MARQUE authored on 2017-03-16
1167
                .setText(sprintf(fmt, getprop('/instrumentation/' ~ arg[0]._r ~ '[' ~ n ~ ']/frequencies/standby-mhz')));
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1168
        }
1169
        if (contains(arg[0], 'auto')) {
1170
            # pour rafraichir automagiquement, toutes les deux secondes un refresh pour un NAV
1171
            var radio = arg[0].auto;
1172
            me._updateRadio({refresh: 1, _r: radio});
1173
            settimer(func me._updateRadio({refresh: 2, _r: radio}), 1);
1174
            settimer(func me._updateRadio({auto: radio}), 2);
1175
        }
1176
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
1177
#}}}
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1178

            
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1179
    updateNAV : func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
1180
# update NAV/LOC rodios display upper left (PFD/MFD){{{
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1181
        # made active via menu
1182
        if (contains(arg[0], "active")) {
adds CDI
Sébastien MARQUE authored on 2017-03-18
1183
            arg[0]._r = 'nav';
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1184
            if (arg[0]['active'] == 'none') {
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1185
                me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1186
                me.screenElements['nav1-id']
1187
                    .setColor(1,1,1);
1188
                me.screenElements['nav2-id']
1189
                    .setColor(1,1,1);
1190
                me.screenElements['NAV1-pointer']
1191
                    .hide();
1192
                me.screenElements['NAV2-pointer']
1193
                    .hide();
1194
            }
1195
            else {
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1196
                arg[0].inactive = (arg[0]['active'] == 1) + 1;
1197
                me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1198
                me.screenElements['nav' ~ arg[0]['active'] ~ '-id']
1199
                    .setColor(0,1,0);
1200
                me.screenElements['NAV' ~ arg[0]['active'] ~ '-pointer']
1201
                    .show();
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1202
                me.screenElements['nav' ~ arg[0].inactive ~ '-id']
1203
                    .setColor(1,1,1);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1204
#                me.screenElements['HDI']
1205
#                    .setRotation();
1206
#                me.screenElements['NAV' ~ inactive ~ '-pointer']
1207
#                    .hide();
1208
#                foreach (var e; [ 'FROM', 'TO', 'CDI' ])
1209
#                    me.screenElements['NAV' ~ inactive ~ '-' ~ e]
1210
#                        .hide();
1211
            }
1212
        }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1213
        elsif (contains(arg[0], 'nav-id')) {
Correction swap NAV tuning
Sébastien MARQUE authored on 2017-03-12
1214
            # 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
1215
            if (arg[0].val == nil)
1216
                arg[0].val = '';
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1217
            me.screenElements["nav" ~ arg[0]['nav-id'] ~ "-id"]
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1218
                    .setText(arg[0].val);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1219
        }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1220
        else {
1221
            arg[0]._r = 'nav';
1222
            me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1223
        }
1224
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
1225
#}}}
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1226

            
1227
    updateCOMM: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
1228
# update COMM radios display upper right (PFD/MFD){{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1229
        arg[0]._r = 'comm';
1230
        me._updateRadio(arg[0]);
1231
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
1232
#}}}
anime time display
Sébastien MARQUE authored on 2017-03-13
1233

            
1234
    updateTIME : func {
1235
# updates the displayed time botoom left {{{
change way of time display
Sébastien MARQUE authored on 2020-06-12
1236
        time[data.settings.time.label]();
adds time display setting
Sébastien MARQUE authored on 2020-06-11
1237
        me.screenElements['TIME-REF-text']
1238
            .setText(data.settings.time.label);
anime time display
Sébastien MARQUE authored on 2017-03-13
1239
        me.screenElements['TIME-text']
change way of time display
Sébastien MARQUE authored on 2020-06-12
1240
            .setText(data.time);
anime time display
Sébastien MARQUE authored on 2017-03-13
1241
    },
1242
#}}}
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1243

            
adds transponder
Sébastien MARQUE authored on 2017-03-17
1244
    updateXPDR : func {
1245
# updates transponder display {{{
1246
        for (var d = 0; d < 4; d+=1)
1247
            me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
1248
                .setText(sprintf('%i', getprop('/instrumentation/transponder/inputs/digit[' ~ d ~ ']')));
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
1249
        var tuning = radios.getValue('xpdr-tuning-digit');
1250
        var fms = radios.getValue('xpdr-tuning-fms-method');
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
1251
        for (var d = 0; d < 4; d+=1)
1252
            me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
1253
                .setColor(1,1,1);
1254
        if (tuning != nil) {
1255
            me.screenElements['XPDR-DIGIT-' ~ tuning ~ '-text']
1256
                .setColor(0,1,1);
1257
            if (fms)
1258
                me.screenElements['XPDR-DIGIT-' ~ (tuning - 1) ~ '-text']
1259
                    .setColor(0,1,1);
1260
        }
adds transponder
Sébastien MARQUE authored on 2017-03-17
1261
        else {
1262
            if (getprop('/instrumentation/transponder/ident'))
1263
                var mode = 'IDENT';
1264
            else
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
1265
                var mode = radios.getValue('xpdr-mode');
adds transponder
Sébastien MARQUE authored on 2017-03-17
1266
            var wow = getprop('/gear/gear/wow');
1267
            if (! wow and mode != 'STBY')
1268
                var color = [0, 1, 0];
1269
            else
1270
                var color = [1, 1, 1];
1271
            for (var d = 0; d < 4; d+=1)
1272
                me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
1273
                    .setColor(color);
1274
            me.screenElements['XPDR-MODE-text']
1275
                .setColor(color)
1276
                .setText(mode);
1277
        }
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
1278
    },
adds transponder
Sébastien MARQUE authored on 2017-03-17
1279
#}}}
1280

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1281
    updateOAT : func {
1282
# update OAT display on normal and reversionnary modes (every 3s) {{{
1283
        var tmp = getprop('/environment/temperature-deg' ~ me._oat_unit);
1284
        me.screenElements['OAT-text']
1285
            .setText(sprintf((abs(tmp) < 10) ? "%.1f %s" : "%i %s", tmp, (me._oat_unit == 'c') ? '°C' : 'F'));
1286
    },
1287
    _oat_unit : 'c',
1288
#}}}
1289

            
1290
    updateWindData : func {
1291
# update the window text and arrows for OPTN1/2 {{{
1292
        if (me._winddata_optn == 0)
1293
            return;
make wind data available in ...
Sébastien MARQUE authored on 2020-05-28
1294
        if (data.ias > 30) {
improves WindData display
Sébastien MARQUE authored on 2017-03-16
1295
            me.screenElements['WindData-NODATA']
1296
                .hide();
1297
            var wind_hdg = getprop('/environment/wind-from-heading-deg');
1298
            var wind_spd = getprop('/environment/wind-speed-kt');
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
1299
            var alpha = wind_hdg - data.hdg;
improves WindData display
Sébastien MARQUE authored on 2017-03-16
1300
            if (me._winddata_optn == 1) {
1301
                me.screenElements['WindData-OPTN1-HDG']
1302
                    .setRotation((alpha + 180) * D2R)
1303
                    .show();
1304
                me.screenElements['WindData-OPTN1-HDG-text']
1305
                    .setText(sprintf("%03i°", wind_hdg))
1306
                    .show();
1307
                me.screenElements['WindData-OPTN1-SPD-text']
1308
                    .setText(int(wind_spd) ~ 'KT')
1309
                    .show();
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1310
            }
improves WindData display
Sébastien MARQUE authored on 2017-03-16
1311
            else { # me._winddata_optn == 2
1312
                alpha *= D2R;
1313
                var Vt = wind_spd * math.sin(alpha);
1314
                var Ve = wind_spd * math.cos(alpha);
1315
                if (Vt != 0) {
1316
                    me.screenElements['WindData-OPTN2-crosswind-text']
1317
                        .setText(sprintf('%i', abs(Vt)))
1318
                        .show();
1319
                    me.screenElements['WindData-OPTN2-crosswind']
1320
                        .setScale(-abs(Vt)/Vt, 1)
1321
                        .setTranslation(-35 * (abs(Vt)/Vt + 1), 0)
1322
                        .show();
1323
                }
1324
                if (Ve != 0) {
1325
                    me.screenElements['WindData-OPTN2-headwind-text']
1326
                        .setText(sprintf('%i', abs(Ve)))
1327
                        .show();
1328
                    me.screenElements['WindData-OPTN2-headwind']
1329
                        .setScale(1, abs(Ve)/Ve)
1330
                        .setTranslation(0, 515 * (1 - abs(Ve)/Ve))
1331
                        .show();
1332
                }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1333
            }
1334
        }
improves WindData display
Sébastien MARQUE authored on 2017-03-16
1335
        else {
1336
            foreach (var e; [
1337
                    'WindData-OPTN1-HDG',
1338
                    'WindData-OPTN1-HDG-text',
1339
                    'WindData-OPTN1-SPD-text',
1340
                    'WindData-OPTN2-crosswind-text',
1341
                    'WindData-OPTN2-crosswind',
1342
                    'WindData-OPTN2-headwind-text',
1343
                    'WindData-OPTN2-headwind'
1344
            ])
1345
                me.screenElements[e].hide();
1346
            me.screenElements['WindData-NODATA'].show();
1347
        }
settimers to maketimer conti...
Sébastien MARQUE authored on 2020-05-13
1348
        me.timers.updateWindData.start();
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1349
    },
1350
    _winddata_optn : 0,
1351
#}}}
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1352

            
adds AOA display
Sébastien MARQUE authored on 2017-04-15
1353
    updateAOA : func {
1354
# update Angle Of Attack {{{
fix AOA not shown
Sébastien MARQUE authored on 2020-05-30
1355
        if (me.device.data.aoa + me.device.data['aoa-auto'] == 0)
adds AOA display
Sébastien MARQUE authored on 2017-04-15
1356
            return;
1357
        var color = [1,1,1];
1358
        var norm = data.aoa / data['stall-aoa'];
nicer AOA display
Sébastien MARQUE authored on 2017-04-16
1359
        me.screenElements['AOA-text']
1360
            .setText(sprintf('% .1f', norm));
adds AOA display
Sébastien MARQUE authored on 2017-04-15
1361
        if (norm > 1) norm = 1;
1362
        if (norm > 0.9)
1363
            color = [1,0,0];
1364
        elsif (norm > 0.7)
1365
            color = [1,1,0];
1366
        elsif (norm < 0) {
1367
            norm = 0;
1368
            color = [1,0,0];
1369
        }
1370
        me.screenElements['AOA-needle']
1371
            .setRotation(-norm * math.pi)
nicer AOA display
Sébastien MARQUE authored on 2017-04-16
1372
            .setColorFill(color);
1373
        me.screenElements['AOA-text']
adds AOA display
Sébastien MARQUE authored on 2017-04-15
1374
            .setColor(color);
settimers to maketimer conti...
Sébastien MARQUE authored on 2020-05-13
1375
        me.timers.updateAOA.start();
adds AOA display
Sébastien MARQUE authored on 2017-04-15
1376
    },
1377
# }}}
1378

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

            
1384
            var dev = radios.getNode(source).getValue();
1385
            var el  = 'BRG' ~ brg;
1386
            if (dev != 'OFF') {
1387
                var info = {
1388
                    pointer : nil,
1389
                    id : 'NO DATA',
1390
                    hdg : nil,
1391
                    dst : '--.-NM'
1392
                };
1393
                if (left(dev, 3) == 'NAV') {
1394
                    info.pointer = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/in-range');
1395
                    if (info.pointer) {
1396
                        info.id  = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/nav-id');
1397
                        info.hdg = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/heading-deg');
1398
                        info.dst = sprintf('%.1d', getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/nav-distance') / 1852); # m -> /1852
1399
                    }
1400
                }
1401
                elsif (dev == 'GPS') {
1402
                    info.pointer = props.getNode('/instrumentation/gps/wp').getChild('wp[1])');
1403
                    if (info.pointer) {
1404
                        info.id  = getprop('/instrumentation/gps/wp/wp[1]/ID');
1405
                        info.hdg = getprop('/instrumentation/gps/wp/wp[1]/bearing-mag-deg');
1406
                        info.dst = sprintf('%.1d', getprop('/instrumentation/gps/wp/wp[1]/distance-nm'));
1407
                    }
1408
                }
1409
                else { # there are 2 available ADF in FG, but instrument manage only 1
1410
                    info.pointer = getprop('/instrumentation/adf/in-range');
1411
                    if (info.pointer) {
1412
                        info.id  = getprop('/instrumentation/adf/ident');
1413
                        info.hdg = getprop('/instrumentation/adf/indicated-bearing-deg');
1414
                    }
1415
                }
1416

            
1417
                if (info.pointer)
1418
                    me.screenElements[el ~ '-pointer']
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
1419
                        .setRotation(-info.hdg - data.hdg * D2R)
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1420
                        .show();
1421
                else
1422
                    me.screenElements[el ~ '-pointer']
1423
                        .hide();
1424
                me.screenElements[el ~ '-SRC-text']
1425
                    .setText(dev);
1426
                me.screenElements[el ~ '-DST-text']
1427
                    .setText(info.dst);
1428
                me.screenElements[el ~ '-WPID-text']
1429
                    .setText(info.id);
1430
                me.screenElements['BRG' ~ brg]
1431
                    .show();
1432
            }
1433
            else {
1434
                me.screenElements['BRG' ~ brg]
1435
                    .hide();
1436
            }
1437
        }
1438
    },
some added comments
Sébastien MARQUE authored on 2017-03-18
1439
#}}}
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
1440

            
adds OMI to PFD
Sébastien MARQUE authored on 2017-03-23
1441
    updateOMI : func {
1442
# display marker baecon Outer, Middle, Inner {{{
1443
        var marker = nil;
1444
        foreach (var m; ['outer', 'middle', 'inner'])
1445
            if (getprop('/instrumentation/marker-beacon/' ~ m)) {
1446
                marker = m;
1447
                me.screenElements['OMI']
1448
                    .show();
1449
                break;
1450
            }
1451
        if (marker != nil) {
1452
            me.screenElements['MarkerText']
1453
                .setText(me._omi_data[marker].t)
1454
                .show();
1455
            me.screenElements['MarkerBG']
1456
                .setColorFill(me._omi_data[marker].bg)
1457
                .show();
1458
        }
1459
        else
1460
            me.screenElements['OMI']
1461
                .hide();
1462
    },
1463
    _omi_data : {
1464
        'outer':  {t: 'O', bg: [0,1,1]},
1465
        'middle': {t: 'M', bg: [1,1,1]},
1466
        'inner':  {t: 'I', bg: [1,1,0]},
1467
    },
1468
#}}}
adds ILS glideslope
Sébastien MARQUE authored on 2020-06-09
1469

            
1470
    updateGS : func {
1471
# display glide-slope on ILS approach {{{
1472
        var deflection = getprop('/instrumentation/nav/gs-needle-deflection-norm');
1473
        me.screenElements['GS-ILS']
1474
            .setTranslation(0, deflection * 100);
1475
    },
1476
#}}}
animation texts EIS + power ...
Sébastien MARQUE authored on 2017-03-19
1477
};