zkv1000 / Nasal / display.nas /
Newer Older
1340 lines | 50.569kb
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',
nicer AOA display
Sébastien MARQUE authored on 2017-04-16
155
                    'AOA', 'AOA-needle', 'AOA-text', 'AOA-approach',
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
156
                );
157
                append(groups.clip,
animation IAS
Sébastien MARQUE authored on 2017-03-10
158
                    'SpeedLint1',
animation ALT
Sébastien MARQUE authored on 2017-03-11
159
                    'SpeedTape',
160
                    'LintAlt',
161
                    'AltLint00011'
162
                );
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
163
                append(groups.text,
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
164
                    'SelectedALT-text',
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
165
                    'TAS-text',
166
                    'GSPD-text',
anime time display
Sébastien MARQUE authored on 2017-03-13
167
                    'TIME-text',
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
168
                    'OAT-text',
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
169
                    'VSIText',
170
                    'Speed110',
171
                    'Alt11100',
172
                    'HDG-text',
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
173
                    'BARO-text',
adds CDI
Sébastien MARQUE authored on 2017-03-18
174
                    'CDI-SRC-text', 'CDI-GPS-ANN-text', 'CDI-GPS-XTK-text',
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
175
                    'BRG1-pointer', 'BRG1-SRC-text', 'BRG1-DST-text', 'BRG1-WPID-text',
176
                    'BRG2-pointer', 'BRG2-SRC-text', 'BRG2-DST-text', 'BRG2-WPID-text',
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
177
                    'WindData-OPTN1-HDG-text', 'WindData-OPTN1-SPD-text',
178
                    'WindData-OPTN2-crosswind-text', 'WindData-OPTN2-headwind-text',
adds transponder
Sébastien MARQUE authored on 2017-03-17
179
                    '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
180
                    'AltBigC', 'AltSmallC'
181
                );
182
                for (var place = 1; place <= 6; place +=1) {
183
                    append(groups.text,
184
                        'AltBigU' ~ place,
185
                        'AltSmallU' ~ place,
186
                        'AltBigD' ~ place,
187
                        'AltSmallD' ~ place
188
                    );
189
                }
adds AOA display
Sébastien MARQUE authored on 2017-04-15
190
                me.device.data.aoa = 0;
191
                me.device.data['aoa-auto'] = 0;
animation ALT
Sébastien MARQUE authored on 2017-03-11
192
            }
adds EIS
Sébastien MARQUE authored on 2017-03-18
193
            else {
EIS can be aircraft specific
Sébastien MARQUE authored on 2017-04-04
194
                if (contains(me.parents[0], 'showEIS'))
195
                    me.showEIS(groups);
adds EIS
Sébastien MARQUE authored on 2017-03-18
196
            }
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
197

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

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

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

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

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

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

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

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

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

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

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

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

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
489
        var path = keyMap[me.device.role];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
490
        var pathid = '';
491
        foreach (var p; me.device.softkeys.path) {
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
492
            path = path[p];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
493
            pathid ~= p;
494
        }
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
495

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

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

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

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

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

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

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

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

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

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

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

            
666
            if (Alt10 >= 80 and Alt100 >= 9 and Alt1000 >= 9)
667
                var Alt10000 += Alt20;
668

            
669
            if (alt> 100)
670
                var Offset10 = 100;
671

            
672
            if (alt> 1000)
673
                var Offset100 = 10;
674

            
675
            if (alt> 10000)
676
                var Offset1000 = 10;
677

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

            
699
                if (altUP == 0) {
700
                    var AltBigUP    = "";
701
                    var AltSmallUP  = "0";
702

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
adds AOA display
Sébastien MARQUE authored on 2017-04-15
1152
    updateAOA : func {
1153
# update Angle Of Attack {{{
1154
        if (me.device.data.aoa == 0)
1155
            return;
1156
        var color = [1,1,1];
1157
        var norm = data.aoa / data['stall-aoa'];
nicer AOA display
Sébastien MARQUE authored on 2017-04-16
1158
        me.screenElements['AOA-text']
1159
            .setText(sprintf('% .1f', norm));
adds AOA display
Sébastien MARQUE authored on 2017-04-15
1160
        if (norm > 1) norm = 1;
1161
        if (norm > 0.9)
1162
            color = [1,0,0];
1163
        elsif (norm > 0.7)
1164
            color = [1,1,0];
1165
        elsif (norm < 0) {
1166
            norm = 0;
1167
            color = [1,0,0];
1168
        }
1169
        me.screenElements['AOA-needle']
1170
            .setRotation(-norm * math.pi)
nicer AOA display
Sébastien MARQUE authored on 2017-04-16
1171
            .setColorFill(color);
1172
        me.screenElements['AOA-text']
adds AOA display
Sébastien MARQUE authored on 2017-04-15
1173
            .setColor(color);
1174
        settimer(func me.updateAOA(), 0.1);
1175
    },
1176
# }}}
1177

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

            
1183
            var dev = radios.getNode(source).getValue();
1184
            var el  = 'BRG' ~ brg;
1185
            if (dev != 'OFF') {
1186
                var info = {
1187
                    pointer : nil,
1188
                    id : 'NO DATA',
1189
                    hdg : nil,
1190
                    dst : '--.-NM'
1191
                };
1192
                if (left(dev, 3) == 'NAV') {
1193
                    info.pointer = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/in-range');
1194
                    if (info.pointer) {
1195
                        info.id  = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/nav-id');
1196
                        info.hdg = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/heading-deg');
1197
                        info.dst = sprintf('%.1d', getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/nav-distance') / 1852); # m -> /1852
1198
                    }
1199
                }
1200
                elsif (dev == 'GPS') {
1201
                    info.pointer = props.getNode('/instrumentation/gps/wp').getChild('wp[1])');
1202
                    if (info.pointer) {
1203
                        info.id  = getprop('/instrumentation/gps/wp/wp[1]/ID');
1204
                        info.hdg = getprop('/instrumentation/gps/wp/wp[1]/bearing-mag-deg');
1205
                        info.dst = sprintf('%.1d', getprop('/instrumentation/gps/wp/wp[1]/distance-nm'));
1206
                    }
1207
                }
1208
                else { # there are 2 available ADF in FG, but instrument manage only 1
1209
                    info.pointer = getprop('/instrumentation/adf/in-range');
1210
                    if (info.pointer) {
1211
                        info.id  = getprop('/instrumentation/adf/ident');
1212
                        info.hdg = getprop('/instrumentation/adf/indicated-bearing-deg');
1213
                    }
1214
                }
1215

            
1216
                if (info.pointer)
1217
                    me.screenElements[el ~ '-pointer']
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
1218
                        .setRotation(-info.hdg - data.hdg * D2R)
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1219
                        .show();
1220
                else
1221
                    me.screenElements[el ~ '-pointer']
1222
                        .hide();
1223
                me.screenElements[el ~ '-SRC-text']
1224
                    .setText(dev);
1225
                me.screenElements[el ~ '-DST-text']
1226
                    .setText(info.dst);
1227
                me.screenElements[el ~ '-WPID-text']
1228
                    .setText(info.id);
1229
                me.screenElements['BRG' ~ brg]
1230
                    .show();
1231
            }
1232
            else {
1233
                me.screenElements['BRG' ~ brg]
1234
                    .hide();
1235
            }
1236
        }
colorize BRG1/2 when needed,...
Sébastien MARQUE authored on 2017-03-21
1237
        settimer(func me.updateBRG(), 0.5);
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1238
    },
some added comments
Sébastien MARQUE authored on 2017-03-18
1239
#}}}
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
1240

            
adds OMI to PFD
Sébastien MARQUE authored on 2017-03-23
1241
    updateOMI : func {
1242
# display marker baecon Outer, Middle, Inner {{{
1243
        var marker = nil;
1244
        foreach (var m; ['outer', 'middle', 'inner'])
1245
            if (getprop('/instrumentation/marker-beacon/' ~ m)) {
1246
                marker = m;
1247
                me.screenElements['OMI']
1248
                    .show();
1249
                break;
1250
            }
1251
        if (marker != nil) {
1252
            me.screenElements['MarkerText']
1253
                .setText(me._omi_data[marker].t)
1254
                .show();
1255
            me.screenElements['MarkerBG']
1256
                .setColorFill(me._omi_data[marker].bg)
1257
                .show();
1258
        }
1259
        else
1260
            me.screenElements['OMI']
1261
                .hide();
1262
        settimer(func me.updateOMI(), 1);
1263
    },
1264
    _omi_data : {
1265
        'outer':  {t: 'O', bg: [0,1,1]},
1266
        'middle': {t: 'M', bg: [1,1,1]},
1267
        'inner':  {t: 'I', bg: [1,1,0]},
1268
    },
1269
#}}}
animation texts EIS + power ...
Sébastien MARQUE authored on 2017-03-19
1270
};
1271

            
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
1272
var keyMap = {
add new vim folds
Sébastien MARQUE authored on 2017-03-15
1273
# softkeys map for PFD and MFD {{{
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
1274
    PFD : {
1275
        first : 1,
1276
        texts : ['INSET', 'SENSOR', 'PFD', 'OBS', 'CDI', 'DME', 'XPDR', 'IDENT', 'TMR/REF', 'NRST' ],
1277
        INSET : {
1278
            texts : ['OFF', 'DCLTR', 'WXLGND', 'TRAFFIC', 'TOPO', 'TERRAIN', 'STRMSCP', 'NEXRAD-C', 'XM LTNG', 'METAR'],
1279
        },
1280
        SENSOR : {
1281
            first : 2,
1282
            texts : [ 'ADC1', 'ADC2', '', 'AHRS1', 'AHRS2'],
1283
        },
1284
        PFD : {
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1285
            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
1286
            'SYN VIS' : {
1287
                texts : [ 'PATHWAY', 'SYN TERR', 'HR2NHDG', 'APTSIGNS', 'FPM'],
1288
            },
1289
            'AOA/WIND' : {
1290
                first : 4,
1291
                texts : ['AOA', 'WIND'],
1292
                AOA : {
1293
                    first : 5,
1294
                    texts : ['AOA ON', 'AOA AUTO'],
1295
                },
1296
                WIND : {
1297
                    first : 2,
1298
                    texts : ['OPTN1', 'OPTN2', '', 'OFF'],
1299
                },
1300
            },
1301
            'HSI FMT' : {
1302
                first : 6,
1303
                texts : ['360 HSI', 'ARC HSI'],
1304
            },
1305
            'ALT UNIT' : {
1306
                first : 5,
1307
                texts : ['METERS', '', 'IN', 'HPA'],
1308
            },
1309
        },
1310
        XPDR : {
1311
            first : 2,
1312
            texts : ['STBY', 'ON', 'ALT', '', 'VFR', 'CODE', 'IDENT'],
1313
            CODE : {
1314
                texts : ['0', '1', '2', '3', '4', '5', '6', '7', 'IDENT', 'BKSP'],
1315
            },
1316
        },
1317
    },
1318
    MFD : {
1319
        texts : ['ENGINE', '', 'MAP', '', '', '', '', '', '', 'DCLTR', 'SHW CHRT', 'CHKLIST'],
1320
        MAP : {
1321
            texts: ['TRAFFIC', 'PROFILE', 'TOPO', 'TERRAIN', 'AIRWAYS', 'STRMSCP','NEXRAD-C', 'XM LTNG', 'METAR', 'LEGEND', 'BACK'],
1322
        },
1323
        CHKLIST : {
1324
            texts : ['ENGINE', '', '', '', '', 'DONE', '', '', '', '', 'EXIT', 'EMERGCY'],
1325
        },
1326
        ENGINE : {
1327
            texts : ['ENGINE', 'ANTI-ICE', '', 'DCLTR', '', 'ASSIST', '', '', '', '', 'FUEL'],
1328
            'ANTI-ICE' : {
1329
                texts : ['LEFT', 'AUTO', 'RIGHT', '', '', '', '', '', '', '', '', 'BACK'],
1330
            },
1331
            FUEL : {
1332
                first : 1,
1333
                texts : ['FULL', 'TABS', '', '', '', '', '', '', '', 'UNDO', 'ENTER'],
1334
            },
1335
        },
1336
    },
1337
};
adds AOA display
Sébastien MARQUE authored on 2017-04-15
1338
if (data['stall-aoa'] == 9999)
1339
    keyMap.PFD.PFD['AOA/WIND'].texts = ['', 'WIND'];
add new vim folds
Sébastien MARQUE authored on 2017-03-15
1340
#}}}