zkv1000 / Nasal / display.nas /
Newer Older
1353 lines | 51.287kb
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,
configurable display size, v...
Sébastien MARQUE authored on 2017-04-15
9
                "size"      : device.data['screen-size'] != nil ? split(',', device.data['screen-size']) : [1024, 768],
10
                "view"      : device.data['screen-view'] != nil ? split(',', device.data['screen-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
commit initial
Sébastien MARQUE authored on 2017-03-07
16
        });
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 = {};
commit initial
Sébastien MARQUE authored on 2017-03-07
21

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

            
commit initial
Sébastien MARQUE authored on 2017-03-07
26
        return m;
27
    },
add new vim folds
Sébastien MARQUE authored on 2017-03-15
28
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
29

            
add new vim folds
Sébastien MARQUE authored on 2017-03-15
30
# timers stuff {{{
ajoute un timer pour cacher ...
Sébastien MARQUE authored on 2017-03-13
31
    timers : {},
32

            
33
    timerTrigger : func {
34
        var now = systime();
35
        foreach (var id; keys(me.timers)) {
36
            if (me.timers[id] < now) {
37
                me.screenElements[id].hide();
38
                delete(me.timers, id);
39
            }
40
        }
41
        settimer(func me.timerTrigger(), 1);
42
    },
43

            
44
    addTimer : func (duration, element) {
45
        if (typeof(element) == 'scalar')
46
            element = [ element ];
47
        var end = systime() + duration;
48
        foreach (var e; element)
49
            me.timers[e] = end;
50
    },
add new vim folds
Sébastien MARQUE authored on 2017-03-15
51
#}}}
ajoute un timer pour cacher ...
Sébastien MARQUE authored on 2017-03-13
52

            
commit initial
Sébastien MARQUE authored on 2017-03-07
53
    loadsvg : func () {
54
        me.screen = me.display.createGroup();
55
        me.screen.hide();
path and relpath to zkv1000 ...
Sébastien MARQUE authored on 2017-04-17
56
        canvas.parsesvg(me.screen, data.zkv1000_reldir ~ 'Systems/screen.svg');
commit initial
Sébastien MARQUE authored on 2017-03-07
57
    },
58

            
59
    _showInitProgress : func (p,t) {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
60
#{{{
commit initial
Sébastien MARQUE authored on 2017-03-07
61
        p.setText(t);
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
62
        if (zkv.getNode(me.device.name ~ '-init').getValue() != 0) {
commit initial
Sébastien MARQUE authored on 2017-03-07
63
            if (size(t) >= 10) t = '';
64
            settimer(func { me._showInitProgress(p, t ~ '.'); }, 0.1);
65
        }
66
        else {
67
            me.progress.hide();
68
            me.screen.show();
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
69
            var groups = {
animation VSI
Sébastien MARQUE authored on 2017-03-10
70
                show : [
makes header visible on MFD ...
Sébastien MARQUE authored on 2017-03-18
71
                    'Header',
commit initial
Sébastien MARQUE authored on 2017-03-07
72
                    'SoftKeysTexts', 
73
                    'COMM', 
74
                    'NAV', 
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
75
                    'nav-freq-switch',
76
                    'comm-freq-switch',
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
77
                ],
78
                text: [
79
                    'nav1-standby-freq', 'nav1-selected-freq', 'nav1-id',
80
                    'nav2-standby-freq', 'nav2-selected-freq', 'nav2-id',
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
81
                    'comm1-standby-freq', 'comm1-selected-freq',
82
                    'comm2-standby-freq', 'comm2-selected-freq',
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
83
                ],
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
84
                hide : [ ],
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
85
                clip: [ ],
86
            };
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
87

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

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
93
            if (me.device.role == 'PFD') {
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
94
                append(groups.show,
commit initial
Sébastien MARQUE authored on 2017-03-07
95
                    'XPDR-TIME', 
AI disponible
Sébastien MARQUE authored on 2017-03-10
96
                    'FlightInstruments',
97
                    'Horizon',
AI disponible, avec bankPoin...
Sébastien MARQUE authored on 2017-03-10
98
                    'bankPointer',
animation VSI
Sébastien MARQUE authored on 2017-03-10
99
                    'VSI',
animation HSI
Sébastien MARQUE authored on 2017-03-11
100
                    'Rose',
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
101
                    'Heading-bug',
102
                    'PFD-Widgets',
trends animation
Sébastien MARQUE authored on 2017-03-13
103
                    'Trends',
104
                    'Airspeed-Trend-Indicator',
105
                    'Altitude-Trend-Indicator',
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
106
                    'OAT',
107
                    'IAS-bg',
108
                    'TAS',
109
                    'GSPD',
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
110
                    'BARO-bg',
adds slipskid animation
Sébastien MARQUE authored on 2017-03-24
111
                    'SlipSkid',
add V-speeds bugs
Sébastien MARQUE authored on 2017-04-04
112
                    'IAS-Vx', 'IAS-Vy', 'IAS-Vr', 'IAS-Vglide',
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
113
                );
114
                append(groups.hide,
adds EIS
Sébastien MARQUE authored on 2017-03-18
115
                    'EIS',
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
116
                    'CDI',
adds OMI to PFD
Sébastien MARQUE authored on 2017-03-23
117
                    'OMI', 'MarkerBG', 'MarkerText',
adds CDI
Sébastien MARQUE authored on 2017-03-18
118
                    'NAV1-pointer', 'NAV1-CDI', 'NAV1-FROM', 'NAV1-TO',
119
                    'NAV2-pointer', 'NAV2-CDI', 'NAV2-FROM', 'NAV2-TO',
120
                    'GPS-pointer', 'GPS-CDI', 'GPS-CTI', 'GPS-CTI-diamond', 'GPS-FROM', 'GPS-TO',
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
121
                    'BRG1-pointer',
122
                    'BRG2-pointer',
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
123
                    'SelectedHDG-bg',
124
                    'SelectedHDG-bgtext',
125
                    'SelectedHDG-text',
126
                    'SelectedCRS-bg',
127
                    'SelectedCRS-bgtext',
128
                    'SelectedCRS-text',
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
129
                    'SelectedALT', 'SelectedALT-bug', 'SelectedALT-bg', 'SelectedALT-symbol',
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
130
                    'TAS',
131
                    'GSPD',
132
                    'WindData',
133
                    'Reversionnary',
134
                    'Annunciation',
135
                    'Comparator',
136
                    'BRG1',
137
                    'BRG2',
138
                    'DME1',
139
                    'PFD-Map',
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
140
                    'PFD-Multilines',
improves WindData display
Sébastien MARQUE authored on 2017-03-16
141
                    'WindData', 'WindData-OPTN1', 'WindData-OPTN2', 'WindData-OPTN1-HDG', 'WindData-OPTN2-symbol', 'WindData-OPTN2-headwind', 'WindData-OPTN2-crosswind', 'WindData-NODATA',
nicer AOA display
Sébastien MARQUE authored on 2017-04-16
142
                    'AOA', 'AOA-needle', 'AOA-text', 'AOA-approach',
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
143
                );
144
                append(groups.clip,
animation IAS
Sébastien MARQUE authored on 2017-03-10
145
                    'SpeedLint1',
animation ALT
Sébastien MARQUE authored on 2017-03-11
146
                    'SpeedTape',
147
                    'LintAlt',
148
                    'AltLint00011'
149
                );
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
150
                append(groups.text,
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
151
                    'SelectedALT-text',
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
152
                    'TAS-text',
153
                    'GSPD-text',
anime time display
Sébastien MARQUE authored on 2017-03-13
154
                    'TIME-text',
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
155
                    'OAT-text',
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
156
                    'VSIText',
157
                    'Speed110',
158
                    'Alt11100',
159
                    'HDG-text',
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
160
                    'BARO-text',
adds CDI
Sébastien MARQUE authored on 2017-03-18
161
                    'CDI-SRC-text', 'CDI-GPS-ANN-text', 'CDI-GPS-XTK-text',
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
162
                    'BRG1-pointer', 'BRG1-SRC-text', 'BRG1-DST-text', 'BRG1-WPID-text',
163
                    'BRG2-pointer', 'BRG2-SRC-text', 'BRG2-DST-text', 'BRG2-WPID-text',
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
164
                    'WindData-OPTN1-HDG-text', 'WindData-OPTN1-SPD-text',
165
                    'WindData-OPTN2-crosswind-text', 'WindData-OPTN2-headwind-text',
adds transponder
Sébastien MARQUE authored on 2017-03-17
166
                    'XPDR-MODE-text', 'XPDR-DIGIT-3-text', 'XPDR-DIGIT-2-text', 'XPDR-DIGIT-1-text', 'XPDR-DIGIT-0-text',
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
167
                    'AltBigC', 'AltSmallC'
168
                );
169
                for (var place = 1; place <= 6; place +=1) {
170
                    append(groups.text,
171
                        'AltBigU' ~ place,
172
                        'AltSmallU' ~ place,
173
                        'AltBigD' ~ place,
174
                        'AltSmallD' ~ place
175
                    );
176
                }
adds AOA display
Sébastien MARQUE authored on 2017-04-15
177
                me.device.data.aoa = 0;
178
                me.device.data['aoa-auto'] = 0;
animation ALT
Sébastien MARQUE authored on 2017-03-11
179
            }
adds EIS
Sébastien MARQUE authored on 2017-03-18
180
            else {
navaids displayed with corre...
Sébastien MARQUE authored on 2017-04-18
181
                var eis_dir = data.zkv1000_dir ~ 'Nasal/EIS/';
182
                var eis_type = getprop('/instrumentation/zkv1000/eis/type');
183
                if (eis_type == nil or
184
                        (io.stat(eis_dir ~ eis_type ~ '.nas') == nil
185
                         and print(eis_type ~ ' not found')))
186
                    eis_type = 'none';
187
                io.load_nasal(eis_dir ~ eis_type ~ '.nas', 'zkv1000');
EIS can be aircraft specific
Sébastien MARQUE authored on 2017-04-04
188
                if (contains(me.parents[0], 'showEIS'))
189
                    me.showEIS(groups);
adds EIS
Sébastien MARQUE authored on 2017-03-18
190
            }
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
191

            
192
            me.loadGroup(groups);
animation ALT
Sébastien MARQUE authored on 2017-03-11
193

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
194
            if (me.device.role == 'PFD') {
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
195
                me.updateAI();
196
                me.updateVSI();
197
                me.updateIAS();
198
                me.updateALT();
199
                me.updateHSI();
anime time display
Sébastien MARQUE authored on 2017-03-13
200
                me.updateTIME();
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
201
                me.updateOAT();
202
                me.updateTAS();
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
203
                me.updateBRG();
adds transponder
Sébastien MARQUE authored on 2017-03-17
204
                me.updateXPDR();
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
205
                me.updateBARO();
adds OMI to PFD
Sébastien MARQUE authored on 2017-03-23
206
                me.updateOMI();
ajoute un timer pour cacher ...
Sébastien MARQUE authored on 2017-03-13
207
                me.timerTrigger();
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
208
            }
animation texts EIS + power ...
Sébastien MARQUE authored on 2017-03-19
209
            else {
210
                me.updateEIS();
navaids displayed with corre...
Sébastien MARQUE authored on 2017-04-18
211
                me.device.timers.map = maketimer(1, me, func {
212
                        me.MFDMapTiles.updateTiles();
213
                        me.MFDMapNavaids.update();
214
                        var gspd = getprop('/velocities/groundspeed-kt');
215
                        if (gspd != 0)
216
                            var next = (me.device.data['range-nm']/(gspd/3600))/(me.display.get('view[1]')/2);
217
                        else
218
                            var next = 10;
219
                        if (next > 10)
220
                            next = 10;
221
                        me.device.timers.map.restart(next);
222
                    });
223
                me.device.timers.map.singleShot = 1;
224
                me.device.data.zoom = 10;
225
                me.MFDMapTiles = MapTiles.new(me.device);
226
                me.MFDMapTiles.changeZoom(0);
227
                me.MFDMapNavaids = PositionedLayer.new(me.device);
implements the ND from Extra...
Sébastien MARQUE authored on 2017-04-17
228
                me.MFDMapNavaids.setVisible(1);
229
                me.MFDMapNavaids.update();
adds Map on MFD
Sébastien MARQUE authored on 2017-03-20
230
                me.MFDMapTiles.initialize_grid();
navaids displayed with corre...
Sébastien MARQUE authored on 2017-04-18
231
                me.device.timers.map.start();
232
                io.load_nasal(data.zkv1000_dir ~ 'Nasal/MFD.pages.nas', 'zkv1000');
adds MFD page selection syst...
Sébastien MARQUE authored on 2017-04-13
233
                me['page selected'] = 0;
234
                me.device.data['page selection'] = [
235
                    {
236
                        name: 'MAP',
237
                        objects: [
238
                            {text: 'NAVIGATION MAP'},
239
                            {text: 'TRAFFIC MAP'},
240
                            {text: 'STORMSCOPE'},
241
                            {text: 'WEATHER DATA LINK'},
242
                            {text: 'TAWS-B'},
243
                        ],
244
                    },
245
                    {
246
                        name: 'WPT',
247
                        objects: [
248
                            {text: 'AIRPORT INFORMATION'},
249
                            {text: 'AIRPORT DIRECTORY'},
250
                            {text: 'DEPARTURE INFORMATION'},
251
                            {text: 'ARRIVAL INFORMATION'},
252
                            {text: 'APPROACH INFORMATION'},
253
                            {text: 'WEATHER INFORMATION'},
254
                            {text: 'INTERSECTION INFORMATION'},
255
                            {text: 'NDB INFORMATION'},
256
                            {text: 'VOR INFORMATION'},
257
                            {text: 'USER WAYPOINT INFORMATION'},
258
                        ],
259
                    },
260
                    {
261
                        name: 'AUX',
262
                        objects: [
263
                            {text: 'TRIP PLANNING'},
264
                            {text: 'UTILITY'},
265
                            {text: 'GPS STATUS'},
266
                            {text: 'SYSTEM SETUP'},
267
                        ],
268
                    },
269
                    {
270
                        name: 'FPL',
271
                        objects: [
272
                            {text: 'ACTIVE FLIGHT PLAN'},
273
                            {text: 'WIDE VIEW, NARROW VIEW'},
274
                            {text: 'FLIGHT PLAN CATALOG'},
275
                        ],
276
                    },
277
                    {
278
                        name: 'PROC',
279
                        objects: [
280
                            {text: 'DEPARTURE LOADING'},
281
                            {text: 'ARRIVAL LOADING'},
282
                            {text: 'APPROACH LOADING'},
283
                        ],
284
                    },
285
                    {
286
                        name: 'NRST',
287
                        objects: [
288
                            {text: 'NEAREST AIRPORTS'},
289
                            {text: 'NEAREST INTERSECTIONS'},
290
                            {text: 'NEAREST NDB'},
291
                            {text: 'NEAREST VOR'},
292
                            {text: 'NEAREST USER WAYPOINTS'},
293
                            {text: 'NEAREST FREQUENCIES'},
294
                            {text: 'NEAREST AIRSPACES'},
295
                        ],
296
                    },
297
                ];
fix MFD page selection syste...
Sébastien MARQUE authored on 2017-04-13
298
                me.setMFDPages();
animation texts EIS + power ...
Sébastien MARQUE authored on 2017-03-19
299
            }
fix COMM display standby fre...
Sébastien MARQUE authored on 2017-04-09
300
            me.updateNAV({auto:'nav', tune: radios.getNode('nav-tune').getValue()});
301
            me.updateCOMM({auto:'comm', tune: radios.getNode('comm-tune').getValue()});
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
302
            me.softkeys_inactivity();
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
303
            me.updateSoftKeys();
commit initial
Sébastien MARQUE authored on 2017-03-07
304
            me.progress.removeAllChildren();
305
            me.progress = nil;
306
            me.showInitProgress = nil;
307
            me._showInitProgress = nil;
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
308
            zkv.removeChild(me.device.role ~ 'init', 0);
commit initial
Sébastien MARQUE authored on 2017-03-07
309
        }
310
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
311
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
312

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
313
    showInitProgress : func (name) {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
314
#{{{
commit initial
Sébastien MARQUE authored on 2017-03-07
315
        me.progress = me.display.createGroup();
316
        me.progress.show();
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
317
        me.progress.createChild("text", name ~ " title")
commit initial
Sébastien MARQUE authored on 2017-03-07
318
            .setTranslation(512, 384)
319
            .setAlignment("center-center")
320
            .setFont("LiberationFonts/LiberationSans-Italic.ttf")
321
            .setFontSize(64, 1)
322
            .setColor(1,1,1)
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
323
            .setText("ZKV1000 " ~ name ~ " init");
commit initial
Sébastien MARQUE authored on 2017-03-07
324

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
325
        zkv.getNode(name ~ '-init',1).setIntValue(1);
commit initial
Sébastien MARQUE authored on 2017-03-07
326

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
327
        me._showInitProgress(me.progress.createChild("text", name ~ "progress")
commit initial
Sébastien MARQUE authored on 2017-03-07
328
            .setTranslation(512, 484)
329
            .setAlignment("center-center")
330
            .setFont("LiberationFonts/LiberationSans-Bold.ttf")
331
            .setFontSize(128, 1)
332
            .setColor(1,0,0), '.');
333
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
334
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
335

            
some added comments
Sébastien MARQUE authored on 2017-03-18
336
    colors : {
337
# set of predefined colors {{{
338
        green : [0, 1, 0],
339
        white : [1, 1, 1],
340
        black : [0, 0, 0],
341
        lightblue : [0, 1, 1],
342
        darkblue : [0, 0, 1],
343
        red : [1, 0, 0],
adds CDI
Sébastien MARQUE authored on 2017-03-18
344
        magenta : [1, 0, 1],
some added comments
Sébastien MARQUE authored on 2017-03-18
345
    },
346
#}}}
347

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

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

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

            
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
460
    softkeys_inactivity : func {
461
# automagically back to previous level after some delay {{{
462
        me.timers2.softkeys_inactivity = maketimer (
463
            me.softkeys_inactivity_delay,
464
            func {
465
                pop(me.device.softkeys.path);
466
                me.updateSoftKeys();
467
            }, me);
468
        me.timers2.softkeys_inactivity.singleShot = 1;
469
    },
470
#}}}
471

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

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

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
502
        var path = keyMap[me.device.role];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
503
        var pathid = '';
504
        foreach (var p; me.device.softkeys.path) {
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
505
            path = path[p];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
506
            pathid ~= p;
507
        }
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
508

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

            
539
        if (size(me.device.softkeys.path))
540
            me.timers2.softkeys_inactivity.restart(me.softkeys_inactivity_delay);
541
        else
542
            me.timers2.softkeys_inactivity.stop();
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
543
    },
544
#}}}
545

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

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

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

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

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

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

            
656
        # From Farmin/G1000 http://wiki.flightgear.org/Project_Farmin/FG1000
657
        if (alt> -1000 and alt< 1000000) {
658
            var Offset10 = 0;
659
            var Offset100 = 0;
660
            var Offset1000 = 0;
661
            if (alt< 0) {
662
                var Ne = 1;
663
                var alt= -alt;
664
            }
665
            else
666
                var Ne = 0;
667

            
668
            var Alt10       = math.mod(alt,100);
669
            var Alt100      = int(math.mod(alt/100,10));
670
            var Alt1000     = int(math.mod(alt/1000,10));
671
            var Alt10000    = int(math.mod(alt/10000,10));
672
            var Alt20       = math.mod(Alt10,20)/20;
673
            if (Alt10 >= 80)
674
                var Alt100 += Alt20;
675

            
676
            if (Alt10 >= 80 and Alt100 >= 9)
677
                var Alt1000 += Alt20;
678

            
679
            if (Alt10 >= 80 and Alt100 >= 9 and Alt1000 >= 9)
680
                var Alt10000 += Alt20;
681

            
682
            if (alt> 100)
683
                var Offset10 = 100;
684

            
685
            if (alt> 1000)
686
                var Offset100 = 10;
687

            
688
            if (alt> 10000)
689
                var Offset1000 = 10;
690

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

            
712
                if (altUP == 0) {
713
                    var AltBigUP    = "";
714
                    var AltSmallUP  = "0";
715

            
716
                }
717
                elsif (math.mod(altUP,500) == 0 and altUP != 0) {
718
                    var AltBigUP    = sprintf(prefix~"%1d", altUP);
719
                    var AltSmallUP  = "";
720
                }
721
                elsif (altUP < 1000 and (math.mod(altUP,500))) {
722
                    var AltBigUP    = "";
723
                    var AltSmallUP  = sprintf(prefix~"%1d", int(math.mod(altUP,1000)));
724
                    var offset = -30.078;
725
                }
726
                elsif ((altUP < 10000) and (altUP >= 1000) and (math.mod(altUP,500))) {
727
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
728
                    var AltSmallUP  = sprintf("%1d", int(math.mod(altUP,1000)));
729
                    var offset += 15.039;
730
                }
731
                else {
732
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
733
                    var mod = int(math.mod(altUP,1000));
734
                    var AltSmallUP  = sprintf("%1d", mod);
735
                    var offset += 30.078;
736
                }
737

            
738
                me.screenElements["AltBigU"~place].setText(AltBigUP);
739
                me.screenElements["AltSmallU"~place].setText(AltSmallUP);
740
                me.screenElements["AltSmallU"~place].setTranslation(offset,0);
741
                var altDOWN = altCentral - (place*100);
742
                var offset = -30.078;
743
                if (altDOWN < 0) {
744
                    var altDOWN = -altDOWN;
745
                    var prefix = "-";
746
                    var offset += 15.039;
747
                }
748
                else
749
                    var prefix = "";
750

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

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

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

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

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

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

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

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

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

            
1040
    updateCOMM: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
1041
# update COMM radios display upper right (PFD/MFD){{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1042
        arg[0]._r = 'comm';
1043
        me._updateRadio(arg[0]);
1044
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
1045
#}}}
anime time display
Sébastien MARQUE authored on 2017-03-13
1046

            
1047
    updateTIME : func {
1048
# updates the displayed time botoom left {{{
1049
        me.screenElements['TIME-text']
1050
            .setText(getprop('/sim/time/gmt-string'));
1051
        settimer(func me.updateTIME(), 1);
1052
    },
1053
#}}}
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1054

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

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

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

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

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

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

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

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

            
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
1285
var keyMap = {
add new vim folds
Sébastien MARQUE authored on 2017-03-15
1286
# softkeys map for PFD and MFD {{{
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
1287
    PFD : {
1288
        first : 1,
1289
        texts : ['INSET', 'SENSOR', 'PFD', 'OBS', 'CDI', 'DME', 'XPDR', 'IDENT', 'TMR/REF', 'NRST' ],
1290
        INSET : {
1291
            texts : ['OFF', 'DCLTR', 'WXLGND', 'TRAFFIC', 'TOPO', 'TERRAIN', 'STRMSCP', 'NEXRAD-C', 'XM LTNG', 'METAR'],
1292
        },
1293
        SENSOR : {
1294
            first : 2,
1295
            texts : [ 'ADC1', 'ADC2', '', 'AHRS1', 'AHRS2'],
1296
        },
1297
        PFD : {
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1298
            texts : [ 'SYN VIS', 'DFLTS', 'AOA/WIND', 'DME', 'BRG1', 'HSI FMT', 'BRG2', '', 'ALT UNIT', 'STD BARO' ],
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
1299
            'SYN VIS' : {
1300
                texts : [ 'PATHWAY', 'SYN TERR', 'HR2NHDG', 'APTSIGNS', 'FPM'],
1301
            },
1302
            'AOA/WIND' : {
1303
                first : 4,
1304
                texts : ['AOA', 'WIND'],
1305
                AOA : {
1306
                    first : 5,
1307
                    texts : ['AOA ON', 'AOA AUTO'],
1308
                },
1309
                WIND : {
1310
                    first : 2,
1311
                    texts : ['OPTN1', 'OPTN2', '', 'OFF'],
1312
                },
1313
            },
1314
            'HSI FMT' : {
1315
                first : 6,
1316
                texts : ['360 HSI', 'ARC HSI'],
1317
            },
1318
            'ALT UNIT' : {
1319
                first : 5,
1320
                texts : ['METERS', '', 'IN', 'HPA'],
1321
            },
1322
        },
1323
        XPDR : {
1324
            first : 2,
1325
            texts : ['STBY', 'ON', 'ALT', '', 'VFR', 'CODE', 'IDENT'],
1326
            CODE : {
1327
                texts : ['0', '1', '2', '3', '4', '5', '6', '7', 'IDENT', 'BKSP'],
1328
            },
1329
        },
1330
    },
1331
    MFD : {
1332
        texts : ['ENGINE', '', 'MAP', '', '', '', '', '', '', 'DCLTR', 'SHW CHRT', 'CHKLIST'],
1333
        MAP : {
1334
            texts: ['TRAFFIC', 'PROFILE', 'TOPO', 'TERRAIN', 'AIRWAYS', 'STRMSCP','NEXRAD-C', 'XM LTNG', 'METAR', 'LEGEND', 'BACK'],
1335
        },
1336
        CHKLIST : {
1337
            texts : ['ENGINE', '', '', '', '', 'DONE', '', '', '', '', 'EXIT', 'EMERGCY'],
1338
        },
1339
        ENGINE : {
1340
            texts : ['ENGINE', 'ANTI-ICE', '', 'DCLTR', '', 'ASSIST', '', '', '', '', 'FUEL'],
1341
            'ANTI-ICE' : {
1342
                texts : ['LEFT', 'AUTO', 'RIGHT', '', '', '', '', '', '', '', '', 'BACK'],
1343
            },
1344
            FUEL : {
1345
                first : 1,
1346
                texts : ['FULL', 'TABS', '', '', '', '', '', '', '', 'UNDO', 'ENTER'],
1347
            },
1348
        },
1349
    },
1350
};
adds AOA display
Sébastien MARQUE authored on 2017-04-15
1351
if (data['stall-aoa'] == 9999)
1352
    keyMap.PFD.PFD['AOA/WIND'].texts = ['', 'WIND'];
add new vim folds
Sébastien MARQUE authored on 2017-03-15
1353
#}}}