zkv1000 / Nasal / display.nas /
Newer Older
1341 lines | 50.532kb
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

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
26
        if (device.role == 'MFD') {
adds Map on MFD
Sébastien MARQUE authored on 2017-03-20
27
            m.MFDMapTiles = MapTiles.new(m.display);
implements the ND from Extra...
Sébastien MARQUE authored on 2017-04-17
28
            m.MFDMapNavaids = PositionedLayer.new(m.display);
path and relpath to zkv1000 ...
Sébastien MARQUE authored on 2017-04-17
29
            var eis_dir = data.zkv1000_dir ~ 'Nasal/EIS/';
EIS can be aircraft specific
Sébastien MARQUE authored on 2017-04-04
30
            var eis_type = getprop('/instrumentation/zkv1000/eis/type');
31
            if (eis_type == nil or
32
                    (io.stat(eis_dir ~ eis_type ~ '.nas') == nil
33
                     and print(eis_type ~ ' not found')))
34
                eis_type = 'none';
35
            io.load_nasal(eis_dir ~ eis_type ~ '.nas', 'zkv1000');
path and relpath to zkv1000 ...
Sébastien MARQUE authored on 2017-04-17
36
            io.load_nasal(data.zkv1000_dir ~ 'Nasal/MFD.pages.nas', 'zkv1000');
adds Map on MFD
Sébastien MARQUE authored on 2017-03-20
37
        }
38

            
commit initial
Sébastien MARQUE authored on 2017-03-07
39
        return m;
40
    },
add new vim folds
Sébastien MARQUE authored on 2017-03-15
41
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
42

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

            
46
    timerTrigger : func {
47
        var now = systime();
48
        foreach (var id; keys(me.timers)) {
49
            if (me.timers[id] < now) {
50
                me.screenElements[id].hide();
51
                delete(me.timers, id);
52
            }
53
        }
54
        settimer(func me.timerTrigger(), 1);
55
    },
56

            
57
    addTimer : func (duration, element) {
58
        if (typeof(element) == 'scalar')
59
            element = [ element ];
60
        var end = systime() + duration;
61
        foreach (var e; element)
62
            me.timers[e] = end;
63
    },
add new vim folds
Sébastien MARQUE authored on 2017-03-15
64
#}}}
ajoute un timer pour cacher ...
Sébastien MARQUE authored on 2017-03-13
65

            
commit initial
Sébastien MARQUE authored on 2017-03-07
66
    loadsvg : func () {
67
        me.screen = me.display.createGroup();
68
        me.screen.hide();
path and relpath to zkv1000 ...
Sébastien MARQUE authored on 2017-04-17
69
        canvas.parsesvg(me.screen, data.zkv1000_reldir ~ 'Systems/screen.svg');
commit initial
Sébastien MARQUE authored on 2017-03-07
70
    },
71

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

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

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

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

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

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
301
    showInitProgress : func (name) {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
302
#{{{
commit initial
Sébastien MARQUE authored on 2017-03-07
303
        me.progress = me.display.createGroup();
304
        me.progress.show();
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
305
        me.progress.createChild("text", name ~ " title")
commit initial
Sébastien MARQUE authored on 2017-03-07
306
            .setTranslation(512, 384)
307
            .setAlignment("center-center")
308
            .setFont("LiberationFonts/LiberationSans-Italic.ttf")
309
            .setFontSize(64, 1)
310
            .setColor(1,1,1)
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
311
            .setText("ZKV1000 " ~ name ~ " init");
commit initial
Sébastien MARQUE authored on 2017-03-07
312

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

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
315
        me._showInitProgress(me.progress.createChild("text", name ~ "progress")
commit initial
Sébastien MARQUE authored on 2017-03-07
316
            .setTranslation(512, 484)
317
            .setAlignment("center-center")
318
            .setFont("LiberationFonts/LiberationSans-Bold.ttf")
319
            .setFontSize(128, 1)
320
            .setColor(1,0,0), '.');
321
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
322
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
323

            
some added comments
Sébastien MARQUE authored on 2017-03-18
324
    colors : {
325
# set of predefined colors {{{
326
        green : [0, 1, 0],
327
        white : [1, 1, 1],
328
        black : [0, 0, 0],
329
        lightblue : [0, 1, 1],
330
        darkblue : [0, 0, 1],
331
        red : [1, 0, 0],
adds CDI
Sébastien MARQUE authored on 2017-03-18
332
        magenta : [1, 0, 1],
some added comments
Sébastien MARQUE authored on 2017-03-18
333
    },
334
#}}}
335

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

            
394
    clips : {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
395
#{{{
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
396
        PitchScale   : "rect(70,664,370,256)",
397
        SpeedLint1   : "rect(252,226,318,204)",
398
        SpeedTape    : "rect(115,239,455,156)",
399
        LintAlt      : "rect(115,808,455,704)",
animation ALT
Sébastien MARQUE authored on 2017-03-11
400
        AltLint00011 : "rect(252,804,318,771)",
AI disponible
Sébastien MARQUE authored on 2017-03-10
401
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
402
#}}}
AI disponible
Sébastien MARQUE authored on 2017-03-10
403

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

            
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
448
    softkeys_inactivity : func {
449
# automagically back to previous level after some delay {{{
450
        me.timers2.softkeys_inactivity = maketimer (
451
            me.softkeys_inactivity_delay,
452
            func {
453
                pop(me.device.softkeys.path);
454
                me.updateSoftKeys();
455
            }, me);
456
        me.timers2.softkeys_inactivity.singleShot = 1;
457
    },
458
#}}}
459

            
add softkeys colors
Sébastien MARQUE authored on 2017-03-21
460
    setSoftKeyColor : func (n, active, alert = 0) {
461
# set colors for active softkeys {{{
462
        var sftk = sprintf('SoftKey%02i-', n);
463
        if (active) {
464
            var bg = alert ? 1 : 0.5;
465
            me.screenElements[sftk ~ 'bg']
466
                .setColorFill(bg,bg,bg);
467
            me.screenElements[sftk ~ 'text']
468
                .setColor(0,0,0);
469
        }
470
        else {
471
            me.screenElements[sftk ~ 'bg']
472
                .setColorFill(0,0,0);
473
            me.screenElements[sftk ~ 'text']
474
                .setColor(1,1,1);
475
        }
476
    },
477
#}}}
478

            
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
479
    updateSoftKeys : func {
480
# update SoftKeys boxes {{{
481
        # on PFD the last boxes are always BACK and ALERTS
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
482
        if (me.device.role == 'PFD') {
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
483
            me.screenElements[sprintf("SoftKey%02i-text", 11)]
484
                .setText('ALERTS');
485
            if (size(me.device.softkeys.path) != 0)
486
                me.screenElements[sprintf("SoftKey%02i-text", 10)]
487
                    .setText('BACK');
488
        }
489

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
490
        var path = keyMap[me.device.role];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
491
        var pathid = '';
492
        foreach (var p; me.device.softkeys.path) {
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
493
            path = path[p];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
494
            pathid ~= p;
495
        }
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
496

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

            
527
        if (size(me.device.softkeys.path))
528
            me.timers2.softkeys_inactivity.restart(me.softkeys_inactivity_delay);
529
        else
530
            me.timers2.softkeys_inactivity.stop();
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
531
    },
532
#}}}
533

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

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
554
    updateVSI: func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
555
# animate VSI {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
556
        var vsi = data.vsi;
animation VSI
Sébastien MARQUE authored on 2017-03-10
557
        me.screenElements.VSIText
558
            .setText(num(math.round(vsi, 10)));
559
        if (vsi > 4500)
560
            vsi = 4500;
561
        elsif (vsi < -4500)
562
            vsi = -4500;
563
        me.screenElements.VSI
564
            .setTranslation(0, vsi * -0.03465);
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
565
        settimer(func me.updateVSI(), 0.1);
animation VSI
Sébastien MARQUE authored on 2017-03-10
566
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
567
#}}}
animation IAS
Sébastien MARQUE authored on 2017-03-10
568

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

            
trends animation
Sébastien MARQUE authored on 2017-03-13
602
        var now = systime();
603
        # estimated speed in 6s
604
        var Sy = 6 * (ias - me._last_ias_kt) / (now - me._last_ias_s);
605
        if (abs(Sy) > 30)
606
            Sy = 30 * abs(Sy)/Sy; # = -30 or 30
607
        me.screenElements['Airspeed-Trend-Indicator']
608
            .setScale(1,Sy)
609
            .setTranslation(0, -284.5 * (Sy - 1));
610
        me._last_ias_kt = ias;
611
        me._last_ias_s = now;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
612
        settimer(func me.updateIAS(), 0.1);
animation IAS
Sébastien MARQUE authored on 2017-03-10
613
    },
trends animation
Sébastien MARQUE authored on 2017-03-13
614
    _last_ias_kt : 0,
615
    _last_ias_s : systime(),
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
616
    _ias_already_exceeded : 0,
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
617
#}}}
animation ALT
Sébastien MARQUE authored on 2017-03-11
618

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
619
    updateTAS: func {
620
# updates the True Airspeed and GroundSpeed indicators {{{
621
        me.screenElements['TAS-text']
622
            .setText(sprintf('%iKT', getprop('/instrumentation/airspeed-indicator/true-speed-kt')));
623
        me.screenElements['GSPD-text']
624
            .setText(sprintf('%iKT', getprop('/velocities/groundspeed-kt')));
625
        settimer(func me.updateTAS(), 0.5);
626
    },
627
#}}}
628

            
629
    updateALT: func () {
630
# animates the altitude lint (PFD) {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
631
        var alt = data.alt;
animation ALT
Sébastien MARQUE authored on 2017-03-11
632
        if (alt < 0)
633
            me.screenElements.Alt11100
634
                .setText(sprintf("% 3i",math.ceil(alt/100)));
635
        elsif (alt < 100)
636
            me.screenElements.Alt11100
637
                .setText('');
638
        else
639
            me.screenElements.Alt11100
640
                .setText(sprintf("% 3i",math.floor(alt/100)));
641
        me.screenElements.AltLint00011
642
            .setTranslation(0,math.fmod(alt,100) * 1.24);
643

            
644
        # From Farmin/G1000 http://wiki.flightgear.org/Project_Farmin/FG1000
645
        if (alt> -1000 and alt< 1000000) {
646
            var Offset10 = 0;
647
            var Offset100 = 0;
648
            var Offset1000 = 0;
649
            if (alt< 0) {
650
                var Ne = 1;
651
                var alt= -alt;
652
            }
653
            else
654
                var Ne = 0;
655

            
656
            var Alt10       = math.mod(alt,100);
657
            var Alt100      = int(math.mod(alt/100,10));
658
            var Alt1000     = int(math.mod(alt/1000,10));
659
            var Alt10000    = int(math.mod(alt/10000,10));
660
            var Alt20       = math.mod(Alt10,20)/20;
661
            if (Alt10 >= 80)
662
                var Alt100 += Alt20;
663

            
664
            if (Alt10 >= 80 and Alt100 >= 9)
665
                var Alt1000 += Alt20;
666

            
667
            if (Alt10 >= 80 and Alt100 >= 9 and Alt1000 >= 9)
668
                var Alt10000 += Alt20;
669

            
670
            if (alt> 100)
671
                var Offset10 = 100;
672

            
673
            if (alt> 1000)
674
                var Offset100 = 10;
675

            
676
            if (alt> 10000)
677
                var Offset1000 = 10;
678

            
679
            if (!Ne) {
680
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*0.57375);
681
                var altCentral = (int(alt/100)*100);
682
            }
683
            elsif (Ne) {
684
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*-0.57375);
685
                var altCentral = -(int(alt/100)*100);
686
            }
687
            me.screenElements["AltBigC"].setText("");
688
            me.screenElements["AltSmallC"].setText("");
689
            for (var place = 1; place <= 6; place += 1) {
690
                var altUP = altCentral + (place*100);
691
                var offset = -30.078;
692
                if (altUP < 0) {
693
                    var altUP = -altUP;
694
                    var prefix = "-";
695
                    var offset += 15.039;
696
                }
697
                else
698
                    var prefix = "";
699

            
700
                if (altUP == 0) {
701
                    var AltBigUP    = "";
702
                    var AltSmallUP  = "0";
703

            
704
                }
705
                elsif (math.mod(altUP,500) == 0 and altUP != 0) {
706
                    var AltBigUP    = sprintf(prefix~"%1d", altUP);
707
                    var AltSmallUP  = "";
708
                }
709
                elsif (altUP < 1000 and (math.mod(altUP,500))) {
710
                    var AltBigUP    = "";
711
                    var AltSmallUP  = sprintf(prefix~"%1d", int(math.mod(altUP,1000)));
712
                    var offset = -30.078;
713
                }
714
                elsif ((altUP < 10000) and (altUP >= 1000) and (math.mod(altUP,500))) {
715
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
716
                    var AltSmallUP  = sprintf("%1d", int(math.mod(altUP,1000)));
717
                    var offset += 15.039;
718
                }
719
                else {
720
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
721
                    var mod = int(math.mod(altUP,1000));
722
                    var AltSmallUP  = sprintf("%1d", mod);
723
                    var offset += 30.078;
724
                }
725

            
726
                me.screenElements["AltBigU"~place].setText(AltBigUP);
727
                me.screenElements["AltSmallU"~place].setText(AltSmallUP);
728
                me.screenElements["AltSmallU"~place].setTranslation(offset,0);
729
                var altDOWN = altCentral - (place*100);
730
                var offset = -30.078;
731
                if (altDOWN < 0) {
732
                    var altDOWN = -altDOWN;
733
                    var prefix = "-";
734
                    var offset += 15.039;
735
                }
736
                else
737
                    var prefix = "";
738

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

            
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
785
    updateBARO : func () {
786
# update BARO widget {{{
787
        var fmt = me._baro_unit == 'inhg' ? '%.2f%s' : '%i%s';
788
        me.screenElements['BARO-text']
789
            .setText(sprintf(fmt,
790
                        getprop('/instrumentation/altimeter/setting-' ~ me._baro_unit),
791
                        me._baro_unit == 'inhg' ? 'in' : 'hPa')
792
                );
793
    },
794
    _baro_unit : 'inhg',
795
#}}}
796

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
797
    updateHSI : func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
798
# rotates the compass (PFD) {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
799
        var hdg = data.hdg;
animation HSI
Sébastien MARQUE authored on 2017-03-11
800
        me.screenElements.Rose
801
            .setRotation(-hdg * D2R);
802
        me.screenElements['HDG-text']
803
            .setText(sprintf("%03u°", hdg));
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
804
        settimer(func me.updateHSI(), 0.1);
animation HSI
Sébastien MARQUE authored on 2017-03-11
805
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
806
#}}}
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
807

            
removes unecessary listeners
Sébastien MARQUE authored on 2017-04-08
808
    updateHDG : func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
809
# moves the heading bug and display heading-deg for 3 seconds (PFD) {{{
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
810
        if (me.device.role == 'MFD')
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
811
            return;
removes unecessary listeners
Sébastien MARQUE authored on 2017-04-08
812
        var hdg = getprop('/instrumentation/zkv1000/afcs/heading-bug-deg');
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
813
        me.screenElements['Heading-bug']
814
            .setRotation(hdg * D2R);
815
        me.screenElements['SelectedHDG-bg']
816
            .show();
817
        me.screenElements['SelectedHDG-bgtext']
818
            .show();
819
        me.screenElements['SelectedHDG-text']
820
            .setText(sprintf('%03d°%s', hdg, ''))
821
            .show();
822
        me.addTimer(3, ['SelectedHDG-text', 'SelectedHDG-bgtext', 'SelectedHDG-bg']);
823
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
824
#}}}
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
825

            
adds CDI
Sébastien MARQUE authored on 2017-03-18
826
    updateCRS : func () {
anime CRS
Sébastien MARQUE authored on 2017-03-13
827
# TODO: update display for NAV/GPS/BRG courses {{{
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
828
        if (me.device.role == 'MFD')
anime CRS
Sébastien MARQUE authored on 2017-03-13
829
            return;
adds CDI
Sébastien MARQUE authored on 2017-03-18
830
        var source = getprop('/instrumentation/zkv1000/cdi/source');
831
        if (source == 'OFF')
832
            return;
833
        var crs = getprop('/instrumentation/zkv1000/cdi/course');
834
        if (crs == nil)
835
            return;
anime CRS
Sébastien MARQUE authored on 2017-03-13
836
        me.screenElements['SelectedCRS-bg']
837
            .show();
838
        me.screenElements['SelectedCRS-bgtext']
839
            .show();
840
        me.screenElements['SelectedCRS-text']
841
            .setText(sprintf('%03d°%s', crs, ''))
adds CDI
Sébastien MARQUE authored on 2017-03-18
842
            .setColor(source == 'GPS' ? me.colors.magenta : me.colors.green)
anime CRS
Sébastien MARQUE authored on 2017-03-13
843
            .show();
844
        me.addTimer(3, ['SelectedCRS-text', 'SelectedCRS-bgtext', 'SelectedCRS-bg']);
845
    },
846
#}}}
847

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

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

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

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

            
1028
    updateCOMM: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
1029
# update COMM radios display upper right (PFD/MFD){{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1030
        arg[0]._r = 'comm';
1031
        me._updateRadio(arg[0]);
1032
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
1033
#}}}
anime time display
Sébastien MARQUE authored on 2017-03-13
1034

            
1035
    updateTIME : func {
1036
# updates the displayed time botoom left {{{
1037
        me.screenElements['TIME-text']
1038
            .setText(getprop('/sim/time/gmt-string'));
1039
        settimer(func me.updateTIME(), 1);
1040
    },
1041
#}}}
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1042

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

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1080
    updateOAT : func {
1081
# update OAT display on normal and reversionnary modes (every 3s) {{{
1082
        var tmp = getprop('/environment/temperature-deg' ~ me._oat_unit);
1083
        me.screenElements['OAT-text']
1084
            .setText(sprintf((abs(tmp) < 10) ? "%.1f %s" : "%i %s", tmp, (me._oat_unit == 'c') ? '°C' : 'F'));
1085
        settimer(func me.updateOAT(), 3);
1086
    },
1087
    _oat_unit : 'c',
1088
#}}}
1089

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

            
adds AOA display
Sébastien MARQUE authored on 2017-04-15
1153
    updateAOA : func {
1154
# update Angle Of Attack {{{
1155
        if (me.device.data.aoa == 0)
1156
            return;
1157
        var color = [1,1,1];
1158
        var norm = data.aoa / data['stall-aoa'];
nicer AOA display
Sébastien MARQUE authored on 2017-04-16
1159
        me.screenElements['AOA-text']
1160
            .setText(sprintf('% .1f', norm));
adds AOA display
Sébastien MARQUE authored on 2017-04-15
1161
        if (norm > 1) norm = 1;
1162
        if (norm > 0.9)
1163
            color = [1,0,0];
1164
        elsif (norm > 0.7)
1165
            color = [1,1,0];
1166
        elsif (norm < 0) {
1167
            norm = 0;
1168
            color = [1,0,0];
1169
        }
1170
        me.screenElements['AOA-needle']
1171
            .setRotation(-norm * math.pi)
nicer AOA display
Sébastien MARQUE authored on 2017-04-16
1172
            .setColorFill(color);
1173
        me.screenElements['AOA-text']
adds AOA display
Sébastien MARQUE authored on 2017-04-15
1174
            .setColor(color);
1175
        settimer(func me.updateAOA(), 0.1);
1176
    },
1177
# }}}
1178

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

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

            
1217
                if (info.pointer)
1218
                    me.screenElements[el ~ '-pointer']
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
1219
                        .setRotation(-info.hdg - data.hdg * D2R)
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1220
                        .show();
1221
                else
1222
                    me.screenElements[el ~ '-pointer']
1223
                        .hide();
1224
                me.screenElements[el ~ '-SRC-text']
1225
                    .setText(dev);
1226
                me.screenElements[el ~ '-DST-text']
1227
                    .setText(info.dst);
1228
                me.screenElements[el ~ '-WPID-text']
1229
                    .setText(info.id);
1230
                me.screenElements['BRG' ~ brg]
1231
                    .show();
1232
            }
1233
            else {
1234
                me.screenElements['BRG' ~ brg]
1235
                    .hide();
1236
            }
1237
        }
colorize BRG1/2 when needed,...
Sébastien MARQUE authored on 2017-03-21
1238
        settimer(func me.updateBRG(), 0.5);
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1239
    },
some added comments
Sébastien MARQUE authored on 2017-03-18
1240
#}}}
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
1241

            
adds OMI to PFD
Sébastien MARQUE authored on 2017-03-23
1242
    updateOMI : func {
1243
# display marker baecon Outer, Middle, Inner {{{
1244
        var marker = nil;
1245
        foreach (var m; ['outer', 'middle', 'inner'])
1246
            if (getprop('/instrumentation/marker-beacon/' ~ m)) {
1247
                marker = m;
1248
                me.screenElements['OMI']
1249
                    .show();
1250
                break;
1251
            }
1252
        if (marker != nil) {
1253
            me.screenElements['MarkerText']
1254
                .setText(me._omi_data[marker].t)
1255
                .show();
1256
            me.screenElements['MarkerBG']
1257
                .setColorFill(me._omi_data[marker].bg)
1258
                .show();
1259
        }
1260
        else
1261
            me.screenElements['OMI']
1262
                .hide();
1263
        settimer(func me.updateOMI(), 1);
1264
    },
1265
    _omi_data : {
1266
        'outer':  {t: 'O', bg: [0,1,1]},
1267
        'middle': {t: 'M', bg: [1,1,1]},
1268
        'inner':  {t: 'I', bg: [1,1,0]},
1269
    },
1270
#}}}
animation texts EIS + power ...
Sébastien MARQUE authored on 2017-03-19
1271
};
1272

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