zkv1000 / Nasal / display.nas /
Newer Older
653 lines | 23.587kb
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) {
commit initial
Sébastien MARQUE authored on 2017-03-07
4
        var m = { parents: [ displayClass ] };
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
5

            
commit initial
Sébastien MARQUE authored on 2017-03-07
6
        m.display = canvas.new({
7
                "name"      : role,
8
                "size"      : [1024, 768],
9
                "view"      : [1024, 768],
10
                "mipmapping": 1
11
        });
12
        m.display.addPlacement({
13
                "node": "Screen",
14
                "parent": role
15
        });
16
        m.display.setColorBackground(0,0,0);
17
        m.role = role;
pass device pointer to displ...
Sébastien MARQUE authored on 2017-03-14
18
        m.device = device;
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
19
        m.screenElements = {};
commit initial
Sébastien MARQUE authored on 2017-03-07
20

            
21
        return m;
22
    },
23

            
ajoute un timer pour cacher ...
Sébastien MARQUE authored on 2017-03-13
24
    timers : {},
25

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

            
37
    addTimer : func (duration, element) {
38
        if (typeof(element) == 'scalar')
39
            element = [ element ];
40
        var end = systime() + duration;
41
        foreach (var e; element)
42
            me.timers[e] = end;
43
    },
44

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

            
51
    _showInitProgress : func (p,t) {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
52
#{{{
commit initial
Sébastien MARQUE authored on 2017-03-07
53
        p.setText(t);
54
        if (zkv.getNode(me.role ~ 'init').getValue() != 0) {
55
            if (size(t) >= 10) t = '';
56
            settimer(func { me._showInitProgress(p, t ~ '.'); }, 0.1);
57
        }
58
        else {
59
            me.progress.hide();
60
            me.screen.show();
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
61
            var groups = {
animation VSI
Sébastien MARQUE authored on 2017-03-10
62
                show : [
commit initial
Sébastien MARQUE authored on 2017-03-07
63
                    'SoftKeysTexts', 
64
                    'COMM', 
65
                    'NAV', 
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
66
                    'nav-freq-switch',
67
                    'comm-freq-switch',
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
68
                ],
69
                text: [
70
                    'nav1-standby-freq', 'nav1-selected-freq', 'nav1-id',
71
                    'nav2-standby-freq', 'nav2-selected-freq', 'nav2-id',
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
72
                    'comm1-standby-freq', 'comm1-selected-freq',
73
                    'comm2-standby-freq', 'comm2-selected-freq',
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
74
                ],
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
75
                hide : [ ],
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
76
                clip: [ ],
77
            };
78
            if (me.role == 'PFD') {
79
                append(groups.show,
commit initial
Sébastien MARQUE authored on 2017-03-07
80
                    'XPDR-TIME', 
AI disponible
Sébastien MARQUE authored on 2017-03-10
81
                    'FlightInstruments',
82
                    'Horizon',
AI disponible, avec bankPoin...
Sébastien MARQUE authored on 2017-03-10
83
                    'bankPointer',
animation VSI
Sébastien MARQUE authored on 2017-03-10
84
                    'VSI',
animation HSI
Sébastien MARQUE authored on 2017-03-11
85
                    'Rose',
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
86
                    'Heading-bug',
87
                    'PFD-Widgets',
trends animation
Sébastien MARQUE authored on 2017-03-13
88
                    'Trends',
89
                    'Airspeed-Trend-Indicator',
90
                    'Altitude-Trend-Indicator',
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
91
                );
92
                append(groups.hide,
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
93
                    'CDI',
animation HSI
Sébastien MARQUE authored on 2017-03-11
94
                    'NAV1-pointer',
95
                    'NAV2-pointer',
96
                    'GPS-pointer',
97
                    'Bearing1',
98
                    'Bearing2',
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
99
                    'SelectedHDG-bg',
100
                    'SelectedHDG-bgtext',
101
                    'SelectedHDG-text',
102
                    'SelectedCRS-bg',
103
                    'SelectedCRS-bgtext',
104
                    'SelectedCRS-text',
105
                    'SelectedALT',
106
                    'TAS',
107
                    'GSPD',
108
                    'OAT',
109
                    'BARO',
110
                    'WindData',
111
                    'Reversionnary',
112
                    'Annunciation',
113
                    'Comparator',
114
                    'BRG1',
115
                    'BRG2',
116
                    'DME1',
117
                    'PFD-Map',
118
                    'PFD-Multilines'
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
119
                );
120
                append(groups.clip,
animation IAS
Sébastien MARQUE authored on 2017-03-10
121
                    'SpeedLint1',
animation ALT
Sébastien MARQUE authored on 2017-03-11
122
                    'SpeedTape',
123
                    'LintAlt',
124
                    'AltLint00011'
125
                );
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
126
                append(groups.text,
anime time display
Sébastien MARQUE authored on 2017-03-13
127
                    'TIME-text',
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
128
                    'VSIText',
129
                    'Speed110',
130
                    'Alt11100',
131
                    'HDG-text',
132
                    'AltBigC', 'AltSmallC'
133
                );
134
                for (var place = 1; place <= 6; place +=1) {
135
                    append(groups.text,
136
                        'AltBigU' ~ place,
137
                        'AltSmallU' ~ place,
138
                        'AltBigD' ~ place,
139
                        'AltSmallD' ~ place
140
                    );
141
                }
animation ALT
Sébastien MARQUE authored on 2017-03-11
142
            }
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
143
            else
144
                append(groups.show, 'Header');
145

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

            
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
148
            if (me.role == 'PFD') {
149
                me.updateAI(getprop('/orientation/roll-deg'),getprop('orientation/pitch-deg'));
150
                me.updateVSI(getprop('/instrumentation/vertical-speed-indicator/indicated-speed-fpm'));
151
                me.updateIAS(getprop('/velocities/airspeed-kt'));
152
                me.updateALT(getprop('instrumentation/altimeter/indicated-altitude-ft'));
153
                me.updateHSI(getprop('orientation/heading-deg'));
anime time display
Sébastien MARQUE authored on 2017-03-13
154
                me.updateTIME();
ajoute un timer pour cacher ...
Sébastien MARQUE authored on 2017-03-13
155
                me.timerTrigger();
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
156
            }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
157
            me._updateRadio({auto:'nav'});
158
            me._updateRadio({auto:'comm'});
commit initial
Sébastien MARQUE authored on 2017-03-07
159
            me.progress.removeAllChildren();
160
            me.progress = nil;
161
            me.showInitProgress = nil;
162
            me._showInitProgress = nil;
163
            zkv.removeChild(me.role ~ 'init');
164
        }
165
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
166
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
167

            
168
    showInitProgress : func (role) {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
169
#{{{
commit initial
Sébastien MARQUE authored on 2017-03-07
170
        me.progress = me.display.createGroup();
171
        me.progress.show();
172
        me.progress.createChild("text", role ~ " title")
173
            .setTranslation(512, 384)
174
            .setAlignment("center-center")
175
            .setFont("LiberationFonts/LiberationSans-Italic.ttf")
176
            .setFontSize(64, 1)
177
            .setColor(1,1,1)
178
            .setText("ZKV1000 " ~ role ~ " init");
179

            
180
        zkv.getNode(role ~ 'init',1).setIntValue(1);
181

            
182
        me._showInitProgress(me.progress.createChild("text", role ~ "progress")
183
            .setTranslation(512, 484)
184
            .setAlignment("center-center")
185
            .setFont("LiberationFonts/LiberationSans-Bold.ttf")
186
            .setFontSize(128, 1)
187
            .setColor(1,0,0), '.');
188
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
189
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
190

            
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
191
    loadGroup : func (h) {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
192
#{{{
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
193
        if (typeof(h) != 'hash') {
194
            msg_dbg(sprintf("%s need a hash, but get a %s from %s",
195
                    caller(0)[0],
196
                    typeof(h),
197
                    caller(1)[0]));
198
            return;
commit initial
Sébastien MARQUE authored on 2017-03-07
199
        }
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
200
        var setMethod = func (e, t) {
201
            if (t == 'hide')
202
                me.screenElements[e].hide();
203
            elsif (t == 'show')
204
                me.screenElements[e].show();
AI disponible
Sébastien MARQUE authored on 2017-03-10
205
            elsif (t == 'rot' or t == 'trans') {
206
                if (! contains(me.screenElements[e], t))
207
                    me.screenElements[e][t] = me.screenElements[e].createTransform();
208
            }
209
            elsif (t == 'clip') {
210
                if (contains(me.clips, e))
211
                    me.screenElements[e].set("clip", me.clips[e]);
212
                else
213
                    print('no defined clip for ' ~ e);
214
            }
animation VSI
Sébastien MARQUE authored on 2017-03-10
215
            elsif (t == 'text') {
216
                if (contains(me.texts, e)) {
217
                    if (contains(me.texts[e], 'alignment'))
218
                        me.screenElements[e].setAlignment(me.texts[e].alignment);
219
                    if (contains(me.texts[e], 'default'))
220
                        me.screenElements[e].setText(me.texts[e].default);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
221
                    if (contains(me.texts[e], 'color'))
222
                        me.screenElements[e].setColor(me.texts[e].color);
animation VSI
Sébastien MARQUE authored on 2017-03-10
223
                }
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
224
#                else
225
#                    print('no text format for ' ~ e);
animation VSI
Sébastien MARQUE authored on 2017-03-10
226
            }
commit initial
Sébastien MARQUE authored on 2017-03-07
227
            else
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
228
                print('unknown method ' ~ t);
229
        };
230
        foreach (var todo; keys(h)) {
231
            if (typeof(h[todo]) != 'vector') h[todo] = [ h[todo] ];
232
            foreach (var id; h[todo]) {
233
                if (! contains(me.screenElements, id)) {
234
                    me.screenElements[id] = me.screen.getElementById(id);
235
                    if (me.screenElements[id] != nil)
236
                        setMethod(id, todo);
237
                    else
238
                        print('SVG ID ' ~ id ~ ' not found');
239
                }
240
                else
241
                    setMethod(id, todo);
242
            }
commit initial
Sébastien MARQUE authored on 2017-03-07
243
        }
244
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
245
#}}}
AI disponible
Sébastien MARQUE authored on 2017-03-10
246

            
247
    clips : {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
248
#{{{
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
249
        PitchScale   : "rect(70,664,370,256)",
250
        SpeedLint1   : "rect(252,226,318,204)",
251
        SpeedTape    : "rect(115,239,455,156)",
252
        LintAlt      : "rect(115,808,455,704)",
animation ALT
Sébastien MARQUE authored on 2017-03-11
253
        AltLint00011 : "rect(252,804,318,771)",
AI disponible
Sébastien MARQUE authored on 2017-03-10
254
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
255
#}}}
AI disponible
Sébastien MARQUE authored on 2017-03-10
256

            
animation VSI
Sébastien MARQUE authored on 2017-03-10
257
    texts : {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
258
#{{{
animation VSI
Sébastien MARQUE authored on 2017-03-10
259
        VSIText : {
260
            alignment: "right-bottom", default : num('0'),
261
        },
animation IAS
Sébastien MARQUE authored on 2017-03-10
262
        Speed110 : {
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
263
            alignment : 'left-bottom'
animation IAS
Sébastien MARQUE authored on 2017-03-10
264
        },
animation ALT (2)
Sébastien MARQUE authored on 2017-03-11
265
        Alt11100 : {
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
266
            alignment:'left-bottom'
animation ALT (2)
Sébastien MARQUE authored on 2017-03-11
267
        },
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
268
        "HDG-text" : {
269
            default: '---°'
270
        },
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
271
        'nav1-standby-freq' : {
272
            color: [0, 1, 1],
273
        },
274
        'nav1-id' : {
275
            default: ''
276
        },
277
        'nav2-id' : {
278
            default: ''
279
        },
animation VSI
Sébastien MARQUE authored on 2017-03-10
280
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
281
#}}}
animation VSI
Sébastien MARQUE authored on 2017-03-10
282

            
AI disponible, avec bankPoin...
Sébastien MARQUE authored on 2017-03-10
283
    updateAI: func(roll,pitch){
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
284
#{{{
AI disponible
Sébastien MARQUE authored on 2017-03-10
285
        if (pitch > 80)
286
            pitch = 80;
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
287
        elsif (pitch < -80)
AI disponible
Sébastien MARQUE authored on 2017-03-10
288
            pitch = -80;
289
        me.screenElements.Horizon
290
            .setRotation(-roll * D2R)
291
            .setTranslation(0, pitch * 6.8571428);
AI disponible, avec bankPoin...
Sébastien MARQUE authored on 2017-03-10
292
        me.screenElements.bankPointer
293
            .setRotation(-roll * D2R);
294
        settimer(func me.updateAI(getprop('/orientation/roll-deg'),getprop('orientation/pitch-deg')), 0.1);
AI disponible
Sébastien MARQUE authored on 2017-03-10
295
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
296
#}}}
animation VSI
Sébastien MARQUE authored on 2017-03-10
297

            
298
    updateVSI: func (vsi) {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
299
# animate VSI {{{
animation VSI
Sébastien MARQUE authored on 2017-03-10
300
        me.screenElements.VSIText
301
            .setText(num(math.round(vsi, 10)));
302
        if (vsi > 4500)
303
            vsi = 4500;
304
        elsif (vsi < -4500)
305
            vsi = -4500;
306
        me.screenElements.VSI
307
            .setTranslation(0, vsi * -0.03465);
308
        settimer(func me.updateVSI(getprop('/instrumentation/vertical-speed-indicator/indicated-speed-fpm')), 0.1);
309
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
310
#}}}
animation IAS
Sébastien MARQUE authored on 2017-03-10
311

            
312
    updateIAS: func (ias) {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
313
# animates the IAS lint (PFD) {{{
animation IAS
Sébastien MARQUE authored on 2017-03-10
314
        if (ias >= 10)
315
            me.screenElements.Speed110
316
                .setText(sprintf("% 2u",num(math.floor(ias/10))));
317
        else
318
            me.screenElements.Speed110
319
                .setText('');
320
        me.screenElements.SpeedLint1
321
            .setTranslation(0,(math.mod(ias,10) + (ias >= 10)*10) * 36);
322
        me.screenElements.SpeedTape
323
            .setTranslation(0,ias * 5.711);
trends animation
Sébastien MARQUE authored on 2017-03-13
324
        var now = systime();
325
        # estimated speed in 6s
326
        var Sy = 6 * (ias - me._last_ias_kt) / (now - me._last_ias_s);
327
        if (abs(Sy) > 30)
328
            Sy = 30 * abs(Sy)/Sy; # = -30 or 30
329
        me.screenElements['Airspeed-Trend-Indicator']
330
            .setScale(1,Sy)
331
            .setTranslation(0, -284.5 * (Sy - 1));
332
        me._last_ias_kt = ias;
333
        me._last_ias_s = now;
animation IAS
Sébastien MARQUE authored on 2017-03-10
334
        settimer(func me.updateIAS(getprop('/velocities/airspeed-kt')), 0.1);
335
    },
trends animation
Sébastien MARQUE authored on 2017-03-13
336
    _last_ias_kt : 0,
337
    _last_ias_s : systime(),
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
338
#}}}
animation ALT
Sébastien MARQUE authored on 2017-03-11
339

            
340
    updateALT: func (alt) {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
341
# animates the altitude lint (PFD) trent to do {{{
animation ALT
Sébastien MARQUE authored on 2017-03-11
342
        if (alt < 0)
343
            me.screenElements.Alt11100
344
                .setText(sprintf("% 3i",math.ceil(alt/100)));
345
        elsif (alt < 100)
346
            me.screenElements.Alt11100
347
                .setText('');
348
        else
349
            me.screenElements.Alt11100
350
                .setText(sprintf("% 3i",math.floor(alt/100)));
351
        me.screenElements.AltLint00011
352
            .setTranslation(0,math.fmod(alt,100) * 1.24);
353

            
354
        # From Farmin/G1000 http://wiki.flightgear.org/Project_Farmin/FG1000
355
        if (alt> -1000 and alt< 1000000) {
356
            var Offset10 = 0;
357
            var Offset100 = 0;
358
            var Offset1000 = 0;
359
            if (alt< 0) {
360
                var Ne = 1;
361
                var alt= -alt;
362
            }
363
            else
364
                var Ne = 0;
365

            
366
            var Alt10       = math.mod(alt,100);
367
            var Alt100      = int(math.mod(alt/100,10));
368
            var Alt1000     = int(math.mod(alt/1000,10));
369
            var Alt10000    = int(math.mod(alt/10000,10));
370
            var Alt20       = math.mod(Alt10,20)/20;
371
            if (Alt10 >= 80)
372
                var Alt100 += Alt20;
373

            
374
            if (Alt10 >= 80 and Alt100 >= 9)
375
                var Alt1000 += Alt20;
376

            
377
            if (Alt10 >= 80 and Alt100 >= 9 and Alt1000 >= 9)
378
                var Alt10000 += Alt20;
379

            
380
            if (alt> 100)
381
                var Offset10 = 100;
382

            
383
            if (alt> 1000)
384
                var Offset100 = 10;
385

            
386
            if (alt> 10000)
387
                var Offset1000 = 10;
388

            
389
            if (!Ne) {
390
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*0.57375);
391
                var altCentral = (int(alt/100)*100);
392
            }
393
            elsif (Ne) {
394
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*-0.57375);
395
                var altCentral = -(int(alt/100)*100);
396
            }
397
            me.screenElements["AltBigC"].setText("");
398
            me.screenElements["AltSmallC"].setText("");
399
            for (var place = 1; place <= 6; place += 1) {
400
                var altUP = altCentral + (place*100);
401
                var offset = -30.078;
402
                if (altUP < 0) {
403
                    var altUP = -altUP;
404
                    var prefix = "-";
405
                    var offset += 15.039;
406
                }
407
                else
408
                    var prefix = "";
409

            
410
                if (altUP == 0) {
411
                    var AltBigUP    = "";
412
                    var AltSmallUP  = "0";
413

            
414
                }
415
                elsif (math.mod(altUP,500) == 0 and altUP != 0) {
416
                    var AltBigUP    = sprintf(prefix~"%1d", altUP);
417
                    var AltSmallUP  = "";
418
                }
419
                elsif (altUP < 1000 and (math.mod(altUP,500))) {
420
                    var AltBigUP    = "";
421
                    var AltSmallUP  = sprintf(prefix~"%1d", int(math.mod(altUP,1000)));
422
                    var offset = -30.078;
423
                }
424
                elsif ((altUP < 10000) and (altUP >= 1000) and (math.mod(altUP,500))) {
425
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
426
                    var AltSmallUP  = sprintf("%1d", int(math.mod(altUP,1000)));
427
                    var offset += 15.039;
428
                }
429
                else {
430
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
431
                    var mod = int(math.mod(altUP,1000));
432
                    var AltSmallUP  = sprintf("%1d", mod);
433
                    var offset += 30.078;
434
                }
435

            
436
                me.screenElements["AltBigU"~place].setText(AltBigUP);
437
                me.screenElements["AltSmallU"~place].setText(AltSmallUP);
438
                me.screenElements["AltSmallU"~place].setTranslation(offset,0);
439
                var altDOWN = altCentral - (place*100);
440
                var offset = -30.078;
441
                if (altDOWN < 0) {
442
                    var altDOWN = -altDOWN;
443
                    var prefix = "-";
444
                    var offset += 15.039;
445
                }
446
                else
447
                    var prefix = "";
448

            
449
                if (altDOWN == 0) {
450
                    var AltBigDOWN  = "";
451
                    var AltSmallDOWN    = "0";
452
                }
453
                elsif (math.mod(altDOWN,500) == 0 and altDOWN != 0) {
454
                    var AltBigDOWN  = sprintf(prefix~"%1d", altDOWN);
455
                    var AltSmallDOWN    = "";
456
                }
457
                elsif (altDOWN < 1000 and (math.mod(altDOWN,500))) {
458
                    var AltBigDOWN  = "";
459
                    var AltSmallDOWN    = sprintf(prefix~"%1d", int(math.mod(altDOWN,1000)));
460
                    var offset = -30.078;
461
                }
462
                elsif ((altDOWN < 10000) and (altDOWN >= 1000) and (math.mod(altDOWN,500))) {
463
                    var AltBigDOWN  = sprintf(prefix~"%1d", int(altDOWN/1000));
464
                    var AltSmallDOWN    = sprintf("%1d", int(math.mod(altDOWN,1000)));
465
                    var offset += 15.039;
466
                }
467
                else {
468
                    var AltBigDOWN  = sprintf(prefix~"%1d", int(altDOWN/1000));
469
                    var mod = int(math.mod(altDOWN,1000));
470
                    var AltSmallDOWN    = sprintf("%1d", mod);
471
                    var offset += 30.078;
472
                }
473
                me.screenElements["AltBigD"~place].setText(AltBigDOWN);
474
                me.screenElements["AltSmallD"~place].setText(AltSmallDOWN);
475
                me.screenElements["AltSmallD"~place].setTranslation(offset,0);
476
            }
477
        }
trends animation
Sébastien MARQUE authored on 2017-03-13
478
        var now = systime();
479
        # altitude in 6s
480
        var Sy = .3 * (alt - me._last_alt_ft) / (now - me._last_alt_s); # scale = 1/20ft
481
        if (abs(Sy) > 15)
482
            Sy = 15 * abs(Sy)/Sy; # = -15 or 15
483
        me.screenElements['Altitude-Trend-Indicator']
484
            .setScale(1,Sy)
485
            .setTranslation(0, -284.5 * (Sy - 1));
486
        me._last_alt_ft = alt;
487
        me._last_alt_s = now;
animation ALT
Sébastien MARQUE authored on 2017-03-11
488
        settimer(func me.updateALT(getprop('instrumentation/altimeter/indicated-altitude-ft')), 0.2);
489
    },
trends animation
Sébastien MARQUE authored on 2017-03-13
490
    _last_alt_ft : 0,
491
    _last_alt_s  : systime(),
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
492
#}}}
animation HSI
Sébastien MARQUE authored on 2017-03-11
493

            
494
    updateHSI : func (hdg) {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
495
# rotates the compass (PFD) {{{
animation HSI
Sébastien MARQUE authored on 2017-03-11
496
        me.screenElements.Rose
497
            .setRotation(-hdg * D2R);
498
        me.screenElements['HDG-text']
499
            .setText(sprintf("%03u°", hdg));
500
        settimer(func me.updateHSI(getprop('orientation/heading-deg')), 0.1);
501
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
502
#}}}
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
503

            
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
504
    updateHDG : func (hdg) {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
505
# moves the heading bug and display heading-deg for 3 seconds (PFD) {{{
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
506
        if (me.role == 'MFD')
507
            return;
508
        me.screenElements['Heading-bug']
509
            .setRotation(hdg * D2R);
510
        me.screenElements['SelectedHDG-bg']
511
            .show();
512
        me.screenElements['SelectedHDG-bgtext']
513
            .show();
514
        me.screenElements['SelectedHDG-text']
515
            .setText(sprintf('%03d°%s', hdg, ''))
516
            .show();
517
        me.addTimer(3, ['SelectedHDG-text', 'SelectedHDG-bgtext', 'SelectedHDG-bg']);
518
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
519
#}}}
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
520

            
anime CRS
Sébastien MARQUE authored on 2017-03-13
521
    updateCRS : func (crs) {
522
# TODO: update display for NAV/GPS/BRG courses {{{
523
        if (me.role == 'MFD')
524
            return;
525
        me.screenElements['SelectedCRS-bg']
526
            .show();
527
        me.screenElements['SelectedCRS-bgtext']
528
            .show();
529
        me.screenElements['SelectedCRS-text']
530
            .setText(sprintf('%03d°%s', crs, ''))
531
            .show();
532
        me.addTimer(3, ['SelectedCRS-text', 'SelectedCRS-bgtext', 'SelectedCRS-bg']);
533
    },
534
#}}}
535

            
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
536
    _updateRadio: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
537
# common parts for NAV/LOC/COMM radios{{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
538
        # arg[0]._r = <comm|nav>
539
        if (contains(arg[0], "active")) {
540
            if (arg[0]['active'] == 'none') {
541
                me.screenElements[arg[0]._r ~ '1-selected-freq']
542
                    .setColor(1,1,1);
543
                me.screenElements[arg[0]._r ~ '2-selected-freq']
544
                    .setColor(1,1,1);
545
            }
546
            else {
547
                me.screenElements[arg[0]._r ~ arg[0]['active'] ~ '-selected-freq']
548
                    .setColor(0,1,0);
549
                me.screenElements[arg[0]._r ~ arg[0].inactive ~ '-selected-freq']
550
                    .setColor(1,1,1);
551
            }
552
        }
553
        if (contains(arg[0], 'tune')) {
554
            # n = 0 -> NAV1/COMM1
555
            # n = 1 -> NAV1/COMM2
556
            me.screenElements[arg[0]._r ~ '-freq-switch']
557
                .setTranslation(0, arg[0].tune * 25);
558
            me.screenElements[arg[0]._r ~ (arg[0].tune + 1) ~ '-standby-freq']
559
                .setColor(0,1,1);
560
            me.screenElements[arg[0]._r ~ ((arg[0].tune == 0) + 1) ~ '-standby-freq']
561
                .setColor(1,1,1);
562
        }
563
        if (contains(arg[0], 'refresh')) {
564
            # rafraichi une seule ligne NAV1/COMM1 ou NAV2/COMM2
565
            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
566
            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-selected-freq']
567
                .setText(sprintf(fmt, getprop('/instrumentation/'
568
                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/selected-mhz')));
569
            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-standby-freq']
570
                .setText(sprintf(fmt, getprop('/instrumentation/'
571
                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/standby-mhz')));
572
        }
573
        if (contains(arg[0], 'set')) {
574
            # positionne la valeur modifiée, les listeners "trigguent" en permanence ces propriétés, donc exit
575
            var n = getprop('/instrumentation/zkv1000/radios/' ~ arg[0]._r ~ '-tune');
576
            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
577
            me.screenElements[arg[0]._r ~ (n + 1) ~ '-standby-freq']
578
                .setText(getprop('/instrumentation/' ~ arg[0]._r ~ '[' ~ n ~ ']/frequencies/standby-mhz'));
579
        }
580
        if (contains(arg[0], 'auto')) {
581
            # pour rafraichir automagiquement, toutes les deux secondes un refresh pour un NAV
582
            var radio = arg[0].auto;
583
            me._updateRadio({refresh: 1, _r: radio});
584
            settimer(func me._updateRadio({refresh: 2, _r: radio}), 1);
585
            settimer(func me._updateRadio({auto: radio}), 2);
586
        }
587
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
588
#}}}
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
589

            
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
590
    updateNAV : func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
591
# update NAV/LOC rodios display upper left (PFD/MFD){{{
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
592
        # made active via menu
593
        if (contains(arg[0], "active")) {
594
            if (arg[0]['active'] == 'none') {
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
595
                arg[0]._r = 'nav';
596
                me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
597
                me.screenElements['nav1-id']
598
                    .setColor(1,1,1);
599
                me.screenElements['nav2-id']
600
                    .setColor(1,1,1);
601
                me.screenElements['NAV1-pointer']
602
                    .hide();
603
                me.screenElements['NAV2-pointer']
604
                    .hide();
605
            }
606
            else {
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
607
                arg[0]._r = 'nav';
608
                arg[0].inactive = (arg[0]['active'] == 1) + 1;
609
                me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
610
                me.screenElements['nav' ~ arg[0]['active'] ~ '-id']
611
                    .setColor(0,1,0);
612
                me.screenElements['NAV' ~ arg[0]['active'] ~ '-pointer']
613
                    .show();
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
614
                me.screenElements['nav' ~ arg[0].inactive ~ '-id']
615
                    .setColor(1,1,1);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
616
#                me.screenElements['HDI']
617
#                    .setRotation();
618
#                me.screenElements['NAV' ~ inactive ~ '-pointer']
619
#                    .hide();
620
#                foreach (var e; [ 'FROM', 'TO', 'CDI' ])
621
#                    me.screenElements['NAV' ~ inactive ~ '-' ~ e]
622
#                        .hide();
623
            }
624
        }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
625
        elsif (contains(arg[0], 'nav-id')) {
Correction swap NAV tuning
Sébastien MARQUE authored on 2017-03-12
626
            # 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
627
            if (arg[0].val == nil)
628
                arg[0].val = '';
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
629
            me.screenElements["nav" ~ arg[0]['nav-id'] ~ "-id"]
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
630
                    .setText(arg[0].val);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
631
        }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
632
        else {
633
            arg[0]._r = 'nav';
634
            me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
635
        }
636
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
637
#}}}
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
638

            
639
    updateCOMM: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
640
# update COMM radios display upper right (PFD/MFD){{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
641
        arg[0]._r = 'comm';
642
        me._updateRadio(arg[0]);
643
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
644
#}}}
anime time display
Sébastien MARQUE authored on 2017-03-13
645

            
646
    updateTIME : func {
647
# updates the displayed time botoom left {{{
648
        me.screenElements['TIME-text']
649
            .setText(getprop('/sim/time/gmt-string'));
650
        settimer(func me.updateTIME(), 1);
651
    },
652
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
653
};