zkv1000 / Nasal / display.nas /
Newer Older
1309 lines | 49.586kb
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,
configurable display size, v...
Sébastien MARQUE authored on 2017-04-15
9
                "size"      : device.data['screen-size'] != nil ? split(',', device.data['screen-size']) : [1024, 768],
10
                "view"      : device.data['screen-view'] != nil ? split(',', device.data['screen-view']) : [1024, 768],
commit initial
Sébastien MARQUE authored on 2017-03-07
11
                "mipmapping": 1
12
        });
13
        m.display.addPlacement({
configurable display size, v...
Sébastien MARQUE authored on 2017-04-15
14
                "node": device.data['screen-object'] != nil ? device.data['screen-object'] : "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];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
487
        var pathid = '';
488
        foreach (var p; me.device.softkeys.path) {
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
489
            path = path[p];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
490
            pathid ~= p;
491
        }
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
492

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

            
523
        if (size(me.device.softkeys.path))
524
            me.timers2.softkeys_inactivity.restart(me.softkeys_inactivity_delay);
525
        else
526
            me.timers2.softkeys_inactivity.stop();
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
527
    },
528
#}}}
529

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

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
550
    updateVSI: func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
551
# animate VSI {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
552
        var vsi = data.vsi;
animation VSI
Sébastien MARQUE authored on 2017-03-10
553
        me.screenElements.VSIText
554
            .setText(num(math.round(vsi, 10)));
555
        if (vsi > 4500)
556
            vsi = 4500;
557
        elsif (vsi < -4500)
558
            vsi = -4500;
559
        me.screenElements.VSI
560
            .setTranslation(0, vsi * -0.03465);
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
561
        settimer(func me.updateVSI(), 0.1);
animation VSI
Sébastien MARQUE authored on 2017-03-10
562
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
563
#}}}
animation IAS
Sébastien MARQUE authored on 2017-03-10
564

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

            
trends animation
Sébastien MARQUE authored on 2017-03-13
598
        var now = systime();
599
        # estimated speed in 6s
600
        var Sy = 6 * (ias - me._last_ias_kt) / (now - me._last_ias_s);
601
        if (abs(Sy) > 30)
602
            Sy = 30 * abs(Sy)/Sy; # = -30 or 30
603
        me.screenElements['Airspeed-Trend-Indicator']
604
            .setScale(1,Sy)
605
            .setTranslation(0, -284.5 * (Sy - 1));
606
        me._last_ias_kt = ias;
607
        me._last_ias_s = now;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
608
        settimer(func me.updateIAS(), 0.1);
animation IAS
Sébastien MARQUE authored on 2017-03-10
609
    },
trends animation
Sébastien MARQUE authored on 2017-03-13
610
    _last_ias_kt : 0,
611
    _last_ias_s : systime(),
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
612
    _ias_already_exceeded : 0,
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
613
#}}}
animation ALT
Sébastien MARQUE authored on 2017-03-11
614

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
615
    updateTAS: func {
616
# updates the True Airspeed and GroundSpeed indicators {{{
617
        me.screenElements['TAS-text']
618
            .setText(sprintf('%iKT', getprop('/instrumentation/airspeed-indicator/true-speed-kt')));
619
        me.screenElements['GSPD-text']
620
            .setText(sprintf('%iKT', getprop('/velocities/groundspeed-kt')));
621
        settimer(func me.updateTAS(), 0.5);
622
    },
623
#}}}
624

            
625
    updateALT: func () {
626
# animates the altitude lint (PFD) {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
627
        var alt = data.alt;
animation ALT
Sébastien MARQUE authored on 2017-03-11
628
        if (alt < 0)
629
            me.screenElements.Alt11100
630
                .setText(sprintf("% 3i",math.ceil(alt/100)));
631
        elsif (alt < 100)
632
            me.screenElements.Alt11100
633
                .setText('');
634
        else
635
            me.screenElements.Alt11100
636
                .setText(sprintf("% 3i",math.floor(alt/100)));
637
        me.screenElements.AltLint00011
638
            .setTranslation(0,math.fmod(alt,100) * 1.24);
639

            
640
        # From Farmin/G1000 http://wiki.flightgear.org/Project_Farmin/FG1000
641
        if (alt> -1000 and alt< 1000000) {
642
            var Offset10 = 0;
643
            var Offset100 = 0;
644
            var Offset1000 = 0;
645
            if (alt< 0) {
646
                var Ne = 1;
647
                var alt= -alt;
648
            }
649
            else
650
                var Ne = 0;
651

            
652
            var Alt10       = math.mod(alt,100);
653
            var Alt100      = int(math.mod(alt/100,10));
654
            var Alt1000     = int(math.mod(alt/1000,10));
655
            var Alt10000    = int(math.mod(alt/10000,10));
656
            var Alt20       = math.mod(Alt10,20)/20;
657
            if (Alt10 >= 80)
658
                var Alt100 += Alt20;
659

            
660
            if (Alt10 >= 80 and Alt100 >= 9)
661
                var Alt1000 += Alt20;
662

            
663
            if (Alt10 >= 80 and Alt100 >= 9 and Alt1000 >= 9)
664
                var Alt10000 += Alt20;
665

            
666
            if (alt> 100)
667
                var Offset10 = 100;
668

            
669
            if (alt> 1000)
670
                var Offset100 = 10;
671

            
672
            if (alt> 10000)
673
                var Offset1000 = 10;
674

            
675
            if (!Ne) {
676
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*0.57375);
677
                var altCentral = (int(alt/100)*100);
678
            }
679
            elsif (Ne) {
680
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*-0.57375);
681
                var altCentral = -(int(alt/100)*100);
682
            }
683
            me.screenElements["AltBigC"].setText("");
684
            me.screenElements["AltSmallC"].setText("");
685
            for (var place = 1; place <= 6; place += 1) {
686
                var altUP = altCentral + (place*100);
687
                var offset = -30.078;
688
                if (altUP < 0) {
689
                    var altUP = -altUP;
690
                    var prefix = "-";
691
                    var offset += 15.039;
692
                }
693
                else
694
                    var prefix = "";
695

            
696
                if (altUP == 0) {
697
                    var AltBigUP    = "";
698
                    var AltSmallUP  = "0";
699

            
700
                }
701
                elsif (math.mod(altUP,500) == 0 and altUP != 0) {
702
                    var AltBigUP    = sprintf(prefix~"%1d", altUP);
703
                    var AltSmallUP  = "";
704
                }
705
                elsif (altUP < 1000 and (math.mod(altUP,500))) {
706
                    var AltBigUP    = "";
707
                    var AltSmallUP  = sprintf(prefix~"%1d", int(math.mod(altUP,1000)));
708
                    var offset = -30.078;
709
                }
710
                elsif ((altUP < 10000) and (altUP >= 1000) and (math.mod(altUP,500))) {
711
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
712
                    var AltSmallUP  = sprintf("%1d", int(math.mod(altUP,1000)));
713
                    var offset += 15.039;
714
                }
715
                else {
716
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
717
                    var mod = int(math.mod(altUP,1000));
718
                    var AltSmallUP  = sprintf("%1d", mod);
719
                    var offset += 30.078;
720
                }
721

            
722
                me.screenElements["AltBigU"~place].setText(AltBigUP);
723
                me.screenElements["AltSmallU"~place].setText(AltSmallUP);
724
                me.screenElements["AltSmallU"~place].setTranslation(offset,0);
725
                var altDOWN = altCentral - (place*100);
726
                var offset = -30.078;
727
                if (altDOWN < 0) {
728
                    var altDOWN = -altDOWN;
729
                    var prefix = "-";
730
                    var offset += 15.039;
731
                }
732
                else
733
                    var prefix = "";
734

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

            
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
781
    updateBARO : func () {
782
# update BARO widget {{{
783
        var fmt = me._baro_unit == 'inhg' ? '%.2f%s' : '%i%s';
784
        me.screenElements['BARO-text']
785
            .setText(sprintf(fmt,
786
                        getprop('/instrumentation/altimeter/setting-' ~ me._baro_unit),
787
                        me._baro_unit == 'inhg' ? 'in' : 'hPa')
788
                );
789
    },
790
    _baro_unit : 'inhg',
791
#}}}
792

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
793
    updateHSI : func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
794
# rotates the compass (PFD) {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
795
        var hdg = data.hdg;
animation HSI
Sébastien MARQUE authored on 2017-03-11
796
        me.screenElements.Rose
797
            .setRotation(-hdg * D2R);
798
        me.screenElements['HDG-text']
799
            .setText(sprintf("%03u°", hdg));
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
800
        settimer(func me.updateHSI(), 0.1);
animation HSI
Sébastien MARQUE authored on 2017-03-11
801
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
802
#}}}
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
803

            
removes unecessary listeners
Sébastien MARQUE authored on 2017-04-08
804
    updateHDG : func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
805
# moves the heading bug and display heading-deg for 3 seconds (PFD) {{{
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
806
        if (me.device.role == 'MFD')
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
807
            return;
removes unecessary listeners
Sébastien MARQUE authored on 2017-04-08
808
        var hdg = getprop('/instrumentation/zkv1000/afcs/heading-bug-deg');
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
809
        me.screenElements['Heading-bug']
810
            .setRotation(hdg * D2R);
811
        me.screenElements['SelectedHDG-bg']
812
            .show();
813
        me.screenElements['SelectedHDG-bgtext']
814
            .show();
815
        me.screenElements['SelectedHDG-text']
816
            .setText(sprintf('%03d°%s', hdg, ''))
817
            .show();
818
        me.addTimer(3, ['SelectedHDG-text', 'SelectedHDG-bgtext', 'SelectedHDG-bg']);
819
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
820
#}}}
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
821

            
adds CDI
Sébastien MARQUE authored on 2017-03-18
822
    updateCRS : func () {
anime CRS
Sébastien MARQUE authored on 2017-03-13
823
# TODO: update display for NAV/GPS/BRG courses {{{
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
824
        if (me.device.role == 'MFD')
anime CRS
Sébastien MARQUE authored on 2017-03-13
825
            return;
adds CDI
Sébastien MARQUE authored on 2017-03-18
826
        var source = getprop('/instrumentation/zkv1000/cdi/source');
827
        if (source == 'OFF')
828
            return;
829
        var crs = getprop('/instrumentation/zkv1000/cdi/course');
830
        if (crs == nil)
831
            return;
anime CRS
Sébastien MARQUE authored on 2017-03-13
832
        me.screenElements['SelectedCRS-bg']
833
            .show();
834
        me.screenElements['SelectedCRS-bgtext']
835
            .show();
836
        me.screenElements['SelectedCRS-text']
837
            .setText(sprintf('%03d°%s', crs, ''))
adds CDI
Sébastien MARQUE authored on 2017-03-18
838
            .setColor(source == 'GPS' ? me.colors.magenta : me.colors.green)
anime CRS
Sébastien MARQUE authored on 2017-03-13
839
            .show();
840
        me.addTimer(3, ['SelectedCRS-text', 'SelectedCRS-bgtext', 'SelectedCRS-bg']);
841
    },
842
#}}}
843

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

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

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

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

            
1024
    updateCOMM: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
1025
# update COMM radios display upper right (PFD/MFD){{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1026
        arg[0]._r = 'comm';
1027
        me._updateRadio(arg[0]);
1028
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
1029
#}}}
anime time display
Sébastien MARQUE authored on 2017-03-13
1030

            
1031
    updateTIME : func {
1032
# updates the displayed time botoom left {{{
1033
        me.screenElements['TIME-text']
1034
            .setText(getprop('/sim/time/gmt-string'));
1035
        settimer(func me.updateTIME(), 1);
1036
    },
1037
#}}}
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1038

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

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1076
    updateOAT : func {
1077
# update OAT display on normal and reversionnary modes (every 3s) {{{
1078
        var tmp = getprop('/environment/temperature-deg' ~ me._oat_unit);
1079
        me.screenElements['OAT-text']
1080
            .setText(sprintf((abs(tmp) < 10) ? "%.1f %s" : "%i %s", tmp, (me._oat_unit == 'c') ? '°C' : 'F'));
1081
        settimer(func me.updateOAT(), 3);
1082
    },
1083
    _oat_unit : 'c',
1084
#}}}
1085

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

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

            
1154
            var dev = radios.getNode(source).getValue();
1155
            var el  = 'BRG' ~ brg;
1156
            if (dev != 'OFF') {
1157
                var info = {
1158
                    pointer : nil,
1159
                    id : 'NO DATA',
1160
                    hdg : nil,
1161
                    dst : '--.-NM'
1162
                };
1163
                if (left(dev, 3) == 'NAV') {
1164
                    info.pointer = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/in-range');
1165
                    if (info.pointer) {
1166
                        info.id  = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/nav-id');
1167
                        info.hdg = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/heading-deg');
1168
                        info.dst = sprintf('%.1d', getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/nav-distance') / 1852); # m -> /1852
1169
                    }
1170
                }
1171
                elsif (dev == 'GPS') {
1172
                    info.pointer = props.getNode('/instrumentation/gps/wp').getChild('wp[1])');
1173
                    if (info.pointer) {
1174
                        info.id  = getprop('/instrumentation/gps/wp/wp[1]/ID');
1175
                        info.hdg = getprop('/instrumentation/gps/wp/wp[1]/bearing-mag-deg');
1176
                        info.dst = sprintf('%.1d', getprop('/instrumentation/gps/wp/wp[1]/distance-nm'));
1177
                    }
1178
                }
1179
                else { # there are 2 available ADF in FG, but instrument manage only 1
1180
                    info.pointer = getprop('/instrumentation/adf/in-range');
1181
                    if (info.pointer) {
1182
                        info.id  = getprop('/instrumentation/adf/ident');
1183
                        info.hdg = getprop('/instrumentation/adf/indicated-bearing-deg');
1184
                    }
1185
                }
1186

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

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

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