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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
541
    clips : {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
542
#{{{
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
543
        PitchScale   : "rect(70,664,370,256)",
544
        SpeedLint1   : "rect(252,226,318,204)",
545
        SpeedTape    : "rect(115,239,455,156)",
546
        LintAlt      : "rect(115,808,455,704)",
animation ALT
Sébastien MARQUE authored on 2017-03-11
547
        AltLint00011 : "rect(252,804,318,771)",
AI disponible
Sébastien MARQUE authored on 2017-03-10
548
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
549
#}}}
AI disponible
Sébastien MARQUE authored on 2017-03-10
550

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

            
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
598
    softkeys_inactivity : func {
599
# automagically back to previous level after some delay {{{
old timers2 removed
Sébastien MARQUE authored on 2020-05-15
600
        me.timers.softkeys_inactivity = maketimer (
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
601
            me.softkeys_inactivity_delay,
602
            func {
603
                pop(me.device.softkeys.path);
604
                me.updateSoftKeys();
605
            }, me);
old timers2 removed
Sébastien MARQUE authored on 2020-05-15
606
        me.timers.softkeys_inactivity.singleShot = 1;
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
607
    },
608
#}}}
609

            
softkey is implemented by de...
Sébastien MARQUE authored on 2017-12-21
610
    setSoftKeyColor : func (n, active, implemented = 1, alert = 0) {
add softkeys colors
Sébastien MARQUE authored on 2017-03-21
611
# set colors for active softkeys {{{
612
        var sftk = sprintf('SoftKey%02i-', n);
613
        if (active) {
614
            var bg = alert ? 1 : 0.5;
615
            me.screenElements[sftk ~ 'bg']
616
                .setColorFill(bg,bg,bg);
617
            me.screenElements[sftk ~ 'text']
618
                .setColor(0,0,0);
619
        }
620
        else {
not yet implemented softkeys...
Sébastien MARQUE authored on 2017-06-08
621
            var tc = implemented ? 1 : 0.5;
add softkeys colors
Sébastien MARQUE authored on 2017-03-21
622
            me.screenElements[sftk ~ 'bg']
623
                .setColorFill(0,0,0);
624
            me.screenElements[sftk ~ 'text']
not yet implemented softkeys...
Sébastien MARQUE authored on 2017-06-08
625
                .setColor(tc,tc,tc);
add softkeys colors
Sébastien MARQUE authored on 2017-03-21
626
        }
627
    },
628
#}}}
629

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

            
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
652
    updateSoftKeys : func {
653
# update SoftKeys boxes {{{
654
        # on PFD the last boxes are always BACK and ALERTS
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
655
        if (me.device.role == 'PFD') {
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
656
            me.screenElements[sprintf("SoftKey%02i-text", 11)]
657
                .setText('ALERTS');
658
            if (size(me.device.softkeys.path) != 0)
659
                me.screenElements[sprintf("SoftKey%02i-text", 10)]
not yet implemented softkeys...
Sébastien MARQUE authored on 2017-06-08
660
                    .setText('BACK')
661
                    .setColor(1,1,1);
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
662
        }
663

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
664
        var path = keyMap[me.device.role];
not yet implemented softkeys...
Sébastien MARQUE authored on 2017-06-08
665
        var bindings = me.device.softkeys.bindings[me.device.role];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
666
        var pathid = '';
667
        foreach (var p; me.device.softkeys.path) {
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
668
            path = path[p];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
669
            pathid ~= p;
not yet implemented softkeys...
Sébastien MARQUE authored on 2017-06-08
670
            if (contains(bindings, p))
671
                bindings = bindings[p];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
672
        }
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
673

            
674
        # feeding with empty menus the first boxes
675
        var start = (contains(path, 'first')) ? path.first : 0;
676
        for (var k = 0; k < start; k+=1) {
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
677
            var sftk = sprintf("SoftKey%02i-", k);
678
            me.screenElements[sftk ~ 'text']
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
679
                .setText('');
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
680
            me.screenElements[sftk ~ 'bg']
681
                .setColorFill(0,0,0);
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
682
        }
683
        # filling with the content the next boxes
684
        forindex (var k; path.texts) {
685
            var i = k + start;
686
            me.screenElements[sprintf("SoftKey%02i-text", i)]
687
                .setText(path.texts[k]);
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
688
            me.setSoftKeyColor(i,
not yet implemented softkeys...
Sébastien MARQUE authored on 2017-06-08
689
                    contains(me.device.softkeys.colored, pathid ~ path.texts[k]),
fix BACK softkey not correct...
Sébastien MARQUE authored on 2020-06-18
690
                    contains(bindings, path.texts[k]) or (me.device.role == 'MFD' and path.texts[k] == 'BACK'));
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
691
        }
692
        # feeding the last boxes with empty string
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
693
        var end = (me.device.role == 'PFD') ? 10 : 12;
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
694
        if (size(path.texts) + start < end) {
695
            start = size(path.texts) + start;
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
696
            for (var k = start; k < end; k += 1) {
697
                var sftk = sprintf("SoftKey%02i-", k);
698
                me.screenElements[sftk ~ 'text']
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
699
                    .setText('');
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
700
                me.screenElements[sftk ~ 'bg']
701
                    .setColorFill(0,0,0);
702
            }
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
703
        }
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
704

            
705
        if (size(me.device.softkeys.path))
old timers2 removed
Sébastien MARQUE authored on 2020-05-15
706
            me.timers.softkeys_inactivity.restart(me.softkeys_inactivity_delay);
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
707
        else
old timers2 removed
Sébastien MARQUE authored on 2020-05-15
708
            me.timers.softkeys_inactivity.stop();
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
709
    },
710
#}}}
711

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

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
733
    updateVSI: func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
734
# animate VSI {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
735
        var vsi = data.vsi;
animation VSI
Sébastien MARQUE authored on 2017-03-10
736
        me.screenElements.VSIText
737
            .setText(num(math.round(vsi, 10)));
settings now have effect
Sébastien MARQUE authored on 2020-06-12
738
        var scale = units.vspeed.from_fpm == 1 ? 1 : 10;
739
        if (vsi > 4500 / scale)
740
            vsi = 4500 / scale;
741
        elsif (vsi < -4500 / scale)
742
            vsi = -4500 / scale;
animation VSI
Sébastien MARQUE authored on 2017-03-10
743
        me.screenElements.VSI
settings now have effect
Sébastien MARQUE authored on 2020-06-12
744
            .setTranslation(0, vsi * -0.03465 * scale);
animation VSI
Sébastien MARQUE authored on 2017-03-10
745
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
746
#}}}
animation IAS
Sébastien MARQUE authored on 2017-03-10
747

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
748
    updateIAS: func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
749
# animates the IAS lint (PFD) {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
750
        var ias = data.ias;
animation IAS
Sébastien MARQUE authored on 2017-03-10
751
        if (ias >= 10)
752
            me.screenElements.Speed110
753
                .setText(sprintf("% 2u",num(math.floor(ias/10))));
754
        else
755
            me.screenElements.Speed110
756
                .setText('');
757
        me.screenElements.SpeedLint1
758
            .setTranslation(0,(math.mod(ias,10) + (ias >= 10)*10) * 36);
759
        me.screenElements.SpeedTape
760
            .setTranslation(0,ias * 5.711);
makes Vspeeds free and adapt...
Sébastien MARQUE authored on 2020-06-19
761
        if (ias > me._Vne and ! me._ias_already_exceeded) { # easier than .getColorFill
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
762
            me._ias_already_exceeded = 1;
763
            me.screenElements['IAS-bg']
764
                .setColorFill(1,0,0);
765
        }
makes Vspeeds free and adapt...
Sébastien MARQUE authored on 2020-06-19
766
        elsif (ias < me._Vne and me._ias_already_exceeded) { # easier than .getColorFill
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
767
            me._ias_already_exceeded = 0;
768
            me.screenElements['IAS-bg']
769
                .setColorFill(0,0,0);
770
        }
makes Vspeeds free and adapt...
Sébastien MARQUE authored on 2020-06-19
771
        foreach (var v; keys(data.Vspeeds)) {
772
            if (me.device.data[v ~ '-visible'] and abs(data.Vspeeds[v] - ias) < 30)
773
                me.screenElements[v]
774
                    .setTranslation(0, (ias - data.Vspeeds[v]) * 5.711)
add V-speeds bugs
Sébastien MARQUE authored on 2017-04-04
775
                    .show();
776
            else
makes Vspeeds free and adapt...
Sébastien MARQUE authored on 2020-06-19
777
                me.screenElements[v]
add V-speeds bugs
Sébastien MARQUE authored on 2017-04-04
778
                    .hide();
779
        }
780

            
improve trends vor ALT and I...
Sébastien MARQUE authored on 2020-04-30
781
        var Sy = 0;
782
        for (var i = 8; i >= 0; i -= 1)
783
            me._last_ias_Sy[i+1] = me._last_ias_Sy[i];
trends animation
Sébastien MARQUE authored on 2017-03-13
784
        var now = systime();
785
        # estimated speed in 6s
makes Vspeeds free and adapt...
Sébastien MARQUE authored on 2020-06-19
786
        me._last_ias_Sy[0] = 6 * (ias - me._last_ias) / (now - me._last_ias_s);
improve trends vor ALT and I...
Sébastien MARQUE authored on 2020-04-30
787
        foreach (var _Sy; me._last_ias_Sy)
788
            Sy += _Sy;
789
        Sy /= 10;
trends animation
Sébastien MARQUE authored on 2017-03-13
790
        if (abs(Sy) > 30)
791
            Sy = 30 * abs(Sy)/Sy; # = -30 or 30
792
        me.screenElements['Airspeed-Trend-Indicator']
793
            .setScale(1,Sy)
794
            .setTranslation(0, -284.5 * (Sy - 1));
makes Vspeeds free and adapt...
Sébastien MARQUE authored on 2020-06-19
795
        me._last_ias = ias;
trends animation
Sébastien MARQUE authored on 2017-03-13
796
        me._last_ias_s = now;
animation IAS
Sébastien MARQUE authored on 2017-03-10
797
    },
makes Vspeeds free and adapt...
Sébastien MARQUE authored on 2020-06-19
798
    _Vne : contains(data.Vspeeds, 'Vne') ? data.Vspeeds.Vne : 999,
799
    _last_ias : 0,
trends animation
Sébastien MARQUE authored on 2017-03-13
800
    _last_ias_s : systime(),
improve trends vor ALT and I...
Sébastien MARQUE authored on 2020-04-30
801
    _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
802
    _ias_already_exceeded : 0,
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
803
#}}}
animation ALT
Sébastien MARQUE authored on 2017-03-11
804

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
805
    updateTAS: func {
806
# updates the True Airspeed and GroundSpeed indicators {{{
settings now have effect
Sébastien MARQUE authored on 2020-06-12
807
        var unit = units.speed.from_kt == 1 ? 'KT' : 'km/h';
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
808
        me.screenElements['TAS-text']
settings now have effect
Sébastien MARQUE authored on 2020-06-12
809
            .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
810
        me.screenElements['GSPD-text']
settings now have effect
Sébastien MARQUE authored on 2020-06-12
811
            .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
812
    },
813
#}}}
814

            
815
    updateALT: func () {
816
# animates the altitude lint (PFD) {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
817
        var alt = data.alt;
animation ALT
Sébastien MARQUE authored on 2017-03-11
818
        if (alt < 0)
819
            me.screenElements.Alt11100
fix altitude indicator
Sébastien MARQUE authored on 2020-05-03
820
                .setText(sprintf("%3d",math.ceil(alt/100)));
animation ALT
Sébastien MARQUE authored on 2017-03-11
821
        elsif (alt < 100)
822
            me.screenElements.Alt11100
823
                .setText('');
824
        else
825
            me.screenElements.Alt11100
fix altitude indicator
Sébastien MARQUE authored on 2020-05-03
826
                .setText(sprintf("%3i",math.floor(alt/100)));
animation ALT
Sébastien MARQUE authored on 2017-03-11
827
        me.screenElements.AltLint00011
828
            .setTranslation(0,math.fmod(alt,100) * 1.24);
829

            
830
        # From Farmin/G1000 http://wiki.flightgear.org/Project_Farmin/FG1000
831
        if (alt> -1000 and alt< 1000000) {
832
            var Offset10 = 0;
833
            var Offset100 = 0;
834
            var Offset1000 = 0;
835
            if (alt< 0) {
836
                var Ne = 1;
837
                var alt= -alt;
838
            }
839
            else
840
                var Ne = 0;
841

            
842
            var Alt10       = math.mod(alt,100);
843
            var Alt100      = int(math.mod(alt/100,10));
844
            var Alt1000     = int(math.mod(alt/1000,10));
845
            var Alt10000    = int(math.mod(alt/10000,10));
846
            var Alt20       = math.mod(Alt10,20)/20;
847
            if (Alt10 >= 80)
848
                var Alt100 += Alt20;
849

            
850
            if (Alt10 >= 80 and Alt100 >= 9)
851
                var Alt1000 += Alt20;
852

            
853
            if (Alt10 >= 80 and Alt100 >= 9 and Alt1000 >= 9)
854
                var Alt10000 += Alt20;
855

            
856
            if (alt> 100)
857
                var Offset10 = 100;
858

            
859
            if (alt> 1000)
860
                var Offset100 = 10;
861

            
862
            if (alt> 10000)
863
                var Offset1000 = 10;
864

            
865
            if (!Ne) {
866
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*0.57375);
867
                var altCentral = (int(alt/100)*100);
868
            }
869
            elsif (Ne) {
870
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*-0.57375);
871
                var altCentral = -(int(alt/100)*100);
872
            }
873
            me.screenElements["AltBigC"].setText("");
874
            me.screenElements["AltSmallC"].setText("");
875
            for (var place = 1; place <= 6; place += 1) {
876
                var altUP = altCentral + (place*100);
877
                var offset = -30.078;
878
                if (altUP < 0) {
879
                    var altUP = -altUP;
880
                    var prefix = "-";
881
                    var offset += 15.039;
882
                }
883
                else
884
                    var prefix = "";
885

            
886
                if (altUP == 0) {
887
                    var AltBigUP    = "";
888
                    var AltSmallUP  = "0";
889

            
890
                }
891
                elsif (math.mod(altUP,500) == 0 and altUP != 0) {
892
                    var AltBigUP    = sprintf(prefix~"%1d", altUP);
893
                    var AltSmallUP  = "";
894
                }
895
                elsif (altUP < 1000 and (math.mod(altUP,500))) {
896
                    var AltBigUP    = "";
897
                    var AltSmallUP  = sprintf(prefix~"%1d", int(math.mod(altUP,1000)));
898
                    var offset = -30.078;
899
                }
900
                elsif ((altUP < 10000) and (altUP >= 1000) and (math.mod(altUP,500))) {
901
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
902
                    var AltSmallUP  = sprintf("%1d", int(math.mod(altUP,1000)));
903
                    var offset += 15.039;
904
                }
905
                else {
906
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
907
                    var mod = int(math.mod(altUP,1000));
908
                    var AltSmallUP  = sprintf("%1d", mod);
909
                    var offset += 30.078;
910
                }
911

            
912
                me.screenElements["AltBigU"~place].setText(AltBigUP);
913
                me.screenElements["AltSmallU"~place].setText(AltSmallUP);
914
                me.screenElements["AltSmallU"~place].setTranslation(offset,0);
915
                var altDOWN = altCentral - (place*100);
916
                var offset = -30.078;
917
                if (altDOWN < 0) {
918
                    var altDOWN = -altDOWN;
919
                    var prefix = "-";
920
                    var offset += 15.039;
921
                }
922
                else
923
                    var prefix = "";
924

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

            
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
977
    updateBARO : func () {
978
# update BARO widget {{{
settings now have effect
Sébastien MARQUE authored on 2020-06-12
979
        var fmt = data.settings.units.pressure == 'inhg' ? '%.2f%s' : '%i%s';
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
980
        me.screenElements['BARO-text']
981
            .setText(sprintf(fmt,
settings now have effect
Sébastien MARQUE authored on 2020-06-12
982
                        getprop('/instrumentation/altimeter/setting-' ~ data.settings.units.pressure),
983
                        data.settings.units.pressure == 'inhg' ? 'in' : 'hPa')
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
984
                );
985
    },
986
#}}}
987

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
988
    updateHSI : func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
989
# rotates the compass (PFD) {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
990
        var hdg = data.hdg;
animation HSI
Sébastien MARQUE authored on 2017-03-11
991
        me.screenElements.Rose
992
            .setRotation(-hdg * D2R);
993
        me.screenElements['HDG-text']
994
            .setText(sprintf("%03u°", hdg));
995
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
996
#}}}
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
997

            
removes unecessary listeners
Sébastien MARQUE authored on 2017-04-08
998
    updateHDG : func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
999
# moves the heading bug and display heading-deg for 3 seconds (PFD) {{{
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
1000
        if (me.device.role == 'MFD')
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
1001
            return;
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
1002
        var hdg = afcs.getValue('heading-bug-deg');
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
1003
        me.screenElements['Heading-bug']
1004
            .setRotation(hdg * D2R);
1005
        me.screenElements['SelectedHDG-bg']
1006
            .show();
1007
        me.screenElements['SelectedHDG-bgtext']
1008
            .show();
1009
        me.screenElements['SelectedHDG-text']
1010
            .setText(sprintf('%03d°%s', hdg, ''))
1011
            .show();
1012
        me.addTimer(3, ['SelectedHDG-text', 'SelectedHDG-bgtext', 'SelectedHDG-bg']);
1013
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
1014
#}}}
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
1015

            
adds CDI
Sébastien MARQUE authored on 2017-03-18
1016
    updateCRS : func () {
anime CRS
Sébastien MARQUE authored on 2017-03-13
1017
# TODO: update display for NAV/GPS/BRG courses {{{
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
1018
        if (me.device.role == 'MFD')
anime CRS
Sébastien MARQUE authored on 2017-03-13
1019
            return;
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
1020
        var source = cdi.getValue('source');
adds CDI
Sébastien MARQUE authored on 2017-03-18
1021
        if (source == 'OFF')
1022
            return;
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
1023
        var crs = cdi.getValue('course');
adds CDI
Sébastien MARQUE authored on 2017-03-18
1024
        if (crs == nil)
1025
            return;
anime CRS
Sébastien MARQUE authored on 2017-03-13
1026
        me.screenElements['SelectedCRS-bg']
1027
            .show();
1028
        me.screenElements['SelectedCRS-bgtext']
1029
            .show();
1030
        me.screenElements['SelectedCRS-text']
1031
            .setText(sprintf('%03d°%s', crs, ''))
adds CDI
Sébastien MARQUE authored on 2017-03-18
1032
            .setColor(source == 'GPS' ? me.colors.magenta : me.colors.green)
anime CRS
Sébastien MARQUE authored on 2017-03-13
1033
            .show();
1034
        me.addTimer(3, ['SelectedCRS-text', 'SelectedCRS-bgtext', 'SelectedCRS-bg']);
1035
    },
1036
#}}}
1037

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1038
    updateSelectedALT : func {
1039
# animation for altitude section, called via updatedALT {{{
creates flightdeck hash to p...
Sébastien MARQUE authored on 2017-04-07
1040
        if (! me.screenElements['SelectedALT'].getVisible())
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
1041
            return;
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
1042
        var selected_alt = afcs.getValue('selected-alt-ft');
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
1043
        var delta_alt = data.alt - selected_alt;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1044
        if (abs(delta_alt) > 300)
1045
            delta_alt = 300 * abs(delta_alt)/delta_alt;
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
1046
        me.screenElements['SelectedALT-symbol']
1047
            .setVisible(abs(delta_alt) > 100);
1048
        me.screenElements['SelectedALT-bg']
1049
            .setVisible(abs(delta_alt) > 100);
1050
        me.screenElements['SelectedALT-text']
1051
            .setText(sprintf("%i", selected_alt))
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1052
            .setVisible(abs(delta_alt) > 100);
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
1053
        me.screenElements['SelectedALT-bug']
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1054
            .setTranslation(0, delta_alt * 0.567); # 170/300 = 0.567
1055
    },
1056
#}}}
1057

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

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

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

            
1249
    updateCOMM: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
1250
# update COMM radios display upper right (PFD/MFD){{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1251
        arg[0]._r = 'comm';
1252
        me._updateRadio(arg[0]);
1253
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
1254
#}}}
anime time display
Sébastien MARQUE authored on 2017-03-13
1255

            
1256
    updateTIME : func {
1257
# updates the displayed time botoom left {{{
change way of time display
Sébastien MARQUE authored on 2020-06-12
1258
        time[data.settings.time.label]();
adds time display setting
Sébastien MARQUE authored on 2020-06-11
1259
        me.screenElements['TIME-REF-text']
1260
            .setText(data.settings.time.label);
anime time display
Sébastien MARQUE authored on 2017-03-13
1261
        me.screenElements['TIME-text']
change way of time display
Sébastien MARQUE authored on 2020-06-12
1262
            .setText(data.time);
anime time display
Sébastien MARQUE authored on 2017-03-13
1263
    },
1264
#}}}
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1265

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

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1303
    updateOAT : func {
1304
# update OAT display on normal and reversionnary modes (every 3s) {{{
adds temperature units setti...
Sébastien MARQUE authored on 2020-06-15
1305
        var tmp = units.temperature.from_C(getprop('/environment/temperature-degc'));
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1306
        me.screenElements['OAT-text']
adds temperature units setti...
Sébastien MARQUE authored on 2020-06-15
1307
            .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
1308
    },
1309
#}}}
1310

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

            
adds AOA display
Sébastien MARQUE authored on 2017-04-15
1374
    updateAOA : func {
1375
# update Angle Of Attack {{{
fix AOA not shown
Sébastien MARQUE authored on 2020-05-30
1376
        if (me.device.data.aoa + me.device.data['aoa-auto'] == 0)
adds AOA display
Sébastien MARQUE authored on 2017-04-15
1377
            return;
1378
        var color = [1,1,1];
1379
        var norm = data.aoa / data['stall-aoa'];
nicer AOA display
Sébastien MARQUE authored on 2017-04-16
1380
        me.screenElements['AOA-text']
1381
            .setText(sprintf('% .1f', norm));
adds AOA display
Sébastien MARQUE authored on 2017-04-15
1382
        if (norm > 1) norm = 1;
1383
        if (norm > 0.9)
1384
            color = [1,0,0];
1385
        elsif (norm > 0.7)
1386
            color = [1,1,0];
1387
        elsif (norm < 0) {
1388
            norm = 0;
1389
            color = [1,0,0];
1390
        }
1391
        me.screenElements['AOA-needle']
1392
            .setRotation(-norm * math.pi)
nicer AOA display
Sébastien MARQUE authored on 2017-04-16
1393
            .setColorFill(color);
1394
        me.screenElements['AOA-text']
adds AOA display
Sébastien MARQUE authored on 2017-04-15
1395
            .setColor(color);
settimers to maketimer conti...
Sébastien MARQUE authored on 2020-05-13
1396
        me.timers.updateAOA.start();
adds AOA display
Sébastien MARQUE authored on 2017-04-15
1397
    },
1398
# }}}
1399

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

            
1405
            var dev = radios.getNode(source).getValue();
1406
            var el  = 'BRG' ~ brg;
1407
            if (dev != 'OFF') {
1408
                var info = {
1409
                    pointer : nil,
1410
                    id : 'NO DATA',
1411
                    hdg : nil,
1412
                    dst : '--.-NM'
1413
                };
1414
                if (left(dev, 3) == 'NAV') {
1415
                    info.pointer = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/in-range');
1416
                    if (info.pointer) {
1417
                        info.id  = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/nav-id');
1418
                        info.hdg = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/heading-deg');
1419
                        info.dst = sprintf('%.1d', getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/nav-distance') / 1852); # m -> /1852
1420
                    }
1421
                }
1422
                elsif (dev == 'GPS') {
1423
                    info.pointer = props.getNode('/instrumentation/gps/wp').getChild('wp[1])');
1424
                    if (info.pointer) {
1425
                        info.id  = getprop('/instrumentation/gps/wp/wp[1]/ID');
1426
                        info.hdg = getprop('/instrumentation/gps/wp/wp[1]/bearing-mag-deg');
1427
                        info.dst = sprintf('%.1d', getprop('/instrumentation/gps/wp/wp[1]/distance-nm'));
1428
                    }
1429
                }
1430
                else { # there are 2 available ADF in FG, but instrument manage only 1
1431
                    info.pointer = getprop('/instrumentation/adf/in-range');
1432
                    if (info.pointer) {
1433
                        info.id  = getprop('/instrumentation/adf/ident');
1434
                        info.hdg = getprop('/instrumentation/adf/indicated-bearing-deg');
1435
                    }
1436
                }
1437

            
1438
                if (info.pointer)
1439
                    me.screenElements[el ~ '-pointer']
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
1440
                        .setRotation(-info.hdg - data.hdg * D2R)
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1441
                        .show();
1442
                else
1443
                    me.screenElements[el ~ '-pointer']
1444
                        .hide();
1445
                me.screenElements[el ~ '-SRC-text']
1446
                    .setText(dev);
1447
                me.screenElements[el ~ '-DST-text']
1448
                    .setText(info.dst);
1449
                me.screenElements[el ~ '-WPID-text']
1450
                    .setText(info.id);
1451
                me.screenElements['BRG' ~ brg]
1452
                    .show();
1453
            }
1454
            else {
1455
                me.screenElements['BRG' ~ brg]
1456
                    .hide();
1457
            }
1458
        }
1459
    },
some added comments
Sébastien MARQUE authored on 2017-03-18
1460
#}}}
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
1461

            
adds OMI to PFD
Sébastien MARQUE authored on 2017-03-23
1462
    updateOMI : func {
1463
# display marker baecon Outer, Middle, Inner {{{
1464
        var marker = nil;
1465
        foreach (var m; ['outer', 'middle', 'inner'])
1466
            if (getprop('/instrumentation/marker-beacon/' ~ m)) {
1467
                marker = m;
1468
                me.screenElements['OMI']
1469
                    .show();
1470
                break;
1471
            }
1472
        if (marker != nil) {
1473
            me.screenElements['MarkerText']
1474
                .setText(me._omi_data[marker].t)
1475
                .show();
1476
            me.screenElements['MarkerBG']
1477
                .setColorFill(me._omi_data[marker].bg)
1478
                .show();
1479
        }
1480
        else
1481
            me.screenElements['OMI']
1482
                .hide();
1483
    },
1484
    _omi_data : {
1485
        'outer':  {t: 'O', bg: [0,1,1]},
1486
        'middle': {t: 'M', bg: [1,1,1]},
1487
        'inner':  {t: 'I', bg: [1,1,0]},
1488
    },
1489
#}}}
adds ILS glideslope
Sébastien MARQUE authored on 2020-06-09
1490

            
1491
    updateGS : func {
1492
# display glide-slope on ILS approach {{{
1493
        var deflection = getprop('/instrumentation/nav/gs-needle-deflection-norm');
1494
        me.screenElements['GS-ILS']
1495
            .setTranslation(0, deflection * 100);
1496
    },
1497
#}}}
animation texts EIS + power ...
Sébastien MARQUE authored on 2017-03-19
1498
};