zkv1000 / Nasal / display.nas /
Newer Older
989 lines | 36.267kb
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 : [
commit initial
Sébastien MARQUE authored on 2017-03-07
67
                    'SoftKeysTexts', 
68
                    'COMM', 
69
                    'NAV', 
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
70
                    'nav-freq-switch',
71
                    'comm-freq-switch',
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
72
                ],
73
                text: [
74
                    'nav1-standby-freq', 'nav1-selected-freq', 'nav1-id',
75
                    'nav2-standby-freq', 'nav2-selected-freq', 'nav2-id',
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
76
                    'comm1-standby-freq', 'comm1-selected-freq',
77
                    'comm2-standby-freq', 'comm2-selected-freq',
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
78
                ],
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
79
                hide : [ ],
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
80
                clip: [ ],
81
            };
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
82

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

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

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

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

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

            
206
        zkv.getNode(role ~ 'init',1).setIntValue(1);
207

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

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

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

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

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

            
327
        var path = keyMap[me.role];
328
        foreach (var p; me.device.softkeys.path)
329
            path = path[p];
330

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

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

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

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

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

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

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

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

            
482
            var Alt10       = math.mod(alt,100);
483
            var Alt100      = int(math.mod(alt/100,10));
484
            var Alt1000     = int(math.mod(alt/1000,10));
485
            var Alt10000    = int(math.mod(alt/10000,10));
486
            var Alt20       = math.mod(Alt10,20)/20;
487
            if (Alt10 >= 80)
488
                var Alt100 += Alt20;
489

            
490
            if (Alt10 >= 80 and Alt100 >= 9)
491
                var Alt1000 += Alt20;
492

            
493
            if (Alt10 >= 80 and Alt100 >= 9 and Alt1000 >= 9)
494
                var Alt10000 += Alt20;
495

            
496
            if (alt> 100)
497
                var Offset10 = 100;
498

            
499
            if (alt> 1000)
500
                var Offset100 = 10;
501

            
502
            if (alt> 10000)
503
                var Offset1000 = 10;
504

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

            
526
                if (altUP == 0) {
527
                    var AltBigUP    = "";
528
                    var AltSmallUP  = "0";
529

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

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

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

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

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

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

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

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

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

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

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

            
787
    updateOAT : func {
788
# update OAT display on normal and reversionnary modes (every 3s) {{{
789
        var tmp = getprop('/environment/temperature-deg' ~ me._oat_unit);
790
        me.screenElements['OAT-text']
791
            .setText(sprintf((abs(tmp) < 10) ? "%.1f %s" : "%i %s", tmp, (me._oat_unit == 'c') ? '°C' : 'F'));
792
        settimer(func me.updateOAT(), 3);
793
    },
794
    _oat_unit : 'c',
795
#}}}
796

            
797
    updateWindData : func {
798
# update the window text and arrows for OPTN1/2 {{{
799
        if (me._winddata_optn == 0)
800
            return;
improves WindData display
Sébastien MARQUE authored on 2017-03-16
801
        if (me._updated_ias < 30) {
802
            me.screenElements['WindData-NODATA']
803
                .hide();
804
            var wind_hdg = getprop('/environment/wind-from-heading-deg');
805
            var wind_spd = getprop('/environment/wind-speed-kt');
806
            var alpha = wind_hdg - me._updated_hdg;
807
            if (me._winddata_optn == 1) {
808
                me.screenElements['WindData-OPTN1-HDG']
809
                    .setRotation((alpha + 180) * D2R)
810
                    .show();
811
                me.screenElements['WindData-OPTN1-HDG-text']
812
                    .setText(sprintf("%03i°", wind_hdg))
813
                    .show();
814
                me.screenElements['WindData-OPTN1-SPD-text']
815
                    .setText(int(wind_spd) ~ 'KT')
816
                    .show();
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
817
            }
improves WindData display
Sébastien MARQUE authored on 2017-03-16
818
            else { # me._winddata_optn == 2
819
                alpha *= D2R;
820
                var Vt = wind_spd * math.sin(alpha);
821
                var Ve = wind_spd * math.cos(alpha);
822
                if (Vt != 0) {
823
                    me.screenElements['WindData-OPTN2-crosswind-text']
824
                        .setText(sprintf('%i', abs(Vt)))
825
                        .show();
826
                    me.screenElements['WindData-OPTN2-crosswind']
827
                        .setScale(-abs(Vt)/Vt, 1)
828
                        .setTranslation(-35 * (abs(Vt)/Vt + 1), 0)
829
                        .show();
830
                }
831
                if (Ve != 0) {
832
                    me.screenElements['WindData-OPTN2-headwind-text']
833
                        .setText(sprintf('%i', abs(Ve)))
834
                        .show();
835
                    me.screenElements['WindData-OPTN2-headwind']
836
                        .setScale(1, abs(Ve)/Ve)
837
                        .setTranslation(0, 515 * (1 - abs(Ve)/Ve))
838
                        .show();
839
                }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
840
            }
841
        }
improves WindData display
Sébastien MARQUE authored on 2017-03-16
842
        else {
843
            foreach (var e; [
844
                    'WindData-OPTN1-HDG',
845
                    'WindData-OPTN1-HDG-text',
846
                    'WindData-OPTN1-SPD-text',
847
                    'WindData-OPTN2-crosswind-text',
848
                    'WindData-OPTN2-crosswind',
849
                    'WindData-OPTN2-headwind-text',
850
                    'WindData-OPTN2-headwind'
851
            ])
852
                me.screenElements[e].hide();
853
            me.screenElements['WindData-NODATA'].show();
854
        }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
855
        settimer(func me.updateWindData(), 0.5);
856
    },
857
    _winddata_optn : 0,
858
#}}}
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
859

            
860
    updateBRG : func {
861
# displays and update
862
        foreach (var brg; [1, 2]) {
863
            var source = 'brg' ~ brg ~ '-source';
864

            
865
            var dev = radios.getNode(source).getValue();
866
            var el  = 'BRG' ~ brg;
867
            if (dev != 'OFF') {
868
                var info = {
869
                    pointer : nil,
870
                    id : 'NO DATA',
871
                    hdg : nil,
872
                    dst : '--.-NM'
873
                };
874
                if (left(dev, 3) == 'NAV') {
875
                    info.pointer = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/in-range');
876
                    if (info.pointer) {
877
                        info.id  = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/nav-id');
878
                        info.hdg = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/heading-deg');
879
                        info.dst = sprintf('%.1d', getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/nav-distance') / 1852); # m -> /1852
880
                    }
881
                }
882
                elsif (dev == 'GPS') {
883
                    info.pointer = props.getNode('/instrumentation/gps/wp').getChild('wp[1])');
884
                    if (info.pointer) {
885
                        info.id  = getprop('/instrumentation/gps/wp/wp[1]/ID');
886
                        info.hdg = getprop('/instrumentation/gps/wp/wp[1]/bearing-mag-deg');
887
                        info.dst = sprintf('%.1d', getprop('/instrumentation/gps/wp/wp[1]/distance-nm'));
888
                    }
889
                }
890
                else { # there are 2 available ADF in FG, but instrument manage only 1
891
                    info.pointer = getprop('/instrumentation/adf/in-range');
892
                    if (info.pointer) {
893
                        info.id  = getprop('/instrumentation/adf/ident');
894
                        info.hdg = getprop('/instrumentation/adf/indicated-bearing-deg');
895
                    }
896
                }
897

            
898
                if (info.pointer)
899
                    me.screenElements[el ~ '-pointer']
900
                        .setRotation(-info.hdg-me._updated_hdg * D2R)
901
                        .show();
902
                else
903
                    me.screenElements[el ~ '-pointer']
904
                        .hide();
905
                me.screenElements[el ~ '-SRC-text']
906
                    .setText(dev);
907
                me.screenElements[el ~ '-DST-text']
908
                    .setText(info.dst);
909
                me.screenElements[el ~ '-WPID-text']
910
                    .setText(info.id);
911
                me.screenElements['BRG' ~ brg]
912
                    .show();
913
            }
914
            else {
915
                me.screenElements['BRG' ~ brg]
916
                    .hide();
917
            }
918
        }
919
        settimer(func me.updateBRG(), 1);
920
    },
commit initial
Sébastien MARQUE authored on 2017-03-07
921
};
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
922

            
923
var keyMap = {
add new vim folds
Sébastien MARQUE authored on 2017-03-15
924
# softkeys map for PFD and MFD {{{
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
925
    PFD : {
926
        first : 1,
927
        texts : ['INSET', 'SENSOR', 'PFD', 'OBS', 'CDI', 'DME', 'XPDR', 'IDENT', 'TMR/REF', 'NRST' ],
928
        INSET : {
929
            texts : ['OFF', 'DCLTR', 'WXLGND', 'TRAFFIC', 'TOPO', 'TERRAIN', 'STRMSCP', 'NEXRAD-C', 'XM LTNG', 'METAR'],
930
        },
931
        SENSOR : {
932
            first : 2,
933
            texts : [ 'ADC1', 'ADC2', '', 'AHRS1', 'AHRS2'],
934
        },
935
        PFD : {
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
936
            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
937
            'SYN VIS' : {
938
                texts : [ 'PATHWAY', 'SYN TERR', 'HR2NHDG', 'APTSIGNS', 'FPM'],
939
            },
940
            'AOA/WIND' : {
941
                first : 4,
942
                texts : ['AOA', 'WIND'],
943
                AOA : {
944
                    first : 5,
945
                    texts : ['AOA ON', 'AOA AUTO'],
946
                },
947
                WIND : {
948
                    first : 2,
949
                    texts : ['OPTN1', 'OPTN2', '', 'OFF'],
950
                },
951
            },
952
            'HSI FMT' : {
953
                first : 6,
954
                texts : ['360 HSI', 'ARC HSI'],
955
            },
956
            'ALT UNIT' : {
957
                first : 5,
958
                texts : ['METERS', '', 'IN', 'HPA'],
959
            },
960
        },
961
        XPDR : {
962
            first : 2,
963
            texts : ['STBY', 'ON', 'ALT', '', 'VFR', 'CODE', 'IDENT'],
964
            CODE : {
965
                texts : ['0', '1', '2', '3', '4', '5', '6', '7', 'IDENT', 'BKSP'],
966
            },
967
        },
968
    },
969
    MFD : {
970
        texts : ['ENGINE', '', 'MAP', '', '', '', '', '', '', 'DCLTR', 'SHW CHRT', 'CHKLIST'],
971
        MAP : {
972
            texts: ['TRAFFIC', 'PROFILE', 'TOPO', 'TERRAIN', 'AIRWAYS', 'STRMSCP','NEXRAD-C', 'XM LTNG', 'METAR', 'LEGEND', 'BACK'],
973
        },
974
        CHKLIST : {
975
            texts : ['ENGINE', '', '', '', '', 'DONE', '', '', '', '', 'EXIT', 'EMERGCY'],
976
        },
977
        ENGINE : {
978
            texts : ['ENGINE', 'ANTI-ICE', '', 'DCLTR', '', 'ASSIST', '', '', '', '', 'FUEL'],
979
            'ANTI-ICE' : {
980
                texts : ['LEFT', 'AUTO', 'RIGHT', '', '', '', '', '', '', '', '', 'BACK'],
981
            },
982
            FUEL : {
983
                first : 1,
984
                texts : ['FULL', 'TABS', '', '', '', '', '', '', '', 'UNDO', 'ENTER'],
985
            },
986
        },
987
    },
988
};
add new vim folds
Sébastien MARQUE authored on 2017-03-15
989
#}}}