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

            
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
22
        m.timers2 = {}; # tho old timer implementation use already a named timer hash
23
        # Softkeys revert to the previous level after 45 seconds of inactivity.
24
        m.softkeys_inactivity_delay = 45;
25

            
adds Map on MFD
Sébastien MARQUE authored on 2017-03-20
26
        if (role == 'MFD') {
27
            m.MFDMapTiles = MapTiles.new(m.display);
28
            m.MFDMapNavDisplay = MapNavDisplay.new(m.display);
29
        }
30

            
commit initial
Sébastien MARQUE authored on 2017-03-07
31
        return m;
32
    },
add new vim folds
Sébastien MARQUE authored on 2017-03-15
33
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
34

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

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

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

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

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

            
add softkeys colors
Sébastien MARQUE authored on 2017-03-21
93
            for (var k = 0; k < 12; k += 1) {
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
94
                append(groups.text, sprintf("SoftKey%02i-text", k));
add softkeys colors
Sébastien MARQUE authored on 2017-03-21
95
                append(groups.show, sprintf("SoftKey%02i-bg", k));
96
            }
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
97

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

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

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

            
230
    showInitProgress : func (role) {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
231
#{{{
commit initial
Sébastien MARQUE authored on 2017-03-07
232
        me.progress = me.display.createGroup();
233
        me.progress.show();
234
        me.progress.createChild("text", role ~ " title")
235
            .setTranslation(512, 384)
236
            .setAlignment("center-center")
237
            .setFont("LiberationFonts/LiberationSans-Italic.ttf")
238
            .setFontSize(64, 1)
239
            .setColor(1,1,1)
240
            .setText("ZKV1000 " ~ role ~ " init");
241

            
242
        zkv.getNode(role ~ 'init',1).setIntValue(1);
243

            
244
        me._showInitProgress(me.progress.createChild("text", role ~ "progress")
245
            .setTranslation(512, 484)
246
            .setAlignment("center-center")
247
            .setFont("LiberationFonts/LiberationSans-Bold.ttf")
248
            .setFontSize(128, 1)
249
            .setColor(1,0,0), '.');
250
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
251
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
252

            
some added comments
Sébastien MARQUE authored on 2017-03-18
253
    colors : {
254
# set of predefined colors {{{
255
        green : [0, 1, 0],
256
        white : [1, 1, 1],
257
        black : [0, 0, 0],
258
        lightblue : [0, 1, 1],
259
        darkblue : [0, 0, 1],
260
        red : [1, 0, 0],
adds CDI
Sébastien MARQUE authored on 2017-03-18
261
        magenta : [1, 0, 1],
some added comments
Sébastien MARQUE authored on 2017-03-18
262
    },
263
#}}}
264

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

            
323
    clips : {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
324
#{{{
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
325
        PitchScale   : "rect(70,664,370,256)",
326
        SpeedLint1   : "rect(252,226,318,204)",
327
        SpeedTape    : "rect(115,239,455,156)",
328
        LintAlt      : "rect(115,808,455,704)",
animation ALT
Sébastien MARQUE authored on 2017-03-11
329
        AltLint00011 : "rect(252,804,318,771)",
AI disponible
Sébastien MARQUE authored on 2017-03-10
330
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
331
#}}}
AI disponible
Sébastien MARQUE authored on 2017-03-10
332

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

            
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
377
    softkeys_inactivity : func {
378
# automagically back to previous level after some delay {{{
379
        me.timers2.softkeys_inactivity = maketimer (
380
            me.softkeys_inactivity_delay,
381
            func {
382
                pop(me.device.softkeys.path);
383
                me.updateSoftKeys();
384
            }, me);
385
        me.timers2.softkeys_inactivity.singleShot = 1;
386
    },
387
#}}}
388

            
add softkeys colors
Sébastien MARQUE authored on 2017-03-21
389
    setSoftKeyColor : func (n, active, alert = 0) {
390
# set colors for active softkeys {{{
391
        var sftk = sprintf('SoftKey%02i-', n);
392
        if (active) {
393
            var bg = alert ? 1 : 0.5;
394
            me.screenElements[sftk ~ 'bg']
395
                .setColorFill(bg,bg,bg);
396
            me.screenElements[sftk ~ 'text']
397
                .setColor(0,0,0);
398
        }
399
        else {
400
            me.screenElements[sftk ~ 'bg']
401
                .setColorFill(0,0,0);
402
            me.screenElements[sftk ~ 'text']
403
                .setColor(1,1,1);
404
        }
405
    },
406
#}}}
407

            
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
408
    updateSoftKeys : func {
409
# update SoftKeys boxes {{{
410
        # on PFD the last boxes are always BACK and ALERTS
411
        if (me.role == 'PFD') {
412
            me.screenElements[sprintf("SoftKey%02i-text", 11)]
413
                .setText('ALERTS');
414
            if (size(me.device.softkeys.path) != 0)
415
                me.screenElements[sprintf("SoftKey%02i-text", 10)]
416
                    .setText('BACK');
417
        }
418

            
419
        var path = keyMap[me.role];
420
        foreach (var p; me.device.softkeys.path)
421
            path = path[p];
422

            
423
        # feeding with empty menus the first boxes
424
        var start = (contains(path, 'first')) ? path.first : 0;
425
        for (var k = 0; k < start; k+=1) {
426
            me.screenElements[sprintf("SoftKey%02i-text", k)]
427
                .setText('');
428
        }
429
        # filling with the content the next boxes
430
        forindex (var k; path.texts) {
431
            var i = k + start;
432
            me.screenElements[sprintf("SoftKey%02i-text", i)]
433
                .setText(path.texts[k]);
434
        }
435
        # feeding the last boxes with empty string
436
        var end = (me.role == 'PFD') ? 10 : 12;
437
        if (size(path.texts) + start < end) {
438
            start = size(path.texts) + start;
439
            for (var k = start; k < end; k += 1)
440
                me.screenElements[sprintf("SoftKey%02i-text", k)]
441
                    .setText('');
442
        }
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
443

            
444
        if (size(me.device.softkeys.path))
445
            me.timers2.softkeys_inactivity.restart(me.softkeys_inactivity_delay);
446
        else
447
            me.timers2.softkeys_inactivity.stop();
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
448
    },
449
#}}}
450

            
refresh of vital information...
Sébastien MARQUE authored on 2017-03-18
451
    update20Hz : func {
452
# 20Hz updates roll, pitch, VSI, IAS, altitude and HDG {{{
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
453
        me._updated_roll = getprop('/orientation/roll-deg');
454
        me._updated_pitch = getprop('orientation/pitch-deg');
455
        me._updated_vsi = getprop('/instrumentation/vertical-speed-indicator/indicated-speed-fpm');
456
        me._updated_ias = getprop('/velocities/airspeed-kt');
457
        me._updated_alt = getprop('/instrumentation/altimeter/indicated-altitude-ft');
458
        me._updated_hdg = getprop('/orientation/heading-deg');
refresh of vital information...
Sébastien MARQUE authored on 2017-03-18
459
        settimer(func me.update20Hz(), 0.05);
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
460
     },
461
    _updated_roll : 0,
462
    _updated_pitch : 0,
463
    _updated_vsi : 0,
464
    _updated_ias : 0,
465
    _updated_alt : 0,
466
    _updated_hdg : 0,
467
#}}}
468

            
refresh of vital information...
Sébastien MARQUE authored on 2017-03-18
469
    update1Hz : func {
470
# 1Hz updates {{{
471
        me._updated_wow = getprop('/gear/gear/wow');
472
        settimer(func me.update20Hz(), 1);
473
    },
474
    _updated_wow : 1,
475
#}}}
476

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
477
    updateAI: func(){
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
478
#{{{
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
479
        var pitch = me._updated_pitch;
480
        var roll = me._updated_roll;
AI disponible
Sébastien MARQUE authored on 2017-03-10
481
        if (pitch > 80)
482
            pitch = 80;
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
483
        elsif (pitch < -80)
AI disponible
Sébastien MARQUE authored on 2017-03-10
484
            pitch = -80;
485
        me.screenElements.Horizon
fix AI animation
Sébastien MARQUE authored on 2017-03-19
486
            .setCenter(459, 282.8 - 6.849 * pitch)
AI disponible
Sébastien MARQUE authored on 2017-03-10
487
            .setRotation(-roll * D2R)
fix AI animation
Sébastien MARQUE authored on 2017-03-19
488
            .setTranslation(0, pitch * 6.849);
AI disponible, avec bankPoin...
Sébastien MARQUE authored on 2017-03-10
489
        me.screenElements.bankPointer
490
            .setRotation(-roll * D2R);
adds slipskid animation
Sébastien MARQUE authored on 2017-03-24
491
        me.screenElements['SlipSkid']
492
            .setTranslation(getprop("/instrumentation/slip-skid-ball/indicated-slip-skid") * 10, 0);
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
493
        settimer(func me.updateAI(), 0.1);
AI disponible
Sébastien MARQUE authored on 2017-03-10
494
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
495
#}}}
animation VSI
Sébastien MARQUE authored on 2017-03-10
496

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
497
    updateVSI: func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
498
# animate VSI {{{
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
499
        var vsi = me._updated_vsi;
animation VSI
Sébastien MARQUE authored on 2017-03-10
500
        me.screenElements.VSIText
501
            .setText(num(math.round(vsi, 10)));
502
        if (vsi > 4500)
503
            vsi = 4500;
504
        elsif (vsi < -4500)
505
            vsi = -4500;
506
        me.screenElements.VSI
507
            .setTranslation(0, vsi * -0.03465);
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
508
        settimer(func me.updateVSI(), 0.1);
animation VSI
Sébastien MARQUE authored on 2017-03-10
509
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
510
#}}}
animation IAS
Sébastien MARQUE authored on 2017-03-10
511

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
512
    updateIAS: func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
513
# animates the IAS lint (PFD) {{{
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
514
        var ias = me._updated_ias;
animation IAS
Sébastien MARQUE authored on 2017-03-10
515
        if (ias >= 10)
516
            me.screenElements.Speed110
517
                .setText(sprintf("% 2u",num(math.floor(ias/10))));
518
        else
519
            me.screenElements.Speed110
520
                .setText('');
521
        me.screenElements.SpeedLint1
522
            .setTranslation(0,(math.mod(ias,10) + (ias >= 10)*10) * 36);
523
        me.screenElements.SpeedTape
524
            .setTranslation(0,ias * 5.711);
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
525
        if (ias > me._ias_vne and ! me._ias_already_exceeded) { # easier than .getColorFill
526
            me._ias_already_exceeded = 1;
527
            me.screenElements['IAS-bg']
528
                .setColorFill(1,0,0);
529
        }
530
        elsif (ias < me._ias_vne and me._ias_already_exceeded) { # easier than .getColorFill
531
            me._ias_already_exceeded = 0;
532
            me.screenElements['IAS-bg']
533
                .setColorFill(0,0,0);
534
        }
add V-speeds bugs
Sébastien MARQUE authored on 2017-04-04
535
        foreach (var v; ['Vx', 'Vy', 'Vr', 'Vglide']) {
536
            if (me.device.data[v ~ '-visible'] and abs(me.device.data[v] - ias) < 30)
537
                me.screenElements['IAS-' ~ v]
538
                    .setTranslation(0, (ias - me.device.data[v]) * 5.711)
539
                    .show();
540
            else
541
                me.screenElements['IAS-' ~ v]
542
                    .hide();
543
        }
544

            
trends animation
Sébastien MARQUE authored on 2017-03-13
545
        var now = systime();
546
        # estimated speed in 6s
547
        var Sy = 6 * (ias - me._last_ias_kt) / (now - me._last_ias_s);
548
        if (abs(Sy) > 30)
549
            Sy = 30 * abs(Sy)/Sy; # = -30 or 30
550
        me.screenElements['Airspeed-Trend-Indicator']
551
            .setScale(1,Sy)
552
            .setTranslation(0, -284.5 * (Sy - 1));
553
        me._last_ias_kt = ias;
554
        me._last_ias_s = now;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
555
        settimer(func me.updateIAS(), 0.1);
animation IAS
Sébastien MARQUE authored on 2017-03-10
556
    },
trends animation
Sébastien MARQUE authored on 2017-03-13
557
    _last_ias_kt : 0,
558
    _last_ias_s : systime(),
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
559
    _ias_vne : 999,
560
    _ias_already_exceeded : 0,
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
561
#}}}
animation ALT
Sébastien MARQUE authored on 2017-03-11
562

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
563
    updateTAS: func {
564
# updates the True Airspeed and GroundSpeed indicators {{{
565
        me.screenElements['TAS-text']
566
            .setText(sprintf('%iKT', getprop('/instrumentation/airspeed-indicator/true-speed-kt')));
567
        me.screenElements['GSPD-text']
568
            .setText(sprintf('%iKT', getprop('/velocities/groundspeed-kt')));
569
        settimer(func me.updateTAS(), 0.5);
570
    },
571
#}}}
572

            
573
    updateALT: func () {
574
# animates the altitude lint (PFD) {{{
575
        var alt = me._updated_alt;
animation ALT
Sébastien MARQUE authored on 2017-03-11
576
        if (alt < 0)
577
            me.screenElements.Alt11100
578
                .setText(sprintf("% 3i",math.ceil(alt/100)));
579
        elsif (alt < 100)
580
            me.screenElements.Alt11100
581
                .setText('');
582
        else
583
            me.screenElements.Alt11100
584
                .setText(sprintf("% 3i",math.floor(alt/100)));
585
        me.screenElements.AltLint00011
586
            .setTranslation(0,math.fmod(alt,100) * 1.24);
587

            
588
        # From Farmin/G1000 http://wiki.flightgear.org/Project_Farmin/FG1000
589
        if (alt> -1000 and alt< 1000000) {
590
            var Offset10 = 0;
591
            var Offset100 = 0;
592
            var Offset1000 = 0;
593
            if (alt< 0) {
594
                var Ne = 1;
595
                var alt= -alt;
596
            }
597
            else
598
                var Ne = 0;
599

            
600
            var Alt10       = math.mod(alt,100);
601
            var Alt100      = int(math.mod(alt/100,10));
602
            var Alt1000     = int(math.mod(alt/1000,10));
603
            var Alt10000    = int(math.mod(alt/10000,10));
604
            var Alt20       = math.mod(Alt10,20)/20;
605
            if (Alt10 >= 80)
606
                var Alt100 += Alt20;
607

            
608
            if (Alt10 >= 80 and Alt100 >= 9)
609
                var Alt1000 += Alt20;
610

            
611
            if (Alt10 >= 80 and Alt100 >= 9 and Alt1000 >= 9)
612
                var Alt10000 += Alt20;
613

            
614
            if (alt> 100)
615
                var Offset10 = 100;
616

            
617
            if (alt> 1000)
618
                var Offset100 = 10;
619

            
620
            if (alt> 10000)
621
                var Offset1000 = 10;
622

            
623
            if (!Ne) {
624
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*0.57375);
625
                var altCentral = (int(alt/100)*100);
626
            }
627
            elsif (Ne) {
628
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*-0.57375);
629
                var altCentral = -(int(alt/100)*100);
630
            }
631
            me.screenElements["AltBigC"].setText("");
632
            me.screenElements["AltSmallC"].setText("");
633
            for (var place = 1; place <= 6; place += 1) {
634
                var altUP = altCentral + (place*100);
635
                var offset = -30.078;
636
                if (altUP < 0) {
637
                    var altUP = -altUP;
638
                    var prefix = "-";
639
                    var offset += 15.039;
640
                }
641
                else
642
                    var prefix = "";
643

            
644
                if (altUP == 0) {
645
                    var AltBigUP    = "";
646
                    var AltSmallUP  = "0";
647

            
648
                }
649
                elsif (math.mod(altUP,500) == 0 and altUP != 0) {
650
                    var AltBigUP    = sprintf(prefix~"%1d", altUP);
651
                    var AltSmallUP  = "";
652
                }
653
                elsif (altUP < 1000 and (math.mod(altUP,500))) {
654
                    var AltBigUP    = "";
655
                    var AltSmallUP  = sprintf(prefix~"%1d", int(math.mod(altUP,1000)));
656
                    var offset = -30.078;
657
                }
658
                elsif ((altUP < 10000) and (altUP >= 1000) and (math.mod(altUP,500))) {
659
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
660
                    var AltSmallUP  = sprintf("%1d", int(math.mod(altUP,1000)));
661
                    var offset += 15.039;
662
                }
663
                else {
664
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
665
                    var mod = int(math.mod(altUP,1000));
666
                    var AltSmallUP  = sprintf("%1d", mod);
667
                    var offset += 30.078;
668
                }
669

            
670
                me.screenElements["AltBigU"~place].setText(AltBigUP);
671
                me.screenElements["AltSmallU"~place].setText(AltSmallUP);
672
                me.screenElements["AltSmallU"~place].setTranslation(offset,0);
673
                var altDOWN = altCentral - (place*100);
674
                var offset = -30.078;
675
                if (altDOWN < 0) {
676
                    var altDOWN = -altDOWN;
677
                    var prefix = "-";
678
                    var offset += 15.039;
679
                }
680
                else
681
                    var prefix = "";
682

            
683
                if (altDOWN == 0) {
684
                    var AltBigDOWN  = "";
685
                    var AltSmallDOWN    = "0";
686
                }
687
                elsif (math.mod(altDOWN,500) == 0 and altDOWN != 0) {
688
                    var AltBigDOWN  = sprintf(prefix~"%1d", altDOWN);
689
                    var AltSmallDOWN    = "";
690
                }
691
                elsif (altDOWN < 1000 and (math.mod(altDOWN,500))) {
692
                    var AltBigDOWN  = "";
693
                    var AltSmallDOWN    = sprintf(prefix~"%1d", int(math.mod(altDOWN,1000)));
694
                    var offset = -30.078;
695
                }
696
                elsif ((altDOWN < 10000) and (altDOWN >= 1000) and (math.mod(altDOWN,500))) {
697
                    var AltBigDOWN  = sprintf(prefix~"%1d", int(altDOWN/1000));
698
                    var AltSmallDOWN    = sprintf("%1d", int(math.mod(altDOWN,1000)));
699
                    var offset += 15.039;
700
                }
701
                else {
702
                    var AltBigDOWN  = sprintf(prefix~"%1d", int(altDOWN/1000));
703
                    var mod = int(math.mod(altDOWN,1000));
704
                    var AltSmallDOWN    = sprintf("%1d", mod);
705
                    var offset += 30.078;
706
                }
707
                me.screenElements["AltBigD"~place].setText(AltBigDOWN);
708
                me.screenElements["AltSmallD"~place].setText(AltSmallDOWN);
709
                me.screenElements["AltSmallD"~place].setTranslation(offset,0);
710
            }
711
        }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
712
        me.updateSelectedALT();
trends animation
Sébastien MARQUE authored on 2017-03-13
713
        var now = systime();
714
        # altitude in 6s
715
        var Sy = .3 * (alt - me._last_alt_ft) / (now - me._last_alt_s); # scale = 1/20ft
716
        if (abs(Sy) > 15)
717
            Sy = 15 * abs(Sy)/Sy; # = -15 or 15
718
        me.screenElements['Altitude-Trend-Indicator']
719
            .setScale(1,Sy)
720
            .setTranslation(0, -284.5 * (Sy - 1));
721
        me._last_alt_ft = alt;
722
        me._last_alt_s = now;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
723
        settimer(func me.updateALT(), 0.2);
animation ALT
Sébastien MARQUE authored on 2017-03-11
724
    },
trends animation
Sébastien MARQUE authored on 2017-03-13
725
    _last_alt_ft : 0,
726
    _last_alt_s  : systime(),
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
727
#}}}
animation HSI
Sébastien MARQUE authored on 2017-03-11
728

            
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
729
    updateBARO : func () {
730
# update BARO widget {{{
731
        var fmt = me._baro_unit == 'inhg' ? '%.2f%s' : '%i%s';
732
        me.screenElements['BARO-text']
733
            .setText(sprintf(fmt,
734
                        getprop('/instrumentation/altimeter/setting-' ~ me._baro_unit),
735
                        me._baro_unit == 'inhg' ? 'in' : 'hPa')
736
                );
737
    },
738
    _baro_unit : 'inhg',
739
#}}}
740

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
741
    updateHSI : func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
742
# rotates the compass (PFD) {{{
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
743
        var hdg = me._updated_hdg;
animation HSI
Sébastien MARQUE authored on 2017-03-11
744
        me.screenElements.Rose
745
            .setRotation(-hdg * D2R);
746
        me.screenElements['HDG-text']
747
            .setText(sprintf("%03u°", hdg));
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
748
        settimer(func me.updateHSI(), 0.1);
animation HSI
Sébastien MARQUE authored on 2017-03-11
749
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
750
#}}}
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
751

            
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
752
    updateHDG : func (hdg) {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
753
# moves the heading bug and display heading-deg for 3 seconds (PFD) {{{
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
754
        if (me.role == 'MFD')
755
            return;
756
        me.screenElements['Heading-bug']
757
            .setRotation(hdg * D2R);
758
        me.screenElements['SelectedHDG-bg']
759
            .show();
760
        me.screenElements['SelectedHDG-bgtext']
761
            .show();
762
        me.screenElements['SelectedHDG-text']
763
            .setText(sprintf('%03d°%s', hdg, ''))
764
            .show();
765
        me.addTimer(3, ['SelectedHDG-text', 'SelectedHDG-bgtext', 'SelectedHDG-bg']);
766
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
767
#}}}
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
768

            
adds CDI
Sébastien MARQUE authored on 2017-03-18
769
    updateCRS : func () {
anime CRS
Sébastien MARQUE authored on 2017-03-13
770
# TODO: update display for NAV/GPS/BRG courses {{{
771
        if (me.role == 'MFD')
772
            return;
adds CDI
Sébastien MARQUE authored on 2017-03-18
773
        var source = getprop('/instrumentation/zkv1000/cdi/source');
774
        if (source == 'OFF')
775
            return;
776
        var crs = getprop('/instrumentation/zkv1000/cdi/course');
777
        if (crs == nil)
778
            return;
anime CRS
Sébastien MARQUE authored on 2017-03-13
779
        me.screenElements['SelectedCRS-bg']
780
            .show();
781
        me.screenElements['SelectedCRS-bgtext']
782
            .show();
783
        me.screenElements['SelectedCRS-text']
784
            .setText(sprintf('%03d°%s', crs, ''))
adds CDI
Sébastien MARQUE authored on 2017-03-18
785
            .setColor(source == 'GPS' ? me.colors.magenta : me.colors.green)
anime CRS
Sébastien MARQUE authored on 2017-03-13
786
            .show();
787
        me.addTimer(3, ['SelectedCRS-text', 'SelectedCRS-bgtext', 'SelectedCRS-bg']);
788
    },
789
#}}}
790

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
791
    updateSelectedALT : func {
792
# animation for altitude section, called via updatedALT {{{
new var organistaion (and fi...
Sébastien MARQUE authored on 2017-03-26
793
        if (! PFD.display.screenElements['SelectedALT'].getVisible())
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
794
            return;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
795
        var selected_alt = getprop('/instrumentation/zkv1000/afcs/selected-alt-ft');
796
        var delta_alt = me._updated_alt - selected_alt;
797
        if (abs(delta_alt) > 300)
798
            delta_alt = 300 * abs(delta_alt)/delta_alt;
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
799
        me.screenElements['SelectedALT-symbol']
800
            .setVisible(abs(delta_alt) > 100);
801
        me.screenElements['SelectedALT-bg']
802
            .setVisible(abs(delta_alt) > 100);
803
        me.screenElements['SelectedALT-text']
804
            .setText(sprintf("%i", selected_alt))
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
805
            .setVisible(abs(delta_alt) > 100);
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
806
        me.screenElements['SelectedALT-bug']
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
807
            .setTranslation(0, delta_alt * 0.567); # 170/300 = 0.567
808
    },
809
#}}}
810

            
adds CDI
Sébastien MARQUE authored on 2017-03-18
811
    updateCDI : func {
812
# animation for CDI {{{
813
        var source = getprop('/instrumentation/zkv1000/cdi/source');
814
        if (source == 'OFF') {
815
            foreach (var s; ['GPS', 'NAV1', 'NAV2'])
816
                foreach (var t; ['pointer', 'CDI'])
817
                    me.screenElements[s ~ '-' ~ t].hide();
818
            me.screenElements['CDI-GPS-ANN-text'].hide();
819
            me.screenElements['CDI-GPS-XTK-text'].hide();
820
            me.screenElements['CDI-SRC-text'].hide();
821
            me.screenElements['CDI'].hide();
822
        }
823
        else {
824
            var course = getprop('/instrumentation/zkv1000/cdi/course');
makes the CDI available
Sébastien MARQUE authored on 2017-03-23
825
            var rot = (course - me._updated_hdg) * D2R;
adds CDI
Sébastien MARQUE authored on 2017-03-18
826
            me.screenElements['CDI']
makes the CDI available
Sébastien MARQUE authored on 2017-03-23
827
                .setRotation(rot)
adds CDI
Sébastien MARQUE authored on 2017-03-18
828
                .show();
829
            me.screenElements['GPS-CTI']
animates GPS-CTI
Sébastien MARQUE authored on 2017-03-24
830
                .setVisible(getprop('/instrumentation/gps/wp/wp[1]/valid'))
831
                .setRotation(getprop('/instrumentation/gps/wp/wp[1]/course-deviation-deg') * D2R);
adds CDI
Sébastien MARQUE authored on 2017-03-18
832
            me.screenElements['GPS-CTI-diamond']
animates GPS-CTI
Sébastien MARQUE authored on 2017-03-24
833
                .setVisible(getprop('/instrumentation/gps/wp/wp[1]/valid'))
834
                .setRotation(getprop('/instrumentation/gps/wp/wp[1]/course-deviation-deg') * D2R);
adds CDI
Sébastien MARQUE authored on 2017-03-18
835
            foreach (var s; ['GPS', 'NAV1', 'NAV2']) {
836
                me.screenElements[s ~ '-pointer']
837
                    .setRotation(rot)
838
                    .setVisible(source == s);
839
                me.screenElements[s ~ '-CDI']
840
                    .setVisible(source == s);
841
                foreach (var f; ['FROM', 'TO'])
842
                    me.screenElements[s ~ '-' ~ f]
makes the CDI available
Sébastien MARQUE authored on 2017-03-23
843
                        .setVisible(s == source and getprop('/instrumentation/zkv1000/cdi/' ~ f ~ '-flag'));
adds CDI
Sébastien MARQUE authored on 2017-03-18
844
                me.screenElements['CDI-SRC-text']
845
                    .setText(source)
846
                    .setColor(source == 'GPS' ? me.colors.magenta : me.colors.green)
847
                    .show();
848
            }
makes the CDI available
Sébastien MARQUE authored on 2017-03-23
849
            var deflection = getprop('/instrumentation/zkv1000/cdi/course-deflection');
850
            if (left(source, 3) == 'NAV')
851
                var scale = deflection / 4;
852
            else { # GPS
853
                # TODO: deviation depending of the flight phase
854
                # for now fixed 1 dot = 1 nm course error
855
                var abs_deflection = abs(deflection);
856
                me.screenElements['CDI-GPS-XTK-text']
857
                    .setText(sprintf('XTK %iNM', abs_deflection))
858
                    .setVisible(abs_deflection > 2.4);
859
                var scale = deflection / 2;
860
            }
861
            scale = (abs(scale) > 1.2) ? 1.2 : scale;
862
            me.screenElements[source ~ '-CDI']
863
                .setTranslation(65 * scale, 0);
864
            settimer(func me.updateCDI(), 0.3);
adds CDI
Sébastien MARQUE authored on 2017-03-18
865
        }
866
    },
867
#}}}
868

            
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
869
    _updateRadio: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
870
# common parts for NAV/LOC/COMM radios{{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
871
        # arg[0]._r = <comm|nav>
872
        if (contains(arg[0], "active")) {
873
            if (arg[0]['active'] == 'none') {
874
                me.screenElements[arg[0]._r ~ '1-selected-freq']
875
                    .setColor(1,1,1);
876
                me.screenElements[arg[0]._r ~ '2-selected-freq']
877
                    .setColor(1,1,1);
878
            }
879
            else {
880
                me.screenElements[arg[0]._r ~ arg[0]['active'] ~ '-selected-freq']
881
                    .setColor(0,1,0);
882
                me.screenElements[arg[0]._r ~ arg[0].inactive ~ '-selected-freq']
883
                    .setColor(1,1,1);
884
            }
885
        }
886
        if (contains(arg[0], 'tune')) {
887
            # n = 0 -> NAV1/COMM1
888
            # n = 1 -> NAV1/COMM2
889
            me.screenElements[arg[0]._r ~ '-freq-switch']
890
                .setTranslation(0, arg[0].tune * 25);
891
            me.screenElements[arg[0]._r ~ (arg[0].tune + 1) ~ '-standby-freq']
892
                .setColor(0,1,1);
893
            me.screenElements[arg[0]._r ~ ((arg[0].tune == 0) + 1) ~ '-standby-freq']
894
                .setColor(1,1,1);
895
        }
896
        if (contains(arg[0], 'refresh')) {
small stuff
Sébastien MARQUE authored on 2017-03-22
897
            # refresh only one line: NAV1/COMM1 or NAV2/COMM2
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
898
            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
899
            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-selected-freq']
900
                .setText(sprintf(fmt, getprop('/instrumentation/'
901
                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/selected-mhz')));
902
            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-standby-freq']
903
                .setText(sprintf(fmt, getprop('/instrumentation/'
904
                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/standby-mhz')));
905
        }
906
        if (contains(arg[0], 'set')) {
907
            # positionne la valeur modifiée, les listeners "trigguent" en permanence ces propriétés, donc exit
908
            var n = getprop('/instrumentation/zkv1000/radios/' ~ arg[0]._r ~ '-tune');
909
            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
910
            me.screenElements[arg[0]._r ~ (n + 1) ~ '-standby-freq']
fix freq display while setti...
Sébastien MARQUE authored on 2017-03-16
911
                .setText(sprintf(fmt, getprop('/instrumentation/' ~ arg[0]._r ~ '[' ~ n ~ ']/frequencies/standby-mhz')));
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
912
        }
913
        if (contains(arg[0], 'auto')) {
914
            # pour rafraichir automagiquement, toutes les deux secondes un refresh pour un NAV
915
            var radio = arg[0].auto;
916
            me._updateRadio({refresh: 1, _r: radio});
917
            settimer(func me._updateRadio({refresh: 2, _r: radio}), 1);
918
            settimer(func me._updateRadio({auto: radio}), 2);
919
        }
920
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
921
#}}}
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
922

            
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
923
    updateNAV : func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
924
# update NAV/LOC rodios display upper left (PFD/MFD){{{
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
925
        # made active via menu
926
        if (contains(arg[0], "active")) {
adds CDI
Sébastien MARQUE authored on 2017-03-18
927
            arg[0]._r = 'nav';
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
928
            if (arg[0]['active'] == 'none') {
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
929
                me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
930
                me.screenElements['nav1-id']
931
                    .setColor(1,1,1);
932
                me.screenElements['nav2-id']
933
                    .setColor(1,1,1);
934
                me.screenElements['NAV1-pointer']
935
                    .hide();
936
                me.screenElements['NAV2-pointer']
937
                    .hide();
938
            }
939
            else {
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
940
                arg[0].inactive = (arg[0]['active'] == 1) + 1;
941
                me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
942
                me.screenElements['nav' ~ arg[0]['active'] ~ '-id']
943
                    .setColor(0,1,0);
944
                me.screenElements['NAV' ~ arg[0]['active'] ~ '-pointer']
945
                    .show();
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
946
                me.screenElements['nav' ~ arg[0].inactive ~ '-id']
947
                    .setColor(1,1,1);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
948
#                me.screenElements['HDI']
949
#                    .setRotation();
950
#                me.screenElements['NAV' ~ inactive ~ '-pointer']
951
#                    .hide();
952
#                foreach (var e; [ 'FROM', 'TO', 'CDI' ])
953
#                    me.screenElements['NAV' ~ inactive ~ '-' ~ e]
954
#                        .hide();
955
            }
956
        }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
957
        elsif (contains(arg[0], 'nav-id')) {
Correction swap NAV tuning
Sébastien MARQUE authored on 2017-03-12
958
            # 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
959
            if (arg[0].val == nil)
960
                arg[0].val = '';
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
961
            me.screenElements["nav" ~ arg[0]['nav-id'] ~ "-id"]
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
962
                    .setText(arg[0].val);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
963
        }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
964
        else {
965
            arg[0]._r = 'nav';
966
            me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
967
        }
968
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
969
#}}}
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
970

            
971
    updateCOMM: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
972
# update COMM radios display upper right (PFD/MFD){{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
973
        arg[0]._r = 'comm';
974
        me._updateRadio(arg[0]);
975
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
976
#}}}
anime time display
Sébastien MARQUE authored on 2017-03-13
977

            
978
    updateTIME : func {
979
# updates the displayed time botoom left {{{
980
        me.screenElements['TIME-text']
981
            .setText(getprop('/sim/time/gmt-string'));
982
        settimer(func me.updateTIME(), 1);
983
    },
984
#}}}
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
985

            
adds transponder
Sébastien MARQUE authored on 2017-03-17
986
    updateXPDR : func {
987
# updates transponder display {{{
988
        for (var d = 0; d < 4; d+=1)
989
            me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
990
                .setText(sprintf('%i', getprop('/instrumentation/transponder/inputs/digit[' ~ d ~ ']')));
991
        var tuning = getprop('/instrumentation/zkv1000/radios/xpdr-tuning-digit');
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
992
        var fms = getprop('/instrumentation/zkv1000/radios/xpdr-tuning-fms-method');
993
        for (var d = 0; d < 4; d+=1)
994
            me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
995
                .setColor(1,1,1);
996
        if (tuning != nil) {
997
            me.screenElements['XPDR-DIGIT-' ~ tuning ~ '-text']
998
                .setColor(0,1,1);
999
            if (fms)
1000
                me.screenElements['XPDR-DIGIT-' ~ (tuning - 1) ~ '-text']
1001
                    .setColor(0,1,1);
1002
        }
adds transponder
Sébastien MARQUE authored on 2017-03-17
1003
        else {
1004
            if (getprop('/instrumentation/transponder/ident'))
1005
                var mode = 'IDENT';
1006
            else
1007
                var mode = getprop('/instrumentation/zkv1000/radio/xpdr-mode');
1008
            var wow = getprop('/gear/gear/wow');
1009
            if (! wow and mode != 'STBY')
1010
                var color = [0, 1, 0];
1011
            else
1012
                var color = [1, 1, 1];
1013
            for (var d = 0; d < 4; d+=1)
1014
                me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
1015
                    .setColor(color);
1016
            me.screenElements['XPDR-MODE-text']
1017
                .setColor(color)
1018
                .setText(mode);
1019
        }
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
1020
    },
adds transponder
Sébastien MARQUE authored on 2017-03-17
1021
#}}}
1022

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1023
    updateOAT : func {
1024
# update OAT display on normal and reversionnary modes (every 3s) {{{
1025
        var tmp = getprop('/environment/temperature-deg' ~ me._oat_unit);
1026
        me.screenElements['OAT-text']
1027
            .setText(sprintf((abs(tmp) < 10) ? "%.1f %s" : "%i %s", tmp, (me._oat_unit == 'c') ? '°C' : 'F'));
1028
        settimer(func me.updateOAT(), 3);
1029
    },
1030
    _oat_unit : 'c',
1031
#}}}
1032

            
1033
    updateWindData : func {
1034
# update the window text and arrows for OPTN1/2 {{{
1035
        if (me._winddata_optn == 0)
1036
            return;
improves WindData display
Sébastien MARQUE authored on 2017-03-16
1037
        if (me._updated_ias < 30) {
1038
            me.screenElements['WindData-NODATA']
1039
                .hide();
1040
            var wind_hdg = getprop('/environment/wind-from-heading-deg');
1041
            var wind_spd = getprop('/environment/wind-speed-kt');
1042
            var alpha = wind_hdg - me._updated_hdg;
1043
            if (me._winddata_optn == 1) {
1044
                me.screenElements['WindData-OPTN1-HDG']
1045
                    .setRotation((alpha + 180) * D2R)
1046
                    .show();
1047
                me.screenElements['WindData-OPTN1-HDG-text']
1048
                    .setText(sprintf("%03i°", wind_hdg))
1049
                    .show();
1050
                me.screenElements['WindData-OPTN1-SPD-text']
1051
                    .setText(int(wind_spd) ~ 'KT')
1052
                    .show();
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1053
            }
improves WindData display
Sébastien MARQUE authored on 2017-03-16
1054
            else { # me._winddata_optn == 2
1055
                alpha *= D2R;
1056
                var Vt = wind_spd * math.sin(alpha);
1057
                var Ve = wind_spd * math.cos(alpha);
1058
                if (Vt != 0) {
1059
                    me.screenElements['WindData-OPTN2-crosswind-text']
1060
                        .setText(sprintf('%i', abs(Vt)))
1061
                        .show();
1062
                    me.screenElements['WindData-OPTN2-crosswind']
1063
                        .setScale(-abs(Vt)/Vt, 1)
1064
                        .setTranslation(-35 * (abs(Vt)/Vt + 1), 0)
1065
                        .show();
1066
                }
1067
                if (Ve != 0) {
1068
                    me.screenElements['WindData-OPTN2-headwind-text']
1069
                        .setText(sprintf('%i', abs(Ve)))
1070
                        .show();
1071
                    me.screenElements['WindData-OPTN2-headwind']
1072
                        .setScale(1, abs(Ve)/Ve)
1073
                        .setTranslation(0, 515 * (1 - abs(Ve)/Ve))
1074
                        .show();
1075
                }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1076
            }
1077
        }
improves WindData display
Sébastien MARQUE authored on 2017-03-16
1078
        else {
1079
            foreach (var e; [
1080
                    'WindData-OPTN1-HDG',
1081
                    'WindData-OPTN1-HDG-text',
1082
                    'WindData-OPTN1-SPD-text',
1083
                    'WindData-OPTN2-crosswind-text',
1084
                    'WindData-OPTN2-crosswind',
1085
                    'WindData-OPTN2-headwind-text',
1086
                    'WindData-OPTN2-headwind'
1087
            ])
1088
                me.screenElements[e].hide();
1089
            me.screenElements['WindData-NODATA'].show();
1090
        }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1091
        settimer(func me.updateWindData(), 0.5);
1092
    },
1093
    _winddata_optn : 0,
1094
#}}}
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1095

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

            
1101
            var dev = radios.getNode(source).getValue();
1102
            var el  = 'BRG' ~ brg;
1103
            if (dev != 'OFF') {
colorize BRG1/2 when needed,...
Sébastien MARQUE authored on 2017-03-21
1104
                if (size(me.device.softkeys.path) == 1 and me.device.softkeys.path[0] == 'PFD')
1105
                    me.setSoftKeyColor(brg == 1 ? 4 : 6, 1);
1106
                else
1107
                    me.setSoftKeyColor(brg == 1 ? 4 : 6, 0);
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1108
                var info = {
1109
                    pointer : nil,
1110
                    id : 'NO DATA',
1111
                    hdg : nil,
1112
                    dst : '--.-NM'
1113
                };
1114
                if (left(dev, 3) == 'NAV') {
1115
                    info.pointer = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/in-range');
1116
                    if (info.pointer) {
1117
                        info.id  = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/nav-id');
1118
                        info.hdg = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/heading-deg');
1119
                        info.dst = sprintf('%.1d', getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/nav-distance') / 1852); # m -> /1852
1120
                    }
1121
                }
1122
                elsif (dev == 'GPS') {
1123
                    info.pointer = props.getNode('/instrumentation/gps/wp').getChild('wp[1])');
1124
                    if (info.pointer) {
1125
                        info.id  = getprop('/instrumentation/gps/wp/wp[1]/ID');
1126
                        info.hdg = getprop('/instrumentation/gps/wp/wp[1]/bearing-mag-deg');
1127
                        info.dst = sprintf('%.1d', getprop('/instrumentation/gps/wp/wp[1]/distance-nm'));
1128
                    }
1129
                }
1130
                else { # there are 2 available ADF in FG, but instrument manage only 1
1131
                    info.pointer = getprop('/instrumentation/adf/in-range');
1132
                    if (info.pointer) {
1133
                        info.id  = getprop('/instrumentation/adf/ident');
1134
                        info.hdg = getprop('/instrumentation/adf/indicated-bearing-deg');
1135
                    }
1136
                }
1137

            
1138
                if (info.pointer)
1139
                    me.screenElements[el ~ '-pointer']
1140
                        .setRotation(-info.hdg-me._updated_hdg * D2R)
1141
                        .show();
1142
                else
1143
                    me.screenElements[el ~ '-pointer']
1144
                        .hide();
1145
                me.screenElements[el ~ '-SRC-text']
1146
                    .setText(dev);
1147
                me.screenElements[el ~ '-DST-text']
1148
                    .setText(info.dst);
1149
                me.screenElements[el ~ '-WPID-text']
1150
                    .setText(info.id);
1151
                me.screenElements['BRG' ~ brg]
1152
                    .show();
1153
            }
1154
            else {
colorize BRG1/2 when needed,...
Sébastien MARQUE authored on 2017-03-21
1155
                me.setSoftKeyColor(brg == 1 ? 4 : 6, 0);
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1156
                me.screenElements['BRG' ~ brg]
1157
                    .hide();
1158
            }
1159
        }
colorize BRG1/2 when needed,...
Sébastien MARQUE authored on 2017-03-21
1160
        settimer(func me.updateBRG(), 0.5);
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1161
    },
some added comments
Sébastien MARQUE authored on 2017-03-18
1162
#}}}
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
1163

            
animation texts EIS + power ...
Sébastien MARQUE authored on 2017-03-19
1164
    updateEIS : func {
1165
# displays Engine Informations System {{{
1166
        var power = getprop('/controls/engines/engine/throttle') * getprop('/engines/engine/running');
1167
        me.screenElements['POWER-pointer']
1168
            .setRotation(D2R * 140 * power);
1169
        me.screenElements['POWER-PERCENT-text']
1170
            .setText(sprintf('%u', power));
1171
        me.screenElements['RPM-text']
1172
            .setText(sprintf(math.round(getprop('/engines/engine/rpm'), 50)));
1173
        me.screenElements['MAN-Hg-text']
1174
            .setText(sprintf('%.1d', getprop('/engines/engine/mp-inhg')));
1175
        me.screenElements['FUEL-FLOW-text']
1176
            .setText(sprintf('%.1f', getprop('/engines/engine/fuel-flow-gph')));
1177
        if (math.mod(me._eis_count, 10) == 0) {
1178
            var psi = getprop('/engines/engine/oil-pressure-psi');
1179
            me.screenElements['PSI-text']
1180
                .setText(psi == nil ? '--' : sprintf('%u', psi));
1181
            me.screenElements['OIL-TEMP-text']
1182
                .setText(sprintf('%i', getprop('/engines/engine/oil-temperature-degf')));
1183
            var used_fuel = getprop('/instrumentation/zkv1000/eis/fuel-qty-at-start')
1184
                          - getprop('/consumables/fuel/tank/level-gal_us')
1185
                          - getprop('/consumables/fuel/tank[1]/level-gal_us');
1186
            me.screenElements['FUEL-USED-text']
1187
                .setText(sprintf('%.1d', used_fuel > 0 ? used_fuel : 0));
1188
            me.screenElements['BUS-V-text']
1189
                .setText(sprintf('%.1i', getprop('/systems/electrical/outputs/bus')));
1190
            me.screenElements['BATT-text']
1191
                .setText(sprintf('%+i', getprop('/systems/electrical/amps')));
1192
            var cht = getprop('/engines/engine/cht-degf');
1193
            me.screenElements['CHT-text']
1194
                .setText(cht == nil ? '--' : sprintf('%i', cht));
1195
            me.screenElements['EGT-text']
1196
                .setText(sprintf('%i', getprop('/engines/engine/egt-degf')));
1197
        }
1198
        settimer(func me.updateEIS(), 1);
1199
        me._eis_count += 1;
1200
    },
1201
    _eis_count : 0,
1202
#}}}
adds OMI to PFD
Sébastien MARQUE authored on 2017-03-23
1203

            
1204
    updateOMI : func {
1205
# display marker baecon Outer, Middle, Inner {{{
1206
        var marker = nil;
1207
        foreach (var m; ['outer', 'middle', 'inner'])
1208
            if (getprop('/instrumentation/marker-beacon/' ~ m)) {
1209
                marker = m;
1210
                me.screenElements['OMI']
1211
                    .show();
1212
                break;
1213
            }
1214
        if (marker != nil) {
1215
            me.screenElements['MarkerText']
1216
                .setText(me._omi_data[marker].t)
1217
                .show();
1218
            me.screenElements['MarkerBG']
1219
                .setColorFill(me._omi_data[marker].bg)
1220
                .show();
1221
        }
1222
        else
1223
            me.screenElements['OMI']
1224
                .hide();
1225
        settimer(func me.updateOMI(), 1);
1226
    },
1227
    _omi_data : {
1228
        'outer':  {t: 'O', bg: [0,1,1]},
1229
        'middle': {t: 'M', bg: [1,1,1]},
1230
        'inner':  {t: 'I', bg: [1,1,0]},
1231
    },
1232
#}}}
animation texts EIS + power ...
Sébastien MARQUE authored on 2017-03-19
1233
};
1234

            
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
1235
var keyMap = {
add new vim folds
Sébastien MARQUE authored on 2017-03-15
1236
# softkeys map for PFD and MFD {{{
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
1237
    PFD : {
1238
        first : 1,
1239
        texts : ['INSET', 'SENSOR', 'PFD', 'OBS', 'CDI', 'DME', 'XPDR', 'IDENT', 'TMR/REF', 'NRST' ],
1240
        INSET : {
1241
            texts : ['OFF', 'DCLTR', 'WXLGND', 'TRAFFIC', 'TOPO', 'TERRAIN', 'STRMSCP', 'NEXRAD-C', 'XM LTNG', 'METAR'],
1242
        },
1243
        SENSOR : {
1244
            first : 2,
1245
            texts : [ 'ADC1', 'ADC2', '', 'AHRS1', 'AHRS2'],
1246
        },
1247
        PFD : {
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1248
            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
1249
            'SYN VIS' : {
1250
                texts : [ 'PATHWAY', 'SYN TERR', 'HR2NHDG', 'APTSIGNS', 'FPM'],
1251
            },
1252
            'AOA/WIND' : {
1253
                first : 4,
1254
                texts : ['AOA', 'WIND'],
1255
                AOA : {
1256
                    first : 5,
1257
                    texts : ['AOA ON', 'AOA AUTO'],
1258
                },
1259
                WIND : {
1260
                    first : 2,
1261
                    texts : ['OPTN1', 'OPTN2', '', 'OFF'],
1262
                },
1263
            },
1264
            'HSI FMT' : {
1265
                first : 6,
1266
                texts : ['360 HSI', 'ARC HSI'],
1267
            },
1268
            'ALT UNIT' : {
1269
                first : 5,
1270
                texts : ['METERS', '', 'IN', 'HPA'],
1271
            },
1272
        },
1273
        XPDR : {
1274
            first : 2,
1275
            texts : ['STBY', 'ON', 'ALT', '', 'VFR', 'CODE', 'IDENT'],
1276
            CODE : {
1277
                texts : ['0', '1', '2', '3', '4', '5', '6', '7', 'IDENT', 'BKSP'],
1278
            },
1279
        },
1280
    },
1281
    MFD : {
1282
        texts : ['ENGINE', '', 'MAP', '', '', '', '', '', '', 'DCLTR', 'SHW CHRT', 'CHKLIST'],
1283
        MAP : {
1284
            texts: ['TRAFFIC', 'PROFILE', 'TOPO', 'TERRAIN', 'AIRWAYS', 'STRMSCP','NEXRAD-C', 'XM LTNG', 'METAR', 'LEGEND', 'BACK'],
1285
        },
1286
        CHKLIST : {
1287
            texts : ['ENGINE', '', '', '', '', 'DONE', '', '', '', '', 'EXIT', 'EMERGCY'],
1288
        },
1289
        ENGINE : {
1290
            texts : ['ENGINE', 'ANTI-ICE', '', 'DCLTR', '', 'ASSIST', '', '', '', '', 'FUEL'],
1291
            'ANTI-ICE' : {
1292
                texts : ['LEFT', 'AUTO', 'RIGHT', '', '', '', '', '', '', '', '', 'BACK'],
1293
            },
1294
            FUEL : {
1295
                first : 1,
1296
                texts : ['FULL', 'TABS', '', '', '', '', '', '', '', 'UNDO', 'ENTER'],
1297
            },
1298
        },
1299
    },
1300
};
add new vim folds
Sébastien MARQUE authored on 2017-03-15
1301
#}}}