zkv1000 / Nasal / display.nas /
Newer Older
627 lines | 22.473kb
cosmétique: folding pour les...
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,
126
                    'VSIText',
127
                    'Speed110',
128
                    'Alt11100',
129
                    'HDG-text',
130
                    'AltBigC', 'AltSmallC'
131
                );
132
                for (var place = 1; place <= 6; place +=1) {
133
                    append(groups.text,
134
                        'AltBigU' ~ place,
135
                        'AltSmallU' ~ place,
136
                        'AltBigD' ~ place,
137
                        'AltSmallD' ~ place
138
                    );
139
                }
animation ALT
Sébastien MARQUE authored on 2017-03-11
140
            }
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
141
            else
142
                append(groups.show, 'Header');
143

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

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

            
165
    showInitProgress : func (role) {
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
        me.progress = me.display.createGroup();
168
        me.progress.show();
169
        me.progress.createChild("text", role ~ " title")
170
            .setTranslation(512, 384)
171
            .setAlignment("center-center")
172
            .setFont("LiberationFonts/LiberationSans-Italic.ttf")
173
            .setFontSize(64, 1)
174
            .setColor(1,1,1)
175
            .setText("ZKV1000 " ~ role ~ " init");
176

            
177
        zkv.getNode(role ~ 'init',1).setIntValue(1);
178

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

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

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

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

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

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

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

            
337
    updateALT: func (alt) {
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
        if (alt < 0)
340
            me.screenElements.Alt11100
341
                .setText(sprintf("% 3i",math.ceil(alt/100)));
342
        elsif (alt < 100)
343
            me.screenElements.Alt11100
344
                .setText('');
345
        else
346
            me.screenElements.Alt11100
347
                .setText(sprintf("% 3i",math.floor(alt/100)));
348
        me.screenElements.AltLint00011
349
            .setTranslation(0,math.fmod(alt,100) * 1.24);
350

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

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

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

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

            
377
            if (alt> 100)
378
                var Offset10 = 100;
379

            
380
            if (alt> 1000)
381
                var Offset100 = 10;
382

            
383
            if (alt> 10000)
384
                var Offset1000 = 10;
385

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

            
407
                if (altUP == 0) {
408
                    var AltBigUP    = "";
409
                    var AltSmallUP  = "0";
410

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

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

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

            
491
    updateHSI : func (hdg) {
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
        me.screenElements.Rose
494
            .setRotation(-hdg * D2R);
495
        me.screenElements['HDG-text']
496
            .setText(sprintf("%03u°", hdg));
497
        settimer(func me.updateHSI(getprop('orientation/heading-deg')), 0.1);
498
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
499
#}}}
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
500

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

            
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
518
    _updateRadio: func {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
519
#{{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
520
        # arg[0]._r = <comm|nav>
521
        if (contains(arg[0], "active")) {
522
            if (arg[0]['active'] == 'none') {
523
                me.screenElements[arg[0]._r ~ '1-selected-freq']
524
                    .setColor(1,1,1);
525
                me.screenElements[arg[0]._r ~ '2-selected-freq']
526
                    .setColor(1,1,1);
527
            }
528
            else {
529
                me.screenElements[arg[0]._r ~ arg[0]['active'] ~ '-selected-freq']
530
                    .setColor(0,1,0);
531
                me.screenElements[arg[0]._r ~ arg[0].inactive ~ '-selected-freq']
532
                    .setColor(1,1,1);
533
            }
534
        }
535
        if (contains(arg[0], 'tune')) {
536
            # n = 0 -> NAV1/COMM1
537
            # n = 1 -> NAV1/COMM2
538
            me.screenElements[arg[0]._r ~ '-freq-switch']
539
                .setTranslation(0, arg[0].tune * 25);
540
            me.screenElements[arg[0]._r ~ (arg[0].tune + 1) ~ '-standby-freq']
541
                .setColor(0,1,1);
542
            me.screenElements[arg[0]._r ~ ((arg[0].tune == 0) + 1) ~ '-standby-freq']
543
                .setColor(1,1,1);
544
        }
545
        if (contains(arg[0], 'refresh')) {
546
            # rafraichi une seule ligne NAV1/COMM1 ou NAV2/COMM2
547
            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
548
            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-selected-freq']
549
                .setText(sprintf(fmt, getprop('/instrumentation/'
550
                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/selected-mhz')));
551
            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-standby-freq']
552
                .setText(sprintf(fmt, getprop('/instrumentation/'
553
                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/standby-mhz')));
554
        }
555
        if (contains(arg[0], 'set')) {
556
            # positionne la valeur modifiée, les listeners "trigguent" en permanence ces propriétés, donc exit
557
            var n = getprop('/instrumentation/zkv1000/radios/' ~ arg[0]._r ~ '-tune');
558
            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
559
            me.screenElements[arg[0]._r ~ (n + 1) ~ '-standby-freq']
560
                .setText(getprop('/instrumentation/' ~ arg[0]._r ~ '[' ~ n ~ ']/frequencies/standby-mhz'));
561
        }
562
        if (contains(arg[0], 'auto')) {
563
            # pour rafraichir automagiquement, toutes les deux secondes un refresh pour un NAV
564
            var radio = arg[0].auto;
565
            me._updateRadio({refresh: 1, _r: radio});
566
            settimer(func me._updateRadio({refresh: 2, _r: radio}), 1);
567
            settimer(func me._updateRadio({auto: radio}), 2);
568
        }
569
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
570
#}}}
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
571

            
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
572
    updateNAV : func {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
573
#{{{
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
574
        # made active via menu
575
        if (contains(arg[0], "active")) {
576
            if (arg[0]['active'] == 'none') {
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
577
                arg[0]._r = 'nav';
578
                me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
579
                me.screenElements['nav1-id']
580
                    .setColor(1,1,1);
581
                me.screenElements['nav2-id']
582
                    .setColor(1,1,1);
583
                me.screenElements['NAV1-pointer']
584
                    .hide();
585
                me.screenElements['NAV2-pointer']
586
                    .hide();
587
            }
588
            else {
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
589
                arg[0]._r = 'nav';
590
                arg[0].inactive = (arg[0]['active'] == 1) + 1;
591
                me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
592
                me.screenElements['nav' ~ arg[0]['active'] ~ '-id']
593
                    .setColor(0,1,0);
594
                me.screenElements['NAV' ~ arg[0]['active'] ~ '-pointer']
595
                    .show();
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
596
                me.screenElements['nav' ~ arg[0].inactive ~ '-id']
597
                    .setColor(1,1,1);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
598
#                me.screenElements['HDI']
599
#                    .setRotation();
600
#                me.screenElements['NAV' ~ inactive ~ '-pointer']
601
#                    .hide();
602
#                foreach (var e; [ 'FROM', 'TO', 'CDI' ])
603
#                    me.screenElements['NAV' ~ inactive ~ '-' ~ e]
604
#                        .hide();
605
            }
606
        }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
607
        elsif (contains(arg[0], 'nav-id')) {
Correction swap NAV tuning
Sébastien MARQUE authored on 2017-03-12
608
            # 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
609
            if (arg[0].val == nil)
610
                arg[0].val = '';
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
611
            me.screenElements["nav" ~ arg[0]['nav-id'] ~ "-id"]
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
612
                    .setText(arg[0].val);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
613
        }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
614
        else {
615
            arg[0]._r = 'nav';
616
            me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
617
        }
618
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
619
#}}}
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
620

            
621
    updateCOMM: func {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
622
#{{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
623
        arg[0]._r = 'comm';
624
        me._updateRadio(arg[0]);
625
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
626
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
627
};