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

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

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

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

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

            
cosmetics
Sébastien MARQUE authored on 2020-05-12
53
        if (m.device.role == 'PFD') {
54
            append(groups.show,
adds some vim z-folds
Sébastien MARQUE authored on 2017-04-19
55
# {{{
cosmetics
Sébastien MARQUE authored on 2020-05-12
56
                'XPDR-TIME',
57
                'FlightInstruments',
58
                'Horizon',
59
                'bankPointer',
60
                'VSI',
61
                'Rose',
62
                'Heading-bug',
63
                'PFD-Widgets',
64
                'Trends',
65
                'Airspeed-Trend-Indicator',
66
                'Altitude-Trend-Indicator',
67
                'OAT',
68
                'IAS-bg',
69
                'TAS',
70
                'GSPD',
71
                'BARO-bg',
72
                'SlipSkid',
73
                'IAS-Vx', 'IAS-Vy', 'IAS-Vr', 'IAS-Vglide',
adds 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
                'VDI',
82
                'NAV1-pointer', 'NAV1-CDI', 'NAV1-FROM', 'NAV1-TO',
83
                'NAV2-pointer', 'NAV2-CDI', 'NAV2-FROM', 'NAV2-TO',
84
                'GPS-pointer', 'GPS-CDI', 'GPS-CTI', 'GPS-CTI-diamond', 'GPS-FROM', 'GPS-TO',
85
                'BRG1-pointer',
86
                'BRG2-pointer',
87
                'SelectedHDG-bg',
88
                'SelectedHDG-bgtext',
89
                'SelectedHDG-text',
90
                'SelectedCRS-bg',
91
                'SelectedCRS-bgtext',
92
                'SelectedCRS-text',
93
                'SelectedALT', 'SelectedALT-bug', 'SelectedALT-bg', 'SelectedALT-symbol',
94
                'TAS',
95
                'GSPD',
96
                'WindData',
97
                'Reversionnary',
98
                'Annunciation',
99
                'Comparator',
100
                'BRG1',
101
                'BRG2',
102
                'DME1',
103
                'PFD-Map-bg',
104
                'PFD-Multilines',
105
                'MapOrientation',
106
                'WindData', 'WindData-OPTN1', 'WindData-OPTN2', 'WindData-OPTN1-HDG', 'WindData-OPTN2-symbol', 'WindData-OPTN2-headwind', 'WindData-OPTN2-crosswind', 'WindData-NODATA',
107
                'AOA', 'AOA-needle', 'AOA-text', 'AOA-approach',
108
                'MFD-navbox',
109
                'Traffic',
adds 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',
126
                'TIME-text',
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 {
231
                if (data.fpSize == 0) return '---NM';
232
                var dist = getprop('/autopilot/route-manager/distance-remaining-nm');
233
                if (dist != nil)
234
                    return sprintf(dist < 100 ? '%2.1fNM' : '%3iNM', dist);
235
                else
236
                    return '---NM';
237
            }, 'Total Distance Remaining'],
238
            DIS: [func {
239
                if (data.fpSize == 0) return '---NM';
240
                var dist = getprop('/autopilot/route-manager/wp/dist');
241
                if (dist != nil)
242
                    return sprintf(dist < 100 ? '%2.1fNM' : '%3iNM', dist);
243
                else
244
                    return '---NM';
245
            }, 'Distance remaining'],
246
            LEG: [func {
247
                if (data.fpSize == 0) return '';
248
                var route = m.device.map.layers.route;
249
                var wp = route.flightPlan[route.currentLeg.index];
250
                return sprintf(' %s %s %s', wp[0].name, utf8.chstr(9658), wp[1].name);
251
            }, ''], # not listed in MFD menu, on PFD only the leg is shown not the item
252
            LDG: [func {
253
                var eteSeconds = getprop('/autopilot/route-manager/ete');
254
                var eteHours = math.floor(eteSeconds / 3600);
255
                var eteMinutes = int((eteSeconds - (eteHours * 3600)) / 60);
256
                return sprintf(eteHours > 99 ? '--:--' : '%02i:%02i', eteHours, eteMinutes);
257
            }, 'ETA at Final Destination'],
258
            END: [func {
259
                var total_fuel = getprop('/consumables/fuel/total-fuel-gals');
260
                var gs = getprop('/velocities/groundspeed-kt');
261
                var consumption = 0;
262
                foreach(var engine; props.globals.getNode('/engines').getChildren('engine')) {
263
                    var ec = engine.getValue('fuel-flow-gph');
264
                    consumption += ec != nil ? ec : 0;
265
                }
266
                if (consumption > 0 and gs > 0)
267
                    return sprintf('%3iNM', (total_fuel * gs) / consumption);
268
                else
269
                    return '---NM';
270
            }, 'Endurance'],
271
            ETA: [func {
272
                var eteSeconds = getprop('/autopilot/route-manager/ete');
273
                var eta_hours = getprop('/sim/time/utc/hour');
274
                var eteHours = math.floor(eteSeconds / 3600);
275
                if (eteHours > 12)
276
                    return '--:--';
277
                var eta_minutes = int((eteSeconds - (eteHours * 3600)) / 60) + getprop('/sim/time/utc/minute');
278
                if (eta_minutes > 59) {
279
                    eta_minutes -= 60;
280
                    eta_hours += 1;
281
                }
282
                eta_hours += eteHours;
283
                if (eta_hours > 23)
284
                    eta_hours -= 24;
285
                return sprintf('%02i:%02i', eta_hours, eta_minutes);
286
            }, 'Estimated Time of Arrival'],
287
            GS:  [func return sprintf('%3iKT', getprop('/velocities/groundspeed-kt')), 'Ground Speed'],
288
            TRK: [func return sprintf('%03i°', getprop('/orientation/track-deg')), 'Track'],
289
            TAS: [func return sprintf('%i', getprop('/instrumentation/airspeed-indicator/true-speed-kt')), 'True Air Speed'],
290
            FOB: [func { return sprintf('%3ilbs', getprop('/consumables/fuel/total-fuel-lbs')); }, 'Fuel on Board'],
291
#            BRG: [func return '---°', 'Bearing'],
292
#            ESA: [func return '-----', 'Enroute Safe Altitude'],
293
#            ISA: [func return '-----', 'ISA Relative Temperature'],
294
#            MSA: [func return '----ft', 'Minimum Safe Altitude'],
295
#            TKE: [func return ' ---°', 'Track Angle Error'],
296
#            VSR: [func return ' ----', 'Vertical Speed Required'],
297
#            XTK: [func return ' ---NM', 'Crosstrack Error'],
298
# }}}
299
        };
300
        if (m.device.role == 'PFD')
301
            foreach (var item; keys(m.navbox))
302
                if (item != 'LEG' and item != 'DIS' and item != 'ETE')
303
                    delete(m.navbox, item);
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
304
        return m;
305
    },
306
#}}}
makes map available for PFD ...
Sébastien MARQUE authored on 2017-04-19
307

            
replace settimer by maketime...
Sébastien MARQUE authored on 2020-05-06
308
    off: func {
309
        foreach(var timer; keys(me.timers2)) {
310
            me.timers2[timer].stop();
311
            delete(me.timers2, timer);
312
        }
313
        me.screen.del();
314
        me.display.del();
315
    },
316

            
317
# temporary Widget Display for HDG and CRS modification {{{
318

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

            
321
    timerTrigger : func {
322
        var now = systime();
replace settimer by maketime...
Sébastien MARQUE authored on 2020-05-06
323
        foreach (var id; keys(me.temporaryWidgetDisplay)) {
324
            if (me.temporaryWidgetDisplay[id] < now) {
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
325
                me.screenElements[id].hide();
replace settimer by maketime...
Sébastien MARQUE authored on 2020-05-06
326
                delete(me.temporaryWidgetDisplay, id);
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
327
            }
commit initial
Sébastien MARQUE authored on 2017-03-07
328
        }
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
329
    },
330

            
331
    addTimer : func (duration, element) {
332
        if (typeof(element) == 'scalar')
333
            element = [ element ];
334
        var end = systime() + duration;
335
        foreach (var e; element)
replace settimer by maketime...
Sébastien MARQUE authored on 2020-05-06
336
            me.temporaryWidgetDisplay[e] = end;
commit initial
Sébastien MARQUE authored on 2017-03-07
337
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
338
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
339

            
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
340
    showInitProgress : func {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
341
#{{{
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
342
        if (me.device.role == 'PFD') {
replace settimer by maketime...
Sébastien MARQUE authored on 2020-05-06
343
            me.timers.updateAI     = maketimer(0.1, me, me.updateAI     );
344
            me.timers.updateVSI    = maketimer(0.1, me, me.updateVSI    );
345
            me.timers.updateIAS    = maketimer(0.1, me, me.updateIAS    );
346
            me.timers.updateALT    = maketimer(0.2, me, me.updateALT    );
347
            me.timers.updateHSI    = maketimer(0.2, me, me.updateHSI    );
348
            me.timers.updateTIME   = maketimer(1.0, me, me.updateTIME   );
349
            me.timers.updateOAT    = maketimer(3.0, me, me.updateOAT    );
350
            me.timers.updateTAS    = maketimer(0.5, me, me.updateTAS    );
351
            me.timers.updateBRG    = maketimer(0.5, me, me.updateBRG    );
352
            me.timers.updateXPDR   = maketimer(0,   me, me.updateXPDR   ); me.timers.updateXPDR.singleShot=1;
353
            me.timers.updateBARO   = maketimer(0,   me, me.updateBARO   ); me.timers.updateBARO.singleShot=1;
354
            me.timers.updateOMI    = maketimer(1.0, me, me.updateOMI    );
355
            me.timers.timerTrigger = maketimer(1.0, me, me.timerTrigger );
settimers to maketimer conti...
Sébastien MARQUE authored on 2020-05-13
356
            me.timers.updateAOA    = maketimer(0.1, me, me.updateAOA    );    me.timers.updateAOA.singleShot=1;
357
            me.timers.updateCDI    = maketimer(0.3, me, me.updateCDI    );    me.timers.updateCDI.singleShot=1;
358
            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
359

            
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
360
            me.screen.show();
add brightness and lights co...
Sébastien MARQUE authored on 2020-04-27
361
            me.device.buttons.MENU = me.device.buttons.GlobalParams;
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
362
        }
363
        else {
364
            me.updateEIS();
365
            io.load_nasal(data.zkv1000_dir ~ 'Nasal/MFD.pages.nas', 'zkv1000');
366
            me['page selected'] = 0;
367
            me.setMFDPages();
368
            me.device.buttons.MENU = me.device.buttons.MapMenu;
369
        }
commit initial
Sébastien MARQUE authored on 2017-03-07
370

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

            
377
        foreach (var timer; keys(me.timers))
378
            me.timers[timer].start();
commit initial
Sébastien MARQUE authored on 2017-03-07
379
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
380
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
381

            
some added comments
Sébastien MARQUE authored on 2017-03-18
382
    colors : {
383
# set of predefined colors {{{
384
        green : [0, 1, 0],
385
        white : [1, 1, 1],
386
        black : [0, 0, 0],
387
        lightblue : [0, 1, 1],
388
        darkblue : [0, 0, 1],
389
        red : [1, 0, 0],
adds CDI
Sébastien MARQUE authored on 2017-03-18
390
        magenta : [1, 0, 1],
add yellow predefined color
Sébastien MARQUE authored on 2020-05-11
391
        yellow : [1, 1, 0],
some added comments
Sébastien MARQUE authored on 2017-03-18
392
    },
393
#}}}
394

            
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
395
    loadGroup : func (h) {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
396
#{{{
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
397
        if (typeof(h) != 'hash') {
398
            msg_dbg(sprintf("%s need a hash, but get a %s from %s",
399
                    caller(0)[0],
400
                    typeof(h),
401
                    caller(1)[0]));
402
            return;
commit initial
Sébastien MARQUE authored on 2017-03-07
403
        }
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
404
        var setMethod = func (e, t) {
405
            if (t == 'hide')
406
                me.screenElements[e].hide();
407
            elsif (t == 'show')
408
                me.screenElements[e].show();
AI disponible
Sébastien MARQUE authored on 2017-03-10
409
            elsif (t == 'rot' or t == 'trans') {
410
                if (! contains(me.screenElements[e], t))
411
                    me.screenElements[e][t] = me.screenElements[e].createTransform();
412
            }
413
            elsif (t == 'clip') {
414
                if (contains(me.clips, e))
415
                    me.screenElements[e].set("clip", me.clips[e]);
416
                else
printlog deprecated + consta...
Sébastien MARQUE authored on 2020-04-24
417
                    logprint(LOG_WARN, 'no defined clip for ' ~ e);
AI disponible
Sébastien MARQUE authored on 2017-03-10
418
            }
animation VSI
Sébastien MARQUE authored on 2017-03-10
419
            elsif (t == 'text') {
420
                if (contains(me.texts, e)) {
421
                    if (contains(me.texts[e], 'alignment'))
422
                        me.screenElements[e].setAlignment(me.texts[e].alignment);
423
                    if (contains(me.texts[e], 'default'))
424
                        me.screenElements[e].setText(me.texts[e].default);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
425
                    if (contains(me.texts[e], 'color'))
426
                        me.screenElements[e].setColor(me.texts[e].color);
adds CDI
Sébastien MARQUE authored on 2017-03-18
427
                    if (contains(me.texts[e], 'visible'))
428
                        me.screenElements[e].setVisible(me.texts[e].visible);
animation VSI
Sébastien MARQUE authored on 2017-03-10
429
                }
printlog with adapted level ...
Sébastien MARQUE authored on 2017-03-20
430
                else
printlog deprecated + consta...
Sébastien MARQUE authored on 2020-04-24
431
                    logprint(LOG_DEBUG, 'no text format for ' ~ e);
animation VSI
Sébastien MARQUE authored on 2017-03-10
432
            }
commit initial
Sébastien MARQUE authored on 2017-03-07
433
            else
printlog deprecated + consta...
Sébastien MARQUE authored on 2020-04-24
434
                logprint(LOG_WARN, 'unknown method ' ~ t);
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
435
        };
436
        foreach (var todo; keys(h)) {
437
            if (typeof(h[todo]) != 'vector') h[todo] = [ h[todo] ];
438
            foreach (var id; h[todo]) {
439
                if (! contains(me.screenElements, id)) {
440
                    me.screenElements[id] = me.screen.getElementById(id);
441
                    if (me.screenElements[id] != nil)
442
                        setMethod(id, todo);
443
                    else
printlog deprecated + consta...
Sébastien MARQUE authored on 2020-04-24
444
                        logprint(LOG_WARN, 'SVG ID ' ~ id ~ ' not found');
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
445
                }
446
                else
447
                    setMethod(id, todo);
448
            }
commit initial
Sébastien MARQUE authored on 2017-03-07
449
        }
450
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
451
#}}}
AI disponible
Sébastien MARQUE authored on 2017-03-10
452

            
453
    clips : {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
454
#{{{
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
455
        PitchScale   : "rect(70,664,370,256)",
456
        SpeedLint1   : "rect(252,226,318,204)",
457
        SpeedTape    : "rect(115,239,455,156)",
458
        LintAlt      : "rect(115,808,455,704)",
animation ALT
Sébastien MARQUE authored on 2017-03-11
459
        AltLint00011 : "rect(252,804,318,771)",
AI disponible
Sébastien MARQUE authored on 2017-03-10
460
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
461
#}}}
AI disponible
Sébastien MARQUE authored on 2017-03-10
462

            
animation VSI
Sébastien MARQUE authored on 2017-03-10
463
    texts : {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
464
#{{{
animation VSI
Sébastien MARQUE authored on 2017-03-10
465
        VSIText : {
466
            alignment: "right-bottom", default : num('0'),
467
        },
animation IAS
Sébastien MARQUE authored on 2017-03-10
468
        Speed110 : {
correct speed and altitude t...
Sébastien MARQUE authored on 2020-05-08
469
            alignment : 'right-bottom'
animation IAS
Sébastien MARQUE authored on 2017-03-10
470
        },
animation ALT (2)
Sébastien MARQUE authored on 2017-03-11
471
        Alt11100 : {
correct speed and altitude t...
Sébastien MARQUE authored on 2020-05-08
472
            alignment:'right-bottom'
animation ALT (2)
Sébastien MARQUE authored on 2017-03-11
473
        },
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
474
        "HDG-text" : {
475
            default: '---°'
476
        },
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
477
        'nav1-standby-freq' : {
478
            color: [0, 1, 1],
479
        },
480
        'nav1-id' : {
481
            default: ''
482
        },
483
        'nav2-id' : {
484
            default: ''
485
        },
adds CDI
Sébastien MARQUE authored on 2017-03-18
486
        'CDI-GPS-ANN-text' : {
487
            visible : 0
488
        },
489
        'CDI-GPS-XTK-text' : {
490
            visible : 0
491
        },
492
        'CDI-SRC-text' : {
493
            visible : 0
494
        },
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
495
        'BARO-text' : {
496
            alignment : 'left-bottom',
improve route info display
Sébastien MARQUE authored on 2020-05-03
497
        },
498
        'LEG-text' : {
499
            alignment : 'center-center',
500
        },
some added comments
Sébastien MARQUE authored on 2017-03-18
501
#        'TAS-text' : {
502
#            alignment : 'right-bottom',
503
#        },
504
#        'GSPD-text' : {
505
#            alignment : 'right-bottom',
506
#        },
animation VSI
Sébastien MARQUE authored on 2017-03-10
507
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
508
#}}}
animation VSI
Sébastien MARQUE authored on 2017-03-10
509

            
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
510
    softkeys_inactivity : func {
511
# automagically back to previous level after some delay {{{
old timers2 removed
Sébastien MARQUE authored on 2020-05-15
512
        me.timers.softkeys_inactivity = maketimer (
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
513
            me.softkeys_inactivity_delay,
514
            func {
515
                pop(me.device.softkeys.path);
516
                me.updateSoftKeys();
517
            }, me);
old timers2 removed
Sébastien MARQUE authored on 2020-05-15
518
        me.timers.softkeys_inactivity.singleShot = 1;
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
519
    },
520
#}}}
521

            
softkey is implemented by de...
Sébastien MARQUE authored on 2017-12-21
522
    setSoftKeyColor : func (n, active, implemented = 1, alert = 0) {
add softkeys colors
Sébastien MARQUE authored on 2017-03-21
523
# set colors for active softkeys {{{
524
        var sftk = sprintf('SoftKey%02i-', n);
525
        if (active) {
526
            var bg = alert ? 1 : 0.5;
527
            me.screenElements[sftk ~ 'bg']
528
                .setColorFill(bg,bg,bg);
529
            me.screenElements[sftk ~ 'text']
530
                .setColor(0,0,0);
531
        }
532
        else {
not yet implemented softkeys...
Sébastien MARQUE authored on 2017-06-08
533
            var tc = implemented ? 1 : 0.5;
add softkeys colors
Sébastien MARQUE authored on 2017-03-21
534
            me.screenElements[sftk ~ 'bg']
535
                .setColorFill(0,0,0);
536
            me.screenElements[sftk ~ 'text']
not yet implemented softkeys...
Sébastien MARQUE authored on 2017-06-08
537
                .setColor(tc,tc,tc);
add softkeys colors
Sébastien MARQUE authored on 2017-03-21
538
        }
539
    },
540
#}}}
541

            
navigation box content
Sébastien MARQUE authored on 2020-05-12
542
    updateNavigationBox : func {
add navigation infos on head...
Sébastien MARQUE authored on 2017-05-24
543
# update Navigation Box on MFD and PFD header {{{
replace settimer by maketime...
Sébastien MARQUE authored on 2020-05-06
544
        var enroute = getprop('/autopilot/route-manager/current-wp') > -1;
add navigation infos on head...
Sébastien MARQUE authored on 2017-05-24
545
        var route = me.device.map.layers.route;
navigation box content
Sébastien MARQUE authored on 2020-05-12
546
        data.fpSize = size(route.flightPlan);
add navigation infos on head...
Sébastien MARQUE authored on 2017-05-24
547
        if (me.device.role == 'MFD') {
548
            for (var i=1; i<=4; i+=1)
549
                me.screenElements['DATA-FIELD' ~ i ~ '-VAL-text']
improve route info display
Sébastien MARQUE authored on 2020-05-03
550
                    .setVisible(enroute)
add navigation infos on head...
Sébastien MARQUE authored on 2017-05-24
551
                    .setText(
navigation box content
Sébastien MARQUE authored on 2020-05-12
552
                        me.navbox[me.screenElements['DATA-FIELD' ~ i ~ '-ID-text'].setVisible(enroute).get('text')][0]()
add navigation infos on head...
Sébastien MARQUE authored on 2017-05-24
553
                    );
554
        }
555
        else { # PFD
improve route info display
Sébastien MARQUE authored on 2020-05-03
556
            me.screenElements['ETE'].setVisible(enroute);
557
            me.screenElements['DIS'].setVisible(enroute);
navigation box content
Sébastien MARQUE authored on 2020-05-12
558
            me.screenElements['ETE-text'].setVisible(enroute).setText(me.navbox.ETE[0]());
559
            me.screenElements['DIS-text'].setVisible(enroute).setText(me.navbox.DIS[0]());
560
            me.screenElements['LEG-text'].setVisible(enroute).setText(me.navbox.LEG[0]());
add navigation infos on head...
Sébastien MARQUE authored on 2017-05-24
561
        }
562
    },
563
#}}}
564

            
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
565
    updateSoftKeys : func {
566
# update SoftKeys boxes {{{
567
        # on PFD the last boxes are always BACK and ALERTS
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
568
        if (me.device.role == 'PFD') {
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
569
            me.screenElements[sprintf("SoftKey%02i-text", 11)]
570
                .setText('ALERTS');
571
            if (size(me.device.softkeys.path) != 0)
572
                me.screenElements[sprintf("SoftKey%02i-text", 10)]
not yet implemented softkeys...
Sébastien MARQUE authored on 2017-06-08
573
                    .setText('BACK')
574
                    .setColor(1,1,1);
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
575
        }
576

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
577
        var path = keyMap[me.device.role];
not yet implemented softkeys...
Sébastien MARQUE authored on 2017-06-08
578
        var bindings = me.device.softkeys.bindings[me.device.role];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
579
        var pathid = '';
580
        foreach (var p; me.device.softkeys.path) {
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
581
            path = path[p];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
582
            pathid ~= p;
not yet implemented softkeys...
Sébastien MARQUE authored on 2017-06-08
583
            if (contains(bindings, p))
584
                bindings = bindings[p];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
585
        }
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
586

            
587
        # feeding with empty menus the first boxes
588
        var start = (contains(path, 'first')) ? path.first : 0;
589
        for (var k = 0; k < start; k+=1) {
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
590
            var sftk = sprintf("SoftKey%02i-", k);
591
            me.screenElements[sftk ~ 'text']
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
592
                .setText('');
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
593
            me.screenElements[sftk ~ 'bg']
594
                .setColorFill(0,0,0);
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
595
        }
596
        # filling with the content the next boxes
597
        forindex (var k; path.texts) {
598
            var i = k + start;
599
            me.screenElements[sprintf("SoftKey%02i-text", i)]
600
                .setText(path.texts[k]);
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
601
            me.setSoftKeyColor(i,
not yet implemented softkeys...
Sébastien MARQUE authored on 2017-06-08
602
                    contains(me.device.softkeys.colored, pathid ~ path.texts[k]),
603
                    contains(bindings, path.texts[k]));
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
604
        }
605
        # feeding the last boxes with empty string
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
606
        var end = (me.device.role == 'PFD') ? 10 : 12;
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
607
        if (size(path.texts) + start < end) {
608
            start = size(path.texts) + start;
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
609
            for (var k = start; k < end; k += 1) {
610
                var sftk = sprintf("SoftKey%02i-", k);
611
                me.screenElements[sftk ~ 'text']
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
612
                    .setText('');
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
613
                me.screenElements[sftk ~ 'bg']
614
                    .setColorFill(0,0,0);
615
            }
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
616
        }
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
617

            
618
        if (size(me.device.softkeys.path))
old timers2 removed
Sébastien MARQUE authored on 2020-05-15
619
            me.timers.softkeys_inactivity.restart(me.softkeys_inactivity_delay);
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
620
        else
old timers2 removed
Sébastien MARQUE authored on 2020-05-15
621
            me.timers.softkeys_inactivity.stop();
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
622
    },
623
#}}}
624

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
625
    updateAI: func(){
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
626
#{{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
627
        var pitch = data.pitch;
628
        var roll = data.roll;
AI disponible
Sébastien MARQUE authored on 2017-03-10
629
        if (pitch > 80)
630
            pitch = 80;
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
631
        elsif (pitch < -80)
AI disponible
Sébastien MARQUE authored on 2017-03-10
632
            pitch = -80;
633
        me.screenElements.Horizon
fix AI animation
Sébastien MARQUE authored on 2017-03-19
634
            .setCenter(459, 282.8 - 6.849 * pitch)
AI disponible
Sébastien MARQUE authored on 2017-03-10
635
            .setRotation(-roll * D2R)
fix AI animation
Sébastien MARQUE authored on 2017-03-19
636
            .setTranslation(0, pitch * 6.849);
AI disponible, avec bankPoin...
Sébastien MARQUE authored on 2017-03-10
637
        me.screenElements.bankPointer
638
            .setRotation(-roll * D2R);
adds slipskid animation
Sébastien MARQUE authored on 2017-03-24
639
        me.screenElements['SlipSkid']
640
            .setTranslation(getprop("/instrumentation/slip-skid-ball/indicated-slip-skid") * 10, 0);
add TCAS
Sébastien MARQUE authored on 2017-12-21
641
        me.screenElements['Traffic']
642
            .setVisible(size(data.tcas));
AI disponible
Sébastien MARQUE authored on 2017-03-10
643
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
644
#}}}
animation VSI
Sébastien MARQUE authored on 2017-03-10
645

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
646
    updateVSI: func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
647
# animate VSI {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
648
        var vsi = data.vsi;
animation VSI
Sébastien MARQUE authored on 2017-03-10
649
        me.screenElements.VSIText
650
            .setText(num(math.round(vsi, 10)));
651
        if (vsi > 4500)
652
            vsi = 4500;
653
        elsif (vsi < -4500)
654
            vsi = -4500;
655
        me.screenElements.VSI
656
            .setTranslation(0, vsi * -0.03465);
657
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
658
#}}}
animation IAS
Sébastien MARQUE authored on 2017-03-10
659

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
660
    updateIAS: func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
661
# animates the IAS lint (PFD) {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
662
        var ias = data.ias;
animation IAS
Sébastien MARQUE authored on 2017-03-10
663
        if (ias >= 10)
664
            me.screenElements.Speed110
665
                .setText(sprintf("% 2u",num(math.floor(ias/10))));
666
        else
667
            me.screenElements.Speed110
668
                .setText('');
669
        me.screenElements.SpeedLint1
670
            .setTranslation(0,(math.mod(ias,10) + (ias >= 10)*10) * 36);
671
        me.screenElements.SpeedTape
672
            .setTranslation(0,ias * 5.711);
put Vspeeds in common data s...
Sébastien MARQUE authored on 2017-04-11
673
        if (ias > data.Vne and ! me._ias_already_exceeded) { # easier than .getColorFill
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
674
            me._ias_already_exceeded = 1;
675
            me.screenElements['IAS-bg']
676
                .setColorFill(1,0,0);
677
        }
put Vspeeds in common data s...
Sébastien MARQUE authored on 2017-04-11
678
        elsif (ias < data.Vne and me._ias_already_exceeded) { # easier than .getColorFill
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
679
            me._ias_already_exceeded = 0;
680
            me.screenElements['IAS-bg']
681
                .setColorFill(0,0,0);
682
        }
add V-speeds bugs
Sébastien MARQUE authored on 2017-04-04
683
        foreach (var v; ['Vx', 'Vy', 'Vr', 'Vglide']) {
put Vspeeds in common data s...
Sébastien MARQUE authored on 2017-04-11
684
            if (me.device.data[v ~ '-visible'] and abs(data[v] - ias) < 30)
add V-speeds bugs
Sébastien MARQUE authored on 2017-04-04
685
                me.screenElements['IAS-' ~ v]
put Vspeeds in common data s...
Sébastien MARQUE authored on 2017-04-11
686
                    .setTranslation(0, (ias - data[v]) * 5.711)
add V-speeds bugs
Sébastien MARQUE authored on 2017-04-04
687
                    .show();
688
            else
689
                me.screenElements['IAS-' ~ v]
690
                    .hide();
691
        }
692

            
improve trends vor ALT and I...
Sébastien MARQUE authored on 2020-04-30
693
        var Sy = 0;
694
        for (var i = 8; i >= 0; i -= 1)
695
            me._last_ias_Sy[i+1] = me._last_ias_Sy[i];
trends animation
Sébastien MARQUE authored on 2017-03-13
696
        var now = systime();
697
        # estimated speed in 6s
improve trends vor ALT and I...
Sébastien MARQUE authored on 2020-04-30
698
        me._last_ias_Sy[0] = 6 * (ias - me._last_ias_kt) / (now - me._last_ias_s);
699
        foreach (var _Sy; me._last_ias_Sy)
700
            Sy += _Sy;
701
        Sy /= 10;
trends animation
Sébastien MARQUE authored on 2017-03-13
702
        if (abs(Sy) > 30)
703
            Sy = 30 * abs(Sy)/Sy; # = -30 or 30
704
        me.screenElements['Airspeed-Trend-Indicator']
705
            .setScale(1,Sy)
706
            .setTranslation(0, -284.5 * (Sy - 1));
707
        me._last_ias_kt = ias;
708
        me._last_ias_s = now;
animation IAS
Sébastien MARQUE authored on 2017-03-10
709
    },
trends animation
Sébastien MARQUE authored on 2017-03-13
710
    _last_ias_kt : 0,
711
    _last_ias_s : systime(),
improve trends vor ALT and I...
Sébastien MARQUE authored on 2020-04-30
712
    _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
713
    _ias_already_exceeded : 0,
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
714
#}}}
animation ALT
Sébastien MARQUE authored on 2017-03-11
715

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
716
    updateTAS: func {
717
# updates the True Airspeed and GroundSpeed indicators {{{
718
        me.screenElements['TAS-text']
719
            .setText(sprintf('%iKT', getprop('/instrumentation/airspeed-indicator/true-speed-kt')));
720
        me.screenElements['GSPD-text']
721
            .setText(sprintf('%iKT', getprop('/velocities/groundspeed-kt')));
722
    },
723
#}}}
724

            
725
    updateALT: func () {
726
# animates the altitude lint (PFD) {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
727
        var alt = data.alt;
animation ALT
Sébastien MARQUE authored on 2017-03-11
728
        if (alt < 0)
729
            me.screenElements.Alt11100
fix altitude indicator
Sébastien MARQUE authored on 2020-05-03
730
                .setText(sprintf("%3d",math.ceil(alt/100)));
animation ALT
Sébastien MARQUE authored on 2017-03-11
731
        elsif (alt < 100)
732
            me.screenElements.Alt11100
733
                .setText('');
734
        else
735
            me.screenElements.Alt11100
fix altitude indicator
Sébastien MARQUE authored on 2020-05-03
736
                .setText(sprintf("%3i",math.floor(alt/100)));
animation ALT
Sébastien MARQUE authored on 2017-03-11
737
        me.screenElements.AltLint00011
738
            .setTranslation(0,math.fmod(alt,100) * 1.24);
739

            
740
        # From Farmin/G1000 http://wiki.flightgear.org/Project_Farmin/FG1000
741
        if (alt> -1000 and alt< 1000000) {
742
            var Offset10 = 0;
743
            var Offset100 = 0;
744
            var Offset1000 = 0;
745
            if (alt< 0) {
746
                var Ne = 1;
747
                var alt= -alt;
748
            }
749
            else
750
                var Ne = 0;
751

            
752
            var Alt10       = math.mod(alt,100);
753
            var Alt100      = int(math.mod(alt/100,10));
754
            var Alt1000     = int(math.mod(alt/1000,10));
755
            var Alt10000    = int(math.mod(alt/10000,10));
756
            var Alt20       = math.mod(Alt10,20)/20;
757
            if (Alt10 >= 80)
758
                var Alt100 += Alt20;
759

            
760
            if (Alt10 >= 80 and Alt100 >= 9)
761
                var Alt1000 += Alt20;
762

            
763
            if (Alt10 >= 80 and Alt100 >= 9 and Alt1000 >= 9)
764
                var Alt10000 += Alt20;
765

            
766
            if (alt> 100)
767
                var Offset10 = 100;
768

            
769
            if (alt> 1000)
770
                var Offset100 = 10;
771

            
772
            if (alt> 10000)
773
                var Offset1000 = 10;
774

            
775
            if (!Ne) {
776
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*0.57375);
777
                var altCentral = (int(alt/100)*100);
778
            }
779
            elsif (Ne) {
780
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*-0.57375);
781
                var altCentral = -(int(alt/100)*100);
782
            }
783
            me.screenElements["AltBigC"].setText("");
784
            me.screenElements["AltSmallC"].setText("");
785
            for (var place = 1; place <= 6; place += 1) {
786
                var altUP = altCentral + (place*100);
787
                var offset = -30.078;
788
                if (altUP < 0) {
789
                    var altUP = -altUP;
790
                    var prefix = "-";
791
                    var offset += 15.039;
792
                }
793
                else
794
                    var prefix = "";
795

            
796
                if (altUP == 0) {
797
                    var AltBigUP    = "";
798
                    var AltSmallUP  = "0";
799

            
800
                }
801
                elsif (math.mod(altUP,500) == 0 and altUP != 0) {
802
                    var AltBigUP    = sprintf(prefix~"%1d", altUP);
803
                    var AltSmallUP  = "";
804
                }
805
                elsif (altUP < 1000 and (math.mod(altUP,500))) {
806
                    var AltBigUP    = "";
807
                    var AltSmallUP  = sprintf(prefix~"%1d", int(math.mod(altUP,1000)));
808
                    var offset = -30.078;
809
                }
810
                elsif ((altUP < 10000) and (altUP >= 1000) and (math.mod(altUP,500))) {
811
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
812
                    var AltSmallUP  = sprintf("%1d", int(math.mod(altUP,1000)));
813
                    var offset += 15.039;
814
                }
815
                else {
816
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
817
                    var mod = int(math.mod(altUP,1000));
818
                    var AltSmallUP  = sprintf("%1d", mod);
819
                    var offset += 30.078;
820
                }
821

            
822
                me.screenElements["AltBigU"~place].setText(AltBigUP);
823
                me.screenElements["AltSmallU"~place].setText(AltSmallUP);
824
                me.screenElements["AltSmallU"~place].setTranslation(offset,0);
825
                var altDOWN = altCentral - (place*100);
826
                var offset = -30.078;
827
                if (altDOWN < 0) {
828
                    var altDOWN = -altDOWN;
829
                    var prefix = "-";
830
                    var offset += 15.039;
831
                }
832
                else
833
                    var prefix = "";
834

            
835
                if (altDOWN == 0) {
836
                    var AltBigDOWN  = "";
837
                    var AltSmallDOWN    = "0";
838
                }
839
                elsif (math.mod(altDOWN,500) == 0 and altDOWN != 0) {
840
                    var AltBigDOWN  = sprintf(prefix~"%1d", altDOWN);
841
                    var AltSmallDOWN    = "";
842
                }
843
                elsif (altDOWN < 1000 and (math.mod(altDOWN,500))) {
844
                    var AltBigDOWN  = "";
845
                    var AltSmallDOWN    = sprintf(prefix~"%1d", int(math.mod(altDOWN,1000)));
846
                    var offset = -30.078;
847
                }
848
                elsif ((altDOWN < 10000) and (altDOWN >= 1000) and (math.mod(altDOWN,500))) {
849
                    var AltBigDOWN  = sprintf(prefix~"%1d", int(altDOWN/1000));
850
                    var AltSmallDOWN    = sprintf("%1d", int(math.mod(altDOWN,1000)));
851
                    var offset += 15.039;
852
                }
853
                else {
854
                    var AltBigDOWN  = sprintf(prefix~"%1d", int(altDOWN/1000));
855
                    var mod = int(math.mod(altDOWN,1000));
856
                    var AltSmallDOWN    = sprintf("%1d", mod);
857
                    var offset += 30.078;
858
                }
859
                me.screenElements["AltBigD"~place].setText(AltBigDOWN);
860
                me.screenElements["AltSmallD"~place].setText(AltSmallDOWN);
861
                me.screenElements["AltSmallD"~place].setTranslation(offset,0);
862
            }
863
        }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
864
        me.updateSelectedALT();
improve trends vor ALT and I...
Sébastien MARQUE authored on 2020-04-30
865
        var Sy = 0;
866
        for (var i = 8; i >= 0; i -= 1)
867
            me._last_alt_Sy[i+1] = me._last_alt_Sy[i];
trends animation
Sébastien MARQUE authored on 2017-03-13
868
        var now = systime();
869
        # altitude in 6s
improve trends vor ALT and I...
Sébastien MARQUE authored on 2020-04-30
870
        me._last_alt_Sy[0] = .3 * (alt - me._last_alt_ft) / (now - me._last_alt_s); # scale = 1/20ft
871
        foreach (var _Sy; me._last_alt_Sy)
872
            Sy += _Sy;
873
        Sy /= 10;
trends animation
Sébastien MARQUE authored on 2017-03-13
874
        if (abs(Sy) > 15)
875
            Sy = 15 * abs(Sy)/Sy; # = -15 or 15
876
        me.screenElements['Altitude-Trend-Indicator']
877
            .setScale(1,Sy)
878
            .setTranslation(0, -284.5 * (Sy - 1));
879
        me._last_alt_ft = alt;
880
        me._last_alt_s = now;
animation ALT
Sébastien MARQUE authored on 2017-03-11
881
    },
trends animation
Sébastien MARQUE authored on 2017-03-13
882
    _last_alt_ft : 0,
improve trends vor ALT and I...
Sébastien MARQUE authored on 2020-04-30
883
    _last_alt_Sy : [0,0,0,0,0,0,0,0,0,0],
trends animation
Sébastien MARQUE authored on 2017-03-13
884
    _last_alt_s  : systime(),
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
885
#}}}
animation HSI
Sébastien MARQUE authored on 2017-03-11
886

            
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
887
    updateBARO : func () {
888
# update BARO widget {{{
889
        var fmt = me._baro_unit == 'inhg' ? '%.2f%s' : '%i%s';
890
        me.screenElements['BARO-text']
891
            .setText(sprintf(fmt,
892
                        getprop('/instrumentation/altimeter/setting-' ~ me._baro_unit),
893
                        me._baro_unit == 'inhg' ? 'in' : 'hPa')
894
                );
895
    },
896
    _baro_unit : 'inhg',
897
#}}}
898

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
899
    updateHSI : func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
900
# rotates the compass (PFD) {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
901
        var hdg = data.hdg;
animation HSI
Sébastien MARQUE authored on 2017-03-11
902
        me.screenElements.Rose
903
            .setRotation(-hdg * D2R);
904
        me.screenElements['HDG-text']
905
            .setText(sprintf("%03u°", hdg));
906
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
907
#}}}
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
908

            
removes unecessary listeners
Sébastien MARQUE authored on 2017-04-08
909
    updateHDG : func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
910
# moves the heading bug and display heading-deg for 3 seconds (PFD) {{{
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
911
        if (me.device.role == 'MFD')
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
912
            return;
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
913
        var hdg = afcs.getValue('heading-bug-deg');
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
914
        me.screenElements['Heading-bug']
915
            .setRotation(hdg * D2R);
916
        me.screenElements['SelectedHDG-bg']
917
            .show();
918
        me.screenElements['SelectedHDG-bgtext']
919
            .show();
920
        me.screenElements['SelectedHDG-text']
921
            .setText(sprintf('%03d°%s', hdg, ''))
922
            .show();
923
        me.addTimer(3, ['SelectedHDG-text', 'SelectedHDG-bgtext', 'SelectedHDG-bg']);
924
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
925
#}}}
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
926

            
adds CDI
Sébastien MARQUE authored on 2017-03-18
927
    updateCRS : func () {
anime CRS
Sébastien MARQUE authored on 2017-03-13
928
# TODO: update display for NAV/GPS/BRG courses {{{
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
929
        if (me.device.role == 'MFD')
anime CRS
Sébastien MARQUE authored on 2017-03-13
930
            return;
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
931
        var source = cdi.getValue('source');
adds CDI
Sébastien MARQUE authored on 2017-03-18
932
        if (source == 'OFF')
933
            return;
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
934
        var crs = cdi.getValue('course');
adds CDI
Sébastien MARQUE authored on 2017-03-18
935
        if (crs == nil)
936
            return;
anime CRS
Sébastien MARQUE authored on 2017-03-13
937
        me.screenElements['SelectedCRS-bg']
938
            .show();
939
        me.screenElements['SelectedCRS-bgtext']
940
            .show();
941
        me.screenElements['SelectedCRS-text']
942
            .setText(sprintf('%03d°%s', crs, ''))
adds CDI
Sébastien MARQUE authored on 2017-03-18
943
            .setColor(source == 'GPS' ? me.colors.magenta : me.colors.green)
anime CRS
Sébastien MARQUE authored on 2017-03-13
944
            .show();
945
        me.addTimer(3, ['SelectedCRS-text', 'SelectedCRS-bgtext', 'SelectedCRS-bg']);
946
    },
947
#}}}
948

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
949
    updateSelectedALT : func {
950
# animation for altitude section, called via updatedALT {{{
creates flightdeck hash to p...
Sébastien MARQUE authored on 2017-04-07
951
        if (! me.screenElements['SelectedALT'].getVisible())
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
952
            return;
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
953
        var selected_alt = afcs.getValue('selected-alt-ft');
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
954
        var delta_alt = data.alt - selected_alt;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
955
        if (abs(delta_alt) > 300)
956
            delta_alt = 300 * abs(delta_alt)/delta_alt;
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
957
        me.screenElements['SelectedALT-symbol']
958
            .setVisible(abs(delta_alt) > 100);
959
        me.screenElements['SelectedALT-bg']
960
            .setVisible(abs(delta_alt) > 100);
961
        me.screenElements['SelectedALT-text']
962
            .setText(sprintf("%i", selected_alt))
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
963
            .setVisible(abs(delta_alt) > 100);
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
964
        me.screenElements['SelectedALT-bug']
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
965
            .setTranslation(0, delta_alt * 0.567); # 170/300 = 0.567
966
    },
967
#}}}
968

            
adds CDI
Sébastien MARQUE authored on 2017-03-18
969
    updateCDI : func {
970
# animation for CDI {{{
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
971
        var source = cdi.getValue('source');
adds CDI
Sébastien MARQUE authored on 2017-03-18
972
        if (source == 'OFF') {
973
            foreach (var s; ['GPS', 'NAV1', 'NAV2'])
974
                foreach (var t; ['pointer', 'CDI'])
975
                    me.screenElements[s ~ '-' ~ t].hide();
976
            me.screenElements['CDI-GPS-ANN-text'].hide();
977
            me.screenElements['CDI-GPS-XTK-text'].hide();
978
            me.screenElements['CDI-SRC-text'].hide();
979
            me.screenElements['CDI'].hide();
980
        }
981
        else {
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
982
            var course = cdi.getValue('course');
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
983
            var rot = (course - data.hdg) * D2R;
adds CDI
Sébastien MARQUE authored on 2017-03-18
984
            me.screenElements['CDI']
makes the CDI available
Sébastien MARQUE authored on 2017-03-23
985
                .setRotation(rot)
adds CDI
Sébastien MARQUE authored on 2017-03-18
986
                .show();
987
            me.screenElements['GPS-CTI']
animates GPS-CTI
Sébastien MARQUE authored on 2017-03-24
988
                .setVisible(getprop('/instrumentation/gps/wp/wp[1]/valid'))
989
                .setRotation(getprop('/instrumentation/gps/wp/wp[1]/course-deviation-deg') * D2R);
adds CDI
Sébastien MARQUE authored on 2017-03-18
990
            me.screenElements['GPS-CTI-diamond']
animates GPS-CTI
Sébastien MARQUE authored on 2017-03-24
991
                .setVisible(getprop('/instrumentation/gps/wp/wp[1]/valid'))
992
                .setRotation(getprop('/instrumentation/gps/wp/wp[1]/course-deviation-deg') * D2R);
adds CDI
Sébastien MARQUE authored on 2017-03-18
993
            foreach (var s; ['GPS', 'NAV1', 'NAV2']) {
994
                me.screenElements[s ~ '-pointer']
995
                    .setRotation(rot)
996
                    .setVisible(source == s);
997
                me.screenElements[s ~ '-CDI']
998
                    .setVisible(source == s);
999
                foreach (var f; ['FROM', 'TO'])
1000
                    me.screenElements[s ~ '-' ~ f]
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
1001
                        .setVisible(s == source and cdi.getValue(f ~ '-flag'));
adds CDI
Sébastien MARQUE authored on 2017-03-18
1002
                me.screenElements['CDI-SRC-text']
1003
                    .setText(source)
1004
                    .setColor(source == 'GPS' ? me.colors.magenta : me.colors.green)
1005
                    .show();
1006
            }
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
1007
            var deflection = cdi.getValue('course-deflection');
makes the CDI available
Sébastien MARQUE authored on 2017-03-23
1008
            if (left(source, 3) == 'NAV')
1009
                var scale = deflection / 4;
1010
            else { # GPS
1011
                # TODO: deviation depending of the flight phase
1012
                # for now fixed 1 dot = 1 nm course error
1013
                var abs_deflection = abs(deflection);
1014
                me.screenElements['CDI-GPS-XTK-text']
1015
                    .setText(sprintf('XTK %iNM', abs_deflection))
1016
                    .setVisible(abs_deflection > 2.4);
1017
                var scale = deflection / 2;
1018
            }
1019
            scale = (abs(scale) > 1.2) ? 1.2 : scale;
1020
            me.screenElements[source ~ '-CDI']
1021
                .setTranslation(65 * scale, 0);
settimers to maketimer conti...
Sébastien MARQUE authored on 2020-05-13
1022
            me.timers.updateCDI.start();
adds CDI
Sébastien MARQUE authored on 2017-03-18
1023
        }
1024
    },
1025
#}}}
1026

            
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1027
    _updateRadio: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
1028
# common parts for NAV/LOC/COMM radios{{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1029
        # arg[0]._r = <comm|nav>
1030
        if (contains(arg[0], "active")) {
1031
            if (arg[0]['active'] == 'none') {
1032
                me.screenElements[arg[0]._r ~ '1-selected-freq']
1033
                    .setColor(1,1,1);
1034
                me.screenElements[arg[0]._r ~ '2-selected-freq']
1035
                    .setColor(1,1,1);
1036
            }
1037
            else {
1038
                me.screenElements[arg[0]._r ~ arg[0]['active'] ~ '-selected-freq']
1039
                    .setColor(0,1,0);
1040
                me.screenElements[arg[0]._r ~ arg[0].inactive ~ '-selected-freq']
1041
                    .setColor(1,1,1);
1042
            }
1043
        }
1044
        if (contains(arg[0], 'tune')) {
1045
            # n = 0 -> NAV1/COMM1
1046
            # n = 1 -> NAV1/COMM2
1047
            me.screenElements[arg[0]._r ~ '-freq-switch']
1048
                .setTranslation(0, arg[0].tune * 25);
1049
            me.screenElements[arg[0]._r ~ (arg[0].tune + 1) ~ '-standby-freq']
1050
                .setColor(0,1,1);
1051
            me.screenElements[arg[0]._r ~ ((arg[0].tune == 0) + 1) ~ '-standby-freq']
1052
                .setColor(1,1,1);
1053
        }
1054
        if (contains(arg[0], 'refresh')) {
small stuff
Sébastien MARQUE authored on 2017-03-22
1055
            # refresh only one line: NAV1/COMM1 or NAV2/COMM2
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1056
            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
1057
            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-selected-freq']
1058
                .setText(sprintf(fmt, getprop('/instrumentation/'
1059
                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/selected-mhz')));
1060
            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-standby-freq']
1061
                .setText(sprintf(fmt, getprop('/instrumentation/'
1062
                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/standby-mhz')));
1063
        }
1064
        if (contains(arg[0], 'set')) {
1065
            # 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
1066
            var n = radios.getValue(arg[0]._r ~ '-tune');
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1067
            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
1068
            me.screenElements[arg[0]._r ~ (n + 1) ~ '-standby-freq']
fix freq display while setti...
Sébastien MARQUE authored on 2017-03-16
1069
                .setText(sprintf(fmt, getprop('/instrumentation/' ~ arg[0]._r ~ '[' ~ n ~ ']/frequencies/standby-mhz')));
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1070
        }
1071
        if (contains(arg[0], 'auto')) {
1072
            # pour rafraichir automagiquement, toutes les deux secondes un refresh pour un NAV
1073
            var radio = arg[0].auto;
1074
            me._updateRadio({refresh: 1, _r: radio});
1075
            settimer(func me._updateRadio({refresh: 2, _r: radio}), 1);
1076
            settimer(func me._updateRadio({auto: radio}), 2);
1077
        }
1078
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
1079
#}}}
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1080

            
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1081
    updateNAV : func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
1082
# update NAV/LOC rodios display upper left (PFD/MFD){{{
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1083
        # made active via menu
1084
        if (contains(arg[0], "active")) {
adds CDI
Sébastien MARQUE authored on 2017-03-18
1085
            arg[0]._r = 'nav';
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1086
            if (arg[0]['active'] == 'none') {
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1087
                me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1088
                me.screenElements['nav1-id']
1089
                    .setColor(1,1,1);
1090
                me.screenElements['nav2-id']
1091
                    .setColor(1,1,1);
1092
                me.screenElements['NAV1-pointer']
1093
                    .hide();
1094
                me.screenElements['NAV2-pointer']
1095
                    .hide();
1096
            }
1097
            else {
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1098
                arg[0].inactive = (arg[0]['active'] == 1) + 1;
1099
                me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1100
                me.screenElements['nav' ~ arg[0]['active'] ~ '-id']
1101
                    .setColor(0,1,0);
1102
                me.screenElements['NAV' ~ arg[0]['active'] ~ '-pointer']
1103
                    .show();
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1104
                me.screenElements['nav' ~ arg[0].inactive ~ '-id']
1105
                    .setColor(1,1,1);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1106
#                me.screenElements['HDI']
1107
#                    .setRotation();
1108
#                me.screenElements['NAV' ~ inactive ~ '-pointer']
1109
#                    .hide();
1110
#                foreach (var e; [ 'FROM', 'TO', 'CDI' ])
1111
#                    me.screenElements['NAV' ~ inactive ~ '-' ~ e]
1112
#                        .hide();
1113
            }
1114
        }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1115
        elsif (contains(arg[0], 'nav-id')) {
Correction swap NAV tuning
Sébastien MARQUE authored on 2017-03-12
1116
            # 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
1117
            if (arg[0].val == nil)
1118
                arg[0].val = '';
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1119
            me.screenElements["nav" ~ arg[0]['nav-id'] ~ "-id"]
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1120
                    .setText(arg[0].val);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1121
        }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1122
        else {
1123
            arg[0]._r = 'nav';
1124
            me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1125
        }
1126
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
1127
#}}}
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1128

            
1129
    updateCOMM: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
1130
# update COMM radios display upper right (PFD/MFD){{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1131
        arg[0]._r = 'comm';
1132
        me._updateRadio(arg[0]);
1133
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
1134
#}}}
anime time display
Sébastien MARQUE authored on 2017-03-13
1135

            
1136
    updateTIME : func {
1137
# updates the displayed time botoom left {{{
1138
        me.screenElements['TIME-text']
1139
            .setText(getprop('/sim/time/gmt-string'));
1140
    },
1141
#}}}
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1142

            
adds transponder
Sébastien MARQUE authored on 2017-03-17
1143
    updateXPDR : func {
1144
# updates transponder display {{{
1145
        for (var d = 0; d < 4; d+=1)
1146
            me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
1147
                .setText(sprintf('%i', getprop('/instrumentation/transponder/inputs/digit[' ~ d ~ ']')));
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
1148
        var tuning = radios.getValue('xpdr-tuning-digit');
1149
        var fms = radios.getValue('xpdr-tuning-fms-method');
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
1150
        for (var d = 0; d < 4; d+=1)
1151
            me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
1152
                .setColor(1,1,1);
1153
        if (tuning != nil) {
1154
            me.screenElements['XPDR-DIGIT-' ~ tuning ~ '-text']
1155
                .setColor(0,1,1);
1156
            if (fms)
1157
                me.screenElements['XPDR-DIGIT-' ~ (tuning - 1) ~ '-text']
1158
                    .setColor(0,1,1);
1159
        }
adds transponder
Sébastien MARQUE authored on 2017-03-17
1160
        else {
1161
            if (getprop('/instrumentation/transponder/ident'))
1162
                var mode = 'IDENT';
1163
            else
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
1164
                var mode = radios.getValue('xpdr-mode');
adds transponder
Sébastien MARQUE authored on 2017-03-17
1165
            var wow = getprop('/gear/gear/wow');
1166
            if (! wow and mode != 'STBY')
1167
                var color = [0, 1, 0];
1168
            else
1169
                var color = [1, 1, 1];
1170
            for (var d = 0; d < 4; d+=1)
1171
                me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
1172
                    .setColor(color);
1173
            me.screenElements['XPDR-MODE-text']
1174
                .setColor(color)
1175
                .setText(mode);
1176
        }
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
1177
    },
adds transponder
Sébastien MARQUE authored on 2017-03-17
1178
#}}}
1179

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1180
    updateOAT : func {
1181
# update OAT display on normal and reversionnary modes (every 3s) {{{
1182
        var tmp = getprop('/environment/temperature-deg' ~ me._oat_unit);
1183
        me.screenElements['OAT-text']
1184
            .setText(sprintf((abs(tmp) < 10) ? "%.1f %s" : "%i %s", tmp, (me._oat_unit == 'c') ? '°C' : 'F'));
1185
    },
1186
    _oat_unit : 'c',
1187
#}}}
1188

            
1189
    updateWindData : func {
1190
# update the window text and arrows for OPTN1/2 {{{
1191
        if (me._winddata_optn == 0)
1192
            return;
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
1193
        if (data.ias < 30) {
improves WindData display
Sébastien MARQUE authored on 2017-03-16
1194
            me.screenElements['WindData-NODATA']
1195
                .hide();
1196
            var wind_hdg = getprop('/environment/wind-from-heading-deg');
1197
            var wind_spd = getprop('/environment/wind-speed-kt');
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
1198
            var alpha = wind_hdg - data.hdg;
improves WindData display
Sébastien MARQUE authored on 2017-03-16
1199
            if (me._winddata_optn == 1) {
1200
                me.screenElements['WindData-OPTN1-HDG']
1201
                    .setRotation((alpha + 180) * D2R)
1202
                    .show();
1203
                me.screenElements['WindData-OPTN1-HDG-text']
1204
                    .setText(sprintf("%03i°", wind_hdg))
1205
                    .show();
1206
                me.screenElements['WindData-OPTN1-SPD-text']
1207
                    .setText(int(wind_spd) ~ 'KT')
1208
                    .show();
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1209
            }
improves WindData display
Sébastien MARQUE authored on 2017-03-16
1210
            else { # me._winddata_optn == 2
1211
                alpha *= D2R;
1212
                var Vt = wind_spd * math.sin(alpha);
1213
                var Ve = wind_spd * math.cos(alpha);
1214
                if (Vt != 0) {
1215
                    me.screenElements['WindData-OPTN2-crosswind-text']
1216
                        .setText(sprintf('%i', abs(Vt)))
1217
                        .show();
1218
                    me.screenElements['WindData-OPTN2-crosswind']
1219
                        .setScale(-abs(Vt)/Vt, 1)
1220
                        .setTranslation(-35 * (abs(Vt)/Vt + 1), 0)
1221
                        .show();
1222
                }
1223
                if (Ve != 0) {
1224
                    me.screenElements['WindData-OPTN2-headwind-text']
1225
                        .setText(sprintf('%i', abs(Ve)))
1226
                        .show();
1227
                    me.screenElements['WindData-OPTN2-headwind']
1228
                        .setScale(1, abs(Ve)/Ve)
1229
                        .setTranslation(0, 515 * (1 - abs(Ve)/Ve))
1230
                        .show();
1231
                }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1232
            }
1233
        }
improves WindData display
Sébastien MARQUE authored on 2017-03-16
1234
        else {
1235
            foreach (var e; [
1236
                    'WindData-OPTN1-HDG',
1237
                    'WindData-OPTN1-HDG-text',
1238
                    'WindData-OPTN1-SPD-text',
1239
                    'WindData-OPTN2-crosswind-text',
1240
                    'WindData-OPTN2-crosswind',
1241
                    'WindData-OPTN2-headwind-text',
1242
                    'WindData-OPTN2-headwind'
1243
            ])
1244
                me.screenElements[e].hide();
1245
            me.screenElements['WindData-NODATA'].show();
1246
        }
settimers to maketimer conti...
Sébastien MARQUE authored on 2020-05-13
1247
        me.timers.updateWindData.start();
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1248
    },
1249
    _winddata_optn : 0,
1250
#}}}
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1251

            
adds AOA display
Sébastien MARQUE authored on 2017-04-15
1252
    updateAOA : func {
1253
# update Angle Of Attack {{{
1254
        if (me.device.data.aoa == 0)
1255
            return;
1256
        var color = [1,1,1];
1257
        var norm = data.aoa / data['stall-aoa'];
nicer AOA display
Sébastien MARQUE authored on 2017-04-16
1258
        me.screenElements['AOA-text']
1259
            .setText(sprintf('% .1f', norm));
adds AOA display
Sébastien MARQUE authored on 2017-04-15
1260
        if (norm > 1) norm = 1;
1261
        if (norm > 0.9)
1262
            color = [1,0,0];
1263
        elsif (norm > 0.7)
1264
            color = [1,1,0];
1265
        elsif (norm < 0) {
1266
            norm = 0;
1267
            color = [1,0,0];
1268
        }
1269
        me.screenElements['AOA-needle']
1270
            .setRotation(-norm * math.pi)
nicer AOA display
Sébastien MARQUE authored on 2017-04-16
1271
            .setColorFill(color);
1272
        me.screenElements['AOA-text']
adds AOA display
Sébastien MARQUE authored on 2017-04-15
1273
            .setColor(color);
settimers to maketimer conti...
Sébastien MARQUE authored on 2020-05-13
1274
        me.timers.updateAOA.start();
adds AOA display
Sébastien MARQUE authored on 2017-04-15
1275
    },
1276
# }}}
1277

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

            
1283
            var dev = radios.getNode(source).getValue();
1284
            var el  = 'BRG' ~ brg;
1285
            if (dev != 'OFF') {
1286
                var info = {
1287
                    pointer : nil,
1288
                    id : 'NO DATA',
1289
                    hdg : nil,
1290
                    dst : '--.-NM'
1291
                };
1292
                if (left(dev, 3) == 'NAV') {
1293
                    info.pointer = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/in-range');
1294
                    if (info.pointer) {
1295
                        info.id  = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/nav-id');
1296
                        info.hdg = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/heading-deg');
1297
                        info.dst = sprintf('%.1d', getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/nav-distance') / 1852); # m -> /1852
1298
                    }
1299
                }
1300
                elsif (dev == 'GPS') {
1301
                    info.pointer = props.getNode('/instrumentation/gps/wp').getChild('wp[1])');
1302
                    if (info.pointer) {
1303
                        info.id  = getprop('/instrumentation/gps/wp/wp[1]/ID');
1304
                        info.hdg = getprop('/instrumentation/gps/wp/wp[1]/bearing-mag-deg');
1305
                        info.dst = sprintf('%.1d', getprop('/instrumentation/gps/wp/wp[1]/distance-nm'));
1306
                    }
1307
                }
1308
                else { # there are 2 available ADF in FG, but instrument manage only 1
1309
                    info.pointer = getprop('/instrumentation/adf/in-range');
1310
                    if (info.pointer) {
1311
                        info.id  = getprop('/instrumentation/adf/ident');
1312
                        info.hdg = getprop('/instrumentation/adf/indicated-bearing-deg');
1313
                    }
1314
                }
1315

            
1316
                if (info.pointer)
1317
                    me.screenElements[el ~ '-pointer']
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
1318
                        .setRotation(-info.hdg - data.hdg * D2R)
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1319
                        .show();
1320
                else
1321
                    me.screenElements[el ~ '-pointer']
1322
                        .hide();
1323
                me.screenElements[el ~ '-SRC-text']
1324
                    .setText(dev);
1325
                me.screenElements[el ~ '-DST-text']
1326
                    .setText(info.dst);
1327
                me.screenElements[el ~ '-WPID-text']
1328
                    .setText(info.id);
1329
                me.screenElements['BRG' ~ brg]
1330
                    .show();
1331
            }
1332
            else {
1333
                me.screenElements['BRG' ~ brg]
1334
                    .hide();
1335
            }
1336
        }
1337
    },
some added comments
Sébastien MARQUE authored on 2017-03-18
1338
#}}}
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
1339

            
adds OMI to PFD
Sébastien MARQUE authored on 2017-03-23
1340
    updateOMI : func {
1341
# display marker baecon Outer, Middle, Inner {{{
1342
        var marker = nil;
1343
        foreach (var m; ['outer', 'middle', 'inner'])
1344
            if (getprop('/instrumentation/marker-beacon/' ~ m)) {
1345
                marker = m;
1346
                me.screenElements['OMI']
1347
                    .show();
1348
                break;
1349
            }
1350
        if (marker != nil) {
1351
            me.screenElements['MarkerText']
1352
                .setText(me._omi_data[marker].t)
1353
                .show();
1354
            me.screenElements['MarkerBG']
1355
                .setColorFill(me._omi_data[marker].bg)
1356
                .show();
1357
        }
1358
        else
1359
            me.screenElements['OMI']
1360
                .hide();
1361
    },
1362
    _omi_data : {
1363
        'outer':  {t: 'O', bg: [0,1,1]},
1364
        'middle': {t: 'M', bg: [1,1,1]},
1365
        'inner':  {t: 'I', bg: [1,1,0]},
1366
    },
1367
#}}}
animation texts EIS + power ...
Sébastien MARQUE authored on 2017-03-19
1368
};