zkv1000 / Nasal / display.nas /
Newer Older
1485 lines | 59.055kb
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 {
settings now have effect
Sébastien MARQUE authored on 2020-06-12
232
                var unit = units.distance.from_nm == 1 ? 'NM' : 'km';
233
                if (data.fpSize == 0) return '---' ~ unit;
234
                var dist = getprop('/autopilot/route-manager/distance-remaining-nm') * units.distance.from_nm;
navigation box content
Sébastien MARQUE authored on 2020-05-12
235
                if (dist != nil)
settings now have effect
Sébastien MARQUE authored on 2020-06-12
236
                    return sprintf(dist < 100 ? '%2.1f%s' : '%3i%s', dist, unit);
navigation box content
Sébastien MARQUE authored on 2020-05-12
237
                else
settings now have effect
Sébastien MARQUE authored on 2020-06-12
238
                    return '---' ~ unit;
navigation box content
Sébastien MARQUE authored on 2020-05-12
239
            }, 'Total Distance Remaining'],
240
            DIS: [func {
settings now have effect
Sébastien MARQUE authored on 2020-06-12
241
                var unit = units.distance.from_nm == 1 ? 'NM' : 'km';
242
                if (data.fpSize == 0) return '---' ~ unit;
243
                var dist = getprop('/autopilot/route-manager/wp/dist') * units.distance.from_nm;
navigation box content
Sébastien MARQUE authored on 2020-05-12
244
                if (dist != nil)
settings now have effect
Sébastien MARQUE authored on 2020-06-12
245
                    return sprintf(dist < 100 ? '%2.1f%s' : '%3i%s', dist, unit);
navigation box content
Sébastien MARQUE authored on 2020-05-12
246
                else
settings now have effect
Sébastien MARQUE authored on 2020-06-12
247
                    return '---' ~ unit;
navigation box content
Sébastien MARQUE authored on 2020-05-12
248
            }, 'Distance remaining'],
249
            LEG: [func {
250
                if (data.fpSize == 0) return '';
251
                var route = m.device.map.layers.route;
252
                var wp = route.flightPlan[route.currentLeg.index];
253
                return sprintf(' %s %s %s', wp[0].name, utf8.chstr(9658), wp[1].name);
254
            }, ''], # not listed in MFD menu, on PFD only the leg is shown not the item
255
            LDG: [func {
256
                var eteSeconds = getprop('/autopilot/route-manager/ete');
257
                var eteHours = math.floor(eteSeconds / 3600);
258
                var eteMinutes = int((eteSeconds - (eteHours * 3600)) / 60);
259
                return sprintf(eteHours > 99 ? '--:--' : '%02i:%02i', eteHours, eteMinutes);
260
            }, 'ETA at Final Destination'],
261
            END: [func {
262
                var total_fuel = getprop('/consumables/fuel/total-fuel-gals');
263
                var gs = getprop('/velocities/groundspeed-kt');
264
                var consumption = 0;
265
                foreach(var engine; props.globals.getNode('/engines').getChildren('engine')) {
266
                    var ec = engine.getValue('fuel-flow-gph');
267
                    consumption += ec != nil ? ec : 0;
268
                }
settings now have effect
Sébastien MARQUE authored on 2020-06-12
269
                var unit = units.distance.from_nm == 1 ? 'NM' : 'km';
navigation box content
Sébastien MARQUE authored on 2020-05-12
270
                if (consumption > 0 and gs > 0)
settings now have effect
Sébastien MARQUE authored on 2020-06-12
271
                    return sprintf('%3i%s', (total_fuel * gs) / consumption * units.distance.from_nm, unit);
navigation box content
Sébastien MARQUE authored on 2020-05-12
272
                else
settings now have effect
Sébastien MARQUE authored on 2020-06-12
273
                    return '---' ~ unit;
navigation box content
Sébastien MARQUE authored on 2020-05-12
274
            }, 'Endurance'],
275
            ETA: [func {
276
                var eteSeconds = getprop('/autopilot/route-manager/ete');
change way of time display
Sébastien MARQUE authored on 2020-06-12
277
                string.scanf(data.time, '%02u:%02u:%02u', var eta = []);
278

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

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

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

            
389
# temporary Widget Display for HDG and CRS modification {{{
390

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

            
393
    timerTrigger : func {
394
        var now = systime();
replace settimer by maketime...
Sébastien MARQUE authored on 2020-05-06
395
        foreach (var id; keys(me.temporaryWidgetDisplay)) {
396
            if (me.temporaryWidgetDisplay[id] < now) {
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
397
                me.screenElements[id].hide();
replace settimer by maketime...
Sébastien MARQUE authored on 2020-05-06
398
                delete(me.temporaryWidgetDisplay, id);
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
399
            }
commit initial
Sébastien MARQUE authored on 2017-03-07
400
        }
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
401
    },
402

            
403
    addTimer : func (duration, element) {
404
        if (typeof(element) == 'scalar')
405
            element = [ element ];
406
        var end = systime() + duration;
407
        foreach (var e; element)
replace settimer by maketime...
Sébastien MARQUE authored on 2020-05-06
408
            me.temporaryWidgetDisplay[e] = end;
commit initial
Sébastien MARQUE authored on 2017-03-07
409
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
410
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
411

            
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
412
    showInitProgress : func {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
413
#{{{
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
414
        if (me.device.role == 'PFD') {
replace settimer by maketime...
Sébastien MARQUE authored on 2020-05-06
415
            me.timers.updateAI     = maketimer(0.1, me, me.updateAI     );
416
            me.timers.updateVSI    = maketimer(0.1, me, me.updateVSI    );
417
            me.timers.updateIAS    = maketimer(0.1, me, me.updateIAS    );
418
            me.timers.updateALT    = maketimer(0.2, me, me.updateALT    );
419
            me.timers.updateHSI    = maketimer(0.2, me, me.updateHSI    );
420
            me.timers.updateTIME   = maketimer(1.0, me, me.updateTIME   );
421
            me.timers.updateOAT    = maketimer(3.0, me, me.updateOAT    );
422
            me.timers.updateTAS    = maketimer(0.5, me, me.updateTAS    );
423
            me.timers.updateBRG    = maketimer(0.5, me, me.updateBRG    );
424
            me.timers.updateXPDR   = maketimer(0,   me, me.updateXPDR   ); me.timers.updateXPDR.singleShot=1;
425
            me.timers.updateBARO   = maketimer(0,   me, me.updateBARO   ); me.timers.updateBARO.singleShot=1;
426
            me.timers.updateOMI    = maketimer(1.0, me, me.updateOMI    );
427
            me.timers.timerTrigger = maketimer(1.0, me, me.timerTrigger );
settimers to maketimer conti...
Sébastien MARQUE authored on 2020-05-13
428
            me.timers.updateAOA    = maketimer(0.1, me, me.updateAOA    );    me.timers.updateAOA.singleShot=1;
429
            me.timers.updateCDI    = maketimer(0.3, me, me.updateCDI    );    me.timers.updateCDI.singleShot=1;
430
            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
431

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

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

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

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

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

            
some added comments
Sébastien MARQUE authored on 2017-03-18
458
    colors : {
459
# set of predefined colors {{{
460
        green : [0, 1, 0],
461
        white : [1, 1, 1],
462
        black : [0, 0, 0],
463
        lightblue : [0, 1, 1],
464
        darkblue : [0, 0, 1],
465
        red : [1, 0, 0],
adds CDI
Sébastien MARQUE authored on 2017-03-18
466
        magenta : [1, 0, 1],
add yellow predefined color
Sébastien MARQUE authored on 2020-05-11
467
        yellow : [1, 1, 0],
some added comments
Sébastien MARQUE authored on 2017-03-18
468
    },
469
#}}}
470

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

            
529
    clips : {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
530
#{{{
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
531
        PitchScale   : "rect(70,664,370,256)",
532
        SpeedLint1   : "rect(252,226,318,204)",
533
        SpeedTape    : "rect(115,239,455,156)",
534
        LintAlt      : "rect(115,808,455,704)",
animation ALT
Sébastien MARQUE authored on 2017-03-11
535
        AltLint00011 : "rect(252,804,318,771)",
AI disponible
Sébastien MARQUE authored on 2017-03-10
536
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
537
#}}}
AI disponible
Sébastien MARQUE authored on 2017-03-10
538

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

            
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
586
    softkeys_inactivity : func {
587
# automagically back to previous level after some delay {{{
old timers2 removed
Sébastien MARQUE authored on 2020-05-15
588
        me.timers.softkeys_inactivity = maketimer (
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
589
            me.softkeys_inactivity_delay,
590
            func {
591
                pop(me.device.softkeys.path);
592
                me.updateSoftKeys();
593
            }, me);
old timers2 removed
Sébastien MARQUE authored on 2020-05-15
594
        me.timers.softkeys_inactivity.singleShot = 1;
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
595
    },
596
#}}}
597

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

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

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

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
652
        var path = keyMap[me.device.role];
not yet implemented softkeys...
Sébastien MARQUE authored on 2017-06-08
653
        var bindings = me.device.softkeys.bindings[me.device.role];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
654
        var pathid = '';
655
        foreach (var p; me.device.softkeys.path) {
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
656
            path = path[p];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
657
            pathid ~= p;
not yet implemented softkeys...
Sébastien MARQUE authored on 2017-06-08
658
            if (contains(bindings, p))
659
                bindings = bindings[p];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
660
        }
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
661

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

            
693
        if (size(me.device.softkeys.path))
old timers2 removed
Sébastien MARQUE authored on 2020-05-15
694
            me.timers.softkeys_inactivity.restart(me.softkeys_inactivity_delay);
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
695
        else
old timers2 removed
Sébastien MARQUE authored on 2020-05-15
696
            me.timers.softkeys_inactivity.stop();
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
697
    },
698
#}}}
699

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

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
721
    updateVSI: func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
722
# animate VSI {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
723
        var vsi = data.vsi;
animation VSI
Sébastien MARQUE authored on 2017-03-10
724
        me.screenElements.VSIText
725
            .setText(num(math.round(vsi, 10)));
settings now have effect
Sébastien MARQUE authored on 2020-06-12
726
        var scale = units.vspeed.from_fpm == 1 ? 1 : 10;
727
        if (vsi > 4500 / scale)
728
            vsi = 4500 / scale;
729
        elsif (vsi < -4500 / scale)
730
            vsi = -4500 / scale;
animation VSI
Sébastien MARQUE authored on 2017-03-10
731
        me.screenElements.VSI
settings now have effect
Sébastien MARQUE authored on 2020-06-12
732
            .setTranslation(0, vsi * -0.03465 * scale);
animation VSI
Sébastien MARQUE authored on 2017-03-10
733
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
734
#}}}
animation IAS
Sébastien MARQUE authored on 2017-03-10
735

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

            
improve trends vor ALT and I...
Sébastien MARQUE authored on 2020-04-30
769
        var Sy = 0;
770
        for (var i = 8; i >= 0; i -= 1)
771
            me._last_ias_Sy[i+1] = me._last_ias_Sy[i];
trends animation
Sébastien MARQUE authored on 2017-03-13
772
        var now = systime();
773
        # estimated speed in 6s
improve trends vor ALT and I...
Sébastien MARQUE authored on 2020-04-30
774
        me._last_ias_Sy[0] = 6 * (ias - me._last_ias_kt) / (now - me._last_ias_s);
775
        foreach (var _Sy; me._last_ias_Sy)
776
            Sy += _Sy;
777
        Sy /= 10;
trends animation
Sébastien MARQUE authored on 2017-03-13
778
        if (abs(Sy) > 30)
779
            Sy = 30 * abs(Sy)/Sy; # = -30 or 30
780
        me.screenElements['Airspeed-Trend-Indicator']
781
            .setScale(1,Sy)
782
            .setTranslation(0, -284.5 * (Sy - 1));
783
        me._last_ias_kt = ias;
784
        me._last_ias_s = now;
animation IAS
Sébastien MARQUE authored on 2017-03-10
785
    },
trends animation
Sébastien MARQUE authored on 2017-03-13
786
    _last_ias_kt : 0,
787
    _last_ias_s : systime(),
improve trends vor ALT and I...
Sébastien MARQUE authored on 2020-04-30
788
    _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
789
    _ias_already_exceeded : 0,
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
790
#}}}
animation ALT
Sébastien MARQUE authored on 2017-03-11
791

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
792
    updateTAS: func {
793
# updates the True Airspeed and GroundSpeed indicators {{{
settings now have effect
Sébastien MARQUE authored on 2020-06-12
794
        var unit = units.speed.from_kt == 1 ? 'KT' : 'km/h';
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
795
        me.screenElements['TAS-text']
settings now have effect
Sébastien MARQUE authored on 2020-06-12
796
            .setText(sprintf('%i%s', getprop('/instrumentation/airspeed-indicator/true-speed-kt') * units.speed.from_kt, unit));
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
797
        me.screenElements['GSPD-text']
settings now have effect
Sébastien MARQUE authored on 2020-06-12
798
            .setText(sprintf('%i%s', getprop('/velocities/groundspeed-kt') * units.speed.from_kt, unit));
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
799
    },
800
#}}}
801

            
802
    updateALT: func () {
803
# animates the altitude lint (PFD) {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
804
        var alt = data.alt;
animation ALT
Sébastien MARQUE authored on 2017-03-11
805
        if (alt < 0)
806
            me.screenElements.Alt11100
fix altitude indicator
Sébastien MARQUE authored on 2020-05-03
807
                .setText(sprintf("%3d",math.ceil(alt/100)));
animation ALT
Sébastien MARQUE authored on 2017-03-11
808
        elsif (alt < 100)
809
            me.screenElements.Alt11100
810
                .setText('');
811
        else
812
            me.screenElements.Alt11100
fix altitude indicator
Sébastien MARQUE authored on 2020-05-03
813
                .setText(sprintf("%3i",math.floor(alt/100)));
animation ALT
Sébastien MARQUE authored on 2017-03-11
814
        me.screenElements.AltLint00011
815
            .setTranslation(0,math.fmod(alt,100) * 1.24);
816

            
817
        # From Farmin/G1000 http://wiki.flightgear.org/Project_Farmin/FG1000
818
        if (alt> -1000 and alt< 1000000) {
819
            var Offset10 = 0;
820
            var Offset100 = 0;
821
            var Offset1000 = 0;
822
            if (alt< 0) {
823
                var Ne = 1;
824
                var alt= -alt;
825
            }
826
            else
827
                var Ne = 0;
828

            
829
            var Alt10       = math.mod(alt,100);
830
            var Alt100      = int(math.mod(alt/100,10));
831
            var Alt1000     = int(math.mod(alt/1000,10));
832
            var Alt10000    = int(math.mod(alt/10000,10));
833
            var Alt20       = math.mod(Alt10,20)/20;
834
            if (Alt10 >= 80)
835
                var Alt100 += Alt20;
836

            
837
            if (Alt10 >= 80 and Alt100 >= 9)
838
                var Alt1000 += Alt20;
839

            
840
            if (Alt10 >= 80 and Alt100 >= 9 and Alt1000 >= 9)
841
                var Alt10000 += Alt20;
842

            
843
            if (alt> 100)
844
                var Offset10 = 100;
845

            
846
            if (alt> 1000)
847
                var Offset100 = 10;
848

            
849
            if (alt> 10000)
850
                var Offset1000 = 10;
851

            
852
            if (!Ne) {
853
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*0.57375);
854
                var altCentral = (int(alt/100)*100);
855
            }
856
            elsif (Ne) {
857
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*-0.57375);
858
                var altCentral = -(int(alt/100)*100);
859
            }
860
            me.screenElements["AltBigC"].setText("");
861
            me.screenElements["AltSmallC"].setText("");
862
            for (var place = 1; place <= 6; place += 1) {
863
                var altUP = altCentral + (place*100);
864
                var offset = -30.078;
865
                if (altUP < 0) {
866
                    var altUP = -altUP;
867
                    var prefix = "-";
868
                    var offset += 15.039;
869
                }
870
                else
871
                    var prefix = "";
872

            
873
                if (altUP == 0) {
874
                    var AltBigUP    = "";
875
                    var AltSmallUP  = "0";
876

            
877
                }
878
                elsif (math.mod(altUP,500) == 0 and altUP != 0) {
879
                    var AltBigUP    = sprintf(prefix~"%1d", altUP);
880
                    var AltSmallUP  = "";
881
                }
882
                elsif (altUP < 1000 and (math.mod(altUP,500))) {
883
                    var AltBigUP    = "";
884
                    var AltSmallUP  = sprintf(prefix~"%1d", int(math.mod(altUP,1000)));
885
                    var offset = -30.078;
886
                }
887
                elsif ((altUP < 10000) and (altUP >= 1000) and (math.mod(altUP,500))) {
888
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
889
                    var AltSmallUP  = sprintf("%1d", int(math.mod(altUP,1000)));
890
                    var offset += 15.039;
891
                }
892
                else {
893
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
894
                    var mod = int(math.mod(altUP,1000));
895
                    var AltSmallUP  = sprintf("%1d", mod);
896
                    var offset += 30.078;
897
                }
898

            
899
                me.screenElements["AltBigU"~place].setText(AltBigUP);
900
                me.screenElements["AltSmallU"~place].setText(AltSmallUP);
901
                me.screenElements["AltSmallU"~place].setTranslation(offset,0);
902
                var altDOWN = altCentral - (place*100);
903
                var offset = -30.078;
904
                if (altDOWN < 0) {
905
                    var altDOWN = -altDOWN;
906
                    var prefix = "-";
907
                    var offset += 15.039;
908
                }
909
                else
910
                    var prefix = "";
911

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

            
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
964
    updateBARO : func () {
965
# update BARO widget {{{
settings now have effect
Sébastien MARQUE authored on 2020-06-12
966
        var fmt = data.settings.units.pressure == 'inhg' ? '%.2f%s' : '%i%s';
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
967
        me.screenElements['BARO-text']
968
            .setText(sprintf(fmt,
settings now have effect
Sébastien MARQUE authored on 2020-06-12
969
                        getprop('/instrumentation/altimeter/setting-' ~ data.settings.units.pressure),
970
                        data.settings.units.pressure == 'inhg' ? 'in' : 'hPa')
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
971
                );
972
    },
973
#}}}
974

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

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

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

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

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

            
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1134
    _updateRadio: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
1135
# common parts for NAV/LOC/COMM radios{{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1136
        # arg[0]._r = <comm|nav>
1137
        if (contains(arg[0], "active")) {
1138
            if (arg[0]['active'] == 'none') {
1139
                me.screenElements[arg[0]._r ~ '1-selected-freq']
1140
                    .setColor(1,1,1);
1141
                me.screenElements[arg[0]._r ~ '2-selected-freq']
1142
                    .setColor(1,1,1);
1143
            }
1144
            else {
1145
                me.screenElements[arg[0]._r ~ arg[0]['active'] ~ '-selected-freq']
1146
                    .setColor(0,1,0);
1147
                me.screenElements[arg[0]._r ~ arg[0].inactive ~ '-selected-freq']
1148
                    .setColor(1,1,1);
1149
            }
1150
        }
1151
        if (contains(arg[0], 'tune')) {
1152
            # n = 0 -> NAV1/COMM1
1153
            # n = 1 -> NAV1/COMM2
1154
            me.screenElements[arg[0]._r ~ '-freq-switch']
1155
                .setTranslation(0, arg[0].tune * 25);
1156
            me.screenElements[arg[0]._r ~ (arg[0].tune + 1) ~ '-standby-freq']
1157
                .setColor(0,1,1);
1158
            me.screenElements[arg[0]._r ~ ((arg[0].tune == 0) + 1) ~ '-standby-freq']
1159
                .setColor(1,1,1);
1160
        }
1161
        if (contains(arg[0], 'refresh')) {
small stuff
Sébastien MARQUE authored on 2017-03-22
1162
            # refresh only one line: NAV1/COMM1 or NAV2/COMM2
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1163
            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
1164
            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-selected-freq']
1165
                .setText(sprintf(fmt, getprop('/instrumentation/'
1166
                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/selected-mhz')));
1167
            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-standby-freq']
1168
                .setText(sprintf(fmt, getprop('/instrumentation/'
1169
                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/standby-mhz')));
1170
        }
1171
        if (contains(arg[0], 'set')) {
1172
            # 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
1173
            var n = radios.getValue(arg[0]._r ~ '-tune');
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1174
            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
1175
            me.screenElements[arg[0]._r ~ (n + 1) ~ '-standby-freq']
fix freq display while setti...
Sébastien MARQUE authored on 2017-03-16
1176
                .setText(sprintf(fmt, getprop('/instrumentation/' ~ arg[0]._r ~ '[' ~ n ~ ']/frequencies/standby-mhz')));
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1177
        }
1178
        if (contains(arg[0], 'auto')) {
1179
            # pour rafraichir automagiquement, toutes les deux secondes un refresh pour un NAV
1180
            var radio = arg[0].auto;
1181
            me._updateRadio({refresh: 1, _r: radio});
1182
            settimer(func me._updateRadio({refresh: 2, _r: radio}), 1);
1183
            settimer(func me._updateRadio({auto: radio}), 2);
1184
        }
1185
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
1186
#}}}
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1187

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

            
1236
    updateCOMM: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
1237
# update COMM radios display upper right (PFD/MFD){{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1238
        arg[0]._r = 'comm';
1239
        me._updateRadio(arg[0]);
1240
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
1241
#}}}
anime time display
Sébastien MARQUE authored on 2017-03-13
1242

            
1243
    updateTIME : func {
1244
# updates the displayed time botoom left {{{
change way of time display
Sébastien MARQUE authored on 2020-06-12
1245
        time[data.settings.time.label]();
adds time display setting
Sébastien MARQUE authored on 2020-06-11
1246
        me.screenElements['TIME-REF-text']
1247
            .setText(data.settings.time.label);
anime time display
Sébastien MARQUE authored on 2017-03-13
1248
        me.screenElements['TIME-text']
change way of time display
Sébastien MARQUE authored on 2020-06-12
1249
            .setText(data.time);
anime time display
Sébastien MARQUE authored on 2017-03-13
1250
    },
1251
#}}}
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1252

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

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1290
    updateOAT : func {
1291
# update OAT display on normal and reversionnary modes (every 3s) {{{
adds temperature units setti...
Sébastien MARQUE authored on 2020-06-15
1292
        var tmp = units.temperature.from_C(getprop('/environment/temperature-degc'));
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1293
        me.screenElements['OAT-text']
adds temperature units setti...
Sébastien MARQUE authored on 2020-06-15
1294
            .setText(sprintf((abs(tmp) < 10) ? "%.1f %s" : "%i %s", tmp, units.temperature.from_C(0) ? 'F' : '°C'));
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1295
    },
1296
#}}}
1297

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

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

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

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

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

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

            
1478
    updateGS : func {
1479
# display glide-slope on ILS approach {{{
1480
        var deflection = getprop('/instrumentation/nav/gs-needle-deflection-norm');
1481
        me.screenElements['GS-ILS']
1482
            .setTranslation(0, deflection * 100);
1483
    },
1484
#}}}
animation texts EIS + power ...
Sébastien MARQUE authored on 2017-03-19
1485
};