zkv1000 / Nasal / display.nas /
Newer Older
652 lines | 23.558kb
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 = {
3
    new: func(node, role) {
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;
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
18
        m.screenElements = {};
commit initial
Sébastien MARQUE authored on 2017-03-07
19

            
20
        return m;
21
    },
22

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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