zkv1000 / Nasal / display.nas /
Newer Older
1174 lines | 44.173kb
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',
adds CDI
Sébastien MARQUE authored on 2017-03-18
108
                    'NAV1-pointer', 'NAV1-CDI', 'NAV1-FROM', 'NAV1-TO',
109
                    'NAV2-pointer', 'NAV2-CDI', 'NAV2-FROM', 'NAV2-TO',
110
                    'GPS-pointer', 'GPS-CDI', 'GPS-CTI', 'GPS-CTI-diamond', 'GPS-FROM', 'GPS-TO',
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 CDI
Sébastien MARQUE authored on 2017-03-18
150
                    'CDI-SRC-text', 'CDI-GPS-ANN-text', 'CDI-GPS-XTK-text',
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
151
                    'BRG1-pointer', 'BRG1-SRC-text', 'BRG1-DST-text', 'BRG1-WPID-text',
152
                    'BRG2-pointer', 'BRG2-SRC-text', 'BRG2-DST-text', 'BRG2-WPID-text',
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
153
                    'WindData-OPTN1-HDG-text', 'WindData-OPTN1-SPD-text',
154
                    'WindData-OPTN2-crosswind-text', 'WindData-OPTN2-headwind-text',
adds transponder
Sébastien MARQUE authored on 2017-03-17
155
                    '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
156
                    'AltBigC', 'AltSmallC'
157
                );
158
                for (var place = 1; place <= 6; place +=1) {
159
                    append(groups.text,
160
                        'AltBigU' ~ place,
161
                        'AltSmallU' ~ place,
162
                        'AltBigD' ~ place,
163
                        'AltSmallD' ~ place
164
                    );
165
                }
animation ALT
Sébastien MARQUE authored on 2017-03-11
166
            }
adds EIS
Sébastien MARQUE authored on 2017-03-18
167
            else {
animation texts EIS + power ...
Sébastien MARQUE authored on 2017-03-19
168
                append(groups.show, 'EIS', 'POWER-pointer');
169
                append(groups.text,
170
                        'RPM-text', 'EGT-text', 'CHT-text', 'FUEL-USED-text',
171
                        'FUEL-FLOW-text', 'MAN-Hg-text', 'POWER-PERCENT-text',
172
                        'RPM-text', 'BUS-V-text', 'BATT-text', 'PSI-text',
173
                        'OIL-TEMP-text'
174
                    );
adds EIS
Sébastien MARQUE authored on 2017-03-18
175
            }
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
176

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

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

            
209
    showInitProgress : func (role) {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
210
#{{{
commit initial
Sébastien MARQUE authored on 2017-03-07
211
        me.progress = me.display.createGroup();
212
        me.progress.show();
213
        me.progress.createChild("text", role ~ " title")
214
            .setTranslation(512, 384)
215
            .setAlignment("center-center")
216
            .setFont("LiberationFonts/LiberationSans-Italic.ttf")
217
            .setFontSize(64, 1)
218
            .setColor(1,1,1)
219
            .setText("ZKV1000 " ~ role ~ " init");
220

            
221
        zkv.getNode(role ~ 'init',1).setIntValue(1);
222

            
223
        me._showInitProgress(me.progress.createChild("text", role ~ "progress")
224
            .setTranslation(512, 484)
225
            .setAlignment("center-center")
226
            .setFont("LiberationFonts/LiberationSans-Bold.ttf")
227
            .setFontSize(128, 1)
228
            .setColor(1,0,0), '.');
229
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
230
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
231

            
some added comments
Sébastien MARQUE authored on 2017-03-18
232
    colors : {
233
# set of predefined colors {{{
234
        green : [0, 1, 0],
235
        white : [1, 1, 1],
236
        black : [0, 0, 0],
237
        lightblue : [0, 1, 1],
238
        darkblue : [0, 0, 1],
239
        red : [1, 0, 0],
adds CDI
Sébastien MARQUE authored on 2017-03-18
240
        magenta : [1, 0, 1],
some added comments
Sébastien MARQUE authored on 2017-03-18
241
    },
242
#}}}
243

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

            
302
    clips : {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
303
#{{{
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
304
        PitchScale   : "rect(70,664,370,256)",
305
        SpeedLint1   : "rect(252,226,318,204)",
306
        SpeedTape    : "rect(115,239,455,156)",
307
        LintAlt      : "rect(115,808,455,704)",
animation ALT
Sébastien MARQUE authored on 2017-03-11
308
        AltLint00011 : "rect(252,804,318,771)",
AI disponible
Sébastien MARQUE authored on 2017-03-10
309
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
310
#}}}
AI disponible
Sébastien MARQUE authored on 2017-03-10
311

            
animation VSI
Sébastien MARQUE authored on 2017-03-10
312
    texts : {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
313
#{{{
animation VSI
Sébastien MARQUE authored on 2017-03-10
314
        VSIText : {
315
            alignment: "right-bottom", default : num('0'),
316
        },
animation IAS
Sébastien MARQUE authored on 2017-03-10
317
        Speed110 : {
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
318
            alignment : 'left-bottom'
animation IAS
Sébastien MARQUE authored on 2017-03-10
319
        },
animation ALT (2)
Sébastien MARQUE authored on 2017-03-11
320
        Alt11100 : {
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
321
            alignment:'left-bottom'
animation ALT (2)
Sébastien MARQUE authored on 2017-03-11
322
        },
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
323
        "HDG-text" : {
324
            default: '---°'
325
        },
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
326
        'nav1-standby-freq' : {
327
            color: [0, 1, 1],
328
        },
329
        'nav1-id' : {
330
            default: ''
331
        },
332
        'nav2-id' : {
333
            default: ''
334
        },
adds CDI
Sébastien MARQUE authored on 2017-03-18
335
        'CDI-GPS-ANN-text' : {
336
            visible : 0
337
        },
338
        'CDI-GPS-XTK-text' : {
339
            visible : 0
340
        },
341
        'CDI-SRC-text' : {
342
            visible : 0
343
        },
some added comments
Sébastien MARQUE authored on 2017-03-18
344
#        'TAS-text' : {
345
#            alignment : 'right-bottom',
346
#        },
347
#        'GSPD-text' : {
348
#            alignment : 'right-bottom',
349
#        },
animation VSI
Sébastien MARQUE authored on 2017-03-10
350
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
351
#}}}
animation VSI
Sébastien MARQUE authored on 2017-03-10
352

            
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
353
    updateSoftKeys : func {
354
# update SoftKeys boxes {{{
355
        # grey background code = #353939
356
        # on PFD the last boxes are always BACK and ALERTS
357
        if (me.role == 'PFD') {
358
            me.screenElements[sprintf("SoftKey%02i-text", 11)]
359
                .setText('ALERTS');
360
            if (size(me.device.softkeys.path) != 0)
361
                me.screenElements[sprintf("SoftKey%02i-text", 10)]
362
                    .setText('BACK');
363
        }
364

            
365
        var path = keyMap[me.role];
366
        foreach (var p; me.device.softkeys.path)
367
            path = path[p];
368

            
369
        # feeding with empty menus the first boxes
370
        var start = (contains(path, 'first')) ? path.first : 0;
371
        for (var k = 0; k < start; k+=1) {
372
            me.screenElements[sprintf("SoftKey%02i-text", k)]
373
                .setText('');
374
        }
375
        # filling with the content the next boxes
376
        forindex (var k; path.texts) {
377
            var i = k + start;
378
            me.screenElements[sprintf("SoftKey%02i-text", i)]
379
                .setText(path.texts[k]);
380
        }
381
        # feeding the last boxes with empty string
382
        var end = (me.role == 'PFD') ? 10 : 12;
383
        if (size(path.texts) + start < end) {
384
            start = size(path.texts) + start;
385
            for (var k = start; k < end; k += 1)
386
                me.screenElements[sprintf("SoftKey%02i-text", k)]
387
                    .setText('');
388
        }
389
    },
390
#}}}
391

            
refresh of vital information...
Sébastien MARQUE authored on 2017-03-18
392
    update20Hz : func {
393
# 20Hz updates roll, pitch, VSI, IAS, altitude and HDG {{{
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
394
        me._updated_roll = getprop('/orientation/roll-deg');
395
        me._updated_pitch = getprop('orientation/pitch-deg');
396
        me._updated_vsi = getprop('/instrumentation/vertical-speed-indicator/indicated-speed-fpm');
397
        me._updated_ias = getprop('/velocities/airspeed-kt');
398
        me._updated_alt = getprop('/instrumentation/altimeter/indicated-altitude-ft');
399
        me._updated_hdg = getprop('/orientation/heading-deg');
refresh of vital information...
Sébastien MARQUE authored on 2017-03-18
400
        settimer(func me.update20Hz(), 0.05);
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
401
     },
402
    _updated_roll : 0,
403
    _updated_pitch : 0,
404
    _updated_vsi : 0,
405
    _updated_ias : 0,
406
    _updated_alt : 0,
407
    _updated_hdg : 0,
408
#}}}
409

            
refresh of vital information...
Sébastien MARQUE authored on 2017-03-18
410
    update1Hz : func {
411
# 1Hz updates {{{
412
        me._updated_wow = getprop('/gear/gear/wow');
413
        settimer(func me.update20Hz(), 1);
414
    },
415
    _updated_wow : 1,
416
#}}}
417

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
418
    updateAI: func(){
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
419
#{{{
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
420
        var pitch = me._updated_pitch;
421
        var roll = me._updated_roll;
AI disponible
Sébastien MARQUE authored on 2017-03-10
422
        if (pitch > 80)
423
            pitch = 80;
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
424
        elsif (pitch < -80)
AI disponible
Sébastien MARQUE authored on 2017-03-10
425
            pitch = -80;
426
        me.screenElements.Horizon
427
            .setRotation(-roll * D2R)
428
            .setTranslation(0, pitch * 6.8571428);
AI disponible, avec bankPoin...
Sébastien MARQUE authored on 2017-03-10
429
        me.screenElements.bankPointer
430
            .setRotation(-roll * D2R);
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
431
        settimer(func me.updateAI(), 0.1);
AI disponible
Sébastien MARQUE authored on 2017-03-10
432
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
433
#}}}
animation VSI
Sébastien MARQUE authored on 2017-03-10
434

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
435
    updateVSI: func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
436
# animate VSI {{{
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
437
        var vsi = me._updated_vsi;
animation VSI
Sébastien MARQUE authored on 2017-03-10
438
        me.screenElements.VSIText
439
            .setText(num(math.round(vsi, 10)));
440
        if (vsi > 4500)
441
            vsi = 4500;
442
        elsif (vsi < -4500)
443
            vsi = -4500;
444
        me.screenElements.VSI
445
            .setTranslation(0, vsi * -0.03465);
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
446
        settimer(func me.updateVSI(), 0.1);
animation VSI
Sébastien MARQUE authored on 2017-03-10
447
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
448
#}}}
animation IAS
Sébastien MARQUE authored on 2017-03-10
449

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
450
    updateIAS: func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
451
# animates the IAS lint (PFD) {{{
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
452
        var ias = me._updated_ias;
animation IAS
Sébastien MARQUE authored on 2017-03-10
453
        if (ias >= 10)
454
            me.screenElements.Speed110
455
                .setText(sprintf("% 2u",num(math.floor(ias/10))));
456
        else
457
            me.screenElements.Speed110
458
                .setText('');
459
        me.screenElements.SpeedLint1
460
            .setTranslation(0,(math.mod(ias,10) + (ias >= 10)*10) * 36);
461
        me.screenElements.SpeedTape
462
            .setTranslation(0,ias * 5.711);
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
463
        if (ias > me._ias_vne and ! me._ias_already_exceeded) { # easier than .getColorFill
464
            me._ias_already_exceeded = 1;
465
            me.screenElements['IAS-bg']
466
                .setColorFill(1,0,0);
467
        }
468
        elsif (ias < me._ias_vne and me._ias_already_exceeded) { # easier than .getColorFill
469
            me._ias_already_exceeded = 0;
470
            me.screenElements['IAS-bg']
471
                .setColorFill(0,0,0);
472
        }
trends animation
Sébastien MARQUE authored on 2017-03-13
473
        var now = systime();
474
        # estimated speed in 6s
475
        var Sy = 6 * (ias - me._last_ias_kt) / (now - me._last_ias_s);
476
        if (abs(Sy) > 30)
477
            Sy = 30 * abs(Sy)/Sy; # = -30 or 30
478
        me.screenElements['Airspeed-Trend-Indicator']
479
            .setScale(1,Sy)
480
            .setTranslation(0, -284.5 * (Sy - 1));
481
        me._last_ias_kt = ias;
482
        me._last_ias_s = now;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
483
        settimer(func me.updateIAS(), 0.1);
animation IAS
Sébastien MARQUE authored on 2017-03-10
484
    },
trends animation
Sébastien MARQUE authored on 2017-03-13
485
    _last_ias_kt : 0,
486
    _last_ias_s : systime(),
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
487
    _ias_vne : 999,
488
    _ias_already_exceeded : 0,
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
489
#}}}
animation ALT
Sébastien MARQUE authored on 2017-03-11
490

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
491
    updateTAS: func {
492
# updates the True Airspeed and GroundSpeed indicators {{{
493
        me.screenElements['TAS-text']
494
            .setText(sprintf('%iKT', getprop('/instrumentation/airspeed-indicator/true-speed-kt')));
495
        me.screenElements['GSPD-text']
496
            .setText(sprintf('%iKT', getprop('/velocities/groundspeed-kt')));
497
        settimer(func me.updateTAS(), 0.5);
498
    },
499
#}}}
500

            
501
    updateALT: func () {
502
# animates the altitude lint (PFD) {{{
503
        var alt = me._updated_alt;
animation ALT
Sébastien MARQUE authored on 2017-03-11
504
        if (alt < 0)
505
            me.screenElements.Alt11100
506
                .setText(sprintf("% 3i",math.ceil(alt/100)));
507
        elsif (alt < 100)
508
            me.screenElements.Alt11100
509
                .setText('');
510
        else
511
            me.screenElements.Alt11100
512
                .setText(sprintf("% 3i",math.floor(alt/100)));
513
        me.screenElements.AltLint00011
514
            .setTranslation(0,math.fmod(alt,100) * 1.24);
515

            
516
        # From Farmin/G1000 http://wiki.flightgear.org/Project_Farmin/FG1000
517
        if (alt> -1000 and alt< 1000000) {
518
            var Offset10 = 0;
519
            var Offset100 = 0;
520
            var Offset1000 = 0;
521
            if (alt< 0) {
522
                var Ne = 1;
523
                var alt= -alt;
524
            }
525
            else
526
                var Ne = 0;
527

            
528
            var Alt10       = math.mod(alt,100);
529
            var Alt100      = int(math.mod(alt/100,10));
530
            var Alt1000     = int(math.mod(alt/1000,10));
531
            var Alt10000    = int(math.mod(alt/10000,10));
532
            var Alt20       = math.mod(Alt10,20)/20;
533
            if (Alt10 >= 80)
534
                var Alt100 += Alt20;
535

            
536
            if (Alt10 >= 80 and Alt100 >= 9)
537
                var Alt1000 += Alt20;
538

            
539
            if (Alt10 >= 80 and Alt100 >= 9 and Alt1000 >= 9)
540
                var Alt10000 += Alt20;
541

            
542
            if (alt> 100)
543
                var Offset10 = 100;
544

            
545
            if (alt> 1000)
546
                var Offset100 = 10;
547

            
548
            if (alt> 10000)
549
                var Offset1000 = 10;
550

            
551
            if (!Ne) {
552
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*0.57375);
553
                var altCentral = (int(alt/100)*100);
554
            }
555
            elsif (Ne) {
556
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*-0.57375);
557
                var altCentral = -(int(alt/100)*100);
558
            }
559
            me.screenElements["AltBigC"].setText("");
560
            me.screenElements["AltSmallC"].setText("");
561
            for (var place = 1; place <= 6; place += 1) {
562
                var altUP = altCentral + (place*100);
563
                var offset = -30.078;
564
                if (altUP < 0) {
565
                    var altUP = -altUP;
566
                    var prefix = "-";
567
                    var offset += 15.039;
568
                }
569
                else
570
                    var prefix = "";
571

            
572
                if (altUP == 0) {
573
                    var AltBigUP    = "";
574
                    var AltSmallUP  = "0";
575

            
576
                }
577
                elsif (math.mod(altUP,500) == 0 and altUP != 0) {
578
                    var AltBigUP    = sprintf(prefix~"%1d", altUP);
579
                    var AltSmallUP  = "";
580
                }
581
                elsif (altUP < 1000 and (math.mod(altUP,500))) {
582
                    var AltBigUP    = "";
583
                    var AltSmallUP  = sprintf(prefix~"%1d", int(math.mod(altUP,1000)));
584
                    var offset = -30.078;
585
                }
586
                elsif ((altUP < 10000) and (altUP >= 1000) and (math.mod(altUP,500))) {
587
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
588
                    var AltSmallUP  = sprintf("%1d", int(math.mod(altUP,1000)));
589
                    var offset += 15.039;
590
                }
591
                else {
592
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
593
                    var mod = int(math.mod(altUP,1000));
594
                    var AltSmallUP  = sprintf("%1d", mod);
595
                    var offset += 30.078;
596
                }
597

            
598
                me.screenElements["AltBigU"~place].setText(AltBigUP);
599
                me.screenElements["AltSmallU"~place].setText(AltSmallUP);
600
                me.screenElements["AltSmallU"~place].setTranslation(offset,0);
601
                var altDOWN = altCentral - (place*100);
602
                var offset = -30.078;
603
                if (altDOWN < 0) {
604
                    var altDOWN = -altDOWN;
605
                    var prefix = "-";
606
                    var offset += 15.039;
607
                }
608
                else
609
                    var prefix = "";
610

            
611
                if (altDOWN == 0) {
612
                    var AltBigDOWN  = "";
613
                    var AltSmallDOWN    = "0";
614
                }
615
                elsif (math.mod(altDOWN,500) == 0 and altDOWN != 0) {
616
                    var AltBigDOWN  = sprintf(prefix~"%1d", altDOWN);
617
                    var AltSmallDOWN    = "";
618
                }
619
                elsif (altDOWN < 1000 and (math.mod(altDOWN,500))) {
620
                    var AltBigDOWN  = "";
621
                    var AltSmallDOWN    = sprintf(prefix~"%1d", int(math.mod(altDOWN,1000)));
622
                    var offset = -30.078;
623
                }
624
                elsif ((altDOWN < 10000) and (altDOWN >= 1000) and (math.mod(altDOWN,500))) {
625
                    var AltBigDOWN  = sprintf(prefix~"%1d", int(altDOWN/1000));
626
                    var AltSmallDOWN    = sprintf("%1d", int(math.mod(altDOWN,1000)));
627
                    var offset += 15.039;
628
                }
629
                else {
630
                    var AltBigDOWN  = sprintf(prefix~"%1d", int(altDOWN/1000));
631
                    var mod = int(math.mod(altDOWN,1000));
632
                    var AltSmallDOWN    = sprintf("%1d", mod);
633
                    var offset += 30.078;
634
                }
635
                me.screenElements["AltBigD"~place].setText(AltBigDOWN);
636
                me.screenElements["AltSmallD"~place].setText(AltSmallDOWN);
637
                me.screenElements["AltSmallD"~place].setTranslation(offset,0);
638
            }
639
        }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
640
        me.updateSelectedALT();
trends animation
Sébastien MARQUE authored on 2017-03-13
641
        var now = systime();
642
        # altitude in 6s
643
        var Sy = .3 * (alt - me._last_alt_ft) / (now - me._last_alt_s); # scale = 1/20ft
644
        if (abs(Sy) > 15)
645
            Sy = 15 * abs(Sy)/Sy; # = -15 or 15
646
        me.screenElements['Altitude-Trend-Indicator']
647
            .setScale(1,Sy)
648
            .setTranslation(0, -284.5 * (Sy - 1));
649
        me._last_alt_ft = alt;
650
        me._last_alt_s = now;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
651
        settimer(func me.updateALT(), 0.2);
animation ALT
Sébastien MARQUE authored on 2017-03-11
652
    },
trends animation
Sébastien MARQUE authored on 2017-03-13
653
    _last_alt_ft : 0,
654
    _last_alt_s  : systime(),
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
655
#}}}
animation HSI
Sébastien MARQUE authored on 2017-03-11
656

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
657
    updateHSI : func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
658
# rotates the compass (PFD) {{{
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
659
        var hdg = me._updated_hdg;
animation HSI
Sébastien MARQUE authored on 2017-03-11
660
        me.screenElements.Rose
661
            .setRotation(-hdg * D2R);
662
        me.screenElements['HDG-text']
663
            .setText(sprintf("%03u°", hdg));
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
664
        settimer(func me.updateHSI(), 0.1);
animation HSI
Sébastien MARQUE authored on 2017-03-11
665
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
666
#}}}
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
667

            
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
668
    updateHDG : func (hdg) {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
669
# moves the heading bug and display heading-deg for 3 seconds (PFD) {{{
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
670
        if (me.role == 'MFD')
671
            return;
672
        me.screenElements['Heading-bug']
673
            .setRotation(hdg * D2R);
674
        me.screenElements['SelectedHDG-bg']
675
            .show();
676
        me.screenElements['SelectedHDG-bgtext']
677
            .show();
678
        me.screenElements['SelectedHDG-text']
679
            .setText(sprintf('%03d°%s', hdg, ''))
680
            .show();
681
        me.addTimer(3, ['SelectedHDG-text', 'SelectedHDG-bgtext', 'SelectedHDG-bg']);
682
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
683
#}}}
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
684

            
adds CDI
Sébastien MARQUE authored on 2017-03-18
685
    updateCRS : func () {
anime CRS
Sébastien MARQUE authored on 2017-03-13
686
# TODO: update display for NAV/GPS/BRG courses {{{
687
        if (me.role == 'MFD')
688
            return;
adds CDI
Sébastien MARQUE authored on 2017-03-18
689
        var source = getprop('/instrumentation/zkv1000/cdi/source');
690
        if (source == 'OFF')
691
            return;
692
        var crs = getprop('/instrumentation/zkv1000/cdi/course');
693
        if (crs == nil)
694
            return;
anime CRS
Sébastien MARQUE authored on 2017-03-13
695
        me.screenElements['SelectedCRS-bg']
696
            .show();
697
        me.screenElements['SelectedCRS-bgtext']
698
            .show();
699
        me.screenElements['SelectedCRS-text']
700
            .setText(sprintf('%03d°%s', crs, ''))
adds CDI
Sébastien MARQUE authored on 2017-03-18
701
            .setColor(source == 'GPS' ? me.colors.magenta : me.colors.green)
anime CRS
Sébastien MARQUE authored on 2017-03-13
702
            .show();
703
        me.addTimer(3, ['SelectedCRS-text', 'SelectedCRS-bgtext', 'SelectedCRS-bg']);
704
    },
705
#}}}
706

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
707
    updateSelectedALT : func {
708
# animation for altitude section, called via updatedALT {{{
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
709
        if (! device[0].display.screenElements['SelectedALT'].getVisible())
710
            return;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
711
        var selected_alt = getprop('/instrumentation/zkv1000/afcs/selected-alt-ft');
712
        var delta_alt = me._updated_alt - selected_alt;
713
        if (abs(delta_alt) > 300)
714
            delta_alt = 300 * abs(delta_alt)/delta_alt;
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
715
        me.screenElements['SelectedALT-symbol']
716
            .setVisible(abs(delta_alt) > 100);
717
        me.screenElements['SelectedALT-bg']
718
            .setVisible(abs(delta_alt) > 100);
719
        me.screenElements['SelectedALT-text']
720
            .setText(sprintf("%i", selected_alt))
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
721
            .setVisible(abs(delta_alt) > 100);
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
722
        me.screenElements['SelectedALT-bug']
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
723
            .setTranslation(0, delta_alt * 0.567); # 170/300 = 0.567
724
    },
725
#}}}
726

            
adds CDI
Sébastien MARQUE authored on 2017-03-18
727
    updateCDI : func {
728
# animation for CDI {{{
729
        var source = getprop('/instrumentation/zkv1000/cdi/source');
730
        if (source == 'OFF') {
731
            foreach (var s; ['GPS', 'NAV1', 'NAV2'])
732
                foreach (var t; ['pointer', 'CDI'])
733
                    me.screenElements[s ~ '-' ~ t].hide();
734
            me.screenElements['CDI-GPS-ANN-text'].hide();
735
            me.screenElements['CDI-GPS-XTK-text'].hide();
736
            me.screenElements['CDI-SRC-text'].hide();
737
            me.screenElements['CDI'].hide();
738
        }
739
        else {
740
            var course = getprop('/instrumentation/zkv1000/cdi/course');
741
            me.screenElements['CDI']
742
                .show();
743
            me.screenElements['GPS-CTI']
744
                .setVisible(source == 'GPS');
745
            me.screenElements['GPS-CTI-diamond']
746
                .setVisible(source == 'GPS');
747
            foreach (var s; ['GPS', 'NAV1', 'NAV2']) {
748
                var rot = (course - me._updated_hdg) * D2R;
749
                me.screenElements[s ~ '-pointer']
750
                    .setRotation(rot)
751
                    .setVisible(source == s);
752
                me.screenElements[s ~ '-CDI']
753
                    .setVisible(source == s);
754
                foreach (var f; ['FROM', 'TO'])
755
                    me.screenElements[s ~ '-' ~ f]
756
                        .setVisible(s == source and getprop('/instrumentation/zkv1000/cdi/', f, '-flag'));
757
                me.screenElements['CDI-SRC-text']
758
                    .setText(source)
759
                    .setColor(source == 'GPS' ? me.colors.magenta : me.colors.green)
760
                    .show();
761
                var deflection = getprop('/instrumentation/zkv1000/cdi/course-deflection');
762
                if (left(source, 3) == 'NAV') {
763
                    var scale = deflection / 4;
764
                    scale = (abs(scale) > 1.2) ? 1.2 : scale;
765
                }
766
                else {
767
                    me.screenElements['CDI-SRC-text']
768
                        .setText('GPS')
769
                        .setColor(1,0,1);
770
                }
771
                me.screenElements[source ~ '-CDI']
772
                    .setTranslation(65 * scale, 0);
773
            }
774
            settimer(func me.updateCDI(), 0.5);
775
        }
776
    },
777
#}}}
778

            
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
779
    _updateRadio: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
780
# common parts for NAV/LOC/COMM radios{{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
781
        # arg[0]._r = <comm|nav>
782
        if (contains(arg[0], "active")) {
783
            if (arg[0]['active'] == 'none') {
784
                me.screenElements[arg[0]._r ~ '1-selected-freq']
785
                    .setColor(1,1,1);
786
                me.screenElements[arg[0]._r ~ '2-selected-freq']
787
                    .setColor(1,1,1);
788
            }
789
            else {
790
                me.screenElements[arg[0]._r ~ arg[0]['active'] ~ '-selected-freq']
791
                    .setColor(0,1,0);
792
                me.screenElements[arg[0]._r ~ arg[0].inactive ~ '-selected-freq']
793
                    .setColor(1,1,1);
794
            }
795
        }
796
        if (contains(arg[0], 'tune')) {
797
            # n = 0 -> NAV1/COMM1
798
            # n = 1 -> NAV1/COMM2
799
            me.screenElements[arg[0]._r ~ '-freq-switch']
800
                .setTranslation(0, arg[0].tune * 25);
801
            me.screenElements[arg[0]._r ~ (arg[0].tune + 1) ~ '-standby-freq']
802
                .setColor(0,1,1);
803
            me.screenElements[arg[0]._r ~ ((arg[0].tune == 0) + 1) ~ '-standby-freq']
804
                .setColor(1,1,1);
805
        }
806
        if (contains(arg[0], 'refresh')) {
807
            # rafraichi une seule ligne NAV1/COMM1 ou NAV2/COMM2
808
            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
809
            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-selected-freq']
810
                .setText(sprintf(fmt, getprop('/instrumentation/'
811
                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/selected-mhz')));
812
            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-standby-freq']
813
                .setText(sprintf(fmt, getprop('/instrumentation/'
814
                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/standby-mhz')));
815
        }
816
        if (contains(arg[0], 'set')) {
817
            # positionne la valeur modifiée, les listeners "trigguent" en permanence ces propriétés, donc exit
818
            var n = getprop('/instrumentation/zkv1000/radios/' ~ arg[0]._r ~ '-tune');
819
            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
820
            me.screenElements[arg[0]._r ~ (n + 1) ~ '-standby-freq']
fix freq display while setti...
Sébastien MARQUE authored on 2017-03-16
821
                .setText(sprintf(fmt, getprop('/instrumentation/' ~ arg[0]._r ~ '[' ~ n ~ ']/frequencies/standby-mhz')));
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
822
        }
823
        if (contains(arg[0], 'auto')) {
824
            # pour rafraichir automagiquement, toutes les deux secondes un refresh pour un NAV
825
            var radio = arg[0].auto;
826
            me._updateRadio({refresh: 1, _r: radio});
827
            settimer(func me._updateRadio({refresh: 2, _r: radio}), 1);
828
            settimer(func me._updateRadio({auto: radio}), 2);
829
        }
830
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
831
#}}}
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
832

            
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
833
    updateNAV : func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
834
# update NAV/LOC rodios display upper left (PFD/MFD){{{
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
835
        # made active via menu
836
        if (contains(arg[0], "active")) {
adds CDI
Sébastien MARQUE authored on 2017-03-18
837
            arg[0]._r = 'nav';
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
838
            if (arg[0]['active'] == 'none') {
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
839
                me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
840
                me.screenElements['nav1-id']
841
                    .setColor(1,1,1);
842
                me.screenElements['nav2-id']
843
                    .setColor(1,1,1);
844
                me.screenElements['NAV1-pointer']
845
                    .hide();
846
                me.screenElements['NAV2-pointer']
847
                    .hide();
848
            }
849
            else {
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
850
                arg[0].inactive = (arg[0]['active'] == 1) + 1;
851
                me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
852
                me.screenElements['nav' ~ arg[0]['active'] ~ '-id']
853
                    .setColor(0,1,0);
854
                me.screenElements['NAV' ~ arg[0]['active'] ~ '-pointer']
855
                    .show();
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
856
                me.screenElements['nav' ~ arg[0].inactive ~ '-id']
857
                    .setColor(1,1,1);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
858
#                me.screenElements['HDI']
859
#                    .setRotation();
860
#                me.screenElements['NAV' ~ inactive ~ '-pointer']
861
#                    .hide();
862
#                foreach (var e; [ 'FROM', 'TO', 'CDI' ])
863
#                    me.screenElements['NAV' ~ inactive ~ '-' ~ e]
864
#                        .hide();
865
            }
866
        }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
867
        elsif (contains(arg[0], 'nav-id')) {
Correction swap NAV tuning
Sébastien MARQUE authored on 2017-03-12
868
            # 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
869
            if (arg[0].val == nil)
870
                arg[0].val = '';
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
871
            me.screenElements["nav" ~ arg[0]['nav-id'] ~ "-id"]
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
872
                    .setText(arg[0].val);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
873
        }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
874
        else {
875
            arg[0]._r = 'nav';
876
            me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
877
        }
878
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
879
#}}}
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
880

            
881
    updateCOMM: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
882
# update COMM radios display upper right (PFD/MFD){{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
883
        arg[0]._r = 'comm';
884
        me._updateRadio(arg[0]);
885
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
886
#}}}
anime time display
Sébastien MARQUE authored on 2017-03-13
887

            
888
    updateTIME : func {
889
# updates the displayed time botoom left {{{
890
        me.screenElements['TIME-text']
891
            .setText(getprop('/sim/time/gmt-string'));
892
        settimer(func me.updateTIME(), 1);
893
    },
894
#}}}
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
895

            
adds transponder
Sébastien MARQUE authored on 2017-03-17
896
    updateXPDR : func {
897
# updates transponder display {{{
898
        for (var d = 0; d < 4; d+=1)
899
            me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
900
                .setText(sprintf('%i', getprop('/instrumentation/transponder/inputs/digit[' ~ d ~ ']')));
901
        var tuning = getprop('/instrumentation/zkv1000/radios/xpdr-tuning-digit');
902
        if (tuning != nil)
903
            for (var d = 0; d < 4; d+=1) {
904
                if (d != tuning)
905
                    me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
906
                        .setColor(1,1,1);
907
                else
908
                    me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
909
                        .setColor(0,1,1);
910
            }
911
        else {
912
            if (getprop('/instrumentation/transponder/ident'))
913
                var mode = 'IDENT';
914
            else
915
                var mode = getprop('/instrumentation/zkv1000/radio/xpdr-mode');
916
            var wow = getprop('/gear/gear/wow');
917
            if (! wow and mode != 'STBY')
918
                var color = [0, 1, 0];
919
            else
920
                var color = [1, 1, 1];
921
            for (var d = 0; d < 4; d+=1)
922
                me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
923
                    .setColor(color);
924
            me.screenElements['XPDR-MODE-text']
925
                .setColor(color)
926
                .setText(mode);
927
        }
928
},
929
#}}}
930

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
931
    updateOAT : func {
932
# update OAT display on normal and reversionnary modes (every 3s) {{{
933
        var tmp = getprop('/environment/temperature-deg' ~ me._oat_unit);
934
        me.screenElements['OAT-text']
935
            .setText(sprintf((abs(tmp) < 10) ? "%.1f %s" : "%i %s", tmp, (me._oat_unit == 'c') ? '°C' : 'F'));
936
        settimer(func me.updateOAT(), 3);
937
    },
938
    _oat_unit : 'c',
939
#}}}
940

            
941
    updateWindData : func {
942
# update the window text and arrows for OPTN1/2 {{{
943
        if (me._winddata_optn == 0)
944
            return;
improves WindData display
Sébastien MARQUE authored on 2017-03-16
945
        if (me._updated_ias < 30) {
946
            me.screenElements['WindData-NODATA']
947
                .hide();
948
            var wind_hdg = getprop('/environment/wind-from-heading-deg');
949
            var wind_spd = getprop('/environment/wind-speed-kt');
950
            var alpha = wind_hdg - me._updated_hdg;
951
            if (me._winddata_optn == 1) {
952
                me.screenElements['WindData-OPTN1-HDG']
953
                    .setRotation((alpha + 180) * D2R)
954
                    .show();
955
                me.screenElements['WindData-OPTN1-HDG-text']
956
                    .setText(sprintf("%03i°", wind_hdg))
957
                    .show();
958
                me.screenElements['WindData-OPTN1-SPD-text']
959
                    .setText(int(wind_spd) ~ 'KT')
960
                    .show();
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
961
            }
improves WindData display
Sébastien MARQUE authored on 2017-03-16
962
            else { # me._winddata_optn == 2
963
                alpha *= D2R;
964
                var Vt = wind_spd * math.sin(alpha);
965
                var Ve = wind_spd * math.cos(alpha);
966
                if (Vt != 0) {
967
                    me.screenElements['WindData-OPTN2-crosswind-text']
968
                        .setText(sprintf('%i', abs(Vt)))
969
                        .show();
970
                    me.screenElements['WindData-OPTN2-crosswind']
971
                        .setScale(-abs(Vt)/Vt, 1)
972
                        .setTranslation(-35 * (abs(Vt)/Vt + 1), 0)
973
                        .show();
974
                }
975
                if (Ve != 0) {
976
                    me.screenElements['WindData-OPTN2-headwind-text']
977
                        .setText(sprintf('%i', abs(Ve)))
978
                        .show();
979
                    me.screenElements['WindData-OPTN2-headwind']
980
                        .setScale(1, abs(Ve)/Ve)
981
                        .setTranslation(0, 515 * (1 - abs(Ve)/Ve))
982
                        .show();
983
                }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
984
            }
985
        }
improves WindData display
Sébastien MARQUE authored on 2017-03-16
986
        else {
987
            foreach (var e; [
988
                    'WindData-OPTN1-HDG',
989
                    'WindData-OPTN1-HDG-text',
990
                    'WindData-OPTN1-SPD-text',
991
                    'WindData-OPTN2-crosswind-text',
992
                    'WindData-OPTN2-crosswind',
993
                    'WindData-OPTN2-headwind-text',
994
                    'WindData-OPTN2-headwind'
995
            ])
996
                me.screenElements[e].hide();
997
            me.screenElements['WindData-NODATA'].show();
998
        }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
999
        settimer(func me.updateWindData(), 0.5);
1000
    },
1001
    _winddata_optn : 0,
1002
#}}}
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1003

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

            
1009
            var dev = radios.getNode(source).getValue();
1010
            var el  = 'BRG' ~ brg;
1011
            if (dev != 'OFF') {
1012
                var info = {
1013
                    pointer : nil,
1014
                    id : 'NO DATA',
1015
                    hdg : nil,
1016
                    dst : '--.-NM'
1017
                };
1018
                if (left(dev, 3) == 'NAV') {
1019
                    info.pointer = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/in-range');
1020
                    if (info.pointer) {
1021
                        info.id  = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/nav-id');
1022
                        info.hdg = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/heading-deg');
1023
                        info.dst = sprintf('%.1d', getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/nav-distance') / 1852); # m -> /1852
1024
                    }
1025
                }
1026
                elsif (dev == 'GPS') {
1027
                    info.pointer = props.getNode('/instrumentation/gps/wp').getChild('wp[1])');
1028
                    if (info.pointer) {
1029
                        info.id  = getprop('/instrumentation/gps/wp/wp[1]/ID');
1030
                        info.hdg = getprop('/instrumentation/gps/wp/wp[1]/bearing-mag-deg');
1031
                        info.dst = sprintf('%.1d', getprop('/instrumentation/gps/wp/wp[1]/distance-nm'));
1032
                    }
1033
                }
1034
                else { # there are 2 available ADF in FG, but instrument manage only 1
1035
                    info.pointer = getprop('/instrumentation/adf/in-range');
1036
                    if (info.pointer) {
1037
                        info.id  = getprop('/instrumentation/adf/ident');
1038
                        info.hdg = getprop('/instrumentation/adf/indicated-bearing-deg');
1039
                    }
1040
                }
1041

            
1042
                if (info.pointer)
1043
                    me.screenElements[el ~ '-pointer']
1044
                        .setRotation(-info.hdg-me._updated_hdg * D2R)
1045
                        .show();
1046
                else
1047
                    me.screenElements[el ~ '-pointer']
1048
                        .hide();
1049
                me.screenElements[el ~ '-SRC-text']
1050
                    .setText(dev);
1051
                me.screenElements[el ~ '-DST-text']
1052
                    .setText(info.dst);
1053
                me.screenElements[el ~ '-WPID-text']
1054
                    .setText(info.id);
1055
                me.screenElements['BRG' ~ brg]
1056
                    .show();
1057
            }
1058
            else {
1059
                me.screenElements['BRG' ~ brg]
1060
                    .hide();
1061
            }
1062
        }
1063
        settimer(func me.updateBRG(), 1);
1064
    },
some added comments
Sébastien MARQUE authored on 2017-03-18
1065
#}}}
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
1066

            
animation texts EIS + power ...
Sébastien MARQUE authored on 2017-03-19
1067
    updateEIS : func {
1068
# displays Engine Informations System {{{
1069
        var power = getprop('/controls/engines/engine/throttle') * getprop('/engines/engine/running');
1070
        me.screenElements['POWER-pointer']
1071
            .setRotation(D2R * 140 * power);
1072
        me.screenElements['POWER-PERCENT-text']
1073
            .setText(sprintf('%u', power));
1074
        me.screenElements['RPM-text']
1075
            .setText(sprintf(math.round(getprop('/engines/engine/rpm'), 50)));
1076
        me.screenElements['MAN-Hg-text']
1077
            .setText(sprintf('%.1d', getprop('/engines/engine/mp-inhg')));
1078
        me.screenElements['FUEL-FLOW-text']
1079
            .setText(sprintf('%.1f', getprop('/engines/engine/fuel-flow-gph')));
1080
        if (math.mod(me._eis_count, 10) == 0) {
1081
            var psi = getprop('/engines/engine/oil-pressure-psi');
1082
            me.screenElements['PSI-text']
1083
                .setText(psi == nil ? '--' : sprintf('%u', psi));
1084
            me.screenElements['OIL-TEMP-text']
1085
                .setText(sprintf('%i', getprop('/engines/engine/oil-temperature-degf')));
1086
            var used_fuel = getprop('/instrumentation/zkv1000/eis/fuel-qty-at-start')
1087
                          - getprop('/consumables/fuel/tank/level-gal_us')
1088
                          - getprop('/consumables/fuel/tank[1]/level-gal_us');
1089
            me.screenElements['FUEL-USED-text']
1090
                .setText(sprintf('%.1d', used_fuel > 0 ? used_fuel : 0));
1091
            me.screenElements['BUS-V-text']
1092
                .setText(sprintf('%.1i', getprop('/systems/electrical/outputs/bus')));
1093
            me.screenElements['BATT-text']
1094
                .setText(sprintf('%+i', getprop('/systems/electrical/amps')));
1095
            var cht = getprop('/engines/engine/cht-degf');
1096
            me.screenElements['CHT-text']
1097
                .setText(cht == nil ? '--' : sprintf('%i', cht));
1098
            me.screenElements['EGT-text']
1099
                .setText(sprintf('%i', getprop('/engines/engine/egt-degf')));
1100
        }
1101
        settimer(func me.updateEIS(), 1);
1102
        me._eis_count += 1;
1103
    },
1104
    _eis_count : 0,
1105
#}}}
1106
};
1107

            
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
1108
var keyMap = {
add new vim folds
Sébastien MARQUE authored on 2017-03-15
1109
# softkeys map for PFD and MFD {{{
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
1110
    PFD : {
1111
        first : 1,
1112
        texts : ['INSET', 'SENSOR', 'PFD', 'OBS', 'CDI', 'DME', 'XPDR', 'IDENT', 'TMR/REF', 'NRST' ],
1113
        INSET : {
1114
            texts : ['OFF', 'DCLTR', 'WXLGND', 'TRAFFIC', 'TOPO', 'TERRAIN', 'STRMSCP', 'NEXRAD-C', 'XM LTNG', 'METAR'],
1115
        },
1116
        SENSOR : {
1117
            first : 2,
1118
            texts : [ 'ADC1', 'ADC2', '', 'AHRS1', 'AHRS2'],
1119
        },
1120
        PFD : {
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1121
            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
1122
            'SYN VIS' : {
1123
                texts : [ 'PATHWAY', 'SYN TERR', 'HR2NHDG', 'APTSIGNS', 'FPM'],
1124
            },
1125
            'AOA/WIND' : {
1126
                first : 4,
1127
                texts : ['AOA', 'WIND'],
1128
                AOA : {
1129
                    first : 5,
1130
                    texts : ['AOA ON', 'AOA AUTO'],
1131
                },
1132
                WIND : {
1133
                    first : 2,
1134
                    texts : ['OPTN1', 'OPTN2', '', 'OFF'],
1135
                },
1136
            },
1137
            'HSI FMT' : {
1138
                first : 6,
1139
                texts : ['360 HSI', 'ARC HSI'],
1140
            },
1141
            'ALT UNIT' : {
1142
                first : 5,
1143
                texts : ['METERS', '', 'IN', 'HPA'],
1144
            },
1145
        },
1146
        XPDR : {
1147
            first : 2,
1148
            texts : ['STBY', 'ON', 'ALT', '', 'VFR', 'CODE', 'IDENT'],
1149
            CODE : {
1150
                texts : ['0', '1', '2', '3', '4', '5', '6', '7', 'IDENT', 'BKSP'],
1151
            },
1152
        },
1153
    },
1154
    MFD : {
1155
        texts : ['ENGINE', '', 'MAP', '', '', '', '', '', '', 'DCLTR', 'SHW CHRT', 'CHKLIST'],
1156
        MAP : {
1157
            texts: ['TRAFFIC', 'PROFILE', 'TOPO', 'TERRAIN', 'AIRWAYS', 'STRMSCP','NEXRAD-C', 'XM LTNG', 'METAR', 'LEGEND', 'BACK'],
1158
        },
1159
        CHKLIST : {
1160
            texts : ['ENGINE', '', '', '', '', 'DONE', '', '', '', '', 'EXIT', 'EMERGCY'],
1161
        },
1162
        ENGINE : {
1163
            texts : ['ENGINE', 'ANTI-ICE', '', 'DCLTR', '', 'ASSIST', '', '', '', '', 'FUEL'],
1164
            'ANTI-ICE' : {
1165
                texts : ['LEFT', 'AUTO', 'RIGHT', '', '', '', '', '', '', '', '', 'BACK'],
1166
            },
1167
            FUEL : {
1168
                first : 1,
1169
                texts : ['FULL', 'TABS', '', '', '', '', '', '', '', 'UNDO', 'ENTER'],
1170
            },
1171
        },
1172
    },
1173
};
add new vim folds
Sébastien MARQUE authored on 2017-03-15
1174
#}}}