zkv1000 / Nasal / display.nas /
Newer Older
1363 lines | 51.906kb
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
                    });
set MFD map size relative to...
Sébastien MARQUE authored on 2017-04-18
223
                me.device.data.mapclip = {
224
                    top: math.ceil(me.screenElements['Header'].getTransformedBounds()[3]),
225
                    right: me.display.get('view[0]'),
226
                    bottom: math.ceil(me.screenElements['SoftKeysTexts'].getTransformedBounds()[1]),
227
                    left: math.ceil(me.screenElements['EIS'].getTransformedBounds()[2]),
228
                };
229
                me.device.data.mapsize = [
230
                    me.device.data.mapclip.right - me.device.data.mapclip.left,
231
                    me.device.data.mapclip.bottom - me.device.data.mapclip.top,
232
                ];
navaids displayed with corre...
Sébastien MARQUE authored on 2017-04-18
233
                me.device.timers.map.singleShot = 1;
234
                me.device.data.zoom = 10;
235
                me.MFDMapTiles = MapTiles.new(me.device);
236
                me.MFDMapTiles.changeZoom(0);
237
                me.MFDMapNavaids = PositionedLayer.new(me.device);
implements the ND from Extra...
Sébastien MARQUE authored on 2017-04-17
238
                me.MFDMapNavaids.setVisible(1);
239
                me.MFDMapNavaids.update();
adds Map on MFD
Sébastien MARQUE authored on 2017-03-20
240
                me.MFDMapTiles.initialize_grid();
navaids displayed with corre...
Sébastien MARQUE authored on 2017-04-18
241
                me.device.timers.map.start();
242
                io.load_nasal(data.zkv1000_dir ~ 'Nasal/MFD.pages.nas', 'zkv1000');
adds MFD page selection syst...
Sébastien MARQUE authored on 2017-04-13
243
                me['page selected'] = 0;
244
                me.device.data['page selection'] = [
245
                    {
246
                        name: 'MAP',
247
                        objects: [
248
                            {text: 'NAVIGATION MAP'},
249
                            {text: 'TRAFFIC MAP'},
250
                            {text: 'STORMSCOPE'},
251
                            {text: 'WEATHER DATA LINK'},
252
                            {text: 'TAWS-B'},
253
                        ],
254
                    },
255
                    {
256
                        name: 'WPT',
257
                        objects: [
258
                            {text: 'AIRPORT INFORMATION'},
259
                            {text: 'AIRPORT DIRECTORY'},
260
                            {text: 'DEPARTURE INFORMATION'},
261
                            {text: 'ARRIVAL INFORMATION'},
262
                            {text: 'APPROACH INFORMATION'},
263
                            {text: 'WEATHER INFORMATION'},
264
                            {text: 'INTERSECTION INFORMATION'},
265
                            {text: 'NDB INFORMATION'},
266
                            {text: 'VOR INFORMATION'},
267
                            {text: 'USER WAYPOINT INFORMATION'},
268
                        ],
269
                    },
270
                    {
271
                        name: 'AUX',
272
                        objects: [
273
                            {text: 'TRIP PLANNING'},
274
                            {text: 'UTILITY'},
275
                            {text: 'GPS STATUS'},
276
                            {text: 'SYSTEM SETUP'},
277
                        ],
278
                    },
279
                    {
280
                        name: 'FPL',
281
                        objects: [
282
                            {text: 'ACTIVE FLIGHT PLAN'},
283
                            {text: 'WIDE VIEW, NARROW VIEW'},
284
                            {text: 'FLIGHT PLAN CATALOG'},
285
                        ],
286
                    },
287
                    {
288
                        name: 'PROC',
289
                        objects: [
290
                            {text: 'DEPARTURE LOADING'},
291
                            {text: 'ARRIVAL LOADING'},
292
                            {text: 'APPROACH LOADING'},
293
                        ],
294
                    },
295
                    {
296
                        name: 'NRST',
297
                        objects: [
298
                            {text: 'NEAREST AIRPORTS'},
299
                            {text: 'NEAREST INTERSECTIONS'},
300
                            {text: 'NEAREST NDB'},
301
                            {text: 'NEAREST VOR'},
302
                            {text: 'NEAREST USER WAYPOINTS'},
303
                            {text: 'NEAREST FREQUENCIES'},
304
                            {text: 'NEAREST AIRSPACES'},
305
                        ],
306
                    },
307
                ];
fix MFD page selection syste...
Sébastien MARQUE authored on 2017-04-13
308
                me.setMFDPages();
animation texts EIS + power ...
Sébastien MARQUE authored on 2017-03-19
309
            }
fix COMM display standby fre...
Sébastien MARQUE authored on 2017-04-09
310
            me.updateNAV({auto:'nav', tune: radios.getNode('nav-tune').getValue()});
311
            me.updateCOMM({auto:'comm', tune: radios.getNode('comm-tune').getValue()});
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
312
            me.softkeys_inactivity();
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
313
            me.updateSoftKeys();
commit initial
Sébastien MARQUE authored on 2017-03-07
314
            me.progress.removeAllChildren();
315
            me.progress = nil;
316
            me.showInitProgress = nil;
317
            me._showInitProgress = nil;
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
318
            zkv.removeChild(me.device.role ~ 'init', 0);
commit initial
Sébastien MARQUE authored on 2017-03-07
319
        }
320
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
321
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
322

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
323
    showInitProgress : func (name) {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
324
#{{{
commit initial
Sébastien MARQUE authored on 2017-03-07
325
        me.progress = me.display.createGroup();
326
        me.progress.show();
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
327
        me.progress.createChild("text", name ~ " title")
commit initial
Sébastien MARQUE authored on 2017-03-07
328
            .setTranslation(512, 384)
329
            .setAlignment("center-center")
330
            .setFont("LiberationFonts/LiberationSans-Italic.ttf")
331
            .setFontSize(64, 1)
332
            .setColor(1,1,1)
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
333
            .setText("ZKV1000 " ~ name ~ " init");
commit initial
Sébastien MARQUE authored on 2017-03-07
334

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

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
337
        me._showInitProgress(me.progress.createChild("text", name ~ "progress")
commit initial
Sébastien MARQUE authored on 2017-03-07
338
            .setTranslation(512, 484)
339
            .setAlignment("center-center")
340
            .setFont("LiberationFonts/LiberationSans-Bold.ttf")
341
            .setFontSize(128, 1)
342
            .setColor(1,0,0), '.');
343
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
344
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
345

            
some added comments
Sébastien MARQUE authored on 2017-03-18
346
    colors : {
347
# set of predefined colors {{{
348
        green : [0, 1, 0],
349
        white : [1, 1, 1],
350
        black : [0, 0, 0],
351
        lightblue : [0, 1, 1],
352
        darkblue : [0, 0, 1],
353
        red : [1, 0, 0],
adds CDI
Sébastien MARQUE authored on 2017-03-18
354
        magenta : [1, 0, 1],
some added comments
Sébastien MARQUE authored on 2017-03-18
355
    },
356
#}}}
357

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

            
416
    clips : {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
417
#{{{
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
418
        PitchScale   : "rect(70,664,370,256)",
419
        SpeedLint1   : "rect(252,226,318,204)",
420
        SpeedTape    : "rect(115,239,455,156)",
421
        LintAlt      : "rect(115,808,455,704)",
animation ALT
Sébastien MARQUE authored on 2017-03-11
422
        AltLint00011 : "rect(252,804,318,771)",
AI disponible
Sébastien MARQUE authored on 2017-03-10
423
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
424
#}}}
AI disponible
Sébastien MARQUE authored on 2017-03-10
425

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

            
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
470
    softkeys_inactivity : func {
471
# automagically back to previous level after some delay {{{
472
        me.timers2.softkeys_inactivity = maketimer (
473
            me.softkeys_inactivity_delay,
474
            func {
475
                pop(me.device.softkeys.path);
476
                me.updateSoftKeys();
477
            }, me);
478
        me.timers2.softkeys_inactivity.singleShot = 1;
479
    },
480
#}}}
481

            
add softkeys colors
Sébastien MARQUE authored on 2017-03-21
482
    setSoftKeyColor : func (n, active, alert = 0) {
483
# set colors for active softkeys {{{
484
        var sftk = sprintf('SoftKey%02i-', n);
485
        if (active) {
486
            var bg = alert ? 1 : 0.5;
487
            me.screenElements[sftk ~ 'bg']
488
                .setColorFill(bg,bg,bg);
489
            me.screenElements[sftk ~ 'text']
490
                .setColor(0,0,0);
491
        }
492
        else {
493
            me.screenElements[sftk ~ 'bg']
494
                .setColorFill(0,0,0);
495
            me.screenElements[sftk ~ 'text']
496
                .setColor(1,1,1);
497
        }
498
    },
499
#}}}
500

            
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
501
    updateSoftKeys : func {
502
# update SoftKeys boxes {{{
503
        # on PFD the last boxes are always BACK and ALERTS
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
504
        if (me.device.role == 'PFD') {
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
505
            me.screenElements[sprintf("SoftKey%02i-text", 11)]
506
                .setText('ALERTS');
507
            if (size(me.device.softkeys.path) != 0)
508
                me.screenElements[sprintf("SoftKey%02i-text", 10)]
509
                    .setText('BACK');
510
        }
511

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
512
        var path = keyMap[me.device.role];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
513
        var pathid = '';
514
        foreach (var p; me.device.softkeys.path) {
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
515
            path = path[p];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
516
            pathid ~= p;
517
        }
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
518

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

            
549
        if (size(me.device.softkeys.path))
550
            me.timers2.softkeys_inactivity.restart(me.softkeys_inactivity_delay);
551
        else
552
            me.timers2.softkeys_inactivity.stop();
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
553
    },
554
#}}}
555

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

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
576
    updateVSI: func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
577
# animate VSI {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
578
        var vsi = data.vsi;
animation VSI
Sébastien MARQUE authored on 2017-03-10
579
        me.screenElements.VSIText
580
            .setText(num(math.round(vsi, 10)));
581
        if (vsi > 4500)
582
            vsi = 4500;
583
        elsif (vsi < -4500)
584
            vsi = -4500;
585
        me.screenElements.VSI
586
            .setTranslation(0, vsi * -0.03465);
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
587
        settimer(func me.updateVSI(), 0.1);
animation VSI
Sébastien MARQUE authored on 2017-03-10
588
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
589
#}}}
animation IAS
Sébastien MARQUE authored on 2017-03-10
590

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

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

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
641
    updateTAS: func {
642
# updates the True Airspeed and GroundSpeed indicators {{{
643
        me.screenElements['TAS-text']
644
            .setText(sprintf('%iKT', getprop('/instrumentation/airspeed-indicator/true-speed-kt')));
645
        me.screenElements['GSPD-text']
646
            .setText(sprintf('%iKT', getprop('/velocities/groundspeed-kt')));
647
        settimer(func me.updateTAS(), 0.5);
648
    },
649
#}}}
650

            
651
    updateALT: func () {
652
# animates the altitude lint (PFD) {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
653
        var alt = data.alt;
animation ALT
Sébastien MARQUE authored on 2017-03-11
654
        if (alt < 0)
655
            me.screenElements.Alt11100
656
                .setText(sprintf("% 3i",math.ceil(alt/100)));
657
        elsif (alt < 100)
658
            me.screenElements.Alt11100
659
                .setText('');
660
        else
661
            me.screenElements.Alt11100
662
                .setText(sprintf("% 3i",math.floor(alt/100)));
663
        me.screenElements.AltLint00011
664
            .setTranslation(0,math.fmod(alt,100) * 1.24);
665

            
666
        # From Farmin/G1000 http://wiki.flightgear.org/Project_Farmin/FG1000
667
        if (alt> -1000 and alt< 1000000) {
668
            var Offset10 = 0;
669
            var Offset100 = 0;
670
            var Offset1000 = 0;
671
            if (alt< 0) {
672
                var Ne = 1;
673
                var alt= -alt;
674
            }
675
            else
676
                var Ne = 0;
677

            
678
            var Alt10       = math.mod(alt,100);
679
            var Alt100      = int(math.mod(alt/100,10));
680
            var Alt1000     = int(math.mod(alt/1000,10));
681
            var Alt10000    = int(math.mod(alt/10000,10));
682
            var Alt20       = math.mod(Alt10,20)/20;
683
            if (Alt10 >= 80)
684
                var Alt100 += Alt20;
685

            
686
            if (Alt10 >= 80 and Alt100 >= 9)
687
                var Alt1000 += Alt20;
688

            
689
            if (Alt10 >= 80 and Alt100 >= 9 and Alt1000 >= 9)
690
                var Alt10000 += Alt20;
691

            
692
            if (alt> 100)
693
                var Offset10 = 100;
694

            
695
            if (alt> 1000)
696
                var Offset100 = 10;
697

            
698
            if (alt> 10000)
699
                var Offset1000 = 10;
700

            
701
            if (!Ne) {
702
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*0.57375);
703
                var altCentral = (int(alt/100)*100);
704
            }
705
            elsif (Ne) {
706
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*-0.57375);
707
                var altCentral = -(int(alt/100)*100);
708
            }
709
            me.screenElements["AltBigC"].setText("");
710
            me.screenElements["AltSmallC"].setText("");
711
            for (var place = 1; place <= 6; place += 1) {
712
                var altUP = altCentral + (place*100);
713
                var offset = -30.078;
714
                if (altUP < 0) {
715
                    var altUP = -altUP;
716
                    var prefix = "-";
717
                    var offset += 15.039;
718
                }
719
                else
720
                    var prefix = "";
721

            
722
                if (altUP == 0) {
723
                    var AltBigUP    = "";
724
                    var AltSmallUP  = "0";
725

            
726
                }
727
                elsif (math.mod(altUP,500) == 0 and altUP != 0) {
728
                    var AltBigUP    = sprintf(prefix~"%1d", altUP);
729
                    var AltSmallUP  = "";
730
                }
731
                elsif (altUP < 1000 and (math.mod(altUP,500))) {
732
                    var AltBigUP    = "";
733
                    var AltSmallUP  = sprintf(prefix~"%1d", int(math.mod(altUP,1000)));
734
                    var offset = -30.078;
735
                }
736
                elsif ((altUP < 10000) and (altUP >= 1000) and (math.mod(altUP,500))) {
737
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
738
                    var AltSmallUP  = sprintf("%1d", int(math.mod(altUP,1000)));
739
                    var offset += 15.039;
740
                }
741
                else {
742
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
743
                    var mod = int(math.mod(altUP,1000));
744
                    var AltSmallUP  = sprintf("%1d", mod);
745
                    var offset += 30.078;
746
                }
747

            
748
                me.screenElements["AltBigU"~place].setText(AltBigUP);
749
                me.screenElements["AltSmallU"~place].setText(AltSmallUP);
750
                me.screenElements["AltSmallU"~place].setTranslation(offset,0);
751
                var altDOWN = altCentral - (place*100);
752
                var offset = -30.078;
753
                if (altDOWN < 0) {
754
                    var altDOWN = -altDOWN;
755
                    var prefix = "-";
756
                    var offset += 15.039;
757
                }
758
                else
759
                    var prefix = "";
760

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

            
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
807
    updateBARO : func () {
808
# update BARO widget {{{
809
        var fmt = me._baro_unit == 'inhg' ? '%.2f%s' : '%i%s';
810
        me.screenElements['BARO-text']
811
            .setText(sprintf(fmt,
812
                        getprop('/instrumentation/altimeter/setting-' ~ me._baro_unit),
813
                        me._baro_unit == 'inhg' ? 'in' : 'hPa')
814
                );
815
    },
816
    _baro_unit : 'inhg',
817
#}}}
818

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
819
    updateHSI : func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
820
# rotates the compass (PFD) {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
821
        var hdg = data.hdg;
animation HSI
Sébastien MARQUE authored on 2017-03-11
822
        me.screenElements.Rose
823
            .setRotation(-hdg * D2R);
824
        me.screenElements['HDG-text']
825
            .setText(sprintf("%03u°", hdg));
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
826
        settimer(func me.updateHSI(), 0.1);
animation HSI
Sébastien MARQUE authored on 2017-03-11
827
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
828
#}}}
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
829

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

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

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

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

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

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

            
1050
    updateCOMM: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
1051
# update COMM radios display upper right (PFD/MFD){{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1052
        arg[0]._r = 'comm';
1053
        me._updateRadio(arg[0]);
1054
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
1055
#}}}
anime time display
Sébastien MARQUE authored on 2017-03-13
1056

            
1057
    updateTIME : func {
1058
# updates the displayed time botoom left {{{
1059
        me.screenElements['TIME-text']
1060
            .setText(getprop('/sim/time/gmt-string'));
1061
        settimer(func me.updateTIME(), 1);
1062
    },
1063
#}}}
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1064

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

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1102
    updateOAT : func {
1103
# update OAT display on normal and reversionnary modes (every 3s) {{{
1104
        var tmp = getprop('/environment/temperature-deg' ~ me._oat_unit);
1105
        me.screenElements['OAT-text']
1106
            .setText(sprintf((abs(tmp) < 10) ? "%.1f %s" : "%i %s", tmp, (me._oat_unit == 'c') ? '°C' : 'F'));
1107
        settimer(func me.updateOAT(), 3);
1108
    },
1109
    _oat_unit : 'c',
1110
#}}}
1111

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

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

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

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

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

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

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