zkv1000 / Nasal / display.nas /
Newer Older
1029 lines | 37.876kb
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 = {
pass device pointer to displ...
Sébastien MARQUE authored on 2017-03-14
3
    new: func(device, role) {
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({
8
                "name"      : role,
9
                "size"      : [1024, 768],
10
                "view"      : [1024, 768],
11
                "mipmapping": 1
12
        });
13
        m.display.addPlacement({
14
                "node": "Screen",
15
                "parent": role
16
        });
17
        m.display.setColorBackground(0,0,0);
18
        m.role = 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

            
22
        return m;
23
    },
add new vim folds
Sébastien MARQUE authored on 2017-03-15
24
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
25

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

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

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

            
commit initial
Sébastien MARQUE authored on 2017-03-07
49
    loadsvg : func () {
50
        me.screen = me.display.createGroup();
51
        me.screen.hide();
52
        canvas.parsesvg(me.screen, "Aircraft/Instruments-3d/zkv1000/Systems/screen.svg");
53
    },
54

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

            
84
            for (var k = 0; k < 12; k += 1)
85
                append(groups.text, sprintf("SoftKey%02i-text", k));
86

            
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
87
            if (me.role == 'PFD') {
88
                append(groups.show,
commit initial
Sébastien MARQUE authored on 2017-03-07
89
                    'XPDR-TIME', 
AI disponible
Sébastien MARQUE authored on 2017-03-10
90
                    'FlightInstruments',
91
                    'Horizon',
AI disponible, avec bankPoin...
Sébastien MARQUE authored on 2017-03-10
92
                    'bankPointer',
animation VSI
Sébastien MARQUE authored on 2017-03-10
93
                    'VSI',
animation HSI
Sébastien MARQUE authored on 2017-03-11
94
                    'Rose',
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
95
                    'Heading-bug',
96
                    'PFD-Widgets',
trends animation
Sébastien MARQUE authored on 2017-03-13
97
                    'Trends',
98
                    'Airspeed-Trend-Indicator',
99
                    'Altitude-Trend-Indicator',
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
100
                    'OAT',
101
                    'IAS-bg',
102
                    'TAS',
103
                    'GSPD',
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
104
                );
105
                append(groups.hide,
adds EIS
Sébastien MARQUE authored on 2017-03-18
106
                    'EIS',
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
107
                    'CDI',
animation HSI
Sébastien MARQUE authored on 2017-03-11
108
                    'NAV1-pointer',
109
                    'NAV2-pointer',
110
                    'GPS-pointer',
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
111
                    'BRG1-pointer',
112
                    'BRG2-pointer',
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
113
                    'SelectedHDG-bg',
114
                    'SelectedHDG-bgtext',
115
                    'SelectedHDG-text',
116
                    'SelectedCRS-bg',
117
                    'SelectedCRS-bgtext',
118
                    'SelectedCRS-text',
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
119
                    'SelectedAlt-bug',
120
                    'SelectedAlt-top',
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
121
                    'TAS',
122
                    'GSPD',
123
                    'BARO',
124
                    'WindData',
125
                    'Reversionnary',
126
                    'Annunciation',
127
                    'Comparator',
128
                    'BRG1',
129
                    'BRG2',
130
                    'DME1',
131
                    'PFD-Map',
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
132
                    'PFD-Multilines',
improves WindData display
Sébastien MARQUE authored on 2017-03-16
133
                    'WindData', 'WindData-OPTN1', 'WindData-OPTN2', 'WindData-OPTN1-HDG', 'WindData-OPTN2-symbol', 'WindData-OPTN2-headwind', 'WindData-OPTN2-crosswind', 'WindData-NODATA',
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
134
                );
135
                append(groups.clip,
animation IAS
Sébastien MARQUE authored on 2017-03-10
136
                    'SpeedLint1',
animation ALT
Sébastien MARQUE authored on 2017-03-11
137
                    'SpeedTape',
138
                    'LintAlt',
139
                    'AltLint00011'
140
                );
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
141
                append(groups.text,
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
142
                    'SelectedAlt-text',
143
                    'TAS-text',
144
                    'GSPD-text',
anime time display
Sébastien MARQUE authored on 2017-03-13
145
                    'TIME-text',
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
146
                    'OAT-text',
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
147
                    'VSIText',
148
                    'Speed110',
149
                    'Alt11100',
150
                    'HDG-text',
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
151
                    'BRG1-pointer', 'BRG1-SRC-text', 'BRG1-DST-text', 'BRG1-WPID-text',
152
                    'BRG2-pointer', 'BRG2-SRC-text', 'BRG2-DST-text', 'BRG2-WPID-text',
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
153
                    'WindData-OPTN1-HDG-text', 'WindData-OPTN1-SPD-text',
154
                    'WindData-OPTN2-crosswind-text', 'WindData-OPTN2-headwind-text',
adds transponder
Sébastien MARQUE authored on 2017-03-17
155
                    '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
156
                    'AltBigC', 'AltSmallC'
157
                );
158
                for (var place = 1; place <= 6; place +=1) {
159
                    append(groups.text,
160
                        'AltBigU' ~ place,
161
                        'AltSmallU' ~ place,
162
                        'AltBigD' ~ place,
163
                        'AltSmallD' ~ place
164
                    );
165
                }
animation ALT
Sébastien MARQUE authored on 2017-03-11
166
            }
adds EIS
Sébastien MARQUE authored on 2017-03-18
167
            else {
168
                append(groups.show, 'EIS');
169
            }
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
170

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

            
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
173
            if (me.role == 'PFD') {
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
174
                me.update();
175
                me.updateAI();
176
                me.updateVSI();
177
                me.updateIAS();
178
                me.updateALT();
179
                me.updateHSI();
anime time display
Sébastien MARQUE authored on 2017-03-13
180
                me.updateTIME();
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
181
                me.updateOAT();
182
                me.updateTAS();
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
183
                me.updateBRG();
adds transponder
Sébastien MARQUE authored on 2017-03-17
184
                me.updateXPDR();
ajoute un timer pour cacher ...
Sébastien MARQUE authored on 2017-03-13
185
                me.timerTrigger();
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
186
            }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
187
            me._updateRadio({auto:'nav'});
188
            me._updateRadio({auto:'comm'});
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
189
            me.updateSoftKeys();
commit initial
Sébastien MARQUE authored on 2017-03-07
190
            me.progress.removeAllChildren();
191
            me.progress = nil;
192
            me.showInitProgress = nil;
193
            me._showInitProgress = nil;
194
            zkv.removeChild(me.role ~ 'init');
195
        }
196
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
197
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
198

            
199
    showInitProgress : func (role) {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
200
#{{{
commit initial
Sébastien MARQUE authored on 2017-03-07
201
        me.progress = me.display.createGroup();
202
        me.progress.show();
203
        me.progress.createChild("text", role ~ " title")
204
            .setTranslation(512, 384)
205
            .setAlignment("center-center")
206
            .setFont("LiberationFonts/LiberationSans-Italic.ttf")
207
            .setFontSize(64, 1)
208
            .setColor(1,1,1)
209
            .setText("ZKV1000 " ~ role ~ " init");
210

            
211
        zkv.getNode(role ~ 'init',1).setIntValue(1);
212

            
213
        me._showInitProgress(me.progress.createChild("text", role ~ "progress")
214
            .setTranslation(512, 484)
215
            .setAlignment("center-center")
216
            .setFont("LiberationFonts/LiberationSans-Bold.ttf")
217
            .setFontSize(128, 1)
218
            .setColor(1,0,0), '.');
219
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
220
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
221

            
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
222
    loadGroup : func (h) {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
223
#{{{
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
224
        if (typeof(h) != 'hash') {
225
            msg_dbg(sprintf("%s need a hash, but get a %s from %s",
226
                    caller(0)[0],
227
                    typeof(h),
228
                    caller(1)[0]));
229
            return;
commit initial
Sébastien MARQUE authored on 2017-03-07
230
        }
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
231
        var setMethod = func (e, t) {
232
            if (t == 'hide')
233
                me.screenElements[e].hide();
234
            elsif (t == 'show')
235
                me.screenElements[e].show();
AI disponible
Sébastien MARQUE authored on 2017-03-10
236
            elsif (t == 'rot' or t == 'trans') {
237
                if (! contains(me.screenElements[e], t))
238
                    me.screenElements[e][t] = me.screenElements[e].createTransform();
239
            }
240
            elsif (t == 'clip') {
241
                if (contains(me.clips, e))
242
                    me.screenElements[e].set("clip", me.clips[e]);
243
                else
244
                    print('no defined clip for ' ~ e);
245
            }
animation VSI
Sébastien MARQUE authored on 2017-03-10
246
            elsif (t == 'text') {
247
                if (contains(me.texts, e)) {
248
                    if (contains(me.texts[e], 'alignment'))
249
                        me.screenElements[e].setAlignment(me.texts[e].alignment);
250
                    if (contains(me.texts[e], 'default'))
251
                        me.screenElements[e].setText(me.texts[e].default);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
252
                    if (contains(me.texts[e], 'color'))
253
                        me.screenElements[e].setColor(me.texts[e].color);
animation VSI
Sébastien MARQUE authored on 2017-03-10
254
                }
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
255
#                else
256
#                    print('no text format for ' ~ e);
animation VSI
Sébastien MARQUE authored on 2017-03-10
257
            }
commit initial
Sébastien MARQUE authored on 2017-03-07
258
            else
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
259
                print('unknown method ' ~ t);
260
        };
261
        foreach (var todo; keys(h)) {
262
            if (typeof(h[todo]) != 'vector') h[todo] = [ h[todo] ];
263
            foreach (var id; h[todo]) {
264
                if (! contains(me.screenElements, id)) {
265
                    me.screenElements[id] = me.screen.getElementById(id);
266
                    if (me.screenElements[id] != nil)
267
                        setMethod(id, todo);
268
                    else
269
                        print('SVG ID ' ~ id ~ ' not found');
270
                }
271
                else
272
                    setMethod(id, todo);
273
            }
commit initial
Sébastien MARQUE authored on 2017-03-07
274
        }
275
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
276
#}}}
AI disponible
Sébastien MARQUE authored on 2017-03-10
277

            
278
    clips : {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
279
#{{{
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
280
        PitchScale   : "rect(70,664,370,256)",
281
        SpeedLint1   : "rect(252,226,318,204)",
282
        SpeedTape    : "rect(115,239,455,156)",
283
        LintAlt      : "rect(115,808,455,704)",
animation ALT
Sébastien MARQUE authored on 2017-03-11
284
        AltLint00011 : "rect(252,804,318,771)",
AI disponible
Sébastien MARQUE authored on 2017-03-10
285
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
286
#}}}
AI disponible
Sébastien MARQUE authored on 2017-03-10
287

            
animation VSI
Sébastien MARQUE authored on 2017-03-10
288
    texts : {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
289
#{{{
animation VSI
Sébastien MARQUE authored on 2017-03-10
290
        VSIText : {
291
            alignment: "right-bottom", default : num('0'),
292
        },
animation IAS
Sébastien MARQUE authored on 2017-03-10
293
        Speed110 : {
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
294
            alignment : 'left-bottom'
animation IAS
Sébastien MARQUE authored on 2017-03-10
295
        },
animation ALT (2)
Sébastien MARQUE authored on 2017-03-11
296
        Alt11100 : {
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
297
            alignment:'left-bottom'
animation ALT (2)
Sébastien MARQUE authored on 2017-03-11
298
        },
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
299
        "HDG-text" : {
300
            default: '---°'
301
        },
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
302
        'nav1-standby-freq' : {
303
            color: [0, 1, 1],
304
        },
305
        'nav1-id' : {
306
            default: ''
307
        },
308
        'nav2-id' : {
309
            default: ''
310
        },
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
311
        'TAS-text' : {
312
            alignment : 'right-bottom',
313
        },
314
        'GSPD-text' : {
315
            alignment : 'right-bottom',
316
        },
animation VSI
Sébastien MARQUE authored on 2017-03-10
317
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
318
#}}}
animation VSI
Sébastien MARQUE authored on 2017-03-10
319

            
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
320
    updateSoftKeys : func {
321
# update SoftKeys boxes {{{
322
        # grey background code = #353939
323
        # on PFD the last boxes are always BACK and ALERTS
324
        if (me.role == 'PFD') {
325
            me.screenElements[sprintf("SoftKey%02i-text", 11)]
326
                .setText('ALERTS');
327
            if (size(me.device.softkeys.path) != 0)
328
                me.screenElements[sprintf("SoftKey%02i-text", 10)]
329
                    .setText('BACK');
330
        }
331

            
332
        var path = keyMap[me.role];
333
        foreach (var p; me.device.softkeys.path)
334
            path = path[p];
335

            
336
        # feeding with empty menus the first boxes
337
        var start = (contains(path, 'first')) ? path.first : 0;
338
        for (var k = 0; k < start; k+=1) {
339
            me.screenElements[sprintf("SoftKey%02i-text", k)]
340
                .setText('');
341
        }
342
        # filling with the content the next boxes
343
        forindex (var k; path.texts) {
344
            var i = k + start;
345
            me.screenElements[sprintf("SoftKey%02i-text", i)]
346
                .setText(path.texts[k]);
347
        }
348
        # feeding the last boxes with empty string
349
        var end = (me.role == 'PFD') ? 10 : 12;
350
        if (size(path.texts) + start < end) {
351
            start = size(path.texts) + start;
352
            for (var k = start; k < end; k += 1)
353
                me.screenElements[sprintf("SoftKey%02i-text", k)]
354
                    .setText('');
355
        }
356
    },
357
#}}}
358

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
359
    update : func {
360
# updates roll, pitch, VSI, IAS, altitude and HDG {{{
361
        me._updated_roll = getprop('/orientation/roll-deg');
362
        me._updated_pitch = getprop('orientation/pitch-deg');
363
        me._updated_vsi = getprop('/instrumentation/vertical-speed-indicator/indicated-speed-fpm');
364
        me._updated_ias = getprop('/velocities/airspeed-kt');
365
        me._updated_alt = getprop('/instrumentation/altimeter/indicated-altitude-ft');
366
        me._updated_hdg = getprop('/orientation/heading-deg');
367
        settimer(func me.update(), 0.05);
368
     },
369
    _updated_roll : 0,
370
    _updated_pitch : 0,
371
    _updated_vsi : 0,
372
    _updated_ias : 0,
373
    _updated_alt : 0,
374
    _updated_hdg : 0,
375
#}}}
376

            
377
    updateAI: func(){
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
378
#{{{
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
379
        var pitch = me._updated_pitch;
380
        var roll = me._updated_roll;
AI disponible
Sébastien MARQUE authored on 2017-03-10
381
        if (pitch > 80)
382
            pitch = 80;
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
383
        elsif (pitch < -80)
AI disponible
Sébastien MARQUE authored on 2017-03-10
384
            pitch = -80;
385
        me.screenElements.Horizon
386
            .setRotation(-roll * D2R)
387
            .setTranslation(0, pitch * 6.8571428);
AI disponible, avec bankPoin...
Sébastien MARQUE authored on 2017-03-10
388
        me.screenElements.bankPointer
389
            .setRotation(-roll * D2R);
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
390
        settimer(func me.updateAI(), 0.1);
AI disponible
Sébastien MARQUE authored on 2017-03-10
391
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
392
#}}}
animation VSI
Sébastien MARQUE authored on 2017-03-10
393

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
394
    updateVSI: func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
395
# animate VSI {{{
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
396
        var vsi = me._updated_vsi;
animation VSI
Sébastien MARQUE authored on 2017-03-10
397
        me.screenElements.VSIText
398
            .setText(num(math.round(vsi, 10)));
399
        if (vsi > 4500)
400
            vsi = 4500;
401
        elsif (vsi < -4500)
402
            vsi = -4500;
403
        me.screenElements.VSI
404
            .setTranslation(0, vsi * -0.03465);
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
405
        settimer(func me.updateVSI(), 0.1);
animation VSI
Sébastien MARQUE authored on 2017-03-10
406
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
407
#}}}
animation IAS
Sébastien MARQUE authored on 2017-03-10
408

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
409
    updateIAS: func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
410
# animates the IAS lint (PFD) {{{
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
411
        var ias = me._updated_ias;
animation IAS
Sébastien MARQUE authored on 2017-03-10
412
        if (ias >= 10)
413
            me.screenElements.Speed110
414
                .setText(sprintf("% 2u",num(math.floor(ias/10))));
415
        else
416
            me.screenElements.Speed110
417
                .setText('');
418
        me.screenElements.SpeedLint1
419
            .setTranslation(0,(math.mod(ias,10) + (ias >= 10)*10) * 36);
420
        me.screenElements.SpeedTape
421
            .setTranslation(0,ias * 5.711);
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
422
        if (ias > me._ias_vne and ! me._ias_already_exceeded) { # easier than .getColorFill
423
            me._ias_already_exceeded = 1;
424
            me.screenElements['IAS-bg']
425
                .setColorFill(1,0,0);
426
        }
427
        elsif (ias < me._ias_vne and me._ias_already_exceeded) { # easier than .getColorFill
428
            me._ias_already_exceeded = 0;
429
            me.screenElements['IAS-bg']
430
                .setColorFill(0,0,0);
431
        }
trends animation
Sébastien MARQUE authored on 2017-03-13
432
        var now = systime();
433
        # estimated speed in 6s
434
        var Sy = 6 * (ias - me._last_ias_kt) / (now - me._last_ias_s);
435
        if (abs(Sy) > 30)
436
            Sy = 30 * abs(Sy)/Sy; # = -30 or 30
437
        me.screenElements['Airspeed-Trend-Indicator']
438
            .setScale(1,Sy)
439
            .setTranslation(0, -284.5 * (Sy - 1));
440
        me._last_ias_kt = ias;
441
        me._last_ias_s = now;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
442
        settimer(func me.updateIAS(), 0.1);
animation IAS
Sébastien MARQUE authored on 2017-03-10
443
    },
trends animation
Sébastien MARQUE authored on 2017-03-13
444
    _last_ias_kt : 0,
445
    _last_ias_s : systime(),
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
446
    _ias_vne : 999,
447
    _ias_already_exceeded : 0,
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
448
#}}}
animation ALT
Sébastien MARQUE authored on 2017-03-11
449

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
450
    updateTAS: func {
451
# updates the True Airspeed and GroundSpeed indicators {{{
452
        me.screenElements['TAS-text']
453
            .setText(sprintf('%iKT', getprop('/instrumentation/airspeed-indicator/true-speed-kt')));
454
        me.screenElements['GSPD-text']
455
            .setText(sprintf('%iKT', getprop('/velocities/groundspeed-kt')));
456
        settimer(func me.updateTAS(), 0.5);
457
    },
458
#}}}
459

            
460
    updateALT: func () {
461
# animates the altitude lint (PFD) {{{
462
        var alt = me._updated_alt;
animation ALT
Sébastien MARQUE authored on 2017-03-11
463
        if (alt < 0)
464
            me.screenElements.Alt11100
465
                .setText(sprintf("% 3i",math.ceil(alt/100)));
466
        elsif (alt < 100)
467
            me.screenElements.Alt11100
468
                .setText('');
469
        else
470
            me.screenElements.Alt11100
471
                .setText(sprintf("% 3i",math.floor(alt/100)));
472
        me.screenElements.AltLint00011
473
            .setTranslation(0,math.fmod(alt,100) * 1.24);
474

            
475
        # From Farmin/G1000 http://wiki.flightgear.org/Project_Farmin/FG1000
476
        if (alt> -1000 and alt< 1000000) {
477
            var Offset10 = 0;
478
            var Offset100 = 0;
479
            var Offset1000 = 0;
480
            if (alt< 0) {
481
                var Ne = 1;
482
                var alt= -alt;
483
            }
484
            else
485
                var Ne = 0;
486

            
487
            var Alt10       = math.mod(alt,100);
488
            var Alt100      = int(math.mod(alt/100,10));
489
            var Alt1000     = int(math.mod(alt/1000,10));
490
            var Alt10000    = int(math.mod(alt/10000,10));
491
            var Alt20       = math.mod(Alt10,20)/20;
492
            if (Alt10 >= 80)
493
                var Alt100 += Alt20;
494

            
495
            if (Alt10 >= 80 and Alt100 >= 9)
496
                var Alt1000 += Alt20;
497

            
498
            if (Alt10 >= 80 and Alt100 >= 9 and Alt1000 >= 9)
499
                var Alt10000 += Alt20;
500

            
501
            if (alt> 100)
502
                var Offset10 = 100;
503

            
504
            if (alt> 1000)
505
                var Offset100 = 10;
506

            
507
            if (alt> 10000)
508
                var Offset1000 = 10;
509

            
510
            if (!Ne) {
511
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*0.57375);
512
                var altCentral = (int(alt/100)*100);
513
            }
514
            elsif (Ne) {
515
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*-0.57375);
516
                var altCentral = -(int(alt/100)*100);
517
            }
518
            me.screenElements["AltBigC"].setText("");
519
            me.screenElements["AltSmallC"].setText("");
520
            for (var place = 1; place <= 6; place += 1) {
521
                var altUP = altCentral + (place*100);
522
                var offset = -30.078;
523
                if (altUP < 0) {
524
                    var altUP = -altUP;
525
                    var prefix = "-";
526
                    var offset += 15.039;
527
                }
528
                else
529
                    var prefix = "";
530

            
531
                if (altUP == 0) {
532
                    var AltBigUP    = "";
533
                    var AltSmallUP  = "0";
534

            
535
                }
536
                elsif (math.mod(altUP,500) == 0 and altUP != 0) {
537
                    var AltBigUP    = sprintf(prefix~"%1d", altUP);
538
                    var AltSmallUP  = "";
539
                }
540
                elsif (altUP < 1000 and (math.mod(altUP,500))) {
541
                    var AltBigUP    = "";
542
                    var AltSmallUP  = sprintf(prefix~"%1d", int(math.mod(altUP,1000)));
543
                    var offset = -30.078;
544
                }
545
                elsif ((altUP < 10000) and (altUP >= 1000) and (math.mod(altUP,500))) {
546
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
547
                    var AltSmallUP  = sprintf("%1d", int(math.mod(altUP,1000)));
548
                    var offset += 15.039;
549
                }
550
                else {
551
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
552
                    var mod = int(math.mod(altUP,1000));
553
                    var AltSmallUP  = sprintf("%1d", mod);
554
                    var offset += 30.078;
555
                }
556

            
557
                me.screenElements["AltBigU"~place].setText(AltBigUP);
558
                me.screenElements["AltSmallU"~place].setText(AltSmallUP);
559
                me.screenElements["AltSmallU"~place].setTranslation(offset,0);
560
                var altDOWN = altCentral - (place*100);
561
                var offset = -30.078;
562
                if (altDOWN < 0) {
563
                    var altDOWN = -altDOWN;
564
                    var prefix = "-";
565
                    var offset += 15.039;
566
                }
567
                else
568
                    var prefix = "";
569

            
570
                if (altDOWN == 0) {
571
                    var AltBigDOWN  = "";
572
                    var AltSmallDOWN    = "0";
573
                }
574
                elsif (math.mod(altDOWN,500) == 0 and altDOWN != 0) {
575
                    var AltBigDOWN  = sprintf(prefix~"%1d", altDOWN);
576
                    var AltSmallDOWN    = "";
577
                }
578
                elsif (altDOWN < 1000 and (math.mod(altDOWN,500))) {
579
                    var AltBigDOWN  = "";
580
                    var AltSmallDOWN    = sprintf(prefix~"%1d", int(math.mod(altDOWN,1000)));
581
                    var offset = -30.078;
582
                }
583
                elsif ((altDOWN < 10000) and (altDOWN >= 1000) and (math.mod(altDOWN,500))) {
584
                    var AltBigDOWN  = sprintf(prefix~"%1d", int(altDOWN/1000));
585
                    var AltSmallDOWN    = sprintf("%1d", int(math.mod(altDOWN,1000)));
586
                    var offset += 15.039;
587
                }
588
                else {
589
                    var AltBigDOWN  = sprintf(prefix~"%1d", int(altDOWN/1000));
590
                    var mod = int(math.mod(altDOWN,1000));
591
                    var AltSmallDOWN    = sprintf("%1d", mod);
592
                    var offset += 30.078;
593
                }
594
                me.screenElements["AltBigD"~place].setText(AltBigDOWN);
595
                me.screenElements["AltSmallD"~place].setText(AltSmallDOWN);
596
                me.screenElements["AltSmallD"~place].setTranslation(offset,0);
597
            }
598
        }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
599
        me.updateSelectedALT();
trends animation
Sébastien MARQUE authored on 2017-03-13
600
        var now = systime();
601
        # altitude in 6s
602
        var Sy = .3 * (alt - me._last_alt_ft) / (now - me._last_alt_s); # scale = 1/20ft
603
        if (abs(Sy) > 15)
604
            Sy = 15 * abs(Sy)/Sy; # = -15 or 15
605
        me.screenElements['Altitude-Trend-Indicator']
606
            .setScale(1,Sy)
607
            .setTranslation(0, -284.5 * (Sy - 1));
608
        me._last_alt_ft = alt;
609
        me._last_alt_s = now;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
610
        settimer(func me.updateALT(), 0.2);
animation ALT
Sébastien MARQUE authored on 2017-03-11
611
    },
trends animation
Sébastien MARQUE authored on 2017-03-13
612
    _last_alt_ft : 0,
613
    _last_alt_s  : systime(),
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
614
#}}}
animation HSI
Sébastien MARQUE authored on 2017-03-11
615

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
616
    updateHSI : func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
617
# rotates the compass (PFD) {{{
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
618
        var hdg = me._updated_hdg;
animation HSI
Sébastien MARQUE authored on 2017-03-11
619
        me.screenElements.Rose
620
            .setRotation(-hdg * D2R);
621
        me.screenElements['HDG-text']
622
            .setText(sprintf("%03u°", hdg));
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
623
        settimer(func me.updateHSI(), 0.1);
animation HSI
Sébastien MARQUE authored on 2017-03-11
624
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
625
#}}}
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
626

            
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
627
    updateHDG : func (hdg) {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
628
# moves the heading bug and display heading-deg for 3 seconds (PFD) {{{
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
629
        if (me.role == 'MFD')
630
            return;
631
        me.screenElements['Heading-bug']
632
            .setRotation(hdg * D2R);
633
        me.screenElements['SelectedHDG-bg']
634
            .show();
635
        me.screenElements['SelectedHDG-bgtext']
636
            .show();
637
        me.screenElements['SelectedHDG-text']
638
            .setText(sprintf('%03d°%s', hdg, ''))
639
            .show();
640
        me.addTimer(3, ['SelectedHDG-text', 'SelectedHDG-bgtext', 'SelectedHDG-bg']);
641
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
642
#}}}
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
643

            
anime CRS
Sébastien MARQUE authored on 2017-03-13
644
    updateCRS : func (crs) {
645
# TODO: update display for NAV/GPS/BRG courses {{{
646
        if (me.role == 'MFD')
647
            return;
648
        me.screenElements['SelectedCRS-bg']
649
            .show();
650
        me.screenElements['SelectedCRS-bgtext']
651
            .show();
652
        me.screenElements['SelectedCRS-text']
653
            .setText(sprintf('%03d°%s', crs, ''))
654
            .show();
655
        me.addTimer(3, ['SelectedCRS-text', 'SelectedCRS-bgtext', 'SelectedCRS-bg']);
656
    },
657
#}}}
658

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
659
    updateSelectedALT : func {
660
# animation for altitude section, called via updatedALT {{{
661
        var selected_alt = getprop('/instrumentation/zkv1000/afcs/selected-alt-ft');
662
        var delta_alt = me._updated_alt - selected_alt;
663
        if (abs(delta_alt) > 300)
664
            delta_alt = 300 * abs(delta_alt)/delta_alt;
665
        me.screenElements['SelectedAlt-top']
666
            .setVisible(abs(delta_alt) > 100);
667
        me.screenElements['SelectedAlt-bug']
668
            .setTranslation(0, delta_alt * 0.567); # 170/300 = 0.567
669
        me.screenElements['SelectedAlt-text']
670
            .setText(sprintf("%i", selected_alt));
671
    },
672
#}}}
673

            
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
674
    _updateRadio: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
675
# common parts for NAV/LOC/COMM radios{{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
676
        # arg[0]._r = <comm|nav>
677
        if (contains(arg[0], "active")) {
678
            if (arg[0]['active'] == 'none') {
679
                me.screenElements[arg[0]._r ~ '1-selected-freq']
680
                    .setColor(1,1,1);
681
                me.screenElements[arg[0]._r ~ '2-selected-freq']
682
                    .setColor(1,1,1);
683
            }
684
            else {
685
                me.screenElements[arg[0]._r ~ arg[0]['active'] ~ '-selected-freq']
686
                    .setColor(0,1,0);
687
                me.screenElements[arg[0]._r ~ arg[0].inactive ~ '-selected-freq']
688
                    .setColor(1,1,1);
689
            }
690
        }
691
        if (contains(arg[0], 'tune')) {
692
            # n = 0 -> NAV1/COMM1
693
            # n = 1 -> NAV1/COMM2
694
            me.screenElements[arg[0]._r ~ '-freq-switch']
695
                .setTranslation(0, arg[0].tune * 25);
696
            me.screenElements[arg[0]._r ~ (arg[0].tune + 1) ~ '-standby-freq']
697
                .setColor(0,1,1);
698
            me.screenElements[arg[0]._r ~ ((arg[0].tune == 0) + 1) ~ '-standby-freq']
699
                .setColor(1,1,1);
700
        }
701
        if (contains(arg[0], 'refresh')) {
702
            # rafraichi une seule ligne NAV1/COMM1 ou NAV2/COMM2
703
            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
704
            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-selected-freq']
705
                .setText(sprintf(fmt, getprop('/instrumentation/'
706
                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/selected-mhz')));
707
            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-standby-freq']
708
                .setText(sprintf(fmt, getprop('/instrumentation/'
709
                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/standby-mhz')));
710
        }
711
        if (contains(arg[0], 'set')) {
712
            # positionne la valeur modifiée, les listeners "trigguent" en permanence ces propriétés, donc exit
713
            var n = getprop('/instrumentation/zkv1000/radios/' ~ arg[0]._r ~ '-tune');
714
            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
715
            me.screenElements[arg[0]._r ~ (n + 1) ~ '-standby-freq']
fix freq display while setti...
Sébastien MARQUE authored on 2017-03-16
716
                .setText(sprintf(fmt, getprop('/instrumentation/' ~ arg[0]._r ~ '[' ~ n ~ ']/frequencies/standby-mhz')));
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
717
        }
718
        if (contains(arg[0], 'auto')) {
719
            # pour rafraichir automagiquement, toutes les deux secondes un refresh pour un NAV
720
            var radio = arg[0].auto;
721
            me._updateRadio({refresh: 1, _r: radio});
722
            settimer(func me._updateRadio({refresh: 2, _r: radio}), 1);
723
            settimer(func me._updateRadio({auto: radio}), 2);
724
        }
725
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
726
#}}}
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
727

            
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
728
    updateNAV : func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
729
# update NAV/LOC rodios display upper left (PFD/MFD){{{
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
730
        # made active via menu
731
        if (contains(arg[0], "active")) {
732
            if (arg[0]['active'] == 'none') {
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
733
                arg[0]._r = 'nav';
734
                me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
735
                me.screenElements['nav1-id']
736
                    .setColor(1,1,1);
737
                me.screenElements['nav2-id']
738
                    .setColor(1,1,1);
739
                me.screenElements['NAV1-pointer']
740
                    .hide();
741
                me.screenElements['NAV2-pointer']
742
                    .hide();
743
            }
744
            else {
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
745
                arg[0]._r = 'nav';
746
                arg[0].inactive = (arg[0]['active'] == 1) + 1;
747
                me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
748
                me.screenElements['nav' ~ arg[0]['active'] ~ '-id']
749
                    .setColor(0,1,0);
750
                me.screenElements['NAV' ~ arg[0]['active'] ~ '-pointer']
751
                    .show();
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
752
                me.screenElements['nav' ~ arg[0].inactive ~ '-id']
753
                    .setColor(1,1,1);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
754
#                me.screenElements['HDI']
755
#                    .setRotation();
756
#                me.screenElements['NAV' ~ inactive ~ '-pointer']
757
#                    .hide();
758
#                foreach (var e; [ 'FROM', 'TO', 'CDI' ])
759
#                    me.screenElements['NAV' ~ inactive ~ '-' ~ e]
760
#                        .hide();
761
            }
762
        }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
763
        elsif (contains(arg[0], 'nav-id')) {
Correction swap NAV tuning
Sébastien MARQUE authored on 2017-03-12
764
            # 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
765
            if (arg[0].val == nil)
766
                arg[0].val = '';
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
767
            me.screenElements["nav" ~ arg[0]['nav-id'] ~ "-id"]
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
768
                    .setText(arg[0].val);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
769
        }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
770
        else {
771
            arg[0]._r = 'nav';
772
            me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
773
        }
774
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
775
#}}}
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
776

            
777
    updateCOMM: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
778
# update COMM radios display upper right (PFD/MFD){{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
779
        arg[0]._r = 'comm';
780
        me._updateRadio(arg[0]);
781
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
782
#}}}
anime time display
Sébastien MARQUE authored on 2017-03-13
783

            
784
    updateTIME : func {
785
# updates the displayed time botoom left {{{
786
        me.screenElements['TIME-text']
787
            .setText(getprop('/sim/time/gmt-string'));
788
        settimer(func me.updateTIME(), 1);
789
    },
790
#}}}
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
791

            
adds transponder
Sébastien MARQUE authored on 2017-03-17
792
    updateXPDR : func {
793
# updates transponder display {{{
794
        for (var d = 0; d < 4; d+=1)
795
            me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
796
                .setText(sprintf('%i', getprop('/instrumentation/transponder/inputs/digit[' ~ d ~ ']')));
797
        var tuning = getprop('/instrumentation/zkv1000/radios/xpdr-tuning-digit');
798
        if (tuning != nil)
799
            for (var d = 0; d < 4; d+=1) {
800
                if (d != tuning)
801
                    me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
802
                        .setColor(1,1,1);
803
                else
804
                    me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
805
                        .setColor(0,1,1);
806
            }
807
        else {
808
            if (getprop('/instrumentation/transponder/ident'))
809
                var mode = 'IDENT';
810
            else
811
                var mode = getprop('/instrumentation/zkv1000/radio/xpdr-mode');
812
            var wow = getprop('/gear/gear/wow');
813
            if (! wow and mode != 'STBY')
814
                var color = [0, 1, 0];
815
            else
816
                var color = [1, 1, 1];
817
            for (var d = 0; d < 4; d+=1)
818
                me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
819
                    .setColor(color);
820
            me.screenElements['XPDR-MODE-text']
821
                .setColor(color)
822
                .setText(mode);
823
        }
824
},
825
#}}}
826

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
827
    updateOAT : func {
828
# update OAT display on normal and reversionnary modes (every 3s) {{{
829
        var tmp = getprop('/environment/temperature-deg' ~ me._oat_unit);
830
        me.screenElements['OAT-text']
831
            .setText(sprintf((abs(tmp) < 10) ? "%.1f %s" : "%i %s", tmp, (me._oat_unit == 'c') ? '°C' : 'F'));
832
        settimer(func me.updateOAT(), 3);
833
    },
834
    _oat_unit : 'c',
835
#}}}
836

            
837
    updateWindData : func {
838
# update the window text and arrows for OPTN1/2 {{{
839
        if (me._winddata_optn == 0)
840
            return;
improves WindData display
Sébastien MARQUE authored on 2017-03-16
841
        if (me._updated_ias < 30) {
842
            me.screenElements['WindData-NODATA']
843
                .hide();
844
            var wind_hdg = getprop('/environment/wind-from-heading-deg');
845
            var wind_spd = getprop('/environment/wind-speed-kt');
846
            var alpha = wind_hdg - me._updated_hdg;
847
            if (me._winddata_optn == 1) {
848
                me.screenElements['WindData-OPTN1-HDG']
849
                    .setRotation((alpha + 180) * D2R)
850
                    .show();
851
                me.screenElements['WindData-OPTN1-HDG-text']
852
                    .setText(sprintf("%03i°", wind_hdg))
853
                    .show();
854
                me.screenElements['WindData-OPTN1-SPD-text']
855
                    .setText(int(wind_spd) ~ 'KT')
856
                    .show();
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
857
            }
improves WindData display
Sébastien MARQUE authored on 2017-03-16
858
            else { # me._winddata_optn == 2
859
                alpha *= D2R;
860
                var Vt = wind_spd * math.sin(alpha);
861
                var Ve = wind_spd * math.cos(alpha);
862
                if (Vt != 0) {
863
                    me.screenElements['WindData-OPTN2-crosswind-text']
864
                        .setText(sprintf('%i', abs(Vt)))
865
                        .show();
866
                    me.screenElements['WindData-OPTN2-crosswind']
867
                        .setScale(-abs(Vt)/Vt, 1)
868
                        .setTranslation(-35 * (abs(Vt)/Vt + 1), 0)
869
                        .show();
870
                }
871
                if (Ve != 0) {
872
                    me.screenElements['WindData-OPTN2-headwind-text']
873
                        .setText(sprintf('%i', abs(Ve)))
874
                        .show();
875
                    me.screenElements['WindData-OPTN2-headwind']
876
                        .setScale(1, abs(Ve)/Ve)
877
                        .setTranslation(0, 515 * (1 - abs(Ve)/Ve))
878
                        .show();
879
                }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
880
            }
881
        }
improves WindData display
Sébastien MARQUE authored on 2017-03-16
882
        else {
883
            foreach (var e; [
884
                    'WindData-OPTN1-HDG',
885
                    'WindData-OPTN1-HDG-text',
886
                    'WindData-OPTN1-SPD-text',
887
                    'WindData-OPTN2-crosswind-text',
888
                    'WindData-OPTN2-crosswind',
889
                    'WindData-OPTN2-headwind-text',
890
                    'WindData-OPTN2-headwind'
891
            ])
892
                me.screenElements[e].hide();
893
            me.screenElements['WindData-NODATA'].show();
894
        }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
895
        settimer(func me.updateWindData(), 0.5);
896
    },
897
    _winddata_optn : 0,
898
#}}}
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
899

            
900
    updateBRG : func {
901
# displays and update
902
        foreach (var brg; [1, 2]) {
903
            var source = 'brg' ~ brg ~ '-source';
904

            
905
            var dev = radios.getNode(source).getValue();
906
            var el  = 'BRG' ~ brg;
907
            if (dev != 'OFF') {
908
                var info = {
909
                    pointer : nil,
910
                    id : 'NO DATA',
911
                    hdg : nil,
912
                    dst : '--.-NM'
913
                };
914
                if (left(dev, 3) == 'NAV') {
915
                    info.pointer = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/in-range');
916
                    if (info.pointer) {
917
                        info.id  = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/nav-id');
918
                        info.hdg = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/heading-deg');
919
                        info.dst = sprintf('%.1d', getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/nav-distance') / 1852); # m -> /1852
920
                    }
921
                }
922
                elsif (dev == 'GPS') {
923
                    info.pointer = props.getNode('/instrumentation/gps/wp').getChild('wp[1])');
924
                    if (info.pointer) {
925
                        info.id  = getprop('/instrumentation/gps/wp/wp[1]/ID');
926
                        info.hdg = getprop('/instrumentation/gps/wp/wp[1]/bearing-mag-deg');
927
                        info.dst = sprintf('%.1d', getprop('/instrumentation/gps/wp/wp[1]/distance-nm'));
928
                    }
929
                }
930
                else { # there are 2 available ADF in FG, but instrument manage only 1
931
                    info.pointer = getprop('/instrumentation/adf/in-range');
932
                    if (info.pointer) {
933
                        info.id  = getprop('/instrumentation/adf/ident');
934
                        info.hdg = getprop('/instrumentation/adf/indicated-bearing-deg');
935
                    }
936
                }
937

            
938
                if (info.pointer)
939
                    me.screenElements[el ~ '-pointer']
940
                        .setRotation(-info.hdg-me._updated_hdg * D2R)
941
                        .show();
942
                else
943
                    me.screenElements[el ~ '-pointer']
944
                        .hide();
945
                me.screenElements[el ~ '-SRC-text']
946
                    .setText(dev);
947
                me.screenElements[el ~ '-DST-text']
948
                    .setText(info.dst);
949
                me.screenElements[el ~ '-WPID-text']
950
                    .setText(info.id);
951
                me.screenElements['BRG' ~ brg]
952
                    .show();
953
            }
954
            else {
955
                me.screenElements['BRG' ~ brg]
956
                    .hide();
957
            }
958
        }
959
        settimer(func me.updateBRG(), 1);
960
    },
commit initial
Sébastien MARQUE authored on 2017-03-07
961
};
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
962

            
963
var keyMap = {
add new vim folds
Sébastien MARQUE authored on 2017-03-15
964
# softkeys map for PFD and MFD {{{
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
965
    PFD : {
966
        first : 1,
967
        texts : ['INSET', 'SENSOR', 'PFD', 'OBS', 'CDI', 'DME', 'XPDR', 'IDENT', 'TMR/REF', 'NRST' ],
968
        INSET : {
969
            texts : ['OFF', 'DCLTR', 'WXLGND', 'TRAFFIC', 'TOPO', 'TERRAIN', 'STRMSCP', 'NEXRAD-C', 'XM LTNG', 'METAR'],
970
        },
971
        SENSOR : {
972
            first : 2,
973
            texts : [ 'ADC1', 'ADC2', '', 'AHRS1', 'AHRS2'],
974
        },
975
        PFD : {
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
976
            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
977
            'SYN VIS' : {
978
                texts : [ 'PATHWAY', 'SYN TERR', 'HR2NHDG', 'APTSIGNS', 'FPM'],
979
            },
980
            'AOA/WIND' : {
981
                first : 4,
982
                texts : ['AOA', 'WIND'],
983
                AOA : {
984
                    first : 5,
985
                    texts : ['AOA ON', 'AOA AUTO'],
986
                },
987
                WIND : {
988
                    first : 2,
989
                    texts : ['OPTN1', 'OPTN2', '', 'OFF'],
990
                },
991
            },
992
            'HSI FMT' : {
993
                first : 6,
994
                texts : ['360 HSI', 'ARC HSI'],
995
            },
996
            'ALT UNIT' : {
997
                first : 5,
998
                texts : ['METERS', '', 'IN', 'HPA'],
999
            },
1000
        },
1001
        XPDR : {
1002
            first : 2,
1003
            texts : ['STBY', 'ON', 'ALT', '', 'VFR', 'CODE', 'IDENT'],
1004
            CODE : {
1005
                texts : ['0', '1', '2', '3', '4', '5', '6', '7', 'IDENT', 'BKSP'],
1006
            },
1007
        },
1008
    },
1009
    MFD : {
1010
        texts : ['ENGINE', '', 'MAP', '', '', '', '', '', '', 'DCLTR', 'SHW CHRT', 'CHKLIST'],
1011
        MAP : {
1012
            texts: ['TRAFFIC', 'PROFILE', 'TOPO', 'TERRAIN', 'AIRWAYS', 'STRMSCP','NEXRAD-C', 'XM LTNG', 'METAR', 'LEGEND', 'BACK'],
1013
        },
1014
        CHKLIST : {
1015
            texts : ['ENGINE', '', '', '', '', 'DONE', '', '', '', '', 'EXIT', 'EMERGCY'],
1016
        },
1017
        ENGINE : {
1018
            texts : ['ENGINE', 'ANTI-ICE', '', 'DCLTR', '', 'ASSIST', '', '', '', '', 'FUEL'],
1019
            'ANTI-ICE' : {
1020
                texts : ['LEFT', 'AUTO', 'RIGHT', '', '', '', '', '', '', '', '', 'BACK'],
1021
            },
1022
            FUEL : {
1023
                first : 1,
1024
                texts : ['FULL', 'TABS', '', '', '', '', '', '', '', 'UNDO', 'ENTER'],
1025
            },
1026
        },
1027
    },
1028
};
add new vim folds
Sébastien MARQUE authored on 2017-03-15
1029
#}}}