zkv1000 / Nasal / display.nas /
Newer Older
1125 lines | 41.679kb
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 {
168
                append(groups.show, 'EIS');
169
            }
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
170

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

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

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

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

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

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

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

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

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

            
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
344
    updateSoftKeys : func {
345
# update SoftKeys boxes {{{
346
        # grey background code = #353939
347
        # on PFD the last boxes are always BACK and ALERTS
348
        if (me.role == 'PFD') {
349
            me.screenElements[sprintf("SoftKey%02i-text", 11)]
350
                .setText('ALERTS');
351
            if (size(me.device.softkeys.path) != 0)
352
                me.screenElements[sprintf("SoftKey%02i-text", 10)]
353
                    .setText('BACK');
354
        }
355

            
356
        var path = keyMap[me.role];
357
        foreach (var p; me.device.softkeys.path)
358
            path = path[p];
359

            
360
        # feeding with empty menus the first boxes
361
        var start = (contains(path, 'first')) ? path.first : 0;
362
        for (var k = 0; k < start; k+=1) {
363
            me.screenElements[sprintf("SoftKey%02i-text", k)]
364
                .setText('');
365
        }
366
        # filling with the content the next boxes
367
        forindex (var k; path.texts) {
368
            var i = k + start;
369
            me.screenElements[sprintf("SoftKey%02i-text", i)]
370
                .setText(path.texts[k]);
371
        }
372
        # feeding the last boxes with empty string
373
        var end = (me.role == 'PFD') ? 10 : 12;
374
        if (size(path.texts) + start < end) {
375
            start = size(path.texts) + start;
376
            for (var k = start; k < end; k += 1)
377
                me.screenElements[sprintf("SoftKey%02i-text", k)]
378
                    .setText('');
379
        }
380
    },
381
#}}}
382

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

            
refresh of vital information...
Sébastien MARQUE authored on 2017-03-18
401
    update1Hz : func {
402
# 1Hz updates {{{
403
        me._updated_wow = getprop('/gear/gear/wow');
404
        settimer(func me.update20Hz(), 1);
405
    },
406
    _updated_wow : 1,
407
#}}}
408

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

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
426
    updateVSI: func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
427
# animate VSI {{{
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
428
        var vsi = me._updated_vsi;
animation VSI
Sébastien MARQUE authored on 2017-03-10
429
        me.screenElements.VSIText
430
            .setText(num(math.round(vsi, 10)));
431
        if (vsi > 4500)
432
            vsi = 4500;
433
        elsif (vsi < -4500)
434
            vsi = -4500;
435
        me.screenElements.VSI
436
            .setTranslation(0, vsi * -0.03465);
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
437
        settimer(func me.updateVSI(), 0.1);
animation VSI
Sébastien MARQUE authored on 2017-03-10
438
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
439
#}}}
animation IAS
Sébastien MARQUE authored on 2017-03-10
440

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

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
482
    updateTAS: func {
483
# updates the True Airspeed and GroundSpeed indicators {{{
484
        me.screenElements['TAS-text']
485
            .setText(sprintf('%iKT', getprop('/instrumentation/airspeed-indicator/true-speed-kt')));
486
        me.screenElements['GSPD-text']
487
            .setText(sprintf('%iKT', getprop('/velocities/groundspeed-kt')));
488
        settimer(func me.updateTAS(), 0.5);
489
    },
490
#}}}
491

            
492
    updateALT: func () {
493
# animates the altitude lint (PFD) {{{
494
        var alt = me._updated_alt;
animation ALT
Sébastien MARQUE authored on 2017-03-11
495
        if (alt < 0)
496
            me.screenElements.Alt11100
497
                .setText(sprintf("% 3i",math.ceil(alt/100)));
498
        elsif (alt < 100)
499
            me.screenElements.Alt11100
500
                .setText('');
501
        else
502
            me.screenElements.Alt11100
503
                .setText(sprintf("% 3i",math.floor(alt/100)));
504
        me.screenElements.AltLint00011
505
            .setTranslation(0,math.fmod(alt,100) * 1.24);
506

            
507
        # From Farmin/G1000 http://wiki.flightgear.org/Project_Farmin/FG1000
508
        if (alt> -1000 and alt< 1000000) {
509
            var Offset10 = 0;
510
            var Offset100 = 0;
511
            var Offset1000 = 0;
512
            if (alt< 0) {
513
                var Ne = 1;
514
                var alt= -alt;
515
            }
516
            else
517
                var Ne = 0;
518

            
519
            var Alt10       = math.mod(alt,100);
520
            var Alt100      = int(math.mod(alt/100,10));
521
            var Alt1000     = int(math.mod(alt/1000,10));
522
            var Alt10000    = int(math.mod(alt/10000,10));
523
            var Alt20       = math.mod(Alt10,20)/20;
524
            if (Alt10 >= 80)
525
                var Alt100 += Alt20;
526

            
527
            if (Alt10 >= 80 and Alt100 >= 9)
528
                var Alt1000 += Alt20;
529

            
530
            if (Alt10 >= 80 and Alt100 >= 9 and Alt1000 >= 9)
531
                var Alt10000 += Alt20;
532

            
533
            if (alt> 100)
534
                var Offset10 = 100;
535

            
536
            if (alt> 1000)
537
                var Offset100 = 10;
538

            
539
            if (alt> 10000)
540
                var Offset1000 = 10;
541

            
542
            if (!Ne) {
543
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*0.57375);
544
                var altCentral = (int(alt/100)*100);
545
            }
546
            elsif (Ne) {
547
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*-0.57375);
548
                var altCentral = -(int(alt/100)*100);
549
            }
550
            me.screenElements["AltBigC"].setText("");
551
            me.screenElements["AltSmallC"].setText("");
552
            for (var place = 1; place <= 6; place += 1) {
553
                var altUP = altCentral + (place*100);
554
                var offset = -30.078;
555
                if (altUP < 0) {
556
                    var altUP = -altUP;
557
                    var prefix = "-";
558
                    var offset += 15.039;
559
                }
560
                else
561
                    var prefix = "";
562

            
563
                if (altUP == 0) {
564
                    var AltBigUP    = "";
565
                    var AltSmallUP  = "0";
566

            
567
                }
568
                elsif (math.mod(altUP,500) == 0 and altUP != 0) {
569
                    var AltBigUP    = sprintf(prefix~"%1d", altUP);
570
                    var AltSmallUP  = "";
571
                }
572
                elsif (altUP < 1000 and (math.mod(altUP,500))) {
573
                    var AltBigUP    = "";
574
                    var AltSmallUP  = sprintf(prefix~"%1d", int(math.mod(altUP,1000)));
575
                    var offset = -30.078;
576
                }
577
                elsif ((altUP < 10000) and (altUP >= 1000) and (math.mod(altUP,500))) {
578
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
579
                    var AltSmallUP  = sprintf("%1d", int(math.mod(altUP,1000)));
580
                    var offset += 15.039;
581
                }
582
                else {
583
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
584
                    var mod = int(math.mod(altUP,1000));
585
                    var AltSmallUP  = sprintf("%1d", mod);
586
                    var offset += 30.078;
587
                }
588

            
589
                me.screenElements["AltBigU"~place].setText(AltBigUP);
590
                me.screenElements["AltSmallU"~place].setText(AltSmallUP);
591
                me.screenElements["AltSmallU"~place].setTranslation(offset,0);
592
                var altDOWN = altCentral - (place*100);
593
                var offset = -30.078;
594
                if (altDOWN < 0) {
595
                    var altDOWN = -altDOWN;
596
                    var prefix = "-";
597
                    var offset += 15.039;
598
                }
599
                else
600
                    var prefix = "";
601

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

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
648
    updateHSI : func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
649
# rotates the compass (PFD) {{{
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
650
        var hdg = me._updated_hdg;
animation HSI
Sébastien MARQUE authored on 2017-03-11
651
        me.screenElements.Rose
652
            .setRotation(-hdg * D2R);
653
        me.screenElements['HDG-text']
654
            .setText(sprintf("%03u°", hdg));
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
655
        settimer(func me.updateHSI(), 0.1);
animation HSI
Sébastien MARQUE authored on 2017-03-11
656
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
657
#}}}
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
658

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

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

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

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

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

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

            
872
    updateCOMM: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
873
# update COMM radios display upper right (PFD/MFD){{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
874
        arg[0]._r = 'comm';
875
        me._updateRadio(arg[0]);
876
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
877
#}}}
anime time display
Sébastien MARQUE authored on 2017-03-13
878

            
879
    updateTIME : func {
880
# updates the displayed time botoom left {{{
881
        me.screenElements['TIME-text']
882
            .setText(getprop('/sim/time/gmt-string'));
883
        settimer(func me.updateTIME(), 1);
884
    },
885
#}}}
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
886

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

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
922
    updateOAT : func {
923
# update OAT display on normal and reversionnary modes (every 3s) {{{
924
        var tmp = getprop('/environment/temperature-deg' ~ me._oat_unit);
925
        me.screenElements['OAT-text']
926
            .setText(sprintf((abs(tmp) < 10) ? "%.1f %s" : "%i %s", tmp, (me._oat_unit == 'c') ? '°C' : 'F'));
927
        settimer(func me.updateOAT(), 3);
928
    },
929
    _oat_unit : 'c',
930
#}}}
931

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

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

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

            
1033
                if (info.pointer)
1034
                    me.screenElements[el ~ '-pointer']
1035
                        .setRotation(-info.hdg-me._updated_hdg * D2R)
1036
                        .show();
1037
                else
1038
                    me.screenElements[el ~ '-pointer']
1039
                        .hide();
1040
                me.screenElements[el ~ '-SRC-text']
1041
                    .setText(dev);
1042
                me.screenElements[el ~ '-DST-text']
1043
                    .setText(info.dst);
1044
                me.screenElements[el ~ '-WPID-text']
1045
                    .setText(info.id);
1046
                me.screenElements['BRG' ~ brg]
1047
                    .show();
1048
            }
1049
            else {
1050
                me.screenElements['BRG' ~ brg]
1051
                    .hide();
1052
            }
1053
        }
1054
        settimer(func me.updateBRG(), 1);
1055
    },
commit initial
Sébastien MARQUE authored on 2017-03-07
1056
};
some added comments
Sébastien MARQUE authored on 2017-03-18
1057
#}}}
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
1058

            
1059
var keyMap = {
add new vim folds
Sébastien MARQUE authored on 2017-03-15
1060
# softkeys map for PFD and MFD {{{
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
1061
    PFD : {
1062
        first : 1,
1063
        texts : ['INSET', 'SENSOR', 'PFD', 'OBS', 'CDI', 'DME', 'XPDR', 'IDENT', 'TMR/REF', 'NRST' ],
1064
        INSET : {
1065
            texts : ['OFF', 'DCLTR', 'WXLGND', 'TRAFFIC', 'TOPO', 'TERRAIN', 'STRMSCP', 'NEXRAD-C', 'XM LTNG', 'METAR'],
1066
        },
1067
        SENSOR : {
1068
            first : 2,
1069
            texts : [ 'ADC1', 'ADC2', '', 'AHRS1', 'AHRS2'],
1070
        },
1071
        PFD : {
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1072
            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
1073
            'SYN VIS' : {
1074
                texts : [ 'PATHWAY', 'SYN TERR', 'HR2NHDG', 'APTSIGNS', 'FPM'],
1075
            },
1076
            'AOA/WIND' : {
1077
                first : 4,
1078
                texts : ['AOA', 'WIND'],
1079
                AOA : {
1080
                    first : 5,
1081
                    texts : ['AOA ON', 'AOA AUTO'],
1082
                },
1083
                WIND : {
1084
                    first : 2,
1085
                    texts : ['OPTN1', 'OPTN2', '', 'OFF'],
1086
                },
1087
            },
1088
            'HSI FMT' : {
1089
                first : 6,
1090
                texts : ['360 HSI', 'ARC HSI'],
1091
            },
1092
            'ALT UNIT' : {
1093
                first : 5,
1094
                texts : ['METERS', '', 'IN', 'HPA'],
1095
            },
1096
        },
1097
        XPDR : {
1098
            first : 2,
1099
            texts : ['STBY', 'ON', 'ALT', '', 'VFR', 'CODE', 'IDENT'],
1100
            CODE : {
1101
                texts : ['0', '1', '2', '3', '4', '5', '6', '7', 'IDENT', 'BKSP'],
1102
            },
1103
        },
1104
    },
1105
    MFD : {
1106
        texts : ['ENGINE', '', 'MAP', '', '', '', '', '', '', 'DCLTR', 'SHW CHRT', 'CHKLIST'],
1107
        MAP : {
1108
            texts: ['TRAFFIC', 'PROFILE', 'TOPO', 'TERRAIN', 'AIRWAYS', 'STRMSCP','NEXRAD-C', 'XM LTNG', 'METAR', 'LEGEND', 'BACK'],
1109
        },
1110
        CHKLIST : {
1111
            texts : ['ENGINE', '', '', '', '', 'DONE', '', '', '', '', 'EXIT', 'EMERGCY'],
1112
        },
1113
        ENGINE : {
1114
            texts : ['ENGINE', 'ANTI-ICE', '', 'DCLTR', '', 'ASSIST', '', '', '', '', 'FUEL'],
1115
            'ANTI-ICE' : {
1116
                texts : ['LEFT', 'AUTO', 'RIGHT', '', '', '', '', '', '', '', '', 'BACK'],
1117
            },
1118
            FUEL : {
1119
                first : 1,
1120
                texts : ['FULL', 'TABS', '', '', '', '', '', '', '', 'UNDO', 'ENTER'],
1121
            },
1122
        },
1123
    },
1124
};
add new vim folds
Sébastien MARQUE authored on 2017-03-15
1125
#}}}