zkv1000 / Nasal / display.nas /
Newer Older
1238 lines | 46.39kb
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 = {
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
3
    new: func(device) {
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({
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
8
                "name"      : device.name,
commit initial
Sébastien MARQUE authored on 2017-03-07
9
                "size"      : [1024, 768],
10
                "view"      : [1024, 768],
11
                "mipmapping": 1
12
        });
13
        m.display.addPlacement({
14
                "node": "Screen",
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
15
                "parent": device.name
commit initial
Sébastien MARQUE authored on 2017-03-07
16
        });
17
        m.display.setColorBackground(0,0,0);
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
18
        m.role = device.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

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
26
        if (device.role == 'MFD') {
adds Map on MFD
Sébastien MARQUE authored on 2017-03-20
27
            m.MFDMapTiles = MapTiles.new(m.display);
28
            m.MFDMapNavDisplay = MapNavDisplay.new(m.display);
EIS can be aircraft specific
Sébastien MARQUE authored on 2017-04-04
29
            var eis_dir = getprop('/sim/fg-aircraft') ~ '/Instruments-3d/zkv1000/Nasal/EIS/';
30
            var eis_type = getprop('/instrumentation/zkv1000/eis/type');
31
            if (eis_type == nil or
32
                    (io.stat(eis_dir ~ eis_type ~ '.nas') == nil
33
                     and print(eis_type ~ ' not found')))
34
                eis_type = 'none';
35
            io.load_nasal(eis_dir ~ eis_type ~ '.nas', 'zkv1000');
adds Map on MFD
Sébastien MARQUE authored on 2017-03-20
36
        }
37

            
commit initial
Sébastien MARQUE authored on 2017-03-07
38
        return m;
39
    },
add new vim folds
Sébastien MARQUE authored on 2017-03-15
40
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
41

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

            
45
    timerTrigger : func {
46
        var now = systime();
47
        foreach (var id; keys(me.timers)) {
48
            if (me.timers[id] < now) {
49
                me.screenElements[id].hide();
50
                delete(me.timers, id);
51
            }
52
        }
53
        settimer(func me.timerTrigger(), 1);
54
    },
55

            
56
    addTimer : func (duration, element) {
57
        if (typeof(element) == 'scalar')
58
            element = [ element ];
59
        var end = systime() + duration;
60
        foreach (var e; element)
61
            me.timers[e] = end;
62
    },
add new vim folds
Sébastien MARQUE authored on 2017-03-15
63
#}}}
ajoute un timer pour cacher ...
Sébastien MARQUE authored on 2017-03-13
64

            
commit initial
Sébastien MARQUE authored on 2017-03-07
65
    loadsvg : func () {
66
        me.screen = me.display.createGroup();
67
        me.screen.hide();
68
        canvas.parsesvg(me.screen, "Aircraft/Instruments-3d/zkv1000/Systems/screen.svg");
69
    },
70

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

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

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

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

            
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
196
            foreach (var freq; keys(data.timers))
197
                data.timers[freq].start();
198

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
199
            if (me.device.role == 'PFD') {
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
200
                me.updateAI();
201
                me.updateVSI();
202
                me.updateIAS();
203
                me.updateALT();
204
                me.updateHSI();
anime time display
Sébastien MARQUE authored on 2017-03-13
205
                me.updateTIME();
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
206
                me.updateOAT();
207
                me.updateTAS();
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
208
                me.updateBRG();
adds transponder
Sébastien MARQUE authored on 2017-03-17
209
                me.updateXPDR();
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
210
                me.updateBARO();
adds OMI to PFD
Sébastien MARQUE authored on 2017-03-23
211
                me.updateOMI();
ajoute un timer pour cacher ...
Sébastien MARQUE authored on 2017-03-13
212
                me.timerTrigger();
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
213
            }
animation texts EIS + power ...
Sébastien MARQUE authored on 2017-03-19
214
            else {
215
                me.updateEIS();
adds Map on MFD
Sébastien MARQUE authored on 2017-03-20
216
                me.MFDMapNavDisplay.showMap();
217
                me.MFDMapTiles.initialize_grid();
218
                me.MFDMapTiles.update_timer.start();
animation texts EIS + power ...
Sébastien MARQUE authored on 2017-03-19
219
            }
fix COMM display standby fre...
Sébastien MARQUE authored on 2017-04-09
220
            me.updateNAV({auto:'nav', tune: radios.getNode('nav-tune').getValue()});
221
            me.updateCOMM({auto:'comm', tune: radios.getNode('comm-tune').getValue()});
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
222
            me.softkeys_inactivity();
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
223
            me.updateSoftKeys();
commit initial
Sébastien MARQUE authored on 2017-03-07
224
            me.progress.removeAllChildren();
225
            me.progress = nil;
226
            me.showInitProgress = nil;
227
            me._showInitProgress = nil;
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
228
            zkv.removeChild(me.device.role ~ 'init', 0);
commit initial
Sébastien MARQUE authored on 2017-03-07
229
        }
230
    },
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

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

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
245
        zkv.getNode(name ~ '-init',1).setIntValue(1);
commit initial
Sébastien MARQUE authored on 2017-03-07
246

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

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

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

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

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

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

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

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

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
422
        var path = keyMap[me.device.role];
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
423
        foreach (var p; me.device.softkeys.path)
424
            path = path[p];
425

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

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

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
454
    updateAI: func(){
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
455
#{{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
456
        var pitch = data.pitch;
457
        var roll = data.roll;
AI disponible
Sébastien MARQUE authored on 2017-03-10
458
        if (pitch > 80)
459
            pitch = 80;
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
460
        elsif (pitch < -80)
AI disponible
Sébastien MARQUE authored on 2017-03-10
461
            pitch = -80;
462
        me.screenElements.Horizon
fix AI animation
Sébastien MARQUE authored on 2017-03-19
463
            .setCenter(459, 282.8 - 6.849 * pitch)
AI disponible
Sébastien MARQUE authored on 2017-03-10
464
            .setRotation(-roll * D2R)
fix AI animation
Sébastien MARQUE authored on 2017-03-19
465
            .setTranslation(0, pitch * 6.849);
AI disponible, avec bankPoin...
Sébastien MARQUE authored on 2017-03-10
466
        me.screenElements.bankPointer
467
            .setRotation(-roll * D2R);
adds slipskid animation
Sébastien MARQUE authored on 2017-03-24
468
        me.screenElements['SlipSkid']
469
            .setTranslation(getprop("/instrumentation/slip-skid-ball/indicated-slip-skid") * 10, 0);
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
470
        settimer(func me.updateAI(), 0.1);
AI disponible
Sébastien MARQUE authored on 2017-03-10
471
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
472
#}}}
animation VSI
Sébastien MARQUE authored on 2017-03-10
473

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
474
    updateVSI: func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
475
# animate VSI {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
476
        var vsi = data.vsi;
animation VSI
Sébastien MARQUE authored on 2017-03-10
477
        me.screenElements.VSIText
478
            .setText(num(math.round(vsi, 10)));
479
        if (vsi > 4500)
480
            vsi = 4500;
481
        elsif (vsi < -4500)
482
            vsi = -4500;
483
        me.screenElements.VSI
484
            .setTranslation(0, vsi * -0.03465);
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
485
        settimer(func me.updateVSI(), 0.1);
animation VSI
Sébastien MARQUE authored on 2017-03-10
486
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
487
#}}}
animation IAS
Sébastien MARQUE authored on 2017-03-10
488

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
489
    updateIAS: func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
490
# animates the IAS lint (PFD) {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
491
        var ias = data.ias;
animation IAS
Sébastien MARQUE authored on 2017-03-10
492
        if (ias >= 10)
493
            me.screenElements.Speed110
494
                .setText(sprintf("% 2u",num(math.floor(ias/10))));
495
        else
496
            me.screenElements.Speed110
497
                .setText('');
498
        me.screenElements.SpeedLint1
499
            .setTranslation(0,(math.mod(ias,10) + (ias >= 10)*10) * 36);
500
        me.screenElements.SpeedTape
501
            .setTranslation(0,ias * 5.711);
put Vspeeds in common data s...
Sébastien MARQUE authored on 2017-04-11
502
        if (ias > data.Vne and ! me._ias_already_exceeded) { # easier than .getColorFill
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
503
            me._ias_already_exceeded = 1;
504
            me.screenElements['IAS-bg']
505
                .setColorFill(1,0,0);
506
        }
put Vspeeds in common data s...
Sébastien MARQUE authored on 2017-04-11
507
        elsif (ias < data.Vne and me._ias_already_exceeded) { # easier than .getColorFill
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
508
            me._ias_already_exceeded = 0;
509
            me.screenElements['IAS-bg']
510
                .setColorFill(0,0,0);
511
        }
add V-speeds bugs
Sébastien MARQUE authored on 2017-04-04
512
        foreach (var v; ['Vx', 'Vy', 'Vr', 'Vglide']) {
put Vspeeds in common data s...
Sébastien MARQUE authored on 2017-04-11
513
            if (me.device.data[v ~ '-visible'] and abs(data[v] - ias) < 30)
add V-speeds bugs
Sébastien MARQUE authored on 2017-04-04
514
                me.screenElements['IAS-' ~ v]
put Vspeeds in common data s...
Sébastien MARQUE authored on 2017-04-11
515
                    .setTranslation(0, (ias - data[v]) * 5.711)
add V-speeds bugs
Sébastien MARQUE authored on 2017-04-04
516
                    .show();
517
            else
518
                me.screenElements['IAS-' ~ v]
519
                    .hide();
520
        }
521

            
trends animation
Sébastien MARQUE authored on 2017-03-13
522
        var now = systime();
523
        # estimated speed in 6s
524
        var Sy = 6 * (ias - me._last_ias_kt) / (now - me._last_ias_s);
525
        if (abs(Sy) > 30)
526
            Sy = 30 * abs(Sy)/Sy; # = -30 or 30
527
        me.screenElements['Airspeed-Trend-Indicator']
528
            .setScale(1,Sy)
529
            .setTranslation(0, -284.5 * (Sy - 1));
530
        me._last_ias_kt = ias;
531
        me._last_ias_s = now;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
532
        settimer(func me.updateIAS(), 0.1);
animation IAS
Sébastien MARQUE authored on 2017-03-10
533
    },
trends animation
Sébastien MARQUE authored on 2017-03-13
534
    _last_ias_kt : 0,
535
    _last_ias_s : systime(),
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
536
    _ias_already_exceeded : 0,
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
537
#}}}
animation ALT
Sébastien MARQUE authored on 2017-03-11
538

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
539
    updateTAS: func {
540
# updates the True Airspeed and GroundSpeed indicators {{{
541
        me.screenElements['TAS-text']
542
            .setText(sprintf('%iKT', getprop('/instrumentation/airspeed-indicator/true-speed-kt')));
543
        me.screenElements['GSPD-text']
544
            .setText(sprintf('%iKT', getprop('/velocities/groundspeed-kt')));
545
        settimer(func me.updateTAS(), 0.5);
546
    },
547
#}}}
548

            
549
    updateALT: func () {
550
# animates the altitude lint (PFD) {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
551
        var alt = data.alt;
animation ALT
Sébastien MARQUE authored on 2017-03-11
552
        if (alt < 0)
553
            me.screenElements.Alt11100
554
                .setText(sprintf("% 3i",math.ceil(alt/100)));
555
        elsif (alt < 100)
556
            me.screenElements.Alt11100
557
                .setText('');
558
        else
559
            me.screenElements.Alt11100
560
                .setText(sprintf("% 3i",math.floor(alt/100)));
561
        me.screenElements.AltLint00011
562
            .setTranslation(0,math.fmod(alt,100) * 1.24);
563

            
564
        # From Farmin/G1000 http://wiki.flightgear.org/Project_Farmin/FG1000
565
        if (alt> -1000 and alt< 1000000) {
566
            var Offset10 = 0;
567
            var Offset100 = 0;
568
            var Offset1000 = 0;
569
            if (alt< 0) {
570
                var Ne = 1;
571
                var alt= -alt;
572
            }
573
            else
574
                var Ne = 0;
575

            
576
            var Alt10       = math.mod(alt,100);
577
            var Alt100      = int(math.mod(alt/100,10));
578
            var Alt1000     = int(math.mod(alt/1000,10));
579
            var Alt10000    = int(math.mod(alt/10000,10));
580
            var Alt20       = math.mod(Alt10,20)/20;
581
            if (Alt10 >= 80)
582
                var Alt100 += Alt20;
583

            
584
            if (Alt10 >= 80 and Alt100 >= 9)
585
                var Alt1000 += Alt20;
586

            
587
            if (Alt10 >= 80 and Alt100 >= 9 and Alt1000 >= 9)
588
                var Alt10000 += Alt20;
589

            
590
            if (alt> 100)
591
                var Offset10 = 100;
592

            
593
            if (alt> 1000)
594
                var Offset100 = 10;
595

            
596
            if (alt> 10000)
597
                var Offset1000 = 10;
598

            
599
            if (!Ne) {
600
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*0.57375);
601
                var altCentral = (int(alt/100)*100);
602
            }
603
            elsif (Ne) {
604
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*-0.57375);
605
                var altCentral = -(int(alt/100)*100);
606
            }
607
            me.screenElements["AltBigC"].setText("");
608
            me.screenElements["AltSmallC"].setText("");
609
            for (var place = 1; place <= 6; place += 1) {
610
                var altUP = altCentral + (place*100);
611
                var offset = -30.078;
612
                if (altUP < 0) {
613
                    var altUP = -altUP;
614
                    var prefix = "-";
615
                    var offset += 15.039;
616
                }
617
                else
618
                    var prefix = "";
619

            
620
                if (altUP == 0) {
621
                    var AltBigUP    = "";
622
                    var AltSmallUP  = "0";
623

            
624
                }
625
                elsif (math.mod(altUP,500) == 0 and altUP != 0) {
626
                    var AltBigUP    = sprintf(prefix~"%1d", altUP);
627
                    var AltSmallUP  = "";
628
                }
629
                elsif (altUP < 1000 and (math.mod(altUP,500))) {
630
                    var AltBigUP    = "";
631
                    var AltSmallUP  = sprintf(prefix~"%1d", int(math.mod(altUP,1000)));
632
                    var offset = -30.078;
633
                }
634
                elsif ((altUP < 10000) and (altUP >= 1000) and (math.mod(altUP,500))) {
635
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
636
                    var AltSmallUP  = sprintf("%1d", int(math.mod(altUP,1000)));
637
                    var offset += 15.039;
638
                }
639
                else {
640
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
641
                    var mod = int(math.mod(altUP,1000));
642
                    var AltSmallUP  = sprintf("%1d", mod);
643
                    var offset += 30.078;
644
                }
645

            
646
                me.screenElements["AltBigU"~place].setText(AltBigUP);
647
                me.screenElements["AltSmallU"~place].setText(AltSmallUP);
648
                me.screenElements["AltSmallU"~place].setTranslation(offset,0);
649
                var altDOWN = altCentral - (place*100);
650
                var offset = -30.078;
651
                if (altDOWN < 0) {
652
                    var altDOWN = -altDOWN;
653
                    var prefix = "-";
654
                    var offset += 15.039;
655
                }
656
                else
657
                    var prefix = "";
658

            
659
                if (altDOWN == 0) {
660
                    var AltBigDOWN  = "";
661
                    var AltSmallDOWN    = "0";
662
                }
663
                elsif (math.mod(altDOWN,500) == 0 and altDOWN != 0) {
664
                    var AltBigDOWN  = sprintf(prefix~"%1d", altDOWN);
665
                    var AltSmallDOWN    = "";
666
                }
667
                elsif (altDOWN < 1000 and (math.mod(altDOWN,500))) {
668
                    var AltBigDOWN  = "";
669
                    var AltSmallDOWN    = sprintf(prefix~"%1d", int(math.mod(altDOWN,1000)));
670
                    var offset = -30.078;
671
                }
672
                elsif ((altDOWN < 10000) and (altDOWN >= 1000) and (math.mod(altDOWN,500))) {
673
                    var AltBigDOWN  = sprintf(prefix~"%1d", int(altDOWN/1000));
674
                    var AltSmallDOWN    = sprintf("%1d", int(math.mod(altDOWN,1000)));
675
                    var offset += 15.039;
676
                }
677
                else {
678
                    var AltBigDOWN  = sprintf(prefix~"%1d", int(altDOWN/1000));
679
                    var mod = int(math.mod(altDOWN,1000));
680
                    var AltSmallDOWN    = sprintf("%1d", mod);
681
                    var offset += 30.078;
682
                }
683
                me.screenElements["AltBigD"~place].setText(AltBigDOWN);
684
                me.screenElements["AltSmallD"~place].setText(AltSmallDOWN);
685
                me.screenElements["AltSmallD"~place].setTranslation(offset,0);
686
            }
687
        }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
688
        me.updateSelectedALT();
trends animation
Sébastien MARQUE authored on 2017-03-13
689
        var now = systime();
690
        # altitude in 6s
691
        var Sy = .3 * (alt - me._last_alt_ft) / (now - me._last_alt_s); # scale = 1/20ft
692
        if (abs(Sy) > 15)
693
            Sy = 15 * abs(Sy)/Sy; # = -15 or 15
694
        me.screenElements['Altitude-Trend-Indicator']
695
            .setScale(1,Sy)
696
            .setTranslation(0, -284.5 * (Sy - 1));
697
        me._last_alt_ft = alt;
698
        me._last_alt_s = now;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
699
        settimer(func me.updateALT(), 0.2);
animation ALT
Sébastien MARQUE authored on 2017-03-11
700
    },
trends animation
Sébastien MARQUE authored on 2017-03-13
701
    _last_alt_ft : 0,
702
    _last_alt_s  : systime(),
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
703
#}}}
animation HSI
Sébastien MARQUE authored on 2017-03-11
704

            
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
705
    updateBARO : func () {
706
# update BARO widget {{{
707
        var fmt = me._baro_unit == 'inhg' ? '%.2f%s' : '%i%s';
708
        me.screenElements['BARO-text']
709
            .setText(sprintf(fmt,
710
                        getprop('/instrumentation/altimeter/setting-' ~ me._baro_unit),
711
                        me._baro_unit == 'inhg' ? 'in' : 'hPa')
712
                );
713
    },
714
    _baro_unit : 'inhg',
715
#}}}
716

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
717
    updateHSI : func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
718
# rotates the compass (PFD) {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
719
        var hdg = data.hdg;
animation HSI
Sébastien MARQUE authored on 2017-03-11
720
        me.screenElements.Rose
721
            .setRotation(-hdg * D2R);
722
        me.screenElements['HDG-text']
723
            .setText(sprintf("%03u°", hdg));
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
724
        settimer(func me.updateHSI(), 0.1);
animation HSI
Sébastien MARQUE authored on 2017-03-11
725
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
726
#}}}
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
727

            
removes unecessary listeners
Sébastien MARQUE authored on 2017-04-08
728
    updateHDG : func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
729
# moves the heading bug and display heading-deg for 3 seconds (PFD) {{{
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
730
        if (me.device.role == 'MFD')
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
731
            return;
removes unecessary listeners
Sébastien MARQUE authored on 2017-04-08
732
        var hdg = getprop('/instrumentation/zkv1000/afcs/heading-bug-deg');
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
733
        me.screenElements['Heading-bug']
734
            .setRotation(hdg * D2R);
735
        me.screenElements['SelectedHDG-bg']
736
            .show();
737
        me.screenElements['SelectedHDG-bgtext']
738
            .show();
739
        me.screenElements['SelectedHDG-text']
740
            .setText(sprintf('%03d°%s', hdg, ''))
741
            .show();
742
        me.addTimer(3, ['SelectedHDG-text', 'SelectedHDG-bgtext', 'SelectedHDG-bg']);
743
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
744
#}}}
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
745

            
adds CDI
Sébastien MARQUE authored on 2017-03-18
746
    updateCRS : func () {
anime CRS
Sébastien MARQUE authored on 2017-03-13
747
# TODO: update display for NAV/GPS/BRG courses {{{
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
748
        if (me.device.role == 'MFD')
anime CRS
Sébastien MARQUE authored on 2017-03-13
749
            return;
adds CDI
Sébastien MARQUE authored on 2017-03-18
750
        var source = getprop('/instrumentation/zkv1000/cdi/source');
751
        if (source == 'OFF')
752
            return;
753
        var crs = getprop('/instrumentation/zkv1000/cdi/course');
754
        if (crs == nil)
755
            return;
anime CRS
Sébastien MARQUE authored on 2017-03-13
756
        me.screenElements['SelectedCRS-bg']
757
            .show();
758
        me.screenElements['SelectedCRS-bgtext']
759
            .show();
760
        me.screenElements['SelectedCRS-text']
761
            .setText(sprintf('%03d°%s', crs, ''))
adds CDI
Sébastien MARQUE authored on 2017-03-18
762
            .setColor(source == 'GPS' ? me.colors.magenta : me.colors.green)
anime CRS
Sébastien MARQUE authored on 2017-03-13
763
            .show();
764
        me.addTimer(3, ['SelectedCRS-text', 'SelectedCRS-bgtext', 'SelectedCRS-bg']);
765
    },
766
#}}}
767

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
768
    updateSelectedALT : func {
769
# animation for altitude section, called via updatedALT {{{
creates flightdeck hash to p...
Sébastien MARQUE authored on 2017-04-07
770
        if (! me.screenElements['SelectedALT'].getVisible())
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
771
            return;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
772
        var selected_alt = getprop('/instrumentation/zkv1000/afcs/selected-alt-ft');
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
773
        var delta_alt = data.alt - selected_alt;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
774
        if (abs(delta_alt) > 300)
775
            delta_alt = 300 * abs(delta_alt)/delta_alt;
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
776
        me.screenElements['SelectedALT-symbol']
777
            .setVisible(abs(delta_alt) > 100);
778
        me.screenElements['SelectedALT-bg']
779
            .setVisible(abs(delta_alt) > 100);
780
        me.screenElements['SelectedALT-text']
781
            .setText(sprintf("%i", selected_alt))
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
782
            .setVisible(abs(delta_alt) > 100);
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
783
        me.screenElements['SelectedALT-bug']
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
784
            .setTranslation(0, delta_alt * 0.567); # 170/300 = 0.567
785
    },
786
#}}}
787

            
adds CDI
Sébastien MARQUE authored on 2017-03-18
788
    updateCDI : func {
789
# animation for CDI {{{
790
        var source = getprop('/instrumentation/zkv1000/cdi/source');
791
        if (source == 'OFF') {
792
            foreach (var s; ['GPS', 'NAV1', 'NAV2'])
793
                foreach (var t; ['pointer', 'CDI'])
794
                    me.screenElements[s ~ '-' ~ t].hide();
795
            me.screenElements['CDI-GPS-ANN-text'].hide();
796
            me.screenElements['CDI-GPS-XTK-text'].hide();
797
            me.screenElements['CDI-SRC-text'].hide();
798
            me.screenElements['CDI'].hide();
799
        }
800
        else {
801
            var course = getprop('/instrumentation/zkv1000/cdi/course');
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
802
            var rot = (course - data.hdg) * D2R;
adds CDI
Sébastien MARQUE authored on 2017-03-18
803
            me.screenElements['CDI']
makes the CDI available
Sébastien MARQUE authored on 2017-03-23
804
                .setRotation(rot)
adds CDI
Sébastien MARQUE authored on 2017-03-18
805
                .show();
806
            me.screenElements['GPS-CTI']
animates GPS-CTI
Sébastien MARQUE authored on 2017-03-24
807
                .setVisible(getprop('/instrumentation/gps/wp/wp[1]/valid'))
808
                .setRotation(getprop('/instrumentation/gps/wp/wp[1]/course-deviation-deg') * D2R);
adds CDI
Sébastien MARQUE authored on 2017-03-18
809
            me.screenElements['GPS-CTI-diamond']
animates GPS-CTI
Sébastien MARQUE authored on 2017-03-24
810
                .setVisible(getprop('/instrumentation/gps/wp/wp[1]/valid'))
811
                .setRotation(getprop('/instrumentation/gps/wp/wp[1]/course-deviation-deg') * D2R);
adds CDI
Sébastien MARQUE authored on 2017-03-18
812
            foreach (var s; ['GPS', 'NAV1', 'NAV2']) {
813
                me.screenElements[s ~ '-pointer']
814
                    .setRotation(rot)
815
                    .setVisible(source == s);
816
                me.screenElements[s ~ '-CDI']
817
                    .setVisible(source == s);
818
                foreach (var f; ['FROM', 'TO'])
819
                    me.screenElements[s ~ '-' ~ f]
makes the CDI available
Sébastien MARQUE authored on 2017-03-23
820
                        .setVisible(s == source and getprop('/instrumentation/zkv1000/cdi/' ~ f ~ '-flag'));
adds CDI
Sébastien MARQUE authored on 2017-03-18
821
                me.screenElements['CDI-SRC-text']
822
                    .setText(source)
823
                    .setColor(source == 'GPS' ? me.colors.magenta : me.colors.green)
824
                    .show();
825
            }
makes the CDI available
Sébastien MARQUE authored on 2017-03-23
826
            var deflection = getprop('/instrumentation/zkv1000/cdi/course-deflection');
827
            if (left(source, 3) == 'NAV')
828
                var scale = deflection / 4;
829
            else { # GPS
830
                # TODO: deviation depending of the flight phase
831
                # for now fixed 1 dot = 1 nm course error
832
                var abs_deflection = abs(deflection);
833
                me.screenElements['CDI-GPS-XTK-text']
834
                    .setText(sprintf('XTK %iNM', abs_deflection))
835
                    .setVisible(abs_deflection > 2.4);
836
                var scale = deflection / 2;
837
            }
838
            scale = (abs(scale) > 1.2) ? 1.2 : scale;
839
            me.screenElements[source ~ '-CDI']
840
                .setTranslation(65 * scale, 0);
841
            settimer(func me.updateCDI(), 0.3);
adds CDI
Sébastien MARQUE authored on 2017-03-18
842
        }
843
    },
844
#}}}
845

            
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
846
    _updateRadio: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
847
# common parts for NAV/LOC/COMM radios{{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
848
        # arg[0]._r = <comm|nav>
849
        if (contains(arg[0], "active")) {
850
            if (arg[0]['active'] == 'none') {
851
                me.screenElements[arg[0]._r ~ '1-selected-freq']
852
                    .setColor(1,1,1);
853
                me.screenElements[arg[0]._r ~ '2-selected-freq']
854
                    .setColor(1,1,1);
855
            }
856
            else {
857
                me.screenElements[arg[0]._r ~ arg[0]['active'] ~ '-selected-freq']
858
                    .setColor(0,1,0);
859
                me.screenElements[arg[0]._r ~ arg[0].inactive ~ '-selected-freq']
860
                    .setColor(1,1,1);
861
            }
862
        }
863
        if (contains(arg[0], 'tune')) {
864
            # n = 0 -> NAV1/COMM1
865
            # n = 1 -> NAV1/COMM2
866
            me.screenElements[arg[0]._r ~ '-freq-switch']
867
                .setTranslation(0, arg[0].tune * 25);
868
            me.screenElements[arg[0]._r ~ (arg[0].tune + 1) ~ '-standby-freq']
869
                .setColor(0,1,1);
870
            me.screenElements[arg[0]._r ~ ((arg[0].tune == 0) + 1) ~ '-standby-freq']
871
                .setColor(1,1,1);
872
        }
873
        if (contains(arg[0], 'refresh')) {
small stuff
Sébastien MARQUE authored on 2017-03-22
874
            # refresh only one line: NAV1/COMM1 or NAV2/COMM2
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
875
            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
876
            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-selected-freq']
877
                .setText(sprintf(fmt, getprop('/instrumentation/'
878
                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/selected-mhz')));
879
            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-standby-freq']
880
                .setText(sprintf(fmt, getprop('/instrumentation/'
881
                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/standby-mhz')));
882
        }
883
        if (contains(arg[0], 'set')) {
884
            # positionne la valeur modifiée, les listeners "trigguent" en permanence ces propriétés, donc exit
885
            var n = getprop('/instrumentation/zkv1000/radios/' ~ arg[0]._r ~ '-tune');
886
            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
887
            me.screenElements[arg[0]._r ~ (n + 1) ~ '-standby-freq']
fix freq display while setti...
Sébastien MARQUE authored on 2017-03-16
888
                .setText(sprintf(fmt, getprop('/instrumentation/' ~ arg[0]._r ~ '[' ~ n ~ ']/frequencies/standby-mhz')));
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
889
        }
890
        if (contains(arg[0], 'auto')) {
891
            # pour rafraichir automagiquement, toutes les deux secondes un refresh pour un NAV
892
            var radio = arg[0].auto;
893
            me._updateRadio({refresh: 1, _r: radio});
894
            settimer(func me._updateRadio({refresh: 2, _r: radio}), 1);
895
            settimer(func me._updateRadio({auto: radio}), 2);
896
        }
897
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
898
#}}}
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
899

            
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
900
    updateNAV : func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
901
# update NAV/LOC rodios display upper left (PFD/MFD){{{
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
902
        # made active via menu
903
        if (contains(arg[0], "active")) {
adds CDI
Sébastien MARQUE authored on 2017-03-18
904
            arg[0]._r = 'nav';
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
905
            if (arg[0]['active'] == 'none') {
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
906
                me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
907
                me.screenElements['nav1-id']
908
                    .setColor(1,1,1);
909
                me.screenElements['nav2-id']
910
                    .setColor(1,1,1);
911
                me.screenElements['NAV1-pointer']
912
                    .hide();
913
                me.screenElements['NAV2-pointer']
914
                    .hide();
915
            }
916
            else {
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
917
                arg[0].inactive = (arg[0]['active'] == 1) + 1;
918
                me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
919
                me.screenElements['nav' ~ arg[0]['active'] ~ '-id']
920
                    .setColor(0,1,0);
921
                me.screenElements['NAV' ~ arg[0]['active'] ~ '-pointer']
922
                    .show();
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
923
                me.screenElements['nav' ~ arg[0].inactive ~ '-id']
924
                    .setColor(1,1,1);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
925
#                me.screenElements['HDI']
926
#                    .setRotation();
927
#                me.screenElements['NAV' ~ inactive ~ '-pointer']
928
#                    .hide();
929
#                foreach (var e; [ 'FROM', 'TO', 'CDI' ])
930
#                    me.screenElements['NAV' ~ inactive ~ '-' ~ e]
931
#                        .hide();
932
            }
933
        }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
934
        elsif (contains(arg[0], 'nav-id')) {
Correction swap NAV tuning
Sébastien MARQUE authored on 2017-03-12
935
            # 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
936
            if (arg[0].val == nil)
937
                arg[0].val = '';
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
938
            me.screenElements["nav" ~ arg[0]['nav-id'] ~ "-id"]
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
939
                    .setText(arg[0].val);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
940
        }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
941
        else {
942
            arg[0]._r = 'nav';
943
            me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
944
        }
945
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
946
#}}}
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
947

            
948
    updateCOMM: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
949
# update COMM radios display upper right (PFD/MFD){{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
950
        arg[0]._r = 'comm';
951
        me._updateRadio(arg[0]);
952
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
953
#}}}
anime time display
Sébastien MARQUE authored on 2017-03-13
954

            
955
    updateTIME : func {
956
# updates the displayed time botoom left {{{
957
        me.screenElements['TIME-text']
958
            .setText(getprop('/sim/time/gmt-string'));
959
        settimer(func me.updateTIME(), 1);
960
    },
961
#}}}
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
962

            
adds transponder
Sébastien MARQUE authored on 2017-03-17
963
    updateXPDR : func {
964
# updates transponder display {{{
965
        for (var d = 0; d < 4; d+=1)
966
            me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
967
                .setText(sprintf('%i', getprop('/instrumentation/transponder/inputs/digit[' ~ d ~ ']')));
968
        var tuning = getprop('/instrumentation/zkv1000/radios/xpdr-tuning-digit');
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
969
        var fms = getprop('/instrumentation/zkv1000/radios/xpdr-tuning-fms-method');
970
        for (var d = 0; d < 4; d+=1)
971
            me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
972
                .setColor(1,1,1);
973
        if (tuning != nil) {
974
            me.screenElements['XPDR-DIGIT-' ~ tuning ~ '-text']
975
                .setColor(0,1,1);
976
            if (fms)
977
                me.screenElements['XPDR-DIGIT-' ~ (tuning - 1) ~ '-text']
978
                    .setColor(0,1,1);
979
        }
adds transponder
Sébastien MARQUE authored on 2017-03-17
980
        else {
981
            if (getprop('/instrumentation/transponder/ident'))
982
                var mode = 'IDENT';
983
            else
984
                var mode = getprop('/instrumentation/zkv1000/radio/xpdr-mode');
985
            var wow = getprop('/gear/gear/wow');
986
            if (! wow and mode != 'STBY')
987
                var color = [0, 1, 0];
988
            else
989
                var color = [1, 1, 1];
990
            for (var d = 0; d < 4; d+=1)
991
                me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
992
                    .setColor(color);
993
            me.screenElements['XPDR-MODE-text']
994
                .setColor(color)
995
                .setText(mode);
996
        }
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
997
    },
adds transponder
Sébastien MARQUE authored on 2017-03-17
998
#}}}
999

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1000
    updateOAT : func {
1001
# update OAT display on normal and reversionnary modes (every 3s) {{{
1002
        var tmp = getprop('/environment/temperature-deg' ~ me._oat_unit);
1003
        me.screenElements['OAT-text']
1004
            .setText(sprintf((abs(tmp) < 10) ? "%.1f %s" : "%i %s", tmp, (me._oat_unit == 'c') ? '°C' : 'F'));
1005
        settimer(func me.updateOAT(), 3);
1006
    },
1007
    _oat_unit : 'c',
1008
#}}}
1009

            
1010
    updateWindData : func {
1011
# update the window text and arrows for OPTN1/2 {{{
1012
        if (me._winddata_optn == 0)
1013
            return;
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
1014
        if (data.ias < 30) {
improves WindData display
Sébastien MARQUE authored on 2017-03-16
1015
            me.screenElements['WindData-NODATA']
1016
                .hide();
1017
            var wind_hdg = getprop('/environment/wind-from-heading-deg');
1018
            var wind_spd = getprop('/environment/wind-speed-kt');
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
1019
            var alpha = wind_hdg - data.hdg;
improves WindData display
Sébastien MARQUE authored on 2017-03-16
1020
            if (me._winddata_optn == 1) {
1021
                me.screenElements['WindData-OPTN1-HDG']
1022
                    .setRotation((alpha + 180) * D2R)
1023
                    .show();
1024
                me.screenElements['WindData-OPTN1-HDG-text']
1025
                    .setText(sprintf("%03i°", wind_hdg))
1026
                    .show();
1027
                me.screenElements['WindData-OPTN1-SPD-text']
1028
                    .setText(int(wind_spd) ~ 'KT')
1029
                    .show();
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1030
            }
improves WindData display
Sébastien MARQUE authored on 2017-03-16
1031
            else { # me._winddata_optn == 2
1032
                alpha *= D2R;
1033
                var Vt = wind_spd * math.sin(alpha);
1034
                var Ve = wind_spd * math.cos(alpha);
1035
                if (Vt != 0) {
1036
                    me.screenElements['WindData-OPTN2-crosswind-text']
1037
                        .setText(sprintf('%i', abs(Vt)))
1038
                        .show();
1039
                    me.screenElements['WindData-OPTN2-crosswind']
1040
                        .setScale(-abs(Vt)/Vt, 1)
1041
                        .setTranslation(-35 * (abs(Vt)/Vt + 1), 0)
1042
                        .show();
1043
                }
1044
                if (Ve != 0) {
1045
                    me.screenElements['WindData-OPTN2-headwind-text']
1046
                        .setText(sprintf('%i', abs(Ve)))
1047
                        .show();
1048
                    me.screenElements['WindData-OPTN2-headwind']
1049
                        .setScale(1, abs(Ve)/Ve)
1050
                        .setTranslation(0, 515 * (1 - abs(Ve)/Ve))
1051
                        .show();
1052
                }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1053
            }
1054
        }
improves WindData display
Sébastien MARQUE authored on 2017-03-16
1055
        else {
1056
            foreach (var e; [
1057
                    'WindData-OPTN1-HDG',
1058
                    'WindData-OPTN1-HDG-text',
1059
                    'WindData-OPTN1-SPD-text',
1060
                    'WindData-OPTN2-crosswind-text',
1061
                    'WindData-OPTN2-crosswind',
1062
                    'WindData-OPTN2-headwind-text',
1063
                    'WindData-OPTN2-headwind'
1064
            ])
1065
                me.screenElements[e].hide();
1066
            me.screenElements['WindData-NODATA'].show();
1067
        }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1068
        settimer(func me.updateWindData(), 0.5);
1069
    },
1070
    _winddata_optn : 0,
1071
#}}}
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1072

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

            
1078
            var dev = radios.getNode(source).getValue();
1079
            var el  = 'BRG' ~ brg;
1080
            if (dev != 'OFF') {
colorize BRG1/2 when needed,...
Sébastien MARQUE authored on 2017-03-21
1081
                if (size(me.device.softkeys.path) == 1 and me.device.softkeys.path[0] == 'PFD')
1082
                    me.setSoftKeyColor(brg == 1 ? 4 : 6, 1);
1083
                else
1084
                    me.setSoftKeyColor(brg == 1 ? 4 : 6, 0);
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1085
                var info = {
1086
                    pointer : nil,
1087
                    id : 'NO DATA',
1088
                    hdg : nil,
1089
                    dst : '--.-NM'
1090
                };
1091
                if (left(dev, 3) == 'NAV') {
1092
                    info.pointer = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/in-range');
1093
                    if (info.pointer) {
1094
                        info.id  = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/nav-id');
1095
                        info.hdg = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/heading-deg');
1096
                        info.dst = sprintf('%.1d', getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/nav-distance') / 1852); # m -> /1852
1097
                    }
1098
                }
1099
                elsif (dev == 'GPS') {
1100
                    info.pointer = props.getNode('/instrumentation/gps/wp').getChild('wp[1])');
1101
                    if (info.pointer) {
1102
                        info.id  = getprop('/instrumentation/gps/wp/wp[1]/ID');
1103
                        info.hdg = getprop('/instrumentation/gps/wp/wp[1]/bearing-mag-deg');
1104
                        info.dst = sprintf('%.1d', getprop('/instrumentation/gps/wp/wp[1]/distance-nm'));
1105
                    }
1106
                }
1107
                else { # there are 2 available ADF in FG, but instrument manage only 1
1108
                    info.pointer = getprop('/instrumentation/adf/in-range');
1109
                    if (info.pointer) {
1110
                        info.id  = getprop('/instrumentation/adf/ident');
1111
                        info.hdg = getprop('/instrumentation/adf/indicated-bearing-deg');
1112
                    }
1113
                }
1114

            
1115
                if (info.pointer)
1116
                    me.screenElements[el ~ '-pointer']
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
1117
                        .setRotation(-info.hdg - data.hdg * D2R)
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1118
                        .show();
1119
                else
1120
                    me.screenElements[el ~ '-pointer']
1121
                        .hide();
1122
                me.screenElements[el ~ '-SRC-text']
1123
                    .setText(dev);
1124
                me.screenElements[el ~ '-DST-text']
1125
                    .setText(info.dst);
1126
                me.screenElements[el ~ '-WPID-text']
1127
                    .setText(info.id);
1128
                me.screenElements['BRG' ~ brg]
1129
                    .show();
1130
            }
1131
            else {
colorize BRG1/2 when needed,...
Sébastien MARQUE authored on 2017-03-21
1132
                me.setSoftKeyColor(brg == 1 ? 4 : 6, 0);
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1133
                me.screenElements['BRG' ~ brg]
1134
                    .hide();
1135
            }
1136
        }
colorize BRG1/2 when needed,...
Sébastien MARQUE authored on 2017-03-21
1137
        settimer(func me.updateBRG(), 0.5);
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1138
    },
some added comments
Sébastien MARQUE authored on 2017-03-18
1139
#}}}
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
1140

            
adds OMI to PFD
Sébastien MARQUE authored on 2017-03-23
1141
    updateOMI : func {
1142
# display marker baecon Outer, Middle, Inner {{{
1143
        var marker = nil;
1144
        foreach (var m; ['outer', 'middle', 'inner'])
1145
            if (getprop('/instrumentation/marker-beacon/' ~ m)) {
1146
                marker = m;
1147
                me.screenElements['OMI']
1148
                    .show();
1149
                break;
1150
            }
1151
        if (marker != nil) {
1152
            me.screenElements['MarkerText']
1153
                .setText(me._omi_data[marker].t)
1154
                .show();
1155
            me.screenElements['MarkerBG']
1156
                .setColorFill(me._omi_data[marker].bg)
1157
                .show();
1158
        }
1159
        else
1160
            me.screenElements['OMI']
1161
                .hide();
1162
        settimer(func me.updateOMI(), 1);
1163
    },
1164
    _omi_data : {
1165
        'outer':  {t: 'O', bg: [0,1,1]},
1166
        'middle': {t: 'M', bg: [1,1,1]},
1167
        'inner':  {t: 'I', bg: [1,1,0]},
1168
    },
1169
#}}}
animation texts EIS + power ...
Sébastien MARQUE authored on 2017-03-19
1170
};
1171

            
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
1172
var keyMap = {
add new vim folds
Sébastien MARQUE authored on 2017-03-15
1173
# softkeys map for PFD and MFD {{{
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
1174
    PFD : {
1175
        first : 1,
1176
        texts : ['INSET', 'SENSOR', 'PFD', 'OBS', 'CDI', 'DME', 'XPDR', 'IDENT', 'TMR/REF', 'NRST' ],
1177
        INSET : {
1178
            texts : ['OFF', 'DCLTR', 'WXLGND', 'TRAFFIC', 'TOPO', 'TERRAIN', 'STRMSCP', 'NEXRAD-C', 'XM LTNG', 'METAR'],
1179
        },
1180
        SENSOR : {
1181
            first : 2,
1182
            texts : [ 'ADC1', 'ADC2', '', 'AHRS1', 'AHRS2'],
1183
        },
1184
        PFD : {
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1185
            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
1186
            'SYN VIS' : {
1187
                texts : [ 'PATHWAY', 'SYN TERR', 'HR2NHDG', 'APTSIGNS', 'FPM'],
1188
            },
1189
            'AOA/WIND' : {
1190
                first : 4,
1191
                texts : ['AOA', 'WIND'],
1192
                AOA : {
1193
                    first : 5,
1194
                    texts : ['AOA ON', 'AOA AUTO'],
1195
                },
1196
                WIND : {
1197
                    first : 2,
1198
                    texts : ['OPTN1', 'OPTN2', '', 'OFF'],
1199
                },
1200
            },
1201
            'HSI FMT' : {
1202
                first : 6,
1203
                texts : ['360 HSI', 'ARC HSI'],
1204
            },
1205
            'ALT UNIT' : {
1206
                first : 5,
1207
                texts : ['METERS', '', 'IN', 'HPA'],
1208
            },
1209
        },
1210
        XPDR : {
1211
            first : 2,
1212
            texts : ['STBY', 'ON', 'ALT', '', 'VFR', 'CODE', 'IDENT'],
1213
            CODE : {
1214
                texts : ['0', '1', '2', '3', '4', '5', '6', '7', 'IDENT', 'BKSP'],
1215
            },
1216
        },
1217
    },
1218
    MFD : {
1219
        texts : ['ENGINE', '', 'MAP', '', '', '', '', '', '', 'DCLTR', 'SHW CHRT', 'CHKLIST'],
1220
        MAP : {
1221
            texts: ['TRAFFIC', 'PROFILE', 'TOPO', 'TERRAIN', 'AIRWAYS', 'STRMSCP','NEXRAD-C', 'XM LTNG', 'METAR', 'LEGEND', 'BACK'],
1222
        },
1223
        CHKLIST : {
1224
            texts : ['ENGINE', '', '', '', '', 'DONE', '', '', '', '', 'EXIT', 'EMERGCY'],
1225
        },
1226
        ENGINE : {
1227
            texts : ['ENGINE', 'ANTI-ICE', '', 'DCLTR', '', 'ASSIST', '', '', '', '', 'FUEL'],
1228
            'ANTI-ICE' : {
1229
                texts : ['LEFT', 'AUTO', 'RIGHT', '', '', '', '', '', '', '', '', 'BACK'],
1230
            },
1231
            FUEL : {
1232
                first : 1,
1233
                texts : ['FULL', 'TABS', '', '', '', '', '', '', '', 'UNDO', 'ENTER'],
1234
            },
1235
        },
1236
    },
1237
};
add new vim folds
Sébastien MARQUE authored on 2017-03-15
1238
#}}}