zkv1000 / Nasal / display.nas /
Newer Older
1302 lines | 49.222kb
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');
fix MFD page selection syste...
Sébastien MARQUE authored on 2017-04-13
36
            io.load_nasal(getprop('/sim/fg-aircraft') ~ '/Instruments-3d/zkv1000/Nasal/MFD.pages.nas', 'zkv1000');
adds Map on MFD
Sébastien MARQUE authored on 2017-03-20
37
        }
38

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

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

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

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

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

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

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

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

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

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
197
            if (me.device.role == 'PFD') {
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
198
                me.updateAI();
199
                me.updateVSI();
200
                me.updateIAS();
201
                me.updateALT();
202
                me.updateHSI();
anime time display
Sébastien MARQUE authored on 2017-03-13
203
                me.updateTIME();
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
204
                me.updateOAT();
205
                me.updateTAS();
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
206
                me.updateBRG();
adds transponder
Sébastien MARQUE authored on 2017-03-17
207
                me.updateXPDR();
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
208
                me.updateBARO();
adds OMI to PFD
Sébastien MARQUE authored on 2017-03-23
209
                me.updateOMI();
ajoute un timer pour cacher ...
Sébastien MARQUE authored on 2017-03-13
210
                me.timerTrigger();
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
211
            }
animation texts EIS + power ...
Sébastien MARQUE authored on 2017-03-19
212
            else {
213
                me.updateEIS();
adds Map on MFD
Sébastien MARQUE authored on 2017-03-20
214
                me.MFDMapNavDisplay.showMap();
215
                me.MFDMapTiles.initialize_grid();
216
                me.MFDMapTiles.update_timer.start();
adds MFD page selection syst...
Sébastien MARQUE authored on 2017-04-13
217
                me['page selected'] = 0;
218
                me.device.data['page selection'] = [
219
                    {
220
                        name: 'MAP',
221
                        objects: [
222
                            {text: 'NAVIGATION MAP'},
223
                            {text: 'TRAFFIC MAP'},
224
                            {text: 'STORMSCOPE'},
225
                            {text: 'WEATHER DATA LINK'},
226
                            {text: 'TAWS-B'},
227
                        ],
228
                    },
229
                    {
230
                        name: 'WPT',
231
                        objects: [
232
                            {text: 'AIRPORT INFORMATION'},
233
                            {text: 'AIRPORT DIRECTORY'},
234
                            {text: 'DEPARTURE INFORMATION'},
235
                            {text: 'ARRIVAL INFORMATION'},
236
                            {text: 'APPROACH INFORMATION'},
237
                            {text: 'WEATHER INFORMATION'},
238
                            {text: 'INTERSECTION INFORMATION'},
239
                            {text: 'NDB INFORMATION'},
240
                            {text: 'VOR INFORMATION'},
241
                            {text: 'USER WAYPOINT INFORMATION'},
242
                        ],
243
                    },
244
                    {
245
                        name: 'AUX',
246
                        objects: [
247
                            {text: 'TRIP PLANNING'},
248
                            {text: 'UTILITY'},
249
                            {text: 'GPS STATUS'},
250
                            {text: 'SYSTEM SETUP'},
251
                        ],
252
                    },
253
                    {
254
                        name: 'FPL',
255
                        objects: [
256
                            {text: 'ACTIVE FLIGHT PLAN'},
257
                            {text: 'WIDE VIEW, NARROW VIEW'},
258
                            {text: 'FLIGHT PLAN CATALOG'},
259
                        ],
260
                    },
261
                    {
262
                        name: 'PROC',
263
                        objects: [
264
                            {text: 'DEPARTURE LOADING'},
265
                            {text: 'ARRIVAL LOADING'},
266
                            {text: 'APPROACH LOADING'},
267
                        ],
268
                    },
269
                    {
270
                        name: 'NRST',
271
                        objects: [
272
                            {text: 'NEAREST AIRPORTS'},
273
                            {text: 'NEAREST INTERSECTIONS'},
274
                            {text: 'NEAREST NDB'},
275
                            {text: 'NEAREST VOR'},
276
                            {text: 'NEAREST USER WAYPOINTS'},
277
                            {text: 'NEAREST FREQUENCIES'},
278
                            {text: 'NEAREST AIRSPACES'},
279
                        ],
280
                    },
281
                ];
fix MFD page selection syste...
Sébastien MARQUE authored on 2017-04-13
282
                me.setMFDPages();
animation texts EIS + power ...
Sébastien MARQUE authored on 2017-03-19
283
            }
fix COMM display standby fre...
Sébastien MARQUE authored on 2017-04-09
284
            me.updateNAV({auto:'nav', tune: radios.getNode('nav-tune').getValue()});
285
            me.updateCOMM({auto:'comm', tune: radios.getNode('comm-tune').getValue()});
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
286
            me.softkeys_inactivity();
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
287
            me.updateSoftKeys();
commit initial
Sébastien MARQUE authored on 2017-03-07
288
            me.progress.removeAllChildren();
289
            me.progress = nil;
290
            me.showInitProgress = nil;
291
            me._showInitProgress = nil;
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
292
            zkv.removeChild(me.device.role ~ 'init', 0);
commit initial
Sébastien MARQUE authored on 2017-03-07
293
        }
294
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
295
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
296

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
297
    showInitProgress : func (name) {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
298
#{{{
commit initial
Sébastien MARQUE authored on 2017-03-07
299
        me.progress = me.display.createGroup();
300
        me.progress.show();
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
301
        me.progress.createChild("text", name ~ " title")
commit initial
Sébastien MARQUE authored on 2017-03-07
302
            .setTranslation(512, 384)
303
            .setAlignment("center-center")
304
            .setFont("LiberationFonts/LiberationSans-Italic.ttf")
305
            .setFontSize(64, 1)
306
            .setColor(1,1,1)
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
307
            .setText("ZKV1000 " ~ name ~ " init");
commit initial
Sébastien MARQUE authored on 2017-03-07
308

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

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
311
        me._showInitProgress(me.progress.createChild("text", name ~ "progress")
commit initial
Sébastien MARQUE authored on 2017-03-07
312
            .setTranslation(512, 484)
313
            .setAlignment("center-center")
314
            .setFont("LiberationFonts/LiberationSans-Bold.ttf")
315
            .setFontSize(128, 1)
316
            .setColor(1,0,0), '.');
317
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
318
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
319

            
some added comments
Sébastien MARQUE authored on 2017-03-18
320
    colors : {
321
# set of predefined colors {{{
322
        green : [0, 1, 0],
323
        white : [1, 1, 1],
324
        black : [0, 0, 0],
325
        lightblue : [0, 1, 1],
326
        darkblue : [0, 0, 1],
327
        red : [1, 0, 0],
adds CDI
Sébastien MARQUE authored on 2017-03-18
328
        magenta : [1, 0, 1],
some added comments
Sébastien MARQUE authored on 2017-03-18
329
    },
330
#}}}
331

            
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
332
    loadGroup : func (h) {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
333
#{{{
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
334
        if (typeof(h) != 'hash') {
335
            msg_dbg(sprintf("%s need a hash, but get a %s from %s",
336
                    caller(0)[0],
337
                    typeof(h),
338
                    caller(1)[0]));
339
            return;
commit initial
Sébastien MARQUE authored on 2017-03-07
340
        }
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
341
        var setMethod = func (e, t) {
342
            if (t == 'hide')
343
                me.screenElements[e].hide();
344
            elsif (t == 'show')
345
                me.screenElements[e].show();
AI disponible
Sébastien MARQUE authored on 2017-03-10
346
            elsif (t == 'rot' or t == 'trans') {
347
                if (! contains(me.screenElements[e], t))
348
                    me.screenElements[e][t] = me.screenElements[e].createTransform();
349
            }
350
            elsif (t == 'clip') {
351
                if (contains(me.clips, e))
352
                    me.screenElements[e].set("clip", me.clips[e]);
353
                else
printlog with adapted level ...
Sébastien MARQUE authored on 2017-03-20
354
                    printlog('warn', 'no defined clip for ' ~ e);
AI disponible
Sébastien MARQUE authored on 2017-03-10
355
            }
animation VSI
Sébastien MARQUE authored on 2017-03-10
356
            elsif (t == 'text') {
357
                if (contains(me.texts, e)) {
358
                    if (contains(me.texts[e], 'alignment'))
359
                        me.screenElements[e].setAlignment(me.texts[e].alignment);
360
                    if (contains(me.texts[e], 'default'))
361
                        me.screenElements[e].setText(me.texts[e].default);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
362
                    if (contains(me.texts[e], 'color'))
363
                        me.screenElements[e].setColor(me.texts[e].color);
adds CDI
Sébastien MARQUE authored on 2017-03-18
364
                    if (contains(me.texts[e], 'visible'))
365
                        me.screenElements[e].setVisible(me.texts[e].visible);
animation VSI
Sébastien MARQUE authored on 2017-03-10
366
                }
printlog with adapted level ...
Sébastien MARQUE authored on 2017-03-20
367
                else
368
                    printlog('debug', 'no text format for ' ~ e);
animation VSI
Sébastien MARQUE authored on 2017-03-10
369
            }
commit initial
Sébastien MARQUE authored on 2017-03-07
370
            else
printlog with adapted level ...
Sébastien MARQUE authored on 2017-03-20
371
                printlog('warn', 'unknown method ' ~ t);
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
372
        };
373
        foreach (var todo; keys(h)) {
374
            if (typeof(h[todo]) != 'vector') h[todo] = [ h[todo] ];
375
            foreach (var id; h[todo]) {
376
                if (! contains(me.screenElements, id)) {
377
                    me.screenElements[id] = me.screen.getElementById(id);
378
                    if (me.screenElements[id] != nil)
379
                        setMethod(id, todo);
380
                    else
printlog with adapted level ...
Sébastien MARQUE authored on 2017-03-20
381
                        printlog('warn', 'SVG ID ' ~ id ~ ' not found');
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
382
                }
383
                else
384
                    setMethod(id, todo);
385
            }
commit initial
Sébastien MARQUE authored on 2017-03-07
386
        }
387
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
388
#}}}
AI disponible
Sébastien MARQUE authored on 2017-03-10
389

            
390
    clips : {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
391
#{{{
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
392
        PitchScale   : "rect(70,664,370,256)",
393
        SpeedLint1   : "rect(252,226,318,204)",
394
        SpeedTape    : "rect(115,239,455,156)",
395
        LintAlt      : "rect(115,808,455,704)",
animation ALT
Sébastien MARQUE authored on 2017-03-11
396
        AltLint00011 : "rect(252,804,318,771)",
AI disponible
Sébastien MARQUE authored on 2017-03-10
397
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
398
#}}}
AI disponible
Sébastien MARQUE authored on 2017-03-10
399

            
animation VSI
Sébastien MARQUE authored on 2017-03-10
400
    texts : {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
401
#{{{
animation VSI
Sébastien MARQUE authored on 2017-03-10
402
        VSIText : {
403
            alignment: "right-bottom", default : num('0'),
404
        },
animation IAS
Sébastien MARQUE authored on 2017-03-10
405
        Speed110 : {
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
406
            alignment : 'left-bottom'
animation IAS
Sébastien MARQUE authored on 2017-03-10
407
        },
animation ALT (2)
Sébastien MARQUE authored on 2017-03-11
408
        Alt11100 : {
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
409
            alignment:'left-bottom'
animation ALT (2)
Sébastien MARQUE authored on 2017-03-11
410
        },
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
411
        "HDG-text" : {
412
            default: '---°'
413
        },
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
414
        'nav1-standby-freq' : {
415
            color: [0, 1, 1],
416
        },
417
        'nav1-id' : {
418
            default: ''
419
        },
420
        'nav2-id' : {
421
            default: ''
422
        },
adds CDI
Sébastien MARQUE authored on 2017-03-18
423
        'CDI-GPS-ANN-text' : {
424
            visible : 0
425
        },
426
        'CDI-GPS-XTK-text' : {
427
            visible : 0
428
        },
429
        'CDI-SRC-text' : {
430
            visible : 0
431
        },
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
432
        'BARO-text' : {
433
            alignment : 'left-bottom',
434
        }
some added comments
Sébastien MARQUE authored on 2017-03-18
435
#        'TAS-text' : {
436
#            alignment : 'right-bottom',
437
#        },
438
#        'GSPD-text' : {
439
#            alignment : 'right-bottom',
440
#        },
animation VSI
Sébastien MARQUE authored on 2017-03-10
441
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
442
#}}}
animation VSI
Sébastien MARQUE authored on 2017-03-10
443

            
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
444
    softkeys_inactivity : func {
445
# automagically back to previous level after some delay {{{
446
        me.timers2.softkeys_inactivity = maketimer (
447
            me.softkeys_inactivity_delay,
448
            func {
449
                pop(me.device.softkeys.path);
450
                me.updateSoftKeys();
451
            }, me);
452
        me.timers2.softkeys_inactivity.singleShot = 1;
453
    },
454
#}}}
455

            
add softkeys colors
Sébastien MARQUE authored on 2017-03-21
456
    setSoftKeyColor : func (n, active, alert = 0) {
457
# set colors for active softkeys {{{
458
        var sftk = sprintf('SoftKey%02i-', n);
459
        if (active) {
460
            var bg = alert ? 1 : 0.5;
461
            me.screenElements[sftk ~ 'bg']
462
                .setColorFill(bg,bg,bg);
463
            me.screenElements[sftk ~ 'text']
464
                .setColor(0,0,0);
465
        }
466
        else {
467
            me.screenElements[sftk ~ 'bg']
468
                .setColorFill(0,0,0);
469
            me.screenElements[sftk ~ 'text']
470
                .setColor(1,1,1);
471
        }
472
    },
473
#}}}
474

            
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
475
    updateSoftKeys : func {
476
# update SoftKeys boxes {{{
477
        # on PFD the last boxes are always BACK and ALERTS
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
478
        if (me.device.role == 'PFD') {
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
479
            me.screenElements[sprintf("SoftKey%02i-text", 11)]
480
                .setText('ALERTS');
481
            if (size(me.device.softkeys.path) != 0)
482
                me.screenElements[sprintf("SoftKey%02i-text", 10)]
483
                    .setText('BACK');
484
        }
485

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

            
490
        # feeding with empty menus the first boxes
491
        var start = (contains(path, 'first')) ? path.first : 0;
492
        for (var k = 0; k < start; k+=1) {
493
            me.screenElements[sprintf("SoftKey%02i-text", k)]
494
                .setText('');
495
        }
496
        # filling with the content the next boxes
497
        forindex (var k; path.texts) {
498
            var i = k + start;
499
            me.screenElements[sprintf("SoftKey%02i-text", i)]
500
                .setText(path.texts[k]);
501
        }
502
        # feeding the last boxes with empty string
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
503
        var end = (me.device.role == 'PFD') ? 10 : 12;
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
504
        if (size(path.texts) + start < end) {
505
            start = size(path.texts) + start;
506
            for (var k = start; k < end; k += 1)
507
                me.screenElements[sprintf("SoftKey%02i-text", k)]
508
                    .setText('');
509
        }
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
510

            
511
        if (size(me.device.softkeys.path))
512
            me.timers2.softkeys_inactivity.restart(me.softkeys_inactivity_delay);
513
        else
514
            me.timers2.softkeys_inactivity.stop();
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
515
    },
516
#}}}
517

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
518
    updateAI: func(){
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
519
#{{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
520
        var pitch = data.pitch;
521
        var roll = data.roll;
AI disponible
Sébastien MARQUE authored on 2017-03-10
522
        if (pitch > 80)
523
            pitch = 80;
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
524
        elsif (pitch < -80)
AI disponible
Sébastien MARQUE authored on 2017-03-10
525
            pitch = -80;
526
        me.screenElements.Horizon
fix AI animation
Sébastien MARQUE authored on 2017-03-19
527
            .setCenter(459, 282.8 - 6.849 * pitch)
AI disponible
Sébastien MARQUE authored on 2017-03-10
528
            .setRotation(-roll * D2R)
fix AI animation
Sébastien MARQUE authored on 2017-03-19
529
            .setTranslation(0, pitch * 6.849);
AI disponible, avec bankPoin...
Sébastien MARQUE authored on 2017-03-10
530
        me.screenElements.bankPointer
531
            .setRotation(-roll * D2R);
adds slipskid animation
Sébastien MARQUE authored on 2017-03-24
532
        me.screenElements['SlipSkid']
533
            .setTranslation(getprop("/instrumentation/slip-skid-ball/indicated-slip-skid") * 10, 0);
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
534
        settimer(func me.updateAI(), 0.1);
AI disponible
Sébastien MARQUE authored on 2017-03-10
535
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
536
#}}}
animation VSI
Sébastien MARQUE authored on 2017-03-10
537

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
538
    updateVSI: func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
539
# animate VSI {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
540
        var vsi = data.vsi;
animation VSI
Sébastien MARQUE authored on 2017-03-10
541
        me.screenElements.VSIText
542
            .setText(num(math.round(vsi, 10)));
543
        if (vsi > 4500)
544
            vsi = 4500;
545
        elsif (vsi < -4500)
546
            vsi = -4500;
547
        me.screenElements.VSI
548
            .setTranslation(0, vsi * -0.03465);
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
549
        settimer(func me.updateVSI(), 0.1);
animation VSI
Sébastien MARQUE authored on 2017-03-10
550
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
551
#}}}
animation IAS
Sébastien MARQUE authored on 2017-03-10
552

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
553
    updateIAS: func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
554
# animates the IAS lint (PFD) {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
555
        var ias = data.ias;
animation IAS
Sébastien MARQUE authored on 2017-03-10
556
        if (ias >= 10)
557
            me.screenElements.Speed110
558
                .setText(sprintf("% 2u",num(math.floor(ias/10))));
559
        else
560
            me.screenElements.Speed110
561
                .setText('');
562
        me.screenElements.SpeedLint1
563
            .setTranslation(0,(math.mod(ias,10) + (ias >= 10)*10) * 36);
564
        me.screenElements.SpeedTape
565
            .setTranslation(0,ias * 5.711);
put Vspeeds in common data s...
Sébastien MARQUE authored on 2017-04-11
566
        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
567
            me._ias_already_exceeded = 1;
568
            me.screenElements['IAS-bg']
569
                .setColorFill(1,0,0);
570
        }
put Vspeeds in common data s...
Sébastien MARQUE authored on 2017-04-11
571
        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
572
            me._ias_already_exceeded = 0;
573
            me.screenElements['IAS-bg']
574
                .setColorFill(0,0,0);
575
        }
add V-speeds bugs
Sébastien MARQUE authored on 2017-04-04
576
        foreach (var v; ['Vx', 'Vy', 'Vr', 'Vglide']) {
put Vspeeds in common data s...
Sébastien MARQUE authored on 2017-04-11
577
            if (me.device.data[v ~ '-visible'] and abs(data[v] - ias) < 30)
add V-speeds bugs
Sébastien MARQUE authored on 2017-04-04
578
                me.screenElements['IAS-' ~ v]
put Vspeeds in common data s...
Sébastien MARQUE authored on 2017-04-11
579
                    .setTranslation(0, (ias - data[v]) * 5.711)
add V-speeds bugs
Sébastien MARQUE authored on 2017-04-04
580
                    .show();
581
            else
582
                me.screenElements['IAS-' ~ v]
583
                    .hide();
584
        }
585

            
trends animation
Sébastien MARQUE authored on 2017-03-13
586
        var now = systime();
587
        # estimated speed in 6s
588
        var Sy = 6 * (ias - me._last_ias_kt) / (now - me._last_ias_s);
589
        if (abs(Sy) > 30)
590
            Sy = 30 * abs(Sy)/Sy; # = -30 or 30
591
        me.screenElements['Airspeed-Trend-Indicator']
592
            .setScale(1,Sy)
593
            .setTranslation(0, -284.5 * (Sy - 1));
594
        me._last_ias_kt = ias;
595
        me._last_ias_s = now;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
596
        settimer(func me.updateIAS(), 0.1);
animation IAS
Sébastien MARQUE authored on 2017-03-10
597
    },
trends animation
Sébastien MARQUE authored on 2017-03-13
598
    _last_ias_kt : 0,
599
    _last_ias_s : systime(),
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
600
    _ias_already_exceeded : 0,
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
601
#}}}
animation ALT
Sébastien MARQUE authored on 2017-03-11
602

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
603
    updateTAS: func {
604
# updates the True Airspeed and GroundSpeed indicators {{{
605
        me.screenElements['TAS-text']
606
            .setText(sprintf('%iKT', getprop('/instrumentation/airspeed-indicator/true-speed-kt')));
607
        me.screenElements['GSPD-text']
608
            .setText(sprintf('%iKT', getprop('/velocities/groundspeed-kt')));
609
        settimer(func me.updateTAS(), 0.5);
610
    },
611
#}}}
612

            
613
    updateALT: func () {
614
# animates the altitude lint (PFD) {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
615
        var alt = data.alt;
animation ALT
Sébastien MARQUE authored on 2017-03-11
616
        if (alt < 0)
617
            me.screenElements.Alt11100
618
                .setText(sprintf("% 3i",math.ceil(alt/100)));
619
        elsif (alt < 100)
620
            me.screenElements.Alt11100
621
                .setText('');
622
        else
623
            me.screenElements.Alt11100
624
                .setText(sprintf("% 3i",math.floor(alt/100)));
625
        me.screenElements.AltLint00011
626
            .setTranslation(0,math.fmod(alt,100) * 1.24);
627

            
628
        # From Farmin/G1000 http://wiki.flightgear.org/Project_Farmin/FG1000
629
        if (alt> -1000 and alt< 1000000) {
630
            var Offset10 = 0;
631
            var Offset100 = 0;
632
            var Offset1000 = 0;
633
            if (alt< 0) {
634
                var Ne = 1;
635
                var alt= -alt;
636
            }
637
            else
638
                var Ne = 0;
639

            
640
            var Alt10       = math.mod(alt,100);
641
            var Alt100      = int(math.mod(alt/100,10));
642
            var Alt1000     = int(math.mod(alt/1000,10));
643
            var Alt10000    = int(math.mod(alt/10000,10));
644
            var Alt20       = math.mod(Alt10,20)/20;
645
            if (Alt10 >= 80)
646
                var Alt100 += Alt20;
647

            
648
            if (Alt10 >= 80 and Alt100 >= 9)
649
                var Alt1000 += Alt20;
650

            
651
            if (Alt10 >= 80 and Alt100 >= 9 and Alt1000 >= 9)
652
                var Alt10000 += Alt20;
653

            
654
            if (alt> 100)
655
                var Offset10 = 100;
656

            
657
            if (alt> 1000)
658
                var Offset100 = 10;
659

            
660
            if (alt> 10000)
661
                var Offset1000 = 10;
662

            
663
            if (!Ne) {
664
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*0.57375);
665
                var altCentral = (int(alt/100)*100);
666
            }
667
            elsif (Ne) {
668
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*-0.57375);
669
                var altCentral = -(int(alt/100)*100);
670
            }
671
            me.screenElements["AltBigC"].setText("");
672
            me.screenElements["AltSmallC"].setText("");
673
            for (var place = 1; place <= 6; place += 1) {
674
                var altUP = altCentral + (place*100);
675
                var offset = -30.078;
676
                if (altUP < 0) {
677
                    var altUP = -altUP;
678
                    var prefix = "-";
679
                    var offset += 15.039;
680
                }
681
                else
682
                    var prefix = "";
683

            
684
                if (altUP == 0) {
685
                    var AltBigUP    = "";
686
                    var AltSmallUP  = "0";
687

            
688
                }
689
                elsif (math.mod(altUP,500) == 0 and altUP != 0) {
690
                    var AltBigUP    = sprintf(prefix~"%1d", altUP);
691
                    var AltSmallUP  = "";
692
                }
693
                elsif (altUP < 1000 and (math.mod(altUP,500))) {
694
                    var AltBigUP    = "";
695
                    var AltSmallUP  = sprintf(prefix~"%1d", int(math.mod(altUP,1000)));
696
                    var offset = -30.078;
697
                }
698
                elsif ((altUP < 10000) and (altUP >= 1000) and (math.mod(altUP,500))) {
699
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
700
                    var AltSmallUP  = sprintf("%1d", int(math.mod(altUP,1000)));
701
                    var offset += 15.039;
702
                }
703
                else {
704
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
705
                    var mod = int(math.mod(altUP,1000));
706
                    var AltSmallUP  = sprintf("%1d", mod);
707
                    var offset += 30.078;
708
                }
709

            
710
                me.screenElements["AltBigU"~place].setText(AltBigUP);
711
                me.screenElements["AltSmallU"~place].setText(AltSmallUP);
712
                me.screenElements["AltSmallU"~place].setTranslation(offset,0);
713
                var altDOWN = altCentral - (place*100);
714
                var offset = -30.078;
715
                if (altDOWN < 0) {
716
                    var altDOWN = -altDOWN;
717
                    var prefix = "-";
718
                    var offset += 15.039;
719
                }
720
                else
721
                    var prefix = "";
722

            
723
                if (altDOWN == 0) {
724
                    var AltBigDOWN  = "";
725
                    var AltSmallDOWN    = "0";
726
                }
727
                elsif (math.mod(altDOWN,500) == 0 and altDOWN != 0) {
728
                    var AltBigDOWN  = sprintf(prefix~"%1d", altDOWN);
729
                    var AltSmallDOWN    = "";
730
                }
731
                elsif (altDOWN < 1000 and (math.mod(altDOWN,500))) {
732
                    var AltBigDOWN  = "";
733
                    var AltSmallDOWN    = sprintf(prefix~"%1d", int(math.mod(altDOWN,1000)));
734
                    var offset = -30.078;
735
                }
736
                elsif ((altDOWN < 10000) and (altDOWN >= 1000) and (math.mod(altDOWN,500))) {
737
                    var AltBigDOWN  = sprintf(prefix~"%1d", int(altDOWN/1000));
738
                    var AltSmallDOWN    = sprintf("%1d", int(math.mod(altDOWN,1000)));
739
                    var offset += 15.039;
740
                }
741
                else {
742
                    var AltBigDOWN  = sprintf(prefix~"%1d", int(altDOWN/1000));
743
                    var mod = int(math.mod(altDOWN,1000));
744
                    var AltSmallDOWN    = sprintf("%1d", mod);
745
                    var offset += 30.078;
746
                }
747
                me.screenElements["AltBigD"~place].setText(AltBigDOWN);
748
                me.screenElements["AltSmallD"~place].setText(AltSmallDOWN);
749
                me.screenElements["AltSmallD"~place].setTranslation(offset,0);
750
            }
751
        }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
752
        me.updateSelectedALT();
trends animation
Sébastien MARQUE authored on 2017-03-13
753
        var now = systime();
754
        # altitude in 6s
755
        var Sy = .3 * (alt - me._last_alt_ft) / (now - me._last_alt_s); # scale = 1/20ft
756
        if (abs(Sy) > 15)
757
            Sy = 15 * abs(Sy)/Sy; # = -15 or 15
758
        me.screenElements['Altitude-Trend-Indicator']
759
            .setScale(1,Sy)
760
            .setTranslation(0, -284.5 * (Sy - 1));
761
        me._last_alt_ft = alt;
762
        me._last_alt_s = now;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
763
        settimer(func me.updateALT(), 0.2);
animation ALT
Sébastien MARQUE authored on 2017-03-11
764
    },
trends animation
Sébastien MARQUE authored on 2017-03-13
765
    _last_alt_ft : 0,
766
    _last_alt_s  : systime(),
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
767
#}}}
animation HSI
Sébastien MARQUE authored on 2017-03-11
768

            
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
769
    updateBARO : func () {
770
# update BARO widget {{{
771
        var fmt = me._baro_unit == 'inhg' ? '%.2f%s' : '%i%s';
772
        me.screenElements['BARO-text']
773
            .setText(sprintf(fmt,
774
                        getprop('/instrumentation/altimeter/setting-' ~ me._baro_unit),
775
                        me._baro_unit == 'inhg' ? 'in' : 'hPa')
776
                );
777
    },
778
    _baro_unit : 'inhg',
779
#}}}
780

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
781
    updateHSI : func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
782
# rotates the compass (PFD) {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
783
        var hdg = data.hdg;
animation HSI
Sébastien MARQUE authored on 2017-03-11
784
        me.screenElements.Rose
785
            .setRotation(-hdg * D2R);
786
        me.screenElements['HDG-text']
787
            .setText(sprintf("%03u°", hdg));
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
788
        settimer(func me.updateHSI(), 0.1);
animation HSI
Sébastien MARQUE authored on 2017-03-11
789
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
790
#}}}
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
791

            
removes unecessary listeners
Sébastien MARQUE authored on 2017-04-08
792
    updateHDG : func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
793
# moves the heading bug and display heading-deg for 3 seconds (PFD) {{{
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
794
        if (me.device.role == 'MFD')
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
795
            return;
removes unecessary listeners
Sébastien MARQUE authored on 2017-04-08
796
        var hdg = getprop('/instrumentation/zkv1000/afcs/heading-bug-deg');
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
797
        me.screenElements['Heading-bug']
798
            .setRotation(hdg * D2R);
799
        me.screenElements['SelectedHDG-bg']
800
            .show();
801
        me.screenElements['SelectedHDG-bgtext']
802
            .show();
803
        me.screenElements['SelectedHDG-text']
804
            .setText(sprintf('%03d°%s', hdg, ''))
805
            .show();
806
        me.addTimer(3, ['SelectedHDG-text', 'SelectedHDG-bgtext', 'SelectedHDG-bg']);
807
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
808
#}}}
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
809

            
adds CDI
Sébastien MARQUE authored on 2017-03-18
810
    updateCRS : func () {
anime CRS
Sébastien MARQUE authored on 2017-03-13
811
# TODO: update display for NAV/GPS/BRG courses {{{
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
812
        if (me.device.role == 'MFD')
anime CRS
Sébastien MARQUE authored on 2017-03-13
813
            return;
adds CDI
Sébastien MARQUE authored on 2017-03-18
814
        var source = getprop('/instrumentation/zkv1000/cdi/source');
815
        if (source == 'OFF')
816
            return;
817
        var crs = getprop('/instrumentation/zkv1000/cdi/course');
818
        if (crs == nil)
819
            return;
anime CRS
Sébastien MARQUE authored on 2017-03-13
820
        me.screenElements['SelectedCRS-bg']
821
            .show();
822
        me.screenElements['SelectedCRS-bgtext']
823
            .show();
824
        me.screenElements['SelectedCRS-text']
825
            .setText(sprintf('%03d°%s', crs, ''))
adds CDI
Sébastien MARQUE authored on 2017-03-18
826
            .setColor(source == 'GPS' ? me.colors.magenta : me.colors.green)
anime CRS
Sébastien MARQUE authored on 2017-03-13
827
            .show();
828
        me.addTimer(3, ['SelectedCRS-text', 'SelectedCRS-bgtext', 'SelectedCRS-bg']);
829
    },
830
#}}}
831

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
832
    updateSelectedALT : func {
833
# animation for altitude section, called via updatedALT {{{
creates flightdeck hash to p...
Sébastien MARQUE authored on 2017-04-07
834
        if (! me.screenElements['SelectedALT'].getVisible())
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
835
            return;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
836
        var selected_alt = getprop('/instrumentation/zkv1000/afcs/selected-alt-ft');
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
837
        var delta_alt = data.alt - selected_alt;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
838
        if (abs(delta_alt) > 300)
839
            delta_alt = 300 * abs(delta_alt)/delta_alt;
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
840
        me.screenElements['SelectedALT-symbol']
841
            .setVisible(abs(delta_alt) > 100);
842
        me.screenElements['SelectedALT-bg']
843
            .setVisible(abs(delta_alt) > 100);
844
        me.screenElements['SelectedALT-text']
845
            .setText(sprintf("%i", selected_alt))
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
846
            .setVisible(abs(delta_alt) > 100);
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
847
        me.screenElements['SelectedALT-bug']
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
848
            .setTranslation(0, delta_alt * 0.567); # 170/300 = 0.567
849
    },
850
#}}}
851

            
adds CDI
Sébastien MARQUE authored on 2017-03-18
852
    updateCDI : func {
853
# animation for CDI {{{
854
        var source = getprop('/instrumentation/zkv1000/cdi/source');
855
        if (source == 'OFF') {
856
            foreach (var s; ['GPS', 'NAV1', 'NAV2'])
857
                foreach (var t; ['pointer', 'CDI'])
858
                    me.screenElements[s ~ '-' ~ t].hide();
859
            me.screenElements['CDI-GPS-ANN-text'].hide();
860
            me.screenElements['CDI-GPS-XTK-text'].hide();
861
            me.screenElements['CDI-SRC-text'].hide();
862
            me.screenElements['CDI'].hide();
863
        }
864
        else {
865
            var course = getprop('/instrumentation/zkv1000/cdi/course');
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
866
            var rot = (course - data.hdg) * D2R;
adds CDI
Sébastien MARQUE authored on 2017-03-18
867
            me.screenElements['CDI']
makes the CDI available
Sébastien MARQUE authored on 2017-03-23
868
                .setRotation(rot)
adds CDI
Sébastien MARQUE authored on 2017-03-18
869
                .show();
870
            me.screenElements['GPS-CTI']
animates GPS-CTI
Sébastien MARQUE authored on 2017-03-24
871
                .setVisible(getprop('/instrumentation/gps/wp/wp[1]/valid'))
872
                .setRotation(getprop('/instrumentation/gps/wp/wp[1]/course-deviation-deg') * D2R);
adds CDI
Sébastien MARQUE authored on 2017-03-18
873
            me.screenElements['GPS-CTI-diamond']
animates GPS-CTI
Sébastien MARQUE authored on 2017-03-24
874
                .setVisible(getprop('/instrumentation/gps/wp/wp[1]/valid'))
875
                .setRotation(getprop('/instrumentation/gps/wp/wp[1]/course-deviation-deg') * D2R);
adds CDI
Sébastien MARQUE authored on 2017-03-18
876
            foreach (var s; ['GPS', 'NAV1', 'NAV2']) {
877
                me.screenElements[s ~ '-pointer']
878
                    .setRotation(rot)
879
                    .setVisible(source == s);
880
                me.screenElements[s ~ '-CDI']
881
                    .setVisible(source == s);
882
                foreach (var f; ['FROM', 'TO'])
883
                    me.screenElements[s ~ '-' ~ f]
makes the CDI available
Sébastien MARQUE authored on 2017-03-23
884
                        .setVisible(s == source and getprop('/instrumentation/zkv1000/cdi/' ~ f ~ '-flag'));
adds CDI
Sébastien MARQUE authored on 2017-03-18
885
                me.screenElements['CDI-SRC-text']
886
                    .setText(source)
887
                    .setColor(source == 'GPS' ? me.colors.magenta : me.colors.green)
888
                    .show();
889
            }
makes the CDI available
Sébastien MARQUE authored on 2017-03-23
890
            var deflection = getprop('/instrumentation/zkv1000/cdi/course-deflection');
891
            if (left(source, 3) == 'NAV')
892
                var scale = deflection / 4;
893
            else { # GPS
894
                # TODO: deviation depending of the flight phase
895
                # for now fixed 1 dot = 1 nm course error
896
                var abs_deflection = abs(deflection);
897
                me.screenElements['CDI-GPS-XTK-text']
898
                    .setText(sprintf('XTK %iNM', abs_deflection))
899
                    .setVisible(abs_deflection > 2.4);
900
                var scale = deflection / 2;
901
            }
902
            scale = (abs(scale) > 1.2) ? 1.2 : scale;
903
            me.screenElements[source ~ '-CDI']
904
                .setTranslation(65 * scale, 0);
905
            settimer(func me.updateCDI(), 0.3);
adds CDI
Sébastien MARQUE authored on 2017-03-18
906
        }
907
    },
908
#}}}
909

            
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
910
    _updateRadio: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
911
# common parts for NAV/LOC/COMM radios{{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
912
        # arg[0]._r = <comm|nav>
913
        if (contains(arg[0], "active")) {
914
            if (arg[0]['active'] == 'none') {
915
                me.screenElements[arg[0]._r ~ '1-selected-freq']
916
                    .setColor(1,1,1);
917
                me.screenElements[arg[0]._r ~ '2-selected-freq']
918
                    .setColor(1,1,1);
919
            }
920
            else {
921
                me.screenElements[arg[0]._r ~ arg[0]['active'] ~ '-selected-freq']
922
                    .setColor(0,1,0);
923
                me.screenElements[arg[0]._r ~ arg[0].inactive ~ '-selected-freq']
924
                    .setColor(1,1,1);
925
            }
926
        }
927
        if (contains(arg[0], 'tune')) {
928
            # n = 0 -> NAV1/COMM1
929
            # n = 1 -> NAV1/COMM2
930
            me.screenElements[arg[0]._r ~ '-freq-switch']
931
                .setTranslation(0, arg[0].tune * 25);
932
            me.screenElements[arg[0]._r ~ (arg[0].tune + 1) ~ '-standby-freq']
933
                .setColor(0,1,1);
934
            me.screenElements[arg[0]._r ~ ((arg[0].tune == 0) + 1) ~ '-standby-freq']
935
                .setColor(1,1,1);
936
        }
937
        if (contains(arg[0], 'refresh')) {
small stuff
Sébastien MARQUE authored on 2017-03-22
938
            # refresh only one line: NAV1/COMM1 or NAV2/COMM2
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
939
            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
940
            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-selected-freq']
941
                .setText(sprintf(fmt, getprop('/instrumentation/'
942
                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/selected-mhz')));
943
            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-standby-freq']
944
                .setText(sprintf(fmt, getprop('/instrumentation/'
945
                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/standby-mhz')));
946
        }
947
        if (contains(arg[0], 'set')) {
948
            # positionne la valeur modifiée, les listeners "trigguent" en permanence ces propriétés, donc exit
949
            var n = getprop('/instrumentation/zkv1000/radios/' ~ arg[0]._r ~ '-tune');
950
            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
951
            me.screenElements[arg[0]._r ~ (n + 1) ~ '-standby-freq']
fix freq display while setti...
Sébastien MARQUE authored on 2017-03-16
952
                .setText(sprintf(fmt, getprop('/instrumentation/' ~ arg[0]._r ~ '[' ~ n ~ ']/frequencies/standby-mhz')));
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
953
        }
954
        if (contains(arg[0], 'auto')) {
955
            # pour rafraichir automagiquement, toutes les deux secondes un refresh pour un NAV
956
            var radio = arg[0].auto;
957
            me._updateRadio({refresh: 1, _r: radio});
958
            settimer(func me._updateRadio({refresh: 2, _r: radio}), 1);
959
            settimer(func me._updateRadio({auto: radio}), 2);
960
        }
961
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
962
#}}}
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
963

            
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
964
    updateNAV : func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
965
# update NAV/LOC rodios display upper left (PFD/MFD){{{
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
966
        # made active via menu
967
        if (contains(arg[0], "active")) {
adds CDI
Sébastien MARQUE authored on 2017-03-18
968
            arg[0]._r = 'nav';
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
969
            if (arg[0]['active'] == 'none') {
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
970
                me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
971
                me.screenElements['nav1-id']
972
                    .setColor(1,1,1);
973
                me.screenElements['nav2-id']
974
                    .setColor(1,1,1);
975
                me.screenElements['NAV1-pointer']
976
                    .hide();
977
                me.screenElements['NAV2-pointer']
978
                    .hide();
979
            }
980
            else {
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
981
                arg[0].inactive = (arg[0]['active'] == 1) + 1;
982
                me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
983
                me.screenElements['nav' ~ arg[0]['active'] ~ '-id']
984
                    .setColor(0,1,0);
985
                me.screenElements['NAV' ~ arg[0]['active'] ~ '-pointer']
986
                    .show();
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
987
                me.screenElements['nav' ~ arg[0].inactive ~ '-id']
988
                    .setColor(1,1,1);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
989
#                me.screenElements['HDI']
990
#                    .setRotation();
991
#                me.screenElements['NAV' ~ inactive ~ '-pointer']
992
#                    .hide();
993
#                foreach (var e; [ 'FROM', 'TO', 'CDI' ])
994
#                    me.screenElements['NAV' ~ inactive ~ '-' ~ e]
995
#                        .hide();
996
            }
997
        }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
998
        elsif (contains(arg[0], 'nav-id')) {
Correction swap NAV tuning
Sébastien MARQUE authored on 2017-03-12
999
            # 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
1000
            if (arg[0].val == nil)
1001
                arg[0].val = '';
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1002
            me.screenElements["nav" ~ arg[0]['nav-id'] ~ "-id"]
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1003
                    .setText(arg[0].val);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1004
        }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1005
        else {
1006
            arg[0]._r = 'nav';
1007
            me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1008
        }
1009
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
1010
#}}}
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1011

            
1012
    updateCOMM: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
1013
# update COMM radios display upper right (PFD/MFD){{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1014
        arg[0]._r = 'comm';
1015
        me._updateRadio(arg[0]);
1016
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
1017
#}}}
anime time display
Sébastien MARQUE authored on 2017-03-13
1018

            
1019
    updateTIME : func {
1020
# updates the displayed time botoom left {{{
1021
        me.screenElements['TIME-text']
1022
            .setText(getprop('/sim/time/gmt-string'));
1023
        settimer(func me.updateTIME(), 1);
1024
    },
1025
#}}}
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1026

            
adds transponder
Sébastien MARQUE authored on 2017-03-17
1027
    updateXPDR : func {
1028
# updates transponder display {{{
1029
        for (var d = 0; d < 4; d+=1)
1030
            me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
1031
                .setText(sprintf('%i', getprop('/instrumentation/transponder/inputs/digit[' ~ d ~ ']')));
1032
        var tuning = getprop('/instrumentation/zkv1000/radios/xpdr-tuning-digit');
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
1033
        var fms = getprop('/instrumentation/zkv1000/radios/xpdr-tuning-fms-method');
1034
        for (var d = 0; d < 4; d+=1)
1035
            me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
1036
                .setColor(1,1,1);
1037
        if (tuning != nil) {
1038
            me.screenElements['XPDR-DIGIT-' ~ tuning ~ '-text']
1039
                .setColor(0,1,1);
1040
            if (fms)
1041
                me.screenElements['XPDR-DIGIT-' ~ (tuning - 1) ~ '-text']
1042
                    .setColor(0,1,1);
1043
        }
adds transponder
Sébastien MARQUE authored on 2017-03-17
1044
        else {
1045
            if (getprop('/instrumentation/transponder/ident'))
1046
                var mode = 'IDENT';
1047
            else
1048
                var mode = getprop('/instrumentation/zkv1000/radio/xpdr-mode');
1049
            var wow = getprop('/gear/gear/wow');
1050
            if (! wow and mode != 'STBY')
1051
                var color = [0, 1, 0];
1052
            else
1053
                var color = [1, 1, 1];
1054
            for (var d = 0; d < 4; d+=1)
1055
                me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
1056
                    .setColor(color);
1057
            me.screenElements['XPDR-MODE-text']
1058
                .setColor(color)
1059
                .setText(mode);
1060
        }
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
1061
    },
adds transponder
Sébastien MARQUE authored on 2017-03-17
1062
#}}}
1063

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1064
    updateOAT : func {
1065
# update OAT display on normal and reversionnary modes (every 3s) {{{
1066
        var tmp = getprop('/environment/temperature-deg' ~ me._oat_unit);
1067
        me.screenElements['OAT-text']
1068
            .setText(sprintf((abs(tmp) < 10) ? "%.1f %s" : "%i %s", tmp, (me._oat_unit == 'c') ? '°C' : 'F'));
1069
        settimer(func me.updateOAT(), 3);
1070
    },
1071
    _oat_unit : 'c',
1072
#}}}
1073

            
1074
    updateWindData : func {
1075
# update the window text and arrows for OPTN1/2 {{{
1076
        if (me._winddata_optn == 0)
1077
            return;
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
1078
        if (data.ias < 30) {
improves WindData display
Sébastien MARQUE authored on 2017-03-16
1079
            me.screenElements['WindData-NODATA']
1080
                .hide();
1081
            var wind_hdg = getprop('/environment/wind-from-heading-deg');
1082
            var wind_spd = getprop('/environment/wind-speed-kt');
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
1083
            var alpha = wind_hdg - data.hdg;
improves WindData display
Sébastien MARQUE authored on 2017-03-16
1084
            if (me._winddata_optn == 1) {
1085
                me.screenElements['WindData-OPTN1-HDG']
1086
                    .setRotation((alpha + 180) * D2R)
1087
                    .show();
1088
                me.screenElements['WindData-OPTN1-HDG-text']
1089
                    .setText(sprintf("%03i°", wind_hdg))
1090
                    .show();
1091
                me.screenElements['WindData-OPTN1-SPD-text']
1092
                    .setText(int(wind_spd) ~ 'KT')
1093
                    .show();
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1094
            }
improves WindData display
Sébastien MARQUE authored on 2017-03-16
1095
            else { # me._winddata_optn == 2
1096
                alpha *= D2R;
1097
                var Vt = wind_spd * math.sin(alpha);
1098
                var Ve = wind_spd * math.cos(alpha);
1099
                if (Vt != 0) {
1100
                    me.screenElements['WindData-OPTN2-crosswind-text']
1101
                        .setText(sprintf('%i', abs(Vt)))
1102
                        .show();
1103
                    me.screenElements['WindData-OPTN2-crosswind']
1104
                        .setScale(-abs(Vt)/Vt, 1)
1105
                        .setTranslation(-35 * (abs(Vt)/Vt + 1), 0)
1106
                        .show();
1107
                }
1108
                if (Ve != 0) {
1109
                    me.screenElements['WindData-OPTN2-headwind-text']
1110
                        .setText(sprintf('%i', abs(Ve)))
1111
                        .show();
1112
                    me.screenElements['WindData-OPTN2-headwind']
1113
                        .setScale(1, abs(Ve)/Ve)
1114
                        .setTranslation(0, 515 * (1 - abs(Ve)/Ve))
1115
                        .show();
1116
                }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1117
            }
1118
        }
improves WindData display
Sébastien MARQUE authored on 2017-03-16
1119
        else {
1120
            foreach (var e; [
1121
                    'WindData-OPTN1-HDG',
1122
                    'WindData-OPTN1-HDG-text',
1123
                    'WindData-OPTN1-SPD-text',
1124
                    'WindData-OPTN2-crosswind-text',
1125
                    'WindData-OPTN2-crosswind',
1126
                    'WindData-OPTN2-headwind-text',
1127
                    'WindData-OPTN2-headwind'
1128
            ])
1129
                me.screenElements[e].hide();
1130
            me.screenElements['WindData-NODATA'].show();
1131
        }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1132
        settimer(func me.updateWindData(), 0.5);
1133
    },
1134
    _winddata_optn : 0,
1135
#}}}
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1136

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

            
1142
            var dev = radios.getNode(source).getValue();
1143
            var el  = 'BRG' ~ brg;
1144
            if (dev != 'OFF') {
colorize BRG1/2 when needed,...
Sébastien MARQUE authored on 2017-03-21
1145
                if (size(me.device.softkeys.path) == 1 and me.device.softkeys.path[0] == 'PFD')
1146
                    me.setSoftKeyColor(brg == 1 ? 4 : 6, 1);
1147
                else
1148
                    me.setSoftKeyColor(brg == 1 ? 4 : 6, 0);
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1149
                var info = {
1150
                    pointer : nil,
1151
                    id : 'NO DATA',
1152
                    hdg : nil,
1153
                    dst : '--.-NM'
1154
                };
1155
                if (left(dev, 3) == 'NAV') {
1156
                    info.pointer = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/in-range');
1157
                    if (info.pointer) {
1158
                        info.id  = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/nav-id');
1159
                        info.hdg = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/heading-deg');
1160
                        info.dst = sprintf('%.1d', getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/nav-distance') / 1852); # m -> /1852
1161
                    }
1162
                }
1163
                elsif (dev == 'GPS') {
1164
                    info.pointer = props.getNode('/instrumentation/gps/wp').getChild('wp[1])');
1165
                    if (info.pointer) {
1166
                        info.id  = getprop('/instrumentation/gps/wp/wp[1]/ID');
1167
                        info.hdg = getprop('/instrumentation/gps/wp/wp[1]/bearing-mag-deg');
1168
                        info.dst = sprintf('%.1d', getprop('/instrumentation/gps/wp/wp[1]/distance-nm'));
1169
                    }
1170
                }
1171
                else { # there are 2 available ADF in FG, but instrument manage only 1
1172
                    info.pointer = getprop('/instrumentation/adf/in-range');
1173
                    if (info.pointer) {
1174
                        info.id  = getprop('/instrumentation/adf/ident');
1175
                        info.hdg = getprop('/instrumentation/adf/indicated-bearing-deg');
1176
                    }
1177
                }
1178

            
1179
                if (info.pointer)
1180
                    me.screenElements[el ~ '-pointer']
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
1181
                        .setRotation(-info.hdg - data.hdg * D2R)
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1182
                        .show();
1183
                else
1184
                    me.screenElements[el ~ '-pointer']
1185
                        .hide();
1186
                me.screenElements[el ~ '-SRC-text']
1187
                    .setText(dev);
1188
                me.screenElements[el ~ '-DST-text']
1189
                    .setText(info.dst);
1190
                me.screenElements[el ~ '-WPID-text']
1191
                    .setText(info.id);
1192
                me.screenElements['BRG' ~ brg]
1193
                    .show();
1194
            }
1195
            else {
colorize BRG1/2 when needed,...
Sébastien MARQUE authored on 2017-03-21
1196
                me.setSoftKeyColor(brg == 1 ? 4 : 6, 0);
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1197
                me.screenElements['BRG' ~ brg]
1198
                    .hide();
1199
            }
1200
        }
colorize BRG1/2 when needed,...
Sébastien MARQUE authored on 2017-03-21
1201
        settimer(func me.updateBRG(), 0.5);
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1202
    },
some added comments
Sébastien MARQUE authored on 2017-03-18
1203
#}}}
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
1204

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

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