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

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

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

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

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

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

            
211
        zkv.getNode(role ~ 'init',1).setIntValue(1);
212

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

            
some added comments
Sébastien MARQUE authored on 2017-03-18
222
    colors : {
223
# set of predefined colors {{{
224
        green : [0, 1, 0],
225
        white : [1, 1, 1],
226
        black : [0, 0, 0],
227
        lightblue : [0, 1, 1],
228
        darkblue : [0, 0, 1],
229
        red : [1, 0, 0],
230
    },
231
#}}}
232

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

            
289
    clips : {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
290
#{{{
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
291
        PitchScale   : "rect(70,664,370,256)",
292
        SpeedLint1   : "rect(252,226,318,204)",
293
        SpeedTape    : "rect(115,239,455,156)",
294
        LintAlt      : "rect(115,808,455,704)",
animation ALT
Sébastien MARQUE authored on 2017-03-11
295
        AltLint00011 : "rect(252,804,318,771)",
AI disponible
Sébastien MARQUE authored on 2017-03-10
296
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
297
#}}}
AI disponible
Sébastien MARQUE authored on 2017-03-10
298

            
animation VSI
Sébastien MARQUE authored on 2017-03-10
299
    texts : {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
300
#{{{
animation VSI
Sébastien MARQUE authored on 2017-03-10
301
        VSIText : {
302
            alignment: "right-bottom", default : num('0'),
303
        },
animation IAS
Sébastien MARQUE authored on 2017-03-10
304
        Speed110 : {
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
305
            alignment : 'left-bottom'
animation IAS
Sébastien MARQUE authored on 2017-03-10
306
        },
animation ALT (2)
Sébastien MARQUE authored on 2017-03-11
307
        Alt11100 : {
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
308
            alignment:'left-bottom'
animation ALT (2)
Sébastien MARQUE authored on 2017-03-11
309
        },
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
310
        "HDG-text" : {
311
            default: '---°'
312
        },
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
313
        'nav1-standby-freq' : {
314
            color: [0, 1, 1],
315
        },
316
        'nav1-id' : {
317
            default: ''
318
        },
319
        'nav2-id' : {
320
            default: ''
321
        },
some added comments
Sébastien MARQUE authored on 2017-03-18
322
#        'TAS-text' : {
323
#            alignment : 'right-bottom',
324
#        },
325
#        'GSPD-text' : {
326
#            alignment : 'right-bottom',
327
#        },
animation VSI
Sébastien MARQUE authored on 2017-03-10
328
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
329
#}}}
animation VSI
Sébastien MARQUE authored on 2017-03-10
330

            
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
331
    updateSoftKeys : func {
332
# update SoftKeys boxes {{{
333
        # grey background code = #353939
334
        # on PFD the last boxes are always BACK and ALERTS
335
        if (me.role == 'PFD') {
336
            me.screenElements[sprintf("SoftKey%02i-text", 11)]
337
                .setText('ALERTS');
338
            if (size(me.device.softkeys.path) != 0)
339
                me.screenElements[sprintf("SoftKey%02i-text", 10)]
340
                    .setText('BACK');
341
        }
342

            
343
        var path = keyMap[me.role];
344
        foreach (var p; me.device.softkeys.path)
345
            path = path[p];
346

            
347
        # feeding with empty menus the first boxes
348
        var start = (contains(path, 'first')) ? path.first : 0;
349
        for (var k = 0; k < start; k+=1) {
350
            me.screenElements[sprintf("SoftKey%02i-text", k)]
351
                .setText('');
352
        }
353
        # filling with the content the next boxes
354
        forindex (var k; path.texts) {
355
            var i = k + start;
356
            me.screenElements[sprintf("SoftKey%02i-text", i)]
357
                .setText(path.texts[k]);
358
        }
359
        # feeding the last boxes with empty string
360
        var end = (me.role == 'PFD') ? 10 : 12;
361
        if (size(path.texts) + start < end) {
362
            start = size(path.texts) + start;
363
            for (var k = start; k < end; k += 1)
364
                me.screenElements[sprintf("SoftKey%02i-text", k)]
365
                    .setText('');
366
        }
367
    },
368
#}}}
369

            
refresh of vital information...
Sébastien MARQUE authored on 2017-03-18
370
    update20Hz : func {
371
# 20Hz updates roll, pitch, VSI, IAS, altitude and HDG {{{
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
372
        me._updated_roll = getprop('/orientation/roll-deg');
373
        me._updated_pitch = getprop('orientation/pitch-deg');
374
        me._updated_vsi = getprop('/instrumentation/vertical-speed-indicator/indicated-speed-fpm');
375
        me._updated_ias = getprop('/velocities/airspeed-kt');
376
        me._updated_alt = getprop('/instrumentation/altimeter/indicated-altitude-ft');
377
        me._updated_hdg = getprop('/orientation/heading-deg');
refresh of vital information...
Sébastien MARQUE authored on 2017-03-18
378
        settimer(func me.update20Hz(), 0.05);
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
379
     },
380
    _updated_roll : 0,
381
    _updated_pitch : 0,
382
    _updated_vsi : 0,
383
    _updated_ias : 0,
384
    _updated_alt : 0,
385
    _updated_hdg : 0,
386
#}}}
387

            
refresh of vital information...
Sébastien MARQUE authored on 2017-03-18
388
    update1Hz : func {
389
# 1Hz updates {{{
390
        me._updated_wow = getprop('/gear/gear/wow');
391
        settimer(func me.update20Hz(), 1);
392
    },
393
    _updated_wow : 1,
394
#}}}
395

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
396
    updateAI: func(){
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
397
#{{{
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
398
        var pitch = me._updated_pitch;
399
        var roll = me._updated_roll;
AI disponible
Sébastien MARQUE authored on 2017-03-10
400
        if (pitch > 80)
401
            pitch = 80;
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
402
        elsif (pitch < -80)
AI disponible
Sébastien MARQUE authored on 2017-03-10
403
            pitch = -80;
404
        me.screenElements.Horizon
405
            .setRotation(-roll * D2R)
406
            .setTranslation(0, pitch * 6.8571428);
AI disponible, avec bankPoin...
Sébastien MARQUE authored on 2017-03-10
407
        me.screenElements.bankPointer
408
            .setRotation(-roll * D2R);
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
409
        settimer(func me.updateAI(), 0.1);
AI disponible
Sébastien MARQUE authored on 2017-03-10
410
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
411
#}}}
animation VSI
Sébastien MARQUE authored on 2017-03-10
412

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
413
    updateVSI: func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
414
# animate VSI {{{
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
415
        var vsi = me._updated_vsi;
animation VSI
Sébastien MARQUE authored on 2017-03-10
416
        me.screenElements.VSIText
417
            .setText(num(math.round(vsi, 10)));
418
        if (vsi > 4500)
419
            vsi = 4500;
420
        elsif (vsi < -4500)
421
            vsi = -4500;
422
        me.screenElements.VSI
423
            .setTranslation(0, vsi * -0.03465);
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
424
        settimer(func me.updateVSI(), 0.1);
animation VSI
Sébastien MARQUE authored on 2017-03-10
425
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
426
#}}}
animation IAS
Sébastien MARQUE authored on 2017-03-10
427

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
428
    updateIAS: func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
429
# animates the IAS lint (PFD) {{{
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
430
        var ias = me._updated_ias;
animation IAS
Sébastien MARQUE authored on 2017-03-10
431
        if (ias >= 10)
432
            me.screenElements.Speed110
433
                .setText(sprintf("% 2u",num(math.floor(ias/10))));
434
        else
435
            me.screenElements.Speed110
436
                .setText('');
437
        me.screenElements.SpeedLint1
438
            .setTranslation(0,(math.mod(ias,10) + (ias >= 10)*10) * 36);
439
        me.screenElements.SpeedTape
440
            .setTranslation(0,ias * 5.711);
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
441
        if (ias > me._ias_vne and ! me._ias_already_exceeded) { # easier than .getColorFill
442
            me._ias_already_exceeded = 1;
443
            me.screenElements['IAS-bg']
444
                .setColorFill(1,0,0);
445
        }
446
        elsif (ias < me._ias_vne and me._ias_already_exceeded) { # easier than .getColorFill
447
            me._ias_already_exceeded = 0;
448
            me.screenElements['IAS-bg']
449
                .setColorFill(0,0,0);
450
        }
trends animation
Sébastien MARQUE authored on 2017-03-13
451
        var now = systime();
452
        # estimated speed in 6s
453
        var Sy = 6 * (ias - me._last_ias_kt) / (now - me._last_ias_s);
454
        if (abs(Sy) > 30)
455
            Sy = 30 * abs(Sy)/Sy; # = -30 or 30
456
        me.screenElements['Airspeed-Trend-Indicator']
457
            .setScale(1,Sy)
458
            .setTranslation(0, -284.5 * (Sy - 1));
459
        me._last_ias_kt = ias;
460
        me._last_ias_s = now;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
461
        settimer(func me.updateIAS(), 0.1);
animation IAS
Sébastien MARQUE authored on 2017-03-10
462
    },
trends animation
Sébastien MARQUE authored on 2017-03-13
463
    _last_ias_kt : 0,
464
    _last_ias_s : systime(),
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
465
    _ias_vne : 999,
466
    _ias_already_exceeded : 0,
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
467
#}}}
animation ALT
Sébastien MARQUE authored on 2017-03-11
468

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
469
    updateTAS: func {
470
# updates the True Airspeed and GroundSpeed indicators {{{
471
        me.screenElements['TAS-text']
472
            .setText(sprintf('%iKT', getprop('/instrumentation/airspeed-indicator/true-speed-kt')));
473
        me.screenElements['GSPD-text']
474
            .setText(sprintf('%iKT', getprop('/velocities/groundspeed-kt')));
475
        settimer(func me.updateTAS(), 0.5);
476
    },
477
#}}}
478

            
479
    updateALT: func () {
480
# animates the altitude lint (PFD) {{{
481
        var alt = me._updated_alt;
animation ALT
Sébastien MARQUE authored on 2017-03-11
482
        if (alt < 0)
483
            me.screenElements.Alt11100
484
                .setText(sprintf("% 3i",math.ceil(alt/100)));
485
        elsif (alt < 100)
486
            me.screenElements.Alt11100
487
                .setText('');
488
        else
489
            me.screenElements.Alt11100
490
                .setText(sprintf("% 3i",math.floor(alt/100)));
491
        me.screenElements.AltLint00011
492
            .setTranslation(0,math.fmod(alt,100) * 1.24);
493

            
494
        # From Farmin/G1000 http://wiki.flightgear.org/Project_Farmin/FG1000
495
        if (alt> -1000 and alt< 1000000) {
496
            var Offset10 = 0;
497
            var Offset100 = 0;
498
            var Offset1000 = 0;
499
            if (alt< 0) {
500
                var Ne = 1;
501
                var alt= -alt;
502
            }
503
            else
504
                var Ne = 0;
505

            
506
            var Alt10       = math.mod(alt,100);
507
            var Alt100      = int(math.mod(alt/100,10));
508
            var Alt1000     = int(math.mod(alt/1000,10));
509
            var Alt10000    = int(math.mod(alt/10000,10));
510
            var Alt20       = math.mod(Alt10,20)/20;
511
            if (Alt10 >= 80)
512
                var Alt100 += Alt20;
513

            
514
            if (Alt10 >= 80 and Alt100 >= 9)
515
                var Alt1000 += Alt20;
516

            
517
            if (Alt10 >= 80 and Alt100 >= 9 and Alt1000 >= 9)
518
                var Alt10000 += Alt20;
519

            
520
            if (alt> 100)
521
                var Offset10 = 100;
522

            
523
            if (alt> 1000)
524
                var Offset100 = 10;
525

            
526
            if (alt> 10000)
527
                var Offset1000 = 10;
528

            
529
            if (!Ne) {
530
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*0.57375);
531
                var altCentral = (int(alt/100)*100);
532
            }
533
            elsif (Ne) {
534
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*-0.57375);
535
                var altCentral = -(int(alt/100)*100);
536
            }
537
            me.screenElements["AltBigC"].setText("");
538
            me.screenElements["AltSmallC"].setText("");
539
            for (var place = 1; place <= 6; place += 1) {
540
                var altUP = altCentral + (place*100);
541
                var offset = -30.078;
542
                if (altUP < 0) {
543
                    var altUP = -altUP;
544
                    var prefix = "-";
545
                    var offset += 15.039;
546
                }
547
                else
548
                    var prefix = "";
549

            
550
                if (altUP == 0) {
551
                    var AltBigUP    = "";
552
                    var AltSmallUP  = "0";
553

            
554
                }
555
                elsif (math.mod(altUP,500) == 0 and altUP != 0) {
556
                    var AltBigUP    = sprintf(prefix~"%1d", altUP);
557
                    var AltSmallUP  = "";
558
                }
559
                elsif (altUP < 1000 and (math.mod(altUP,500))) {
560
                    var AltBigUP    = "";
561
                    var AltSmallUP  = sprintf(prefix~"%1d", int(math.mod(altUP,1000)));
562
                    var offset = -30.078;
563
                }
564
                elsif ((altUP < 10000) and (altUP >= 1000) and (math.mod(altUP,500))) {
565
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
566
                    var AltSmallUP  = sprintf("%1d", int(math.mod(altUP,1000)));
567
                    var offset += 15.039;
568
                }
569
                else {
570
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
571
                    var mod = int(math.mod(altUP,1000));
572
                    var AltSmallUP  = sprintf("%1d", mod);
573
                    var offset += 30.078;
574
                }
575

            
576
                me.screenElements["AltBigU"~place].setText(AltBigUP);
577
                me.screenElements["AltSmallU"~place].setText(AltSmallUP);
578
                me.screenElements["AltSmallU"~place].setTranslation(offset,0);
579
                var altDOWN = altCentral - (place*100);
580
                var offset = -30.078;
581
                if (altDOWN < 0) {
582
                    var altDOWN = -altDOWN;
583
                    var prefix = "-";
584
                    var offset += 15.039;
585
                }
586
                else
587
                    var prefix = "";
588

            
589
                if (altDOWN == 0) {
590
                    var AltBigDOWN  = "";
591
                    var AltSmallDOWN    = "0";
592
                }
593
                elsif (math.mod(altDOWN,500) == 0 and altDOWN != 0) {
594
                    var AltBigDOWN  = sprintf(prefix~"%1d", altDOWN);
595
                    var AltSmallDOWN    = "";
596
                }
597
                elsif (altDOWN < 1000 and (math.mod(altDOWN,500))) {
598
                    var AltBigDOWN  = "";
599
                    var AltSmallDOWN    = sprintf(prefix~"%1d", int(math.mod(altDOWN,1000)));
600
                    var offset = -30.078;
601
                }
602
                elsif ((altDOWN < 10000) and (altDOWN >= 1000) and (math.mod(altDOWN,500))) {
603
                    var AltBigDOWN  = sprintf(prefix~"%1d", int(altDOWN/1000));
604
                    var AltSmallDOWN    = sprintf("%1d", int(math.mod(altDOWN,1000)));
605
                    var offset += 15.039;
606
                }
607
                else {
608
                    var AltBigDOWN  = sprintf(prefix~"%1d", int(altDOWN/1000));
609
                    var mod = int(math.mod(altDOWN,1000));
610
                    var AltSmallDOWN    = sprintf("%1d", mod);
611
                    var offset += 30.078;
612
                }
613
                me.screenElements["AltBigD"~place].setText(AltBigDOWN);
614
                me.screenElements["AltSmallD"~place].setText(AltSmallDOWN);
615
                me.screenElements["AltSmallD"~place].setTranslation(offset,0);
616
            }
617
        }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
618
        me.updateSelectedALT();
trends animation
Sébastien MARQUE authored on 2017-03-13
619
        var now = systime();
620
        # altitude in 6s
621
        var Sy = .3 * (alt - me._last_alt_ft) / (now - me._last_alt_s); # scale = 1/20ft
622
        if (abs(Sy) > 15)
623
            Sy = 15 * abs(Sy)/Sy; # = -15 or 15
624
        me.screenElements['Altitude-Trend-Indicator']
625
            .setScale(1,Sy)
626
            .setTranslation(0, -284.5 * (Sy - 1));
627
        me._last_alt_ft = alt;
628
        me._last_alt_s = now;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
629
        settimer(func me.updateALT(), 0.2);
animation ALT
Sébastien MARQUE authored on 2017-03-11
630
    },
trends animation
Sébastien MARQUE authored on 2017-03-13
631
    _last_alt_ft : 0,
632
    _last_alt_s  : systime(),
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
633
#}}}
animation HSI
Sébastien MARQUE authored on 2017-03-11
634

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
635
    updateHSI : func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
636
# rotates the compass (PFD) {{{
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
637
        var hdg = me._updated_hdg;
animation HSI
Sébastien MARQUE authored on 2017-03-11
638
        me.screenElements.Rose
639
            .setRotation(-hdg * D2R);
640
        me.screenElements['HDG-text']
641
            .setText(sprintf("%03u°", hdg));
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
642
        settimer(func me.updateHSI(), 0.1);
animation HSI
Sébastien MARQUE authored on 2017-03-11
643
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
644
#}}}
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
645

            
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
646
    updateHDG : func (hdg) {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
647
# moves the heading bug and display heading-deg for 3 seconds (PFD) {{{
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
648
        if (me.role == 'MFD')
649
            return;
650
        me.screenElements['Heading-bug']
651
            .setRotation(hdg * D2R);
652
        me.screenElements['SelectedHDG-bg']
653
            .show();
654
        me.screenElements['SelectedHDG-bgtext']
655
            .show();
656
        me.screenElements['SelectedHDG-text']
657
            .setText(sprintf('%03d°%s', hdg, ''))
658
            .show();
659
        me.addTimer(3, ['SelectedHDG-text', 'SelectedHDG-bgtext', 'SelectedHDG-bg']);
660
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
661
#}}}
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
662

            
anime CRS
Sébastien MARQUE authored on 2017-03-13
663
    updateCRS : func (crs) {
664
# TODO: update display for NAV/GPS/BRG courses {{{
665
        if (me.role == 'MFD')
666
            return;
667
        me.screenElements['SelectedCRS-bg']
668
            .show();
669
        me.screenElements['SelectedCRS-bgtext']
670
            .show();
671
        me.screenElements['SelectedCRS-text']
672
            .setText(sprintf('%03d°%s', crs, ''))
673
            .show();
674
        me.addTimer(3, ['SelectedCRS-text', 'SelectedCRS-bgtext', 'SelectedCRS-bg']);
675
    },
676
#}}}
677

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
678
    updateSelectedALT : func {
679
# animation for altitude section, called via updatedALT {{{
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
680
        if (! device[0].display.screenElements['SelectedALT'].getVisible())
681
            return;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
682
        var selected_alt = getprop('/instrumentation/zkv1000/afcs/selected-alt-ft');
683
        var delta_alt = me._updated_alt - selected_alt;
684
        if (abs(delta_alt) > 300)
685
            delta_alt = 300 * abs(delta_alt)/delta_alt;
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
686
        me.screenElements['SelectedALT-symbol']
687
            .setVisible(abs(delta_alt) > 100);
688
        me.screenElements['SelectedALT-bg']
689
            .setVisible(abs(delta_alt) > 100);
690
        me.screenElements['SelectedALT-text']
691
            .setText(sprintf("%i", selected_alt))
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
692
            .setVisible(abs(delta_alt) > 100);
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
693
        me.screenElements['SelectedALT-bug']
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
694
            .setTranslation(0, delta_alt * 0.567); # 170/300 = 0.567
695
    },
696
#}}}
697

            
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
698
    _updateRadio: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
699
# common parts for NAV/LOC/COMM radios{{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
700
        # arg[0]._r = <comm|nav>
701
        if (contains(arg[0], "active")) {
702
            if (arg[0]['active'] == 'none') {
703
                me.screenElements[arg[0]._r ~ '1-selected-freq']
704
                    .setColor(1,1,1);
705
                me.screenElements[arg[0]._r ~ '2-selected-freq']
706
                    .setColor(1,1,1);
707
            }
708
            else {
709
                me.screenElements[arg[0]._r ~ arg[0]['active'] ~ '-selected-freq']
710
                    .setColor(0,1,0);
711
                me.screenElements[arg[0]._r ~ arg[0].inactive ~ '-selected-freq']
712
                    .setColor(1,1,1);
713
            }
714
        }
715
        if (contains(arg[0], 'tune')) {
716
            # n = 0 -> NAV1/COMM1
717
            # n = 1 -> NAV1/COMM2
718
            me.screenElements[arg[0]._r ~ '-freq-switch']
719
                .setTranslation(0, arg[0].tune * 25);
720
            me.screenElements[arg[0]._r ~ (arg[0].tune + 1) ~ '-standby-freq']
721
                .setColor(0,1,1);
722
            me.screenElements[arg[0]._r ~ ((arg[0].tune == 0) + 1) ~ '-standby-freq']
723
                .setColor(1,1,1);
724
        }
725
        if (contains(arg[0], 'refresh')) {
726
            # rafraichi une seule ligne NAV1/COMM1 ou NAV2/COMM2
727
            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
728
            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-selected-freq']
729
                .setText(sprintf(fmt, getprop('/instrumentation/'
730
                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/selected-mhz')));
731
            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-standby-freq']
732
                .setText(sprintf(fmt, getprop('/instrumentation/'
733
                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/standby-mhz')));
734
        }
735
        if (contains(arg[0], 'set')) {
736
            # positionne la valeur modifiée, les listeners "trigguent" en permanence ces propriétés, donc exit
737
            var n = getprop('/instrumentation/zkv1000/radios/' ~ arg[0]._r ~ '-tune');
738
            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
739
            me.screenElements[arg[0]._r ~ (n + 1) ~ '-standby-freq']
fix freq display while setti...
Sébastien MARQUE authored on 2017-03-16
740
                .setText(sprintf(fmt, getprop('/instrumentation/' ~ arg[0]._r ~ '[' ~ n ~ ']/frequencies/standby-mhz')));
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
741
        }
742
        if (contains(arg[0], 'auto')) {
743
            # pour rafraichir automagiquement, toutes les deux secondes un refresh pour un NAV
744
            var radio = arg[0].auto;
745
            me._updateRadio({refresh: 1, _r: radio});
746
            settimer(func me._updateRadio({refresh: 2, _r: radio}), 1);
747
            settimer(func me._updateRadio({auto: radio}), 2);
748
        }
749
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
750
#}}}
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
751

            
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
752
    updateNAV : func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
753
# update NAV/LOC rodios display upper left (PFD/MFD){{{
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
754
        # made active via menu
755
        if (contains(arg[0], "active")) {
756
            if (arg[0]['active'] == 'none') {
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
757
                arg[0]._r = 'nav';
758
                me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
759
                me.screenElements['nav1-id']
760
                    .setColor(1,1,1);
761
                me.screenElements['nav2-id']
762
                    .setColor(1,1,1);
763
                me.screenElements['NAV1-pointer']
764
                    .hide();
765
                me.screenElements['NAV2-pointer']
766
                    .hide();
767
            }
768
            else {
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
769
                arg[0]._r = 'nav';
770
                arg[0].inactive = (arg[0]['active'] == 1) + 1;
771
                me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
772
                me.screenElements['nav' ~ arg[0]['active'] ~ '-id']
773
                    .setColor(0,1,0);
774
                me.screenElements['NAV' ~ arg[0]['active'] ~ '-pointer']
775
                    .show();
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
776
                me.screenElements['nav' ~ arg[0].inactive ~ '-id']
777
                    .setColor(1,1,1);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
778
#                me.screenElements['HDI']
779
#                    .setRotation();
780
#                me.screenElements['NAV' ~ inactive ~ '-pointer']
781
#                    .hide();
782
#                foreach (var e; [ 'FROM', 'TO', 'CDI' ])
783
#                    me.screenElements['NAV' ~ inactive ~ '-' ~ e]
784
#                        .hide();
785
            }
786
        }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
787
        elsif (contains(arg[0], 'nav-id')) {
Correction swap NAV tuning
Sébastien MARQUE authored on 2017-03-12
788
            # 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
789
            if (arg[0].val == nil)
790
                arg[0].val = '';
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
791
            me.screenElements["nav" ~ arg[0]['nav-id'] ~ "-id"]
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
792
                    .setText(arg[0].val);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
793
        }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
794
        else {
795
            arg[0]._r = 'nav';
796
            me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
797
        }
798
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
799
#}}}
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
800

            
801
    updateCOMM: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
802
# update COMM radios display upper right (PFD/MFD){{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
803
        arg[0]._r = 'comm';
804
        me._updateRadio(arg[0]);
805
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
806
#}}}
anime time display
Sébastien MARQUE authored on 2017-03-13
807

            
808
    updateTIME : func {
809
# updates the displayed time botoom left {{{
810
        me.screenElements['TIME-text']
811
            .setText(getprop('/sim/time/gmt-string'));
812
        settimer(func me.updateTIME(), 1);
813
    },
814
#}}}
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
815

            
adds transponder
Sébastien MARQUE authored on 2017-03-17
816
    updateXPDR : func {
817
# updates transponder display {{{
818
        for (var d = 0; d < 4; d+=1)
819
            me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
820
                .setText(sprintf('%i', getprop('/instrumentation/transponder/inputs/digit[' ~ d ~ ']')));
821
        var tuning = getprop('/instrumentation/zkv1000/radios/xpdr-tuning-digit');
822
        if (tuning != nil)
823
            for (var d = 0; d < 4; d+=1) {
824
                if (d != tuning)
825
                    me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
826
                        .setColor(1,1,1);
827
                else
828
                    me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
829
                        .setColor(0,1,1);
830
            }
831
        else {
832
            if (getprop('/instrumentation/transponder/ident'))
833
                var mode = 'IDENT';
834
            else
835
                var mode = getprop('/instrumentation/zkv1000/radio/xpdr-mode');
836
            var wow = getprop('/gear/gear/wow');
837
            if (! wow and mode != 'STBY')
838
                var color = [0, 1, 0];
839
            else
840
                var color = [1, 1, 1];
841
            for (var d = 0; d < 4; d+=1)
842
                me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
843
                    .setColor(color);
844
            me.screenElements['XPDR-MODE-text']
845
                .setColor(color)
846
                .setText(mode);
847
        }
848
},
849
#}}}
850

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
851
    updateOAT : func {
852
# update OAT display on normal and reversionnary modes (every 3s) {{{
853
        var tmp = getprop('/environment/temperature-deg' ~ me._oat_unit);
854
        me.screenElements['OAT-text']
855
            .setText(sprintf((abs(tmp) < 10) ? "%.1f %s" : "%i %s", tmp, (me._oat_unit == 'c') ? '°C' : 'F'));
856
        settimer(func me.updateOAT(), 3);
857
    },
858
    _oat_unit : 'c',
859
#}}}
860

            
861
    updateWindData : func {
862
# update the window text and arrows for OPTN1/2 {{{
863
        if (me._winddata_optn == 0)
864
            return;
improves WindData display
Sébastien MARQUE authored on 2017-03-16
865
        if (me._updated_ias < 30) {
866
            me.screenElements['WindData-NODATA']
867
                .hide();
868
            var wind_hdg = getprop('/environment/wind-from-heading-deg');
869
            var wind_spd = getprop('/environment/wind-speed-kt');
870
            var alpha = wind_hdg - me._updated_hdg;
871
            if (me._winddata_optn == 1) {
872
                me.screenElements['WindData-OPTN1-HDG']
873
                    .setRotation((alpha + 180) * D2R)
874
                    .show();
875
                me.screenElements['WindData-OPTN1-HDG-text']
876
                    .setText(sprintf("%03i°", wind_hdg))
877
                    .show();
878
                me.screenElements['WindData-OPTN1-SPD-text']
879
                    .setText(int(wind_spd) ~ 'KT')
880
                    .show();
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
881
            }
improves WindData display
Sébastien MARQUE authored on 2017-03-16
882
            else { # me._winddata_optn == 2
883
                alpha *= D2R;
884
                var Vt = wind_spd * math.sin(alpha);
885
                var Ve = wind_spd * math.cos(alpha);
886
                if (Vt != 0) {
887
                    me.screenElements['WindData-OPTN2-crosswind-text']
888
                        .setText(sprintf('%i', abs(Vt)))
889
                        .show();
890
                    me.screenElements['WindData-OPTN2-crosswind']
891
                        .setScale(-abs(Vt)/Vt, 1)
892
                        .setTranslation(-35 * (abs(Vt)/Vt + 1), 0)
893
                        .show();
894
                }
895
                if (Ve != 0) {
896
                    me.screenElements['WindData-OPTN2-headwind-text']
897
                        .setText(sprintf('%i', abs(Ve)))
898
                        .show();
899
                    me.screenElements['WindData-OPTN2-headwind']
900
                        .setScale(1, abs(Ve)/Ve)
901
                        .setTranslation(0, 515 * (1 - abs(Ve)/Ve))
902
                        .show();
903
                }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
904
            }
905
        }
improves WindData display
Sébastien MARQUE authored on 2017-03-16
906
        else {
907
            foreach (var e; [
908
                    'WindData-OPTN1-HDG',
909
                    'WindData-OPTN1-HDG-text',
910
                    'WindData-OPTN1-SPD-text',
911
                    'WindData-OPTN2-crosswind-text',
912
                    'WindData-OPTN2-crosswind',
913
                    'WindData-OPTN2-headwind-text',
914
                    'WindData-OPTN2-headwind'
915
            ])
916
                me.screenElements[e].hide();
917
            me.screenElements['WindData-NODATA'].show();
918
        }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
919
        settimer(func me.updateWindData(), 0.5);
920
    },
921
    _winddata_optn : 0,
922
#}}}
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
923

            
924
    updateBRG : func {
some added comments
Sébastien MARQUE authored on 2017-03-18
925
# displays and update BRG1/2 {{{
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
926
        foreach (var brg; [1, 2]) {
927
            var source = 'brg' ~ brg ~ '-source';
928

            
929
            var dev = radios.getNode(source).getValue();
930
            var el  = 'BRG' ~ brg;
931
            if (dev != 'OFF') {
932
                var info = {
933
                    pointer : nil,
934
                    id : 'NO DATA',
935
                    hdg : nil,
936
                    dst : '--.-NM'
937
                };
938
                if (left(dev, 3) == 'NAV') {
939
                    info.pointer = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/in-range');
940
                    if (info.pointer) {
941
                        info.id  = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/nav-id');
942
                        info.hdg = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/heading-deg');
943
                        info.dst = sprintf('%.1d', getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/nav-distance') / 1852); # m -> /1852
944
                    }
945
                }
946
                elsif (dev == 'GPS') {
947
                    info.pointer = props.getNode('/instrumentation/gps/wp').getChild('wp[1])');
948
                    if (info.pointer) {
949
                        info.id  = getprop('/instrumentation/gps/wp/wp[1]/ID');
950
                        info.hdg = getprop('/instrumentation/gps/wp/wp[1]/bearing-mag-deg');
951
                        info.dst = sprintf('%.1d', getprop('/instrumentation/gps/wp/wp[1]/distance-nm'));
952
                    }
953
                }
954
                else { # there are 2 available ADF in FG, but instrument manage only 1
955
                    info.pointer = getprop('/instrumentation/adf/in-range');
956
                    if (info.pointer) {
957
                        info.id  = getprop('/instrumentation/adf/ident');
958
                        info.hdg = getprop('/instrumentation/adf/indicated-bearing-deg');
959
                    }
960
                }
961

            
962
                if (info.pointer)
963
                    me.screenElements[el ~ '-pointer']
964
                        .setRotation(-info.hdg-me._updated_hdg * D2R)
965
                        .show();
966
                else
967
                    me.screenElements[el ~ '-pointer']
968
                        .hide();
969
                me.screenElements[el ~ '-SRC-text']
970
                    .setText(dev);
971
                me.screenElements[el ~ '-DST-text']
972
                    .setText(info.dst);
973
                me.screenElements[el ~ '-WPID-text']
974
                    .setText(info.id);
975
                me.screenElements['BRG' ~ brg]
976
                    .show();
977
            }
978
            else {
979
                me.screenElements['BRG' ~ brg]
980
                    .hide();
981
            }
982
        }
983
        settimer(func me.updateBRG(), 1);
984
    },
commit initial
Sébastien MARQUE authored on 2017-03-07
985
};
some added comments
Sébastien MARQUE authored on 2017-03-18
986
#}}}
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
987

            
988
var keyMap = {
add new vim folds
Sébastien MARQUE authored on 2017-03-15
989
# softkeys map for PFD and MFD {{{
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
990
    PFD : {
991
        first : 1,
992
        texts : ['INSET', 'SENSOR', 'PFD', 'OBS', 'CDI', 'DME', 'XPDR', 'IDENT', 'TMR/REF', 'NRST' ],
993
        INSET : {
994
            texts : ['OFF', 'DCLTR', 'WXLGND', 'TRAFFIC', 'TOPO', 'TERRAIN', 'STRMSCP', 'NEXRAD-C', 'XM LTNG', 'METAR'],
995
        },
996
        SENSOR : {
997
            first : 2,
998
            texts : [ 'ADC1', 'ADC2', '', 'AHRS1', 'AHRS2'],
999
        },
1000
        PFD : {
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1001
            texts : [ 'SYN VIS', 'DFLTS', 'AOA/WIND', 'DME', 'BRG1', 'HSI FMT', 'BRG2', '', 'ALT UNIT', 'STD BARO' ],
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
1002
            'SYN VIS' : {
1003
                texts : [ 'PATHWAY', 'SYN TERR', 'HR2NHDG', 'APTSIGNS', 'FPM'],
1004
            },
1005
            'AOA/WIND' : {
1006
                first : 4,
1007
                texts : ['AOA', 'WIND'],
1008
                AOA : {
1009
                    first : 5,
1010
                    texts : ['AOA ON', 'AOA AUTO'],
1011
                },
1012
                WIND : {
1013
                    first : 2,
1014
                    texts : ['OPTN1', 'OPTN2', '', 'OFF'],
1015
                },
1016
            },
1017
            'HSI FMT' : {
1018
                first : 6,
1019
                texts : ['360 HSI', 'ARC HSI'],
1020
            },
1021
            'ALT UNIT' : {
1022
                first : 5,
1023
                texts : ['METERS', '', 'IN', 'HPA'],
1024
            },
1025
        },
1026
        XPDR : {
1027
            first : 2,
1028
            texts : ['STBY', 'ON', 'ALT', '', 'VFR', 'CODE', 'IDENT'],
1029
            CODE : {
1030
                texts : ['0', '1', '2', '3', '4', '5', '6', '7', 'IDENT', 'BKSP'],
1031
            },
1032
        },
1033
    },
1034
    MFD : {
1035
        texts : ['ENGINE', '', 'MAP', '', '', '', '', '', '', 'DCLTR', 'SHW CHRT', 'CHKLIST'],
1036
        MAP : {
1037
            texts: ['TRAFFIC', 'PROFILE', 'TOPO', 'TERRAIN', 'AIRWAYS', 'STRMSCP','NEXRAD-C', 'XM LTNG', 'METAR', 'LEGEND', 'BACK'],
1038
        },
1039
        CHKLIST : {
1040
            texts : ['ENGINE', '', '', '', '', 'DONE', '', '', '', '', 'EXIT', 'EMERGCY'],
1041
        },
1042
        ENGINE : {
1043
            texts : ['ENGINE', 'ANTI-ICE', '', 'DCLTR', '', 'ASSIST', '', '', '', '', 'FUEL'],
1044
            'ANTI-ICE' : {
1045
                texts : ['LEFT', 'AUTO', 'RIGHT', '', '', '', '', '', '', '', '', 'BACK'],
1046
            },
1047
            FUEL : {
1048
                first : 1,
1049
                texts : ['FULL', 'TABS', '', '', '', '', '', '', '', 'UNDO', 'ENTER'],
1050
            },
1051
        },
1052
    },
1053
};
add new vim folds
Sébastien MARQUE authored on 2017-03-15
1054
#}}}