zkv1000 / Nasal / display.nas /
Newer Older
769 lines | 27.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) {
add new vim folds
Sébastien MARQUE authored on 2017-03-15
4
# the contructor {{{
commit initial
Sébastien MARQUE authored on 2017-03-07
5
        var m = { parents: [ displayClass ] };
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
6

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

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

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

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

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

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

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

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

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

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

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

            
177
    showInitProgress : func (role) {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
178
#{{{
commit initial
Sébastien MARQUE authored on 2017-03-07
179
        me.progress = me.display.createGroup();
180
        me.progress.show();
181
        me.progress.createChild("text", role ~ " title")
182
            .setTranslation(512, 384)
183
            .setAlignment("center-center")
184
            .setFont("LiberationFonts/LiberationSans-Italic.ttf")
185
            .setFontSize(64, 1)
186
            .setColor(1,1,1)
187
            .setText("ZKV1000 " ~ role ~ " init");
188

            
189
        zkv.getNode(role ~ 'init',1).setIntValue(1);
190

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

            
256
    clips : {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
257
#{{{
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
258
        PitchScale   : "rect(70,664,370,256)",
259
        SpeedLint1   : "rect(252,226,318,204)",
260
        SpeedTape    : "rect(115,239,455,156)",
261
        LintAlt      : "rect(115,808,455,704)",
animation ALT
Sébastien MARQUE authored on 2017-03-11
262
        AltLint00011 : "rect(252,804,318,771)",
AI disponible
Sébastien MARQUE authored on 2017-03-10
263
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
264
#}}}
AI disponible
Sébastien MARQUE authored on 2017-03-10
265

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

            
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
292
    updateSoftKeys : func {
293
# update SoftKeys boxes {{{
294
        # grey background code = #353939
295
        # on PFD the last boxes are always BACK and ALERTS
296
        if (me.role == 'PFD') {
297
            me.screenElements[sprintf("SoftKey%02i-text", 11)]
298
                .setText('ALERTS');
299
            if (size(me.device.softkeys.path) != 0)
300
                me.screenElements[sprintf("SoftKey%02i-text", 10)]
301
                    .setText('BACK');
302
        }
303

            
304
        var path = keyMap[me.role];
305
        foreach (var p; me.device.softkeys.path)
306
            path = path[p];
307

            
308
        # feeding with empty menus the first boxes
309
        var start = (contains(path, 'first')) ? path.first : 0;
310
        for (var k = 0; k < start; k+=1) {
311
            me.screenElements[sprintf("SoftKey%02i-text", k)]
312
                .setText('');
313
        }
314
        # filling with the content the next boxes
315
        forindex (var k; path.texts) {
316
            var i = k + start;
317
            me.screenElements[sprintf("SoftKey%02i-text", i)]
318
                .setText(path.texts[k]);
319
        }
320
        # feeding the last boxes with empty string
321
        var end = (me.role == 'PFD') ? 10 : 12;
322
        if (size(path.texts) + start < end) {
323
            start = size(path.texts) + start;
324
            for (var k = start; k < end; k += 1)
325
                me.screenElements[sprintf("SoftKey%02i-text", k)]
326
                    .setText('');
327
        }
328
    },
329
#}}}
330

            
AI disponible, avec bankPoin...
Sébastien MARQUE authored on 2017-03-10
331
    updateAI: func(roll,pitch){
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
332
#{{{
AI disponible
Sébastien MARQUE authored on 2017-03-10
333
        if (pitch > 80)
334
            pitch = 80;
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
335
        elsif (pitch < -80)
AI disponible
Sébastien MARQUE authored on 2017-03-10
336
            pitch = -80;
337
        me.screenElements.Horizon
338
            .setRotation(-roll * D2R)
339
            .setTranslation(0, pitch * 6.8571428);
AI disponible, avec bankPoin...
Sébastien MARQUE authored on 2017-03-10
340
        me.screenElements.bankPointer
341
            .setRotation(-roll * D2R);
342
        settimer(func me.updateAI(getprop('/orientation/roll-deg'),getprop('orientation/pitch-deg')), 0.1);
AI disponible
Sébastien MARQUE authored on 2017-03-10
343
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
344
#}}}
animation VSI
Sébastien MARQUE authored on 2017-03-10
345

            
346
    updateVSI: func (vsi) {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
347
# animate VSI {{{
animation VSI
Sébastien MARQUE authored on 2017-03-10
348
        me.screenElements.VSIText
349
            .setText(num(math.round(vsi, 10)));
350
        if (vsi > 4500)
351
            vsi = 4500;
352
        elsif (vsi < -4500)
353
            vsi = -4500;
354
        me.screenElements.VSI
355
            .setTranslation(0, vsi * -0.03465);
356
        settimer(func me.updateVSI(getprop('/instrumentation/vertical-speed-indicator/indicated-speed-fpm')), 0.1);
357
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
358
#}}}
animation IAS
Sébastien MARQUE authored on 2017-03-10
359

            
360
    updateIAS: func (ias) {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
361
# animates the IAS lint (PFD) {{{
animation IAS
Sébastien MARQUE authored on 2017-03-10
362
        if (ias >= 10)
363
            me.screenElements.Speed110
364
                .setText(sprintf("% 2u",num(math.floor(ias/10))));
365
        else
366
            me.screenElements.Speed110
367
                .setText('');
368
        me.screenElements.SpeedLint1
369
            .setTranslation(0,(math.mod(ias,10) + (ias >= 10)*10) * 36);
370
        me.screenElements.SpeedTape
371
            .setTranslation(0,ias * 5.711);
trends animation
Sébastien MARQUE authored on 2017-03-13
372
        var now = systime();
373
        # estimated speed in 6s
374
        var Sy = 6 * (ias - me._last_ias_kt) / (now - me._last_ias_s);
375
        if (abs(Sy) > 30)
376
            Sy = 30 * abs(Sy)/Sy; # = -30 or 30
377
        me.screenElements['Airspeed-Trend-Indicator']
378
            .setScale(1,Sy)
379
            .setTranslation(0, -284.5 * (Sy - 1));
380
        me._last_ias_kt = ias;
381
        me._last_ias_s = now;
animation IAS
Sébastien MARQUE authored on 2017-03-10
382
        settimer(func me.updateIAS(getprop('/velocities/airspeed-kt')), 0.1);
383
    },
trends animation
Sébastien MARQUE authored on 2017-03-13
384
    _last_ias_kt : 0,
385
    _last_ias_s : systime(),
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
386
#}}}
animation ALT
Sébastien MARQUE authored on 2017-03-11
387

            
388
    updateALT: func (alt) {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
389
# animates the altitude lint (PFD) trent to do {{{
animation ALT
Sébastien MARQUE authored on 2017-03-11
390
        if (alt < 0)
391
            me.screenElements.Alt11100
392
                .setText(sprintf("% 3i",math.ceil(alt/100)));
393
        elsif (alt < 100)
394
            me.screenElements.Alt11100
395
                .setText('');
396
        else
397
            me.screenElements.Alt11100
398
                .setText(sprintf("% 3i",math.floor(alt/100)));
399
        me.screenElements.AltLint00011
400
            .setTranslation(0,math.fmod(alt,100) * 1.24);
401

            
402
        # From Farmin/G1000 http://wiki.flightgear.org/Project_Farmin/FG1000
403
        if (alt> -1000 and alt< 1000000) {
404
            var Offset10 = 0;
405
            var Offset100 = 0;
406
            var Offset1000 = 0;
407
            if (alt< 0) {
408
                var Ne = 1;
409
                var alt= -alt;
410
            }
411
            else
412
                var Ne = 0;
413

            
414
            var Alt10       = math.mod(alt,100);
415
            var Alt100      = int(math.mod(alt/100,10));
416
            var Alt1000     = int(math.mod(alt/1000,10));
417
            var Alt10000    = int(math.mod(alt/10000,10));
418
            var Alt20       = math.mod(Alt10,20)/20;
419
            if (Alt10 >= 80)
420
                var Alt100 += Alt20;
421

            
422
            if (Alt10 >= 80 and Alt100 >= 9)
423
                var Alt1000 += Alt20;
424

            
425
            if (Alt10 >= 80 and Alt100 >= 9 and Alt1000 >= 9)
426
                var Alt10000 += Alt20;
427

            
428
            if (alt> 100)
429
                var Offset10 = 100;
430

            
431
            if (alt> 1000)
432
                var Offset100 = 10;
433

            
434
            if (alt> 10000)
435
                var Offset1000 = 10;
436

            
437
            if (!Ne) {
438
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*0.57375);
439
                var altCentral = (int(alt/100)*100);
440
            }
441
            elsif (Ne) {
442
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*-0.57375);
443
                var altCentral = -(int(alt/100)*100);
444
            }
445
            me.screenElements["AltBigC"].setText("");
446
            me.screenElements["AltSmallC"].setText("");
447
            for (var place = 1; place <= 6; place += 1) {
448
                var altUP = altCentral + (place*100);
449
                var offset = -30.078;
450
                if (altUP < 0) {
451
                    var altUP = -altUP;
452
                    var prefix = "-";
453
                    var offset += 15.039;
454
                }
455
                else
456
                    var prefix = "";
457

            
458
                if (altUP == 0) {
459
                    var AltBigUP    = "";
460
                    var AltSmallUP  = "0";
461

            
462
                }
463
                elsif (math.mod(altUP,500) == 0 and altUP != 0) {
464
                    var AltBigUP    = sprintf(prefix~"%1d", altUP);
465
                    var AltSmallUP  = "";
466
                }
467
                elsif (altUP < 1000 and (math.mod(altUP,500))) {
468
                    var AltBigUP    = "";
469
                    var AltSmallUP  = sprintf(prefix~"%1d", int(math.mod(altUP,1000)));
470
                    var offset = -30.078;
471
                }
472
                elsif ((altUP < 10000) and (altUP >= 1000) and (math.mod(altUP,500))) {
473
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
474
                    var AltSmallUP  = sprintf("%1d", int(math.mod(altUP,1000)));
475
                    var offset += 15.039;
476
                }
477
                else {
478
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
479
                    var mod = int(math.mod(altUP,1000));
480
                    var AltSmallUP  = sprintf("%1d", mod);
481
                    var offset += 30.078;
482
                }
483

            
484
                me.screenElements["AltBigU"~place].setText(AltBigUP);
485
                me.screenElements["AltSmallU"~place].setText(AltSmallUP);
486
                me.screenElements["AltSmallU"~place].setTranslation(offset,0);
487
                var altDOWN = altCentral - (place*100);
488
                var offset = -30.078;
489
                if (altDOWN < 0) {
490
                    var altDOWN = -altDOWN;
491
                    var prefix = "-";
492
                    var offset += 15.039;
493
                }
494
                else
495
                    var prefix = "";
496

            
497
                if (altDOWN == 0) {
498
                    var AltBigDOWN  = "";
499
                    var AltSmallDOWN    = "0";
500
                }
501
                elsif (math.mod(altDOWN,500) == 0 and altDOWN != 0) {
502
                    var AltBigDOWN  = sprintf(prefix~"%1d", altDOWN);
503
                    var AltSmallDOWN    = "";
504
                }
505
                elsif (altDOWN < 1000 and (math.mod(altDOWN,500))) {
506
                    var AltBigDOWN  = "";
507
                    var AltSmallDOWN    = sprintf(prefix~"%1d", int(math.mod(altDOWN,1000)));
508
                    var offset = -30.078;
509
                }
510
                elsif ((altDOWN < 10000) and (altDOWN >= 1000) and (math.mod(altDOWN,500))) {
511
                    var AltBigDOWN  = sprintf(prefix~"%1d", int(altDOWN/1000));
512
                    var AltSmallDOWN    = sprintf("%1d", int(math.mod(altDOWN,1000)));
513
                    var offset += 15.039;
514
                }
515
                else {
516
                    var AltBigDOWN  = sprintf(prefix~"%1d", int(altDOWN/1000));
517
                    var mod = int(math.mod(altDOWN,1000));
518
                    var AltSmallDOWN    = sprintf("%1d", mod);
519
                    var offset += 30.078;
520
                }
521
                me.screenElements["AltBigD"~place].setText(AltBigDOWN);
522
                me.screenElements["AltSmallD"~place].setText(AltSmallDOWN);
523
                me.screenElements["AltSmallD"~place].setTranslation(offset,0);
524
            }
525
        }
trends animation
Sébastien MARQUE authored on 2017-03-13
526
        var now = systime();
527
        # altitude in 6s
528
        var Sy = .3 * (alt - me._last_alt_ft) / (now - me._last_alt_s); # scale = 1/20ft
529
        if (abs(Sy) > 15)
530
            Sy = 15 * abs(Sy)/Sy; # = -15 or 15
531
        me.screenElements['Altitude-Trend-Indicator']
532
            .setScale(1,Sy)
533
            .setTranslation(0, -284.5 * (Sy - 1));
534
        me._last_alt_ft = alt;
535
        me._last_alt_s = now;
animation ALT
Sébastien MARQUE authored on 2017-03-11
536
        settimer(func me.updateALT(getprop('instrumentation/altimeter/indicated-altitude-ft')), 0.2);
537
    },
trends animation
Sébastien MARQUE authored on 2017-03-13
538
    _last_alt_ft : 0,
539
    _last_alt_s  : systime(),
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
540
#}}}
animation HSI
Sébastien MARQUE authored on 2017-03-11
541

            
542
    updateHSI : func (hdg) {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
543
# rotates the compass (PFD) {{{
animation HSI
Sébastien MARQUE authored on 2017-03-11
544
        me.screenElements.Rose
545
            .setRotation(-hdg * D2R);
546
        me.screenElements['HDG-text']
547
            .setText(sprintf("%03u°", hdg));
548
        settimer(func me.updateHSI(getprop('orientation/heading-deg')), 0.1);
549
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
550
#}}}
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
551

            
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
552
    updateHDG : func (hdg) {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
553
# moves the heading bug and display heading-deg for 3 seconds (PFD) {{{
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
554
        if (me.role == 'MFD')
555
            return;
556
        me.screenElements['Heading-bug']
557
            .setRotation(hdg * D2R);
558
        me.screenElements['SelectedHDG-bg']
559
            .show();
560
        me.screenElements['SelectedHDG-bgtext']
561
            .show();
562
        me.screenElements['SelectedHDG-text']
563
            .setText(sprintf('%03d°%s', hdg, ''))
564
            .show();
565
        me.addTimer(3, ['SelectedHDG-text', 'SelectedHDG-bgtext', 'SelectedHDG-bg']);
566
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
567
#}}}
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
568

            
anime CRS
Sébastien MARQUE authored on 2017-03-13
569
    updateCRS : func (crs) {
570
# TODO: update display for NAV/GPS/BRG courses {{{
571
        if (me.role == 'MFD')
572
            return;
573
        me.screenElements['SelectedCRS-bg']
574
            .show();
575
        me.screenElements['SelectedCRS-bgtext']
576
            .show();
577
        me.screenElements['SelectedCRS-text']
578
            .setText(sprintf('%03d°%s', crs, ''))
579
            .show();
580
        me.addTimer(3, ['SelectedCRS-text', 'SelectedCRS-bgtext', 'SelectedCRS-bg']);
581
    },
582
#}}}
583

            
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
584
    _updateRadio: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
585
# common parts for NAV/LOC/COMM radios{{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
586
        # arg[0]._r = <comm|nav>
587
        if (contains(arg[0], "active")) {
588
            if (arg[0]['active'] == 'none') {
589
                me.screenElements[arg[0]._r ~ '1-selected-freq']
590
                    .setColor(1,1,1);
591
                me.screenElements[arg[0]._r ~ '2-selected-freq']
592
                    .setColor(1,1,1);
593
            }
594
            else {
595
                me.screenElements[arg[0]._r ~ arg[0]['active'] ~ '-selected-freq']
596
                    .setColor(0,1,0);
597
                me.screenElements[arg[0]._r ~ arg[0].inactive ~ '-selected-freq']
598
                    .setColor(1,1,1);
599
            }
600
        }
601
        if (contains(arg[0], 'tune')) {
602
            # n = 0 -> NAV1/COMM1
603
            # n = 1 -> NAV1/COMM2
604
            me.screenElements[arg[0]._r ~ '-freq-switch']
605
                .setTranslation(0, arg[0].tune * 25);
606
            me.screenElements[arg[0]._r ~ (arg[0].tune + 1) ~ '-standby-freq']
607
                .setColor(0,1,1);
608
            me.screenElements[arg[0]._r ~ ((arg[0].tune == 0) + 1) ~ '-standby-freq']
609
                .setColor(1,1,1);
610
        }
611
        if (contains(arg[0], 'refresh')) {
612
            # rafraichi une seule ligne NAV1/COMM1 ou NAV2/COMM2
613
            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
614
            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-selected-freq']
615
                .setText(sprintf(fmt, getprop('/instrumentation/'
616
                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/selected-mhz')));
617
            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-standby-freq']
618
                .setText(sprintf(fmt, getprop('/instrumentation/'
619
                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/standby-mhz')));
620
        }
621
        if (contains(arg[0], 'set')) {
622
            # positionne la valeur modifiée, les listeners "trigguent" en permanence ces propriétés, donc exit
623
            var n = getprop('/instrumentation/zkv1000/radios/' ~ arg[0]._r ~ '-tune');
624
            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
625
            me.screenElements[arg[0]._r ~ (n + 1) ~ '-standby-freq']
626
                .setText(getprop('/instrumentation/' ~ arg[0]._r ~ '[' ~ n ~ ']/frequencies/standby-mhz'));
627
        }
628
        if (contains(arg[0], 'auto')) {
629
            # pour rafraichir automagiquement, toutes les deux secondes un refresh pour un NAV
630
            var radio = arg[0].auto;
631
            me._updateRadio({refresh: 1, _r: radio});
632
            settimer(func me._updateRadio({refresh: 2, _r: radio}), 1);
633
            settimer(func me._updateRadio({auto: radio}), 2);
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

            
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
638
    updateNAV : func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
639
# update NAV/LOC rodios display upper left (PFD/MFD){{{
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
640
        # made active via menu
641
        if (contains(arg[0], "active")) {
642
            if (arg[0]['active'] == 'none') {
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
643
                arg[0]._r = 'nav';
644
                me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
645
                me.screenElements['nav1-id']
646
                    .setColor(1,1,1);
647
                me.screenElements['nav2-id']
648
                    .setColor(1,1,1);
649
                me.screenElements['NAV1-pointer']
650
                    .hide();
651
                me.screenElements['NAV2-pointer']
652
                    .hide();
653
            }
654
            else {
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
655
                arg[0]._r = 'nav';
656
                arg[0].inactive = (arg[0]['active'] == 1) + 1;
657
                me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
658
                me.screenElements['nav' ~ arg[0]['active'] ~ '-id']
659
                    .setColor(0,1,0);
660
                me.screenElements['NAV' ~ arg[0]['active'] ~ '-pointer']
661
                    .show();
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
662
                me.screenElements['nav' ~ arg[0].inactive ~ '-id']
663
                    .setColor(1,1,1);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
664
#                me.screenElements['HDI']
665
#                    .setRotation();
666
#                me.screenElements['NAV' ~ inactive ~ '-pointer']
667
#                    .hide();
668
#                foreach (var e; [ 'FROM', 'TO', 'CDI' ])
669
#                    me.screenElements['NAV' ~ inactive ~ '-' ~ e]
670
#                        .hide();
671
            }
672
        }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
673
        elsif (contains(arg[0], 'nav-id')) {
Correction swap NAV tuning
Sébastien MARQUE authored on 2017-03-12
674
            # 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
675
            if (arg[0].val == nil)
676
                arg[0].val = '';
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
677
            me.screenElements["nav" ~ arg[0]['nav-id'] ~ "-id"]
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
678
                    .setText(arg[0].val);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
679
        }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
680
        else {
681
            arg[0]._r = 'nav';
682
            me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
683
        }
684
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
685
#}}}
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
686

            
687
    updateCOMM: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
688
# update COMM radios display upper right (PFD/MFD){{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
689
        arg[0]._r = 'comm';
690
        me._updateRadio(arg[0]);
691
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
692
#}}}
anime time display
Sébastien MARQUE authored on 2017-03-13
693

            
694
    updateTIME : func {
695
# updates the displayed time botoom left {{{
696
        me.screenElements['TIME-text']
697
            .setText(getprop('/sim/time/gmt-string'));
698
        settimer(func me.updateTIME(), 1);
699
    },
700
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
701
};
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
702

            
703
var keyMap = {
add new vim folds
Sébastien MARQUE authored on 2017-03-15
704
# softkeys map for PFD and MFD {{{
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
705
    PFD : {
706
        first : 1,
707
        texts : ['INSET', 'SENSOR', 'PFD', 'OBS', 'CDI', 'DME', 'XPDR', 'IDENT', 'TMR/REF', 'NRST' ],
708
        INSET : {
709
            texts : ['OFF', 'DCLTR', 'WXLGND', 'TRAFFIC', 'TOPO', 'TERRAIN', 'STRMSCP', 'NEXRAD-C', 'XM LTNG', 'METAR'],
710
        },
711
        SENSOR : {
712
            first : 2,
713
            texts : [ 'ADC1', 'ADC2', '', 'AHRS1', 'AHRS2'],
714
        },
715
        PFD : {
716
            texts : [ 'SYN VIS', 'DFLTS', 'AOA/WIND', 'DME', 'BRG', 'HSI FMT', '', '', 'ALT UNIT', 'STD BARO' ],
717
            'SYN VIS' : {
718
                texts : [ 'PATHWAY', 'SYN TERR', 'HR2NHDG', 'APTSIGNS', 'FPM'],
719
            },
720
            'AOA/WIND' : {
721
                first : 4,
722
                texts : ['AOA', 'WIND'],
723
                AOA : {
724
                    first : 5,
725
                    texts : ['AOA ON', 'AOA AUTO'],
726
                },
727
                WIND : {
728
                    first : 2,
729
                    texts : ['OPTN1', 'OPTN2', '', 'OFF'],
730
                },
731
            },
732
            'HSI FMT' : {
733
                first : 6,
734
                texts : ['360 HSI', 'ARC HSI'],
735
            },
736
            'ALT UNIT' : {
737
                first : 5,
738
                texts : ['METERS', '', 'IN', 'HPA'],
739
            },
740
        },
741
        XPDR : {
742
            first : 2,
743
            texts : ['STBY', 'ON', 'ALT', '', 'VFR', 'CODE', 'IDENT'],
744
            CODE : {
745
                texts : ['0', '1', '2', '3', '4', '5', '6', '7', 'IDENT', 'BKSP'],
746
            },
747
        },
748
    },
749
    MFD : {
750
        texts : ['ENGINE', '', 'MAP', '', '', '', '', '', '', 'DCLTR', 'SHW CHRT', 'CHKLIST'],
751
        MAP : {
752
            texts: ['TRAFFIC', 'PROFILE', 'TOPO', 'TERRAIN', 'AIRWAYS', 'STRMSCP','NEXRAD-C', 'XM LTNG', 'METAR', 'LEGEND', 'BACK'],
753
        },
754
        CHKLIST : {
755
            texts : ['ENGINE', '', '', '', '', 'DONE', '', '', '', '', 'EXIT', 'EMERGCY'],
756
        },
757
        ENGINE : {
758
            texts : ['ENGINE', 'ANTI-ICE', '', 'DCLTR', '', 'ASSIST', '', '', '', '', 'FUEL'],
759
            'ANTI-ICE' : {
760
                texts : ['LEFT', 'AUTO', 'RIGHT', '', '', '', '', '', '', '', '', 'BACK'],
761
            },
762
            FUEL : {
763
                first : 1,
764
                texts : ['FULL', 'TABS', '', '', '', '', '', '', '', 'UNDO', 'ENTER'],
765
            },
766
        },
767
    },
768
};
add new vim folds
Sébastien MARQUE authored on 2017-03-15
769
#}}}