zkv1000 / Nasal / display.nas /
Newer Older
1200 lines | 45.108kb
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

            
adds Map on MFD
Sébastien MARQUE authored on 2017-03-20
22
        if (role == 'MFD') {
23
            m.MFDMapTiles = MapTiles.new(m.display);
24
            m.MFDMapNavDisplay = MapNavDisplay.new(m.display);
25
        }
26

            
commit initial
Sébastien MARQUE authored on 2017-03-07
27
        return m;
28
    },
add new vim folds
Sébastien MARQUE authored on 2017-03-15
29
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
30

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

            
34
    timerTrigger : func {
35
        var now = systime();
36
        foreach (var id; keys(me.timers)) {
37
            if (me.timers[id] < now) {
38
                me.screenElements[id].hide();
39
                delete(me.timers, id);
40
            }
41
        }
42
        settimer(func me.timerTrigger(), 1);
43
    },
44

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

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

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

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

            
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
92
            if (me.role == 'PFD') {
93
                append(groups.show,
commit initial
Sébastien MARQUE authored on 2017-03-07
94
                    'XPDR-TIME', 
AI disponible
Sébastien MARQUE authored on 2017-03-10
95
                    'FlightInstruments',
96
                    'Horizon',
AI disponible, avec bankPoin...
Sébastien MARQUE authored on 2017-03-10
97
                    'bankPointer',
animation VSI
Sébastien MARQUE authored on 2017-03-10
98
                    'VSI',
animation HSI
Sébastien MARQUE authored on 2017-03-11
99
                    'Rose',
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
100
                    'Heading-bug',
101
                    'PFD-Widgets',
trends animation
Sébastien MARQUE authored on 2017-03-13
102
                    'Trends',
103
                    'Airspeed-Trend-Indicator',
104
                    'Altitude-Trend-Indicator',
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
105
                    'OAT',
106
                    'IAS-bg',
107
                    'TAS',
108
                    'GSPD',
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
109
                    'BARO-bg',
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
110
                );
111
                append(groups.hide,
adds EIS
Sébastien MARQUE authored on 2017-03-18
112
                    'EIS',
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
113
                    'CDI',
adds CDI
Sébastien MARQUE authored on 2017-03-18
114
                    'NAV1-pointer', 'NAV1-CDI', 'NAV1-FROM', 'NAV1-TO',
115
                    'NAV2-pointer', 'NAV2-CDI', 'NAV2-FROM', 'NAV2-TO',
116
                    '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
117
                    'BRG1-pointer',
118
                    'BRG2-pointer',
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
119
                    'SelectedHDG-bg',
120
                    'SelectedHDG-bgtext',
121
                    'SelectedHDG-text',
122
                    'SelectedCRS-bg',
123
                    'SelectedCRS-bgtext',
124
                    'SelectedCRS-text',
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
125
                    'SelectedALT', 'SelectedALT-bug', 'SelectedALT-bg', 'SelectedALT-symbol',
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
126
                    'TAS',
127
                    'GSPD',
128
                    'WindData',
129
                    'Reversionnary',
130
                    'Annunciation',
131
                    'Comparator',
132
                    'BRG1',
133
                    'BRG2',
134
                    'DME1',
135
                    'PFD-Map',
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
136
                    'PFD-Multilines',
improves WindData display
Sébastien MARQUE authored on 2017-03-16
137
                    '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
138
                );
139
                append(groups.clip,
animation IAS
Sébastien MARQUE authored on 2017-03-10
140
                    'SpeedLint1',
animation ALT
Sébastien MARQUE authored on 2017-03-11
141
                    'SpeedTape',
142
                    'LintAlt',
143
                    'AltLint00011'
144
                );
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
145
                append(groups.text,
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
146
                    'SelectedALT-text',
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
147
                    'TAS-text',
148
                    'GSPD-text',
anime time display
Sébastien MARQUE authored on 2017-03-13
149
                    'TIME-text',
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
150
                    'OAT-text',
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
151
                    'VSIText',
152
                    'Speed110',
153
                    'Alt11100',
154
                    'HDG-text',
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
155
                    'BARO-text',
adds CDI
Sébastien MARQUE authored on 2017-03-18
156
                    'CDI-SRC-text', 'CDI-GPS-ANN-text', 'CDI-GPS-XTK-text',
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
157
                    'BRG1-pointer', 'BRG1-SRC-text', 'BRG1-DST-text', 'BRG1-WPID-text',
158
                    'BRG2-pointer', 'BRG2-SRC-text', 'BRG2-DST-text', 'BRG2-WPID-text',
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
159
                    'WindData-OPTN1-HDG-text', 'WindData-OPTN1-SPD-text',
160
                    'WindData-OPTN2-crosswind-text', 'WindData-OPTN2-headwind-text',
adds transponder
Sébastien MARQUE authored on 2017-03-17
161
                    '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
162
                    'AltBigC', 'AltSmallC'
163
                );
164
                for (var place = 1; place <= 6; place +=1) {
165
                    append(groups.text,
166
                        'AltBigU' ~ place,
167
                        'AltSmallU' ~ place,
168
                        'AltBigD' ~ place,
169
                        'AltSmallD' ~ place
170
                    );
171
                }
animation ALT
Sébastien MARQUE authored on 2017-03-11
172
            }
adds EIS
Sébastien MARQUE authored on 2017-03-18
173
            else {
animation texts EIS + power ...
Sébastien MARQUE authored on 2017-03-19
174
                append(groups.show, 'EIS', 'POWER-pointer');
175
                append(groups.text,
176
                        'RPM-text', 'EGT-text', 'CHT-text', 'FUEL-USED-text',
177
                        'FUEL-FLOW-text', 'MAN-Hg-text', 'POWER-PERCENT-text',
178
                        'RPM-text', 'BUS-V-text', 'BATT-text', 'PSI-text',
179
                        'OIL-TEMP-text'
180
                    );
adds EIS
Sébastien MARQUE authored on 2017-03-18
181
            }
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
182

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

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

            
219
    showInitProgress : func (role) {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
220
#{{{
commit initial
Sébastien MARQUE authored on 2017-03-07
221
        me.progress = me.display.createGroup();
222
        me.progress.show();
223
        me.progress.createChild("text", role ~ " title")
224
            .setTranslation(512, 384)
225
            .setAlignment("center-center")
226
            .setFont("LiberationFonts/LiberationSans-Italic.ttf")
227
            .setFontSize(64, 1)
228
            .setColor(1,1,1)
229
            .setText("ZKV1000 " ~ role ~ " init");
230

            
231
        zkv.getNode(role ~ 'init',1).setIntValue(1);
232

            
233
        me._showInitProgress(me.progress.createChild("text", role ~ "progress")
234
            .setTranslation(512, 484)
235
            .setAlignment("center-center")
236
            .setFont("LiberationFonts/LiberationSans-Bold.ttf")
237
            .setFontSize(128, 1)
238
            .setColor(1,0,0), '.');
239
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
240
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
241

            
some added comments
Sébastien MARQUE authored on 2017-03-18
242
    colors : {
243
# set of predefined colors {{{
244
        green : [0, 1, 0],
245
        white : [1, 1, 1],
246
        black : [0, 0, 0],
247
        lightblue : [0, 1, 1],
248
        darkblue : [0, 0, 1],
249
        red : [1, 0, 0],
adds CDI
Sébastien MARQUE authored on 2017-03-18
250
        magenta : [1, 0, 1],
some added comments
Sébastien MARQUE authored on 2017-03-18
251
    },
252
#}}}
253

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

            
312
    clips : {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
313
#{{{
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
314
        PitchScale   : "rect(70,664,370,256)",
315
        SpeedLint1   : "rect(252,226,318,204)",
316
        SpeedTape    : "rect(115,239,455,156)",
317
        LintAlt      : "rect(115,808,455,704)",
animation ALT
Sébastien MARQUE authored on 2017-03-11
318
        AltLint00011 : "rect(252,804,318,771)",
AI disponible
Sébastien MARQUE authored on 2017-03-10
319
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
320
#}}}
AI disponible
Sébastien MARQUE authored on 2017-03-10
321

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

            
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
366
    updateSoftKeys : func {
367
# update SoftKeys boxes {{{
368
        # grey background code = #353939
369
        # on PFD the last boxes are always BACK and ALERTS
370
        if (me.role == 'PFD') {
371
            me.screenElements[sprintf("SoftKey%02i-text", 11)]
372
                .setText('ALERTS');
373
            if (size(me.device.softkeys.path) != 0)
374
                me.screenElements[sprintf("SoftKey%02i-text", 10)]
375
                    .setText('BACK');
376
        }
377

            
378
        var path = keyMap[me.role];
379
        foreach (var p; me.device.softkeys.path)
380
            path = path[p];
381

            
382
        # feeding with empty menus the first boxes
383
        var start = (contains(path, 'first')) ? path.first : 0;
384
        for (var k = 0; k < start; k+=1) {
385
            me.screenElements[sprintf("SoftKey%02i-text", k)]
386
                .setText('');
387
        }
388
        # filling with the content the next boxes
389
        forindex (var k; path.texts) {
390
            var i = k + start;
391
            me.screenElements[sprintf("SoftKey%02i-text", i)]
392
                .setText(path.texts[k]);
393
        }
394
        # feeding the last boxes with empty string
395
        var end = (me.role == 'PFD') ? 10 : 12;
396
        if (size(path.texts) + start < end) {
397
            start = size(path.texts) + start;
398
            for (var k = start; k < end; k += 1)
399
                me.screenElements[sprintf("SoftKey%02i-text", k)]
400
                    .setText('');
401
        }
402
    },
403
#}}}
404

            
refresh of vital information...
Sébastien MARQUE authored on 2017-03-18
405
    update20Hz : func {
406
# 20Hz updates roll, pitch, VSI, IAS, altitude and HDG {{{
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
407
        me._updated_roll = getprop('/orientation/roll-deg');
408
        me._updated_pitch = getprop('orientation/pitch-deg');
409
        me._updated_vsi = getprop('/instrumentation/vertical-speed-indicator/indicated-speed-fpm');
410
        me._updated_ias = getprop('/velocities/airspeed-kt');
411
        me._updated_alt = getprop('/instrumentation/altimeter/indicated-altitude-ft');
412
        me._updated_hdg = getprop('/orientation/heading-deg');
refresh of vital information...
Sébastien MARQUE authored on 2017-03-18
413
        settimer(func me.update20Hz(), 0.05);
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
414
     },
415
    _updated_roll : 0,
416
    _updated_pitch : 0,
417
    _updated_vsi : 0,
418
    _updated_ias : 0,
419
    _updated_alt : 0,
420
    _updated_hdg : 0,
421
#}}}
422

            
refresh of vital information...
Sébastien MARQUE authored on 2017-03-18
423
    update1Hz : func {
424
# 1Hz updates {{{
425
        me._updated_wow = getprop('/gear/gear/wow');
426
        settimer(func me.update20Hz(), 1);
427
    },
428
    _updated_wow : 1,
429
#}}}
430

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
431
    updateAI: func(){
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
432
#{{{
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
433
        var pitch = me._updated_pitch;
434
        var roll = me._updated_roll;
AI disponible
Sébastien MARQUE authored on 2017-03-10
435
        if (pitch > 80)
436
            pitch = 80;
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
437
        elsif (pitch < -80)
AI disponible
Sébastien MARQUE authored on 2017-03-10
438
            pitch = -80;
439
        me.screenElements.Horizon
fix AI animation
Sébastien MARQUE authored on 2017-03-19
440
            .setCenter(459, 282.8 - 6.849 * pitch)
AI disponible
Sébastien MARQUE authored on 2017-03-10
441
            .setRotation(-roll * D2R)
fix AI animation
Sébastien MARQUE authored on 2017-03-19
442
            .setTranslation(0, pitch * 6.849);
AI disponible, avec bankPoin...
Sébastien MARQUE authored on 2017-03-10
443
        me.screenElements.bankPointer
444
            .setRotation(-roll * D2R);
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
445
        settimer(func me.updateAI(), 0.1);
AI disponible
Sébastien MARQUE authored on 2017-03-10
446
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
447
#}}}
animation VSI
Sébastien MARQUE authored on 2017-03-10
448

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
449
    updateVSI: func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
450
# animate VSI {{{
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
451
        var vsi = me._updated_vsi;
animation VSI
Sébastien MARQUE authored on 2017-03-10
452
        me.screenElements.VSIText
453
            .setText(num(math.round(vsi, 10)));
454
        if (vsi > 4500)
455
            vsi = 4500;
456
        elsif (vsi < -4500)
457
            vsi = -4500;
458
        me.screenElements.VSI
459
            .setTranslation(0, vsi * -0.03465);
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
460
        settimer(func me.updateVSI(), 0.1);
animation VSI
Sébastien MARQUE authored on 2017-03-10
461
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
462
#}}}
animation IAS
Sébastien MARQUE authored on 2017-03-10
463

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

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
505
    updateTAS: func {
506
# updates the True Airspeed and GroundSpeed indicators {{{
507
        me.screenElements['TAS-text']
508
            .setText(sprintf('%iKT', getprop('/instrumentation/airspeed-indicator/true-speed-kt')));
509
        me.screenElements['GSPD-text']
510
            .setText(sprintf('%iKT', getprop('/velocities/groundspeed-kt')));
511
        settimer(func me.updateTAS(), 0.5);
512
    },
513
#}}}
514

            
515
    updateALT: func () {
516
# animates the altitude lint (PFD) {{{
517
        var alt = me._updated_alt;
animation ALT
Sébastien MARQUE authored on 2017-03-11
518
        if (alt < 0)
519
            me.screenElements.Alt11100
520
                .setText(sprintf("% 3i",math.ceil(alt/100)));
521
        elsif (alt < 100)
522
            me.screenElements.Alt11100
523
                .setText('');
524
        else
525
            me.screenElements.Alt11100
526
                .setText(sprintf("% 3i",math.floor(alt/100)));
527
        me.screenElements.AltLint00011
528
            .setTranslation(0,math.fmod(alt,100) * 1.24);
529

            
530
        # From Farmin/G1000 http://wiki.flightgear.org/Project_Farmin/FG1000
531
        if (alt> -1000 and alt< 1000000) {
532
            var Offset10 = 0;
533
            var Offset100 = 0;
534
            var Offset1000 = 0;
535
            if (alt< 0) {
536
                var Ne = 1;
537
                var alt= -alt;
538
            }
539
            else
540
                var Ne = 0;
541

            
542
            var Alt10       = math.mod(alt,100);
543
            var Alt100      = int(math.mod(alt/100,10));
544
            var Alt1000     = int(math.mod(alt/1000,10));
545
            var Alt10000    = int(math.mod(alt/10000,10));
546
            var Alt20       = math.mod(Alt10,20)/20;
547
            if (Alt10 >= 80)
548
                var Alt100 += Alt20;
549

            
550
            if (Alt10 >= 80 and Alt100 >= 9)
551
                var Alt1000 += Alt20;
552

            
553
            if (Alt10 >= 80 and Alt100 >= 9 and Alt1000 >= 9)
554
                var Alt10000 += Alt20;
555

            
556
            if (alt> 100)
557
                var Offset10 = 100;
558

            
559
            if (alt> 1000)
560
                var Offset100 = 10;
561

            
562
            if (alt> 10000)
563
                var Offset1000 = 10;
564

            
565
            if (!Ne) {
566
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*0.57375);
567
                var altCentral = (int(alt/100)*100);
568
            }
569
            elsif (Ne) {
570
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*-0.57375);
571
                var altCentral = -(int(alt/100)*100);
572
            }
573
            me.screenElements["AltBigC"].setText("");
574
            me.screenElements["AltSmallC"].setText("");
575
            for (var place = 1; place <= 6; place += 1) {
576
                var altUP = altCentral + (place*100);
577
                var offset = -30.078;
578
                if (altUP < 0) {
579
                    var altUP = -altUP;
580
                    var prefix = "-";
581
                    var offset += 15.039;
582
                }
583
                else
584
                    var prefix = "";
585

            
586
                if (altUP == 0) {
587
                    var AltBigUP    = "";
588
                    var AltSmallUP  = "0";
589

            
590
                }
591
                elsif (math.mod(altUP,500) == 0 and altUP != 0) {
592
                    var AltBigUP    = sprintf(prefix~"%1d", altUP);
593
                    var AltSmallUP  = "";
594
                }
595
                elsif (altUP < 1000 and (math.mod(altUP,500))) {
596
                    var AltBigUP    = "";
597
                    var AltSmallUP  = sprintf(prefix~"%1d", int(math.mod(altUP,1000)));
598
                    var offset = -30.078;
599
                }
600
                elsif ((altUP < 10000) and (altUP >= 1000) and (math.mod(altUP,500))) {
601
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
602
                    var AltSmallUP  = sprintf("%1d", int(math.mod(altUP,1000)));
603
                    var offset += 15.039;
604
                }
605
                else {
606
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
607
                    var mod = int(math.mod(altUP,1000));
608
                    var AltSmallUP  = sprintf("%1d", mod);
609
                    var offset += 30.078;
610
                }
611

            
612
                me.screenElements["AltBigU"~place].setText(AltBigUP);
613
                me.screenElements["AltSmallU"~place].setText(AltSmallUP);
614
                me.screenElements["AltSmallU"~place].setTranslation(offset,0);
615
                var altDOWN = altCentral - (place*100);
616
                var offset = -30.078;
617
                if (altDOWN < 0) {
618
                    var altDOWN = -altDOWN;
619
                    var prefix = "-";
620
                    var offset += 15.039;
621
                }
622
                else
623
                    var prefix = "";
624

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

            
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
671
    updateBARO : func () {
672
# update BARO widget {{{
673
        var fmt = me._baro_unit == 'inhg' ? '%.2f%s' : '%i%s';
674
        me.screenElements['BARO-text']
675
            .setText(sprintf(fmt,
676
                        getprop('/instrumentation/altimeter/setting-' ~ me._baro_unit),
677
                        me._baro_unit == 'inhg' ? 'in' : 'hPa')
678
                );
679
    },
680
    _baro_unit : 'inhg',
681
#}}}
682

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
683
    updateHSI : func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
684
# rotates the compass (PFD) {{{
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
685
        var hdg = me._updated_hdg;
animation HSI
Sébastien MARQUE authored on 2017-03-11
686
        me.screenElements.Rose
687
            .setRotation(-hdg * D2R);
688
        me.screenElements['HDG-text']
689
            .setText(sprintf("%03u°", hdg));
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
690
        settimer(func me.updateHSI(), 0.1);
animation HSI
Sébastien MARQUE authored on 2017-03-11
691
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
692
#}}}
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
693

            
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
694
    updateHDG : func (hdg) {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
695
# moves the heading bug and display heading-deg for 3 seconds (PFD) {{{
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
696
        if (me.role == 'MFD')
697
            return;
698
        me.screenElements['Heading-bug']
699
            .setRotation(hdg * D2R);
700
        me.screenElements['SelectedHDG-bg']
701
            .show();
702
        me.screenElements['SelectedHDG-bgtext']
703
            .show();
704
        me.screenElements['SelectedHDG-text']
705
            .setText(sprintf('%03d°%s', hdg, ''))
706
            .show();
707
        me.addTimer(3, ['SelectedHDG-text', 'SelectedHDG-bgtext', 'SelectedHDG-bg']);
708
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
709
#}}}
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
710

            
adds CDI
Sébastien MARQUE authored on 2017-03-18
711
    updateCRS : func () {
anime CRS
Sébastien MARQUE authored on 2017-03-13
712
# TODO: update display for NAV/GPS/BRG courses {{{
713
        if (me.role == 'MFD')
714
            return;
adds CDI
Sébastien MARQUE authored on 2017-03-18
715
        var source = getprop('/instrumentation/zkv1000/cdi/source');
716
        if (source == 'OFF')
717
            return;
718
        var crs = getprop('/instrumentation/zkv1000/cdi/course');
719
        if (crs == nil)
720
            return;
anime CRS
Sébastien MARQUE authored on 2017-03-13
721
        me.screenElements['SelectedCRS-bg']
722
            .show();
723
        me.screenElements['SelectedCRS-bgtext']
724
            .show();
725
        me.screenElements['SelectedCRS-text']
726
            .setText(sprintf('%03d°%s', crs, ''))
adds CDI
Sébastien MARQUE authored on 2017-03-18
727
            .setColor(source == 'GPS' ? me.colors.magenta : me.colors.green)
anime CRS
Sébastien MARQUE authored on 2017-03-13
728
            .show();
729
        me.addTimer(3, ['SelectedCRS-text', 'SelectedCRS-bgtext', 'SelectedCRS-bg']);
730
    },
731
#}}}
732

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
733
    updateSelectedALT : func {
734
# animation for altitude section, called via updatedALT {{{
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
735
        if (! device[0].display.screenElements['SelectedALT'].getVisible())
736
            return;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
737
        var selected_alt = getprop('/instrumentation/zkv1000/afcs/selected-alt-ft');
738
        var delta_alt = me._updated_alt - selected_alt;
739
        if (abs(delta_alt) > 300)
740
            delta_alt = 300 * abs(delta_alt)/delta_alt;
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
741
        me.screenElements['SelectedALT-symbol']
742
            .setVisible(abs(delta_alt) > 100);
743
        me.screenElements['SelectedALT-bg']
744
            .setVisible(abs(delta_alt) > 100);
745
        me.screenElements['SelectedALT-text']
746
            .setText(sprintf("%i", selected_alt))
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
747
            .setVisible(abs(delta_alt) > 100);
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
748
        me.screenElements['SelectedALT-bug']
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
749
            .setTranslation(0, delta_alt * 0.567); # 170/300 = 0.567
750
    },
751
#}}}
752

            
adds CDI
Sébastien MARQUE authored on 2017-03-18
753
    updateCDI : func {
754
# animation for CDI {{{
755
        var source = getprop('/instrumentation/zkv1000/cdi/source');
756
        if (source == 'OFF') {
757
            foreach (var s; ['GPS', 'NAV1', 'NAV2'])
758
                foreach (var t; ['pointer', 'CDI'])
759
                    me.screenElements[s ~ '-' ~ t].hide();
760
            me.screenElements['CDI-GPS-ANN-text'].hide();
761
            me.screenElements['CDI-GPS-XTK-text'].hide();
762
            me.screenElements['CDI-SRC-text'].hide();
763
            me.screenElements['CDI'].hide();
764
        }
765
        else {
766
            var course = getprop('/instrumentation/zkv1000/cdi/course');
767
            me.screenElements['CDI']
768
                .show();
769
            me.screenElements['GPS-CTI']
770
                .setVisible(source == 'GPS');
771
            me.screenElements['GPS-CTI-diamond']
772
                .setVisible(source == 'GPS');
773
            foreach (var s; ['GPS', 'NAV1', 'NAV2']) {
774
                var rot = (course - me._updated_hdg) * D2R;
775
                me.screenElements[s ~ '-pointer']
776
                    .setRotation(rot)
777
                    .setVisible(source == s);
778
                me.screenElements[s ~ '-CDI']
779
                    .setVisible(source == s);
780
                foreach (var f; ['FROM', 'TO'])
781
                    me.screenElements[s ~ '-' ~ f]
782
                        .setVisible(s == source and getprop('/instrumentation/zkv1000/cdi/', f, '-flag'));
783
                me.screenElements['CDI-SRC-text']
784
                    .setText(source)
785
                    .setColor(source == 'GPS' ? me.colors.magenta : me.colors.green)
786
                    .show();
787
                var deflection = getprop('/instrumentation/zkv1000/cdi/course-deflection');
788
                if (left(source, 3) == 'NAV') {
789
                    var scale = deflection / 4;
790
                    scale = (abs(scale) > 1.2) ? 1.2 : scale;
791
                }
792
                else {
793
                    me.screenElements['CDI-SRC-text']
794
                        .setText('GPS')
795
                        .setColor(1,0,1);
796
                }
797
                me.screenElements[source ~ '-CDI']
798
                    .setTranslation(65 * scale, 0);
799
            }
800
            settimer(func me.updateCDI(), 0.5);
801
        }
802
    },
803
#}}}
804

            
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
805
    _updateRadio: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
806
# common parts for NAV/LOC/COMM radios{{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
807
        # arg[0]._r = <comm|nav>
808
        if (contains(arg[0], "active")) {
809
            if (arg[0]['active'] == 'none') {
810
                me.screenElements[arg[0]._r ~ '1-selected-freq']
811
                    .setColor(1,1,1);
812
                me.screenElements[arg[0]._r ~ '2-selected-freq']
813
                    .setColor(1,1,1);
814
            }
815
            else {
816
                me.screenElements[arg[0]._r ~ arg[0]['active'] ~ '-selected-freq']
817
                    .setColor(0,1,0);
818
                me.screenElements[arg[0]._r ~ arg[0].inactive ~ '-selected-freq']
819
                    .setColor(1,1,1);
820
            }
821
        }
822
        if (contains(arg[0], 'tune')) {
823
            # n = 0 -> NAV1/COMM1
824
            # n = 1 -> NAV1/COMM2
825
            me.screenElements[arg[0]._r ~ '-freq-switch']
826
                .setTranslation(0, arg[0].tune * 25);
827
            me.screenElements[arg[0]._r ~ (arg[0].tune + 1) ~ '-standby-freq']
828
                .setColor(0,1,1);
829
            me.screenElements[arg[0]._r ~ ((arg[0].tune == 0) + 1) ~ '-standby-freq']
830
                .setColor(1,1,1);
831
        }
832
        if (contains(arg[0], 'refresh')) {
833
            # rafraichi une seule ligne NAV1/COMM1 ou NAV2/COMM2
834
            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
835
            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-selected-freq']
836
                .setText(sprintf(fmt, getprop('/instrumentation/'
837
                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/selected-mhz')));
838
            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-standby-freq']
839
                .setText(sprintf(fmt, getprop('/instrumentation/'
840
                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/standby-mhz')));
841
        }
842
        if (contains(arg[0], 'set')) {
843
            # positionne la valeur modifiée, les listeners "trigguent" en permanence ces propriétés, donc exit
844
            var n = getprop('/instrumentation/zkv1000/radios/' ~ arg[0]._r ~ '-tune');
845
            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
846
            me.screenElements[arg[0]._r ~ (n + 1) ~ '-standby-freq']
fix freq display while setti...
Sébastien MARQUE authored on 2017-03-16
847
                .setText(sprintf(fmt, getprop('/instrumentation/' ~ arg[0]._r ~ '[' ~ n ~ ']/frequencies/standby-mhz')));
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
848
        }
849
        if (contains(arg[0], 'auto')) {
850
            # pour rafraichir automagiquement, toutes les deux secondes un refresh pour un NAV
851
            var radio = arg[0].auto;
852
            me._updateRadio({refresh: 1, _r: radio});
853
            settimer(func me._updateRadio({refresh: 2, _r: radio}), 1);
854
            settimer(func me._updateRadio({auto: radio}), 2);
855
        }
856
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
857
#}}}
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
858

            
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
859
    updateNAV : func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
860
# update NAV/LOC rodios display upper left (PFD/MFD){{{
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
861
        # made active via menu
862
        if (contains(arg[0], "active")) {
adds CDI
Sébastien MARQUE authored on 2017-03-18
863
            arg[0]._r = 'nav';
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
864
            if (arg[0]['active'] == 'none') {
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
865
                me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
866
                me.screenElements['nav1-id']
867
                    .setColor(1,1,1);
868
                me.screenElements['nav2-id']
869
                    .setColor(1,1,1);
870
                me.screenElements['NAV1-pointer']
871
                    .hide();
872
                me.screenElements['NAV2-pointer']
873
                    .hide();
874
            }
875
            else {
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
876
                arg[0].inactive = (arg[0]['active'] == 1) + 1;
877
                me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
878
                me.screenElements['nav' ~ arg[0]['active'] ~ '-id']
879
                    .setColor(0,1,0);
880
                me.screenElements['NAV' ~ arg[0]['active'] ~ '-pointer']
881
                    .show();
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
882
                me.screenElements['nav' ~ arg[0].inactive ~ '-id']
883
                    .setColor(1,1,1);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
884
#                me.screenElements['HDI']
885
#                    .setRotation();
886
#                me.screenElements['NAV' ~ inactive ~ '-pointer']
887
#                    .hide();
888
#                foreach (var e; [ 'FROM', 'TO', 'CDI' ])
889
#                    me.screenElements['NAV' ~ inactive ~ '-' ~ e]
890
#                        .hide();
891
            }
892
        }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
893
        elsif (contains(arg[0], 'nav-id')) {
Correction swap NAV tuning
Sébastien MARQUE authored on 2017-03-12
894
            # 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
895
            if (arg[0].val == nil)
896
                arg[0].val = '';
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
897
            me.screenElements["nav" ~ arg[0]['nav-id'] ~ "-id"]
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
898
                    .setText(arg[0].val);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
899
        }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
900
        else {
901
            arg[0]._r = 'nav';
902
            me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
903
        }
904
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
905
#}}}
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
906

            
907
    updateCOMM: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
908
# update COMM radios display upper right (PFD/MFD){{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
909
        arg[0]._r = 'comm';
910
        me._updateRadio(arg[0]);
911
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
912
#}}}
anime time display
Sébastien MARQUE authored on 2017-03-13
913

            
914
    updateTIME : func {
915
# updates the displayed time botoom left {{{
916
        me.screenElements['TIME-text']
917
            .setText(getprop('/sim/time/gmt-string'));
918
        settimer(func me.updateTIME(), 1);
919
    },
920
#}}}
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
921

            
adds transponder
Sébastien MARQUE authored on 2017-03-17
922
    updateXPDR : func {
923
# updates transponder display {{{
924
        for (var d = 0; d < 4; d+=1)
925
            me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
926
                .setText(sprintf('%i', getprop('/instrumentation/transponder/inputs/digit[' ~ d ~ ']')));
927
        var tuning = getprop('/instrumentation/zkv1000/radios/xpdr-tuning-digit');
928
        if (tuning != nil)
929
            for (var d = 0; d < 4; d+=1) {
930
                if (d != tuning)
931
                    me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
932
                        .setColor(1,1,1);
933
                else
934
                    me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
935
                        .setColor(0,1,1);
936
            }
937
        else {
938
            if (getprop('/instrumentation/transponder/ident'))
939
                var mode = 'IDENT';
940
            else
941
                var mode = getprop('/instrumentation/zkv1000/radio/xpdr-mode');
942
            var wow = getprop('/gear/gear/wow');
943
            if (! wow and mode != 'STBY')
944
                var color = [0, 1, 0];
945
            else
946
                var color = [1, 1, 1];
947
            for (var d = 0; d < 4; d+=1)
948
                me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
949
                    .setColor(color);
950
            me.screenElements['XPDR-MODE-text']
951
                .setColor(color)
952
                .setText(mode);
953
        }
954
},
955
#}}}
956

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
957
    updateOAT : func {
958
# update OAT display on normal and reversionnary modes (every 3s) {{{
959
        var tmp = getprop('/environment/temperature-deg' ~ me._oat_unit);
960
        me.screenElements['OAT-text']
961
            .setText(sprintf((abs(tmp) < 10) ? "%.1f %s" : "%i %s", tmp, (me._oat_unit == 'c') ? '°C' : 'F'));
962
        settimer(func me.updateOAT(), 3);
963
    },
964
    _oat_unit : 'c',
965
#}}}
966

            
967
    updateWindData : func {
968
# update the window text and arrows for OPTN1/2 {{{
969
        if (me._winddata_optn == 0)
970
            return;
improves WindData display
Sébastien MARQUE authored on 2017-03-16
971
        if (me._updated_ias < 30) {
972
            me.screenElements['WindData-NODATA']
973
                .hide();
974
            var wind_hdg = getprop('/environment/wind-from-heading-deg');
975
            var wind_spd = getprop('/environment/wind-speed-kt');
976
            var alpha = wind_hdg - me._updated_hdg;
977
            if (me._winddata_optn == 1) {
978
                me.screenElements['WindData-OPTN1-HDG']
979
                    .setRotation((alpha + 180) * D2R)
980
                    .show();
981
                me.screenElements['WindData-OPTN1-HDG-text']
982
                    .setText(sprintf("%03i°", wind_hdg))
983
                    .show();
984
                me.screenElements['WindData-OPTN1-SPD-text']
985
                    .setText(int(wind_spd) ~ 'KT')
986
                    .show();
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
987
            }
improves WindData display
Sébastien MARQUE authored on 2017-03-16
988
            else { # me._winddata_optn == 2
989
                alpha *= D2R;
990
                var Vt = wind_spd * math.sin(alpha);
991
                var Ve = wind_spd * math.cos(alpha);
992
                if (Vt != 0) {
993
                    me.screenElements['WindData-OPTN2-crosswind-text']
994
                        .setText(sprintf('%i', abs(Vt)))
995
                        .show();
996
                    me.screenElements['WindData-OPTN2-crosswind']
997
                        .setScale(-abs(Vt)/Vt, 1)
998
                        .setTranslation(-35 * (abs(Vt)/Vt + 1), 0)
999
                        .show();
1000
                }
1001
                if (Ve != 0) {
1002
                    me.screenElements['WindData-OPTN2-headwind-text']
1003
                        .setText(sprintf('%i', abs(Ve)))
1004
                        .show();
1005
                    me.screenElements['WindData-OPTN2-headwind']
1006
                        .setScale(1, abs(Ve)/Ve)
1007
                        .setTranslation(0, 515 * (1 - abs(Ve)/Ve))
1008
                        .show();
1009
                }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1010
            }
1011
        }
improves WindData display
Sébastien MARQUE authored on 2017-03-16
1012
        else {
1013
            foreach (var e; [
1014
                    'WindData-OPTN1-HDG',
1015
                    'WindData-OPTN1-HDG-text',
1016
                    'WindData-OPTN1-SPD-text',
1017
                    'WindData-OPTN2-crosswind-text',
1018
                    'WindData-OPTN2-crosswind',
1019
                    'WindData-OPTN2-headwind-text',
1020
                    'WindData-OPTN2-headwind'
1021
            ])
1022
                me.screenElements[e].hide();
1023
            me.screenElements['WindData-NODATA'].show();
1024
        }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1025
        settimer(func me.updateWindData(), 0.5);
1026
    },
1027
    _winddata_optn : 0,
1028
#}}}
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1029

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

            
1035
            var dev = radios.getNode(source).getValue();
1036
            var el  = 'BRG' ~ brg;
1037
            if (dev != 'OFF') {
1038
                var info = {
1039
                    pointer : nil,
1040
                    id : 'NO DATA',
1041
                    hdg : nil,
1042
                    dst : '--.-NM'
1043
                };
1044
                if (left(dev, 3) == 'NAV') {
1045
                    info.pointer = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/in-range');
1046
                    if (info.pointer) {
1047
                        info.id  = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/nav-id');
1048
                        info.hdg = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/heading-deg');
1049
                        info.dst = sprintf('%.1d', getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/nav-distance') / 1852); # m -> /1852
1050
                    }
1051
                }
1052
                elsif (dev == 'GPS') {
1053
                    info.pointer = props.getNode('/instrumentation/gps/wp').getChild('wp[1])');
1054
                    if (info.pointer) {
1055
                        info.id  = getprop('/instrumentation/gps/wp/wp[1]/ID');
1056
                        info.hdg = getprop('/instrumentation/gps/wp/wp[1]/bearing-mag-deg');
1057
                        info.dst = sprintf('%.1d', getprop('/instrumentation/gps/wp/wp[1]/distance-nm'));
1058
                    }
1059
                }
1060
                else { # there are 2 available ADF in FG, but instrument manage only 1
1061
                    info.pointer = getprop('/instrumentation/adf/in-range');
1062
                    if (info.pointer) {
1063
                        info.id  = getprop('/instrumentation/adf/ident');
1064
                        info.hdg = getprop('/instrumentation/adf/indicated-bearing-deg');
1065
                    }
1066
                }
1067

            
1068
                if (info.pointer)
1069
                    me.screenElements[el ~ '-pointer']
1070
                        .setRotation(-info.hdg-me._updated_hdg * D2R)
1071
                        .show();
1072
                else
1073
                    me.screenElements[el ~ '-pointer']
1074
                        .hide();
1075
                me.screenElements[el ~ '-SRC-text']
1076
                    .setText(dev);
1077
                me.screenElements[el ~ '-DST-text']
1078
                    .setText(info.dst);
1079
                me.screenElements[el ~ '-WPID-text']
1080
                    .setText(info.id);
1081
                me.screenElements['BRG' ~ brg]
1082
                    .show();
1083
            }
1084
            else {
1085
                me.screenElements['BRG' ~ brg]
1086
                    .hide();
1087
            }
1088
        }
1089
        settimer(func me.updateBRG(), 1);
1090
    },
some added comments
Sébastien MARQUE authored on 2017-03-18
1091
#}}}
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
1092

            
animation texts EIS + power ...
Sébastien MARQUE authored on 2017-03-19
1093
    updateEIS : func {
1094
# displays Engine Informations System {{{
1095
        var power = getprop('/controls/engines/engine/throttle') * getprop('/engines/engine/running');
1096
        me.screenElements['POWER-pointer']
1097
            .setRotation(D2R * 140 * power);
1098
        me.screenElements['POWER-PERCENT-text']
1099
            .setText(sprintf('%u', power));
1100
        me.screenElements['RPM-text']
1101
            .setText(sprintf(math.round(getprop('/engines/engine/rpm'), 50)));
1102
        me.screenElements['MAN-Hg-text']
1103
            .setText(sprintf('%.1d', getprop('/engines/engine/mp-inhg')));
1104
        me.screenElements['FUEL-FLOW-text']
1105
            .setText(sprintf('%.1f', getprop('/engines/engine/fuel-flow-gph')));
1106
        if (math.mod(me._eis_count, 10) == 0) {
1107
            var psi = getprop('/engines/engine/oil-pressure-psi');
1108
            me.screenElements['PSI-text']
1109
                .setText(psi == nil ? '--' : sprintf('%u', psi));
1110
            me.screenElements['OIL-TEMP-text']
1111
                .setText(sprintf('%i', getprop('/engines/engine/oil-temperature-degf')));
1112
            var used_fuel = getprop('/instrumentation/zkv1000/eis/fuel-qty-at-start')
1113
                          - getprop('/consumables/fuel/tank/level-gal_us')
1114
                          - getprop('/consumables/fuel/tank[1]/level-gal_us');
1115
            me.screenElements['FUEL-USED-text']
1116
                .setText(sprintf('%.1d', used_fuel > 0 ? used_fuel : 0));
1117
            me.screenElements['BUS-V-text']
1118
                .setText(sprintf('%.1i', getprop('/systems/electrical/outputs/bus')));
1119
            me.screenElements['BATT-text']
1120
                .setText(sprintf('%+i', getprop('/systems/electrical/amps')));
1121
            var cht = getprop('/engines/engine/cht-degf');
1122
            me.screenElements['CHT-text']
1123
                .setText(cht == nil ? '--' : sprintf('%i', cht));
1124
            me.screenElements['EGT-text']
1125
                .setText(sprintf('%i', getprop('/engines/engine/egt-degf')));
1126
        }
1127
        settimer(func me.updateEIS(), 1);
1128
        me._eis_count += 1;
1129
    },
1130
    _eis_count : 0,
1131
#}}}
1132
};
1133

            
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
1134
var keyMap = {
add new vim folds
Sébastien MARQUE authored on 2017-03-15
1135
# softkeys map for PFD and MFD {{{
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
1136
    PFD : {
1137
        first : 1,
1138
        texts : ['INSET', 'SENSOR', 'PFD', 'OBS', 'CDI', 'DME', 'XPDR', 'IDENT', 'TMR/REF', 'NRST' ],
1139
        INSET : {
1140
            texts : ['OFF', 'DCLTR', 'WXLGND', 'TRAFFIC', 'TOPO', 'TERRAIN', 'STRMSCP', 'NEXRAD-C', 'XM LTNG', 'METAR'],
1141
        },
1142
        SENSOR : {
1143
            first : 2,
1144
            texts : [ 'ADC1', 'ADC2', '', 'AHRS1', 'AHRS2'],
1145
        },
1146
        PFD : {
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1147
            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
1148
            'SYN VIS' : {
1149
                texts : [ 'PATHWAY', 'SYN TERR', 'HR2NHDG', 'APTSIGNS', 'FPM'],
1150
            },
1151
            'AOA/WIND' : {
1152
                first : 4,
1153
                texts : ['AOA', 'WIND'],
1154
                AOA : {
1155
                    first : 5,
1156
                    texts : ['AOA ON', 'AOA AUTO'],
1157
                },
1158
                WIND : {
1159
                    first : 2,
1160
                    texts : ['OPTN1', 'OPTN2', '', 'OFF'],
1161
                },
1162
            },
1163
            'HSI FMT' : {
1164
                first : 6,
1165
                texts : ['360 HSI', 'ARC HSI'],
1166
            },
1167
            'ALT UNIT' : {
1168
                first : 5,
1169
                texts : ['METERS', '', 'IN', 'HPA'],
1170
            },
1171
        },
1172
        XPDR : {
1173
            first : 2,
1174
            texts : ['STBY', 'ON', 'ALT', '', 'VFR', 'CODE', 'IDENT'],
1175
            CODE : {
1176
                texts : ['0', '1', '2', '3', '4', '5', '6', '7', 'IDENT', 'BKSP'],
1177
            },
1178
        },
1179
    },
1180
    MFD : {
1181
        texts : ['ENGINE', '', 'MAP', '', '', '', '', '', '', 'DCLTR', 'SHW CHRT', 'CHKLIST'],
1182
        MAP : {
1183
            texts: ['TRAFFIC', 'PROFILE', 'TOPO', 'TERRAIN', 'AIRWAYS', 'STRMSCP','NEXRAD-C', 'XM LTNG', 'METAR', 'LEGEND', 'BACK'],
1184
        },
1185
        CHKLIST : {
1186
            texts : ['ENGINE', '', '', '', '', 'DONE', '', '', '', '', 'EXIT', 'EMERGCY'],
1187
        },
1188
        ENGINE : {
1189
            texts : ['ENGINE', 'ANTI-ICE', '', 'DCLTR', '', 'ASSIST', '', '', '', '', 'FUEL'],
1190
            'ANTI-ICE' : {
1191
                texts : ['LEFT', 'AUTO', 'RIGHT', '', '', '', '', '', '', '', '', 'BACK'],
1192
            },
1193
            FUEL : {
1194
                first : 1,
1195
                texts : ['FULL', 'TABS', '', '', '', '', '', '', '', 'UNDO', 'ENTER'],
1196
            },
1197
        },
1198
    },
1199
};
add new vim folds
Sébastien MARQUE authored on 2017-03-15
1200
#}}}