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

            
commit initial
Sébastien MARQUE authored on 2017-03-07
26
        return m;
27
    },
add new vim folds
Sébastien MARQUE authored on 2017-03-15
28
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
29

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

            
33
    timerTrigger : func {
34
        var now = systime();
35
        foreach (var id; keys(me.timers)) {
36
            if (me.timers[id] < now) {
37
                me.screenElements[id].hide();
38
                delete(me.timers, id);
39
            }
40
        }
41
        settimer(func me.timerTrigger(), 1);
42
    },
43

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

            
commit initial
Sébastien MARQUE authored on 2017-03-07
53
    loadsvg : func () {
54
        me.screen = me.display.createGroup();
55
        me.screen.hide();
path and relpath to zkv1000 ...
Sébastien MARQUE authored on 2017-04-17
56
        canvas.parsesvg(me.screen, data.zkv1000_reldir ~ 'Systems/screen.svg');
commit initial
Sébastien MARQUE authored on 2017-03-07
57
    },
58

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

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

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

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

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
202
            if (me.device.role == 'PFD') {
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
203
                me.updateAI();
204
                me.updateVSI();
205
                me.updateIAS();
206
                me.updateALT();
207
                me.updateHSI();
anime time display
Sébastien MARQUE authored on 2017-03-13
208
                me.updateTIME();
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
209
                me.updateOAT();
210
                me.updateTAS();
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
211
                me.updateBRG();
adds transponder
Sébastien MARQUE authored on 2017-03-17
212
                me.updateXPDR();
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
213
                me.updateBARO();
adds OMI to PFD
Sébastien MARQUE authored on 2017-03-23
214
                me.updateOMI();
ajoute un timer pour cacher ...
Sébastien MARQUE authored on 2017-03-13
215
                me.timerTrigger();
makes map available for PFD ...
Sébastien MARQUE authored on 2017-04-19
216
                me.device.data.mapclip = {
217
                    top: math.ceil(me.screenElements['PFD-Map-bg'].getTransformedBounds()[1]) - 1,
218
                    right: math.ceil(me.screenElements['PFD-Map-bg'].getTransformedBounds()[2]) - 1,
219
                    bottom: math.ceil(me.screenElements['PFD-Map-bg'].getTransformedBounds()[3]) - 1,
220
                    left: math.ceil(me.screenElements['PFD-Map-bg'].getTransformedBounds()[0]) - 1,
221
                };
222
                me.device.data.mapsize = [
223
                    me.device.data.mapclip.right - me.device.data.mapclip.left,
224
                    me.device.data.mapclip.bottom - me.device.data.mapclip.top,
225
                ];
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
226
            }
animation texts EIS + power ...
Sébastien MARQUE authored on 2017-03-19
227
            else {
228
                me.updateEIS();
set MFD map size relative to...
Sébastien MARQUE authored on 2017-04-18
229
                me.device.data.mapclip = {
230
                    top: math.ceil(me.screenElements['Header'].getTransformedBounds()[3]),
231
                    right: me.display.get('view[0]'),
232
                    bottom: math.ceil(me.screenElements['SoftKeysTexts'].getTransformedBounds()[1]),
233
                    left: math.ceil(me.screenElements['EIS'].getTransformedBounds()[2]),
234
                };
235
                me.device.data.mapsize = [
236
                    me.device.data.mapclip.right - me.device.data.mapclip.left,
237
                    me.device.data.mapclip.bottom - me.device.data.mapclip.top,
238
                ];
navaids displayed with corre...
Sébastien MARQUE authored on 2017-04-18
239
                io.load_nasal(data.zkv1000_dir ~ 'Nasal/MFD.pages.nas', 'zkv1000');
adds MFD page selection syst...
Sébastien MARQUE authored on 2017-04-13
240
                me['page selected'] = 0;
241
                me.device.data['page selection'] = [
adds some vim z-folds
Sébastien MARQUE authored on 2017-04-19
242
# {{{
adds MFD page selection syst...
Sébastien MARQUE authored on 2017-04-13
243
                    {
244
                        name: 'MAP',
245
                        objects: [
246
                            {text: 'NAVIGATION MAP'},
247
                            {text: 'TRAFFIC MAP'},
248
                            {text: 'STORMSCOPE'},
249
                            {text: 'WEATHER DATA LINK'},
250
                            {text: 'TAWS-B'},
251
                        ],
252
                    },
253
                    {
254
                        name: 'WPT',
255
                        objects: [
256
                            {text: 'AIRPORT INFORMATION'},
257
                            {text: 'AIRPORT DIRECTORY'},
258
                            {text: 'DEPARTURE INFORMATION'},
259
                            {text: 'ARRIVAL INFORMATION'},
260
                            {text: 'APPROACH INFORMATION'},
261
                            {text: 'WEATHER INFORMATION'},
262
                            {text: 'INTERSECTION INFORMATION'},
263
                            {text: 'NDB INFORMATION'},
264
                            {text: 'VOR INFORMATION'},
265
                            {text: 'USER WAYPOINT INFORMATION'},
266
                        ],
267
                    },
268
                    {
269
                        name: 'AUX',
270
                        objects: [
271
                            {text: 'TRIP PLANNING'},
272
                            {text: 'UTILITY'},
273
                            {text: 'GPS STATUS'},
274
                            {text: 'SYSTEM SETUP'},
275
                        ],
276
                    },
277
                    {
278
                        name: 'FPL',
279
                        objects: [
280
                            {text: 'ACTIVE FLIGHT PLAN'},
281
                            {text: 'WIDE VIEW, NARROW VIEW'},
282
                            {text: 'FLIGHT PLAN CATALOG'},
283
                        ],
284
                    },
285
                    {
286
                        name: 'PROC',
287
                        objects: [
288
                            {text: 'DEPARTURE LOADING'},
289
                            {text: 'ARRIVAL LOADING'},
290
                            {text: 'APPROACH LOADING'},
291
                        ],
292
                    },
293
                    {
294
                        name: 'NRST',
295
                        objects: [
296
                            {text: 'NEAREST AIRPORTS'},
297
                            {text: 'NEAREST INTERSECTIONS'},
298
                            {text: 'NEAREST NDB'},
299
                            {text: 'NEAREST VOR'},
300
                            {text: 'NEAREST USER WAYPOINTS'},
301
                            {text: 'NEAREST FREQUENCIES'},
302
                            {text: 'NEAREST AIRSPACES'},
303
                        ],
304
                    },
adds some vim z-folds
Sébastien MARQUE authored on 2017-04-19
305
# }}}
adds MFD page selection syst...
Sébastien MARQUE authored on 2017-04-13
306
                ];
fix MFD page selection syste...
Sébastien MARQUE authored on 2017-04-13
307
                me.setMFDPages();
animation texts EIS + power ...
Sébastien MARQUE authored on 2017-03-19
308
            }
makes map available for PFD ...
Sébastien MARQUE authored on 2017-04-19
309
            me.device.data.zoom = 10;
310
            me.MapTiles = MapTiles.new(me.device);
311
            me.MapNavaids = PositionedLayer.new(me.device);
312
            if (! contains(data.timers, 'map')) {
313
                data.timers.map = maketimer(1, me, func {
314
                        foreach (var d; keys(flightdeck)) {
315
                            flightdeck[d].display.MapTiles.update();
316
                            flightdeck[d].display.MapNavaids.update();
317
                        }
318
                        var gspd = getprop('/velocities/groundspeed-kt');
319
                        if (gspd != 0)
320
                            var next = (me.device.data['range-nm']/(gspd/3600))/(me.display.get('view[1]')/2);
321
                        else
322
                            var next = 10;
323
                        if (next > 10)
324
                            next = 10;
325
                        data.timers.map.restart(next);
326
                    });
327
                data.timers.map.singleShot = 1;
328
                data.timers.map.start();
329
            }
330

            
fix COMM display standby fre...
Sébastien MARQUE authored on 2017-04-09
331
            me.updateNAV({auto:'nav', tune: radios.getNode('nav-tune').getValue()});
332
            me.updateCOMM({auto:'comm', tune: radios.getNode('comm-tune').getValue()});
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
333
            me.softkeys_inactivity();
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
334
            me.updateSoftKeys();
commit initial
Sébastien MARQUE authored on 2017-03-07
335
            me.progress.removeAllChildren();
336
            me.progress = nil;
337
            me.showInitProgress = nil;
338
            me._showInitProgress = nil;
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
339
            zkv.removeChild(me.device.role ~ 'init', 0);
commit initial
Sébastien MARQUE authored on 2017-03-07
340
        }
341
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
342
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
343

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
344
    showInitProgress : func (name) {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
345
#{{{
commit initial
Sébastien MARQUE authored on 2017-03-07
346
        me.progress = me.display.createGroup();
347
        me.progress.show();
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
348
        me.progress.createChild("text", name ~ " title")
commit initial
Sébastien MARQUE authored on 2017-03-07
349
            .setTranslation(512, 384)
350
            .setAlignment("center-center")
351
            .setFont("LiberationFonts/LiberationSans-Italic.ttf")
352
            .setFontSize(64, 1)
353
            .setColor(1,1,1)
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
354
            .setText("ZKV1000 " ~ name ~ " init");
commit initial
Sébastien MARQUE authored on 2017-03-07
355

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

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
358
        me._showInitProgress(me.progress.createChild("text", name ~ "progress")
commit initial
Sébastien MARQUE authored on 2017-03-07
359
            .setTranslation(512, 484)
360
            .setAlignment("center-center")
361
            .setFont("LiberationFonts/LiberationSans-Bold.ttf")
362
            .setFontSize(128, 1)
363
            .setColor(1,0,0), '.');
364
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
365
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
366

            
some added comments
Sébastien MARQUE authored on 2017-03-18
367
    colors : {
368
# set of predefined colors {{{
369
        green : [0, 1, 0],
370
        white : [1, 1, 1],
371
        black : [0, 0, 0],
372
        lightblue : [0, 1, 1],
373
        darkblue : [0, 0, 1],
374
        red : [1, 0, 0],
adds CDI
Sébastien MARQUE authored on 2017-03-18
375
        magenta : [1, 0, 1],
some added comments
Sébastien MARQUE authored on 2017-03-18
376
    },
377
#}}}
378

            
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
379
    loadGroup : func (h) {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
380
#{{{
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
381
        if (typeof(h) != 'hash') {
382
            msg_dbg(sprintf("%s need a hash, but get a %s from %s",
383
                    caller(0)[0],
384
                    typeof(h),
385
                    caller(1)[0]));
386
            return;
commit initial
Sébastien MARQUE authored on 2017-03-07
387
        }
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
388
        var setMethod = func (e, t) {
389
            if (t == 'hide')
390
                me.screenElements[e].hide();
391
            elsif (t == 'show')
392
                me.screenElements[e].show();
AI disponible
Sébastien MARQUE authored on 2017-03-10
393
            elsif (t == 'rot' or t == 'trans') {
394
                if (! contains(me.screenElements[e], t))
395
                    me.screenElements[e][t] = me.screenElements[e].createTransform();
396
            }
397
            elsif (t == 'clip') {
398
                if (contains(me.clips, e))
399
                    me.screenElements[e].set("clip", me.clips[e]);
400
                else
printlog with adapted level ...
Sébastien MARQUE authored on 2017-03-20
401
                    printlog('warn', 'no defined clip for ' ~ e);
AI disponible
Sébastien MARQUE authored on 2017-03-10
402
            }
animation VSI
Sébastien MARQUE authored on 2017-03-10
403
            elsif (t == 'text') {
404
                if (contains(me.texts, e)) {
405
                    if (contains(me.texts[e], 'alignment'))
406
                        me.screenElements[e].setAlignment(me.texts[e].alignment);
407
                    if (contains(me.texts[e], 'default'))
408
                        me.screenElements[e].setText(me.texts[e].default);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
409
                    if (contains(me.texts[e], 'color'))
410
                        me.screenElements[e].setColor(me.texts[e].color);
adds CDI
Sébastien MARQUE authored on 2017-03-18
411
                    if (contains(me.texts[e], 'visible'))
412
                        me.screenElements[e].setVisible(me.texts[e].visible);
animation VSI
Sébastien MARQUE authored on 2017-03-10
413
                }
printlog with adapted level ...
Sébastien MARQUE authored on 2017-03-20
414
                else
415
                    printlog('debug', 'no text format for ' ~ e);
animation VSI
Sébastien MARQUE authored on 2017-03-10
416
            }
commit initial
Sébastien MARQUE authored on 2017-03-07
417
            else
printlog with adapted level ...
Sébastien MARQUE authored on 2017-03-20
418
                printlog('warn', 'unknown method ' ~ t);
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
419
        };
420
        foreach (var todo; keys(h)) {
421
            if (typeof(h[todo]) != 'vector') h[todo] = [ h[todo] ];
422
            foreach (var id; h[todo]) {
423
                if (! contains(me.screenElements, id)) {
424
                    me.screenElements[id] = me.screen.getElementById(id);
425
                    if (me.screenElements[id] != nil)
426
                        setMethod(id, todo);
427
                    else
printlog with adapted level ...
Sébastien MARQUE authored on 2017-03-20
428
                        printlog('warn', 'SVG ID ' ~ id ~ ' not found');
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
429
                }
430
                else
431
                    setMethod(id, todo);
432
            }
commit initial
Sébastien MARQUE authored on 2017-03-07
433
        }
434
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
435
#}}}
AI disponible
Sébastien MARQUE authored on 2017-03-10
436

            
437
    clips : {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
438
#{{{
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
439
        PitchScale   : "rect(70,664,370,256)",
440
        SpeedLint1   : "rect(252,226,318,204)",
441
        SpeedTape    : "rect(115,239,455,156)",
442
        LintAlt      : "rect(115,808,455,704)",
animation ALT
Sébastien MARQUE authored on 2017-03-11
443
        AltLint00011 : "rect(252,804,318,771)",
AI disponible
Sébastien MARQUE authored on 2017-03-10
444
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
445
#}}}
AI disponible
Sébastien MARQUE authored on 2017-03-10
446

            
animation VSI
Sébastien MARQUE authored on 2017-03-10
447
    texts : {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
448
#{{{
animation VSI
Sébastien MARQUE authored on 2017-03-10
449
        VSIText : {
450
            alignment: "right-bottom", default : num('0'),
451
        },
animation IAS
Sébastien MARQUE authored on 2017-03-10
452
        Speed110 : {
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
453
            alignment : 'left-bottom'
animation IAS
Sébastien MARQUE authored on 2017-03-10
454
        },
animation ALT (2)
Sébastien MARQUE authored on 2017-03-11
455
        Alt11100 : {
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
456
            alignment:'left-bottom'
animation ALT (2)
Sébastien MARQUE authored on 2017-03-11
457
        },
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
458
        "HDG-text" : {
459
            default: '---°'
460
        },
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
461
        'nav1-standby-freq' : {
462
            color: [0, 1, 1],
463
        },
464
        'nav1-id' : {
465
            default: ''
466
        },
467
        'nav2-id' : {
468
            default: ''
469
        },
adds CDI
Sébastien MARQUE authored on 2017-03-18
470
        'CDI-GPS-ANN-text' : {
471
            visible : 0
472
        },
473
        'CDI-GPS-XTK-text' : {
474
            visible : 0
475
        },
476
        'CDI-SRC-text' : {
477
            visible : 0
478
        },
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
479
        'BARO-text' : {
480
            alignment : 'left-bottom',
481
        }
some added comments
Sébastien MARQUE authored on 2017-03-18
482
#        'TAS-text' : {
483
#            alignment : 'right-bottom',
484
#        },
485
#        'GSPD-text' : {
486
#            alignment : 'right-bottom',
487
#        },
animation VSI
Sébastien MARQUE authored on 2017-03-10
488
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
489
#}}}
animation VSI
Sébastien MARQUE authored on 2017-03-10
490

            
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
491
    softkeys_inactivity : func {
492
# automagically back to previous level after some delay {{{
493
        me.timers2.softkeys_inactivity = maketimer (
494
            me.softkeys_inactivity_delay,
495
            func {
496
                pop(me.device.softkeys.path);
497
                me.updateSoftKeys();
498
            }, me);
499
        me.timers2.softkeys_inactivity.singleShot = 1;
500
    },
501
#}}}
502

            
add softkeys colors
Sébastien MARQUE authored on 2017-03-21
503
    setSoftKeyColor : func (n, active, alert = 0) {
504
# set colors for active softkeys {{{
505
        var sftk = sprintf('SoftKey%02i-', n);
506
        if (active) {
507
            var bg = alert ? 1 : 0.5;
508
            me.screenElements[sftk ~ 'bg']
509
                .setColorFill(bg,bg,bg);
510
            me.screenElements[sftk ~ 'text']
511
                .setColor(0,0,0);
512
        }
513
        else {
514
            me.screenElements[sftk ~ 'bg']
515
                .setColorFill(0,0,0);
516
            me.screenElements[sftk ~ 'text']
517
                .setColor(1,1,1);
518
        }
519
    },
520
#}}}
521

            
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
522
    updateSoftKeys : func {
523
# update SoftKeys boxes {{{
524
        # on PFD the last boxes are always BACK and ALERTS
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
525
        if (me.device.role == 'PFD') {
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
526
            me.screenElements[sprintf("SoftKey%02i-text", 11)]
527
                .setText('ALERTS');
528
            if (size(me.device.softkeys.path) != 0)
529
                me.screenElements[sprintf("SoftKey%02i-text", 10)]
530
                    .setText('BACK');
531
        }
532

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
533
        var path = keyMap[me.device.role];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
534
        var pathid = '';
535
        foreach (var p; me.device.softkeys.path) {
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
536
            path = path[p];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
537
            pathid ~= p;
538
        }
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
539

            
540
        # feeding with empty menus the first boxes
541
        var start = (contains(path, 'first')) ? path.first : 0;
542
        for (var k = 0; k < start; k+=1) {
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
543
            var sftk = sprintf("SoftKey%02i-", k);
544
            me.screenElements[sftk ~ 'text']
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
545
                .setText('');
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
546
            me.screenElements[sftk ~ 'bg']
547
                .setColorFill(0,0,0);
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
548
        }
549
        # filling with the content the next boxes
550
        forindex (var k; path.texts) {
551
            var i = k + start;
552
            me.screenElements[sprintf("SoftKey%02i-text", i)]
553
                .setText(path.texts[k]);
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
554
            me.setSoftKeyColor(i,
555
                    contains(me.device.softkeys.colored, pathid ~ path.texts[k]));
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
556
        }
557
        # feeding the last boxes with empty string
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
558
        var end = (me.device.role == 'PFD') ? 10 : 12;
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
559
        if (size(path.texts) + start < end) {
560
            start = size(path.texts) + start;
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
561
            for (var k = start; k < end; k += 1) {
562
                var sftk = sprintf("SoftKey%02i-", k);
563
                me.screenElements[sftk ~ 'text']
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
564
                    .setText('');
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
565
                me.screenElements[sftk ~ 'bg']
566
                    .setColorFill(0,0,0);
567
            }
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
568
        }
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
569

            
570
        if (size(me.device.softkeys.path))
571
            me.timers2.softkeys_inactivity.restart(me.softkeys_inactivity_delay);
572
        else
573
            me.timers2.softkeys_inactivity.stop();
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
574
    },
575
#}}}
576

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
577
    updateAI: func(){
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
578
#{{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
579
        var pitch = data.pitch;
580
        var roll = data.roll;
AI disponible
Sébastien MARQUE authored on 2017-03-10
581
        if (pitch > 80)
582
            pitch = 80;
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
583
        elsif (pitch < -80)
AI disponible
Sébastien MARQUE authored on 2017-03-10
584
            pitch = -80;
585
        me.screenElements.Horizon
fix AI animation
Sébastien MARQUE authored on 2017-03-19
586
            .setCenter(459, 282.8 - 6.849 * pitch)
AI disponible
Sébastien MARQUE authored on 2017-03-10
587
            .setRotation(-roll * D2R)
fix AI animation
Sébastien MARQUE authored on 2017-03-19
588
            .setTranslation(0, pitch * 6.849);
AI disponible, avec bankPoin...
Sébastien MARQUE authored on 2017-03-10
589
        me.screenElements.bankPointer
590
            .setRotation(-roll * D2R);
adds slipskid animation
Sébastien MARQUE authored on 2017-03-24
591
        me.screenElements['SlipSkid']
592
            .setTranslation(getprop("/instrumentation/slip-skid-ball/indicated-slip-skid") * 10, 0);
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
593
        settimer(func me.updateAI(), 0.1);
AI disponible
Sébastien MARQUE authored on 2017-03-10
594
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
595
#}}}
animation VSI
Sébastien MARQUE authored on 2017-03-10
596

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
597
    updateVSI: func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
598
# animate VSI {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
599
        var vsi = data.vsi;
animation VSI
Sébastien MARQUE authored on 2017-03-10
600
        me.screenElements.VSIText
601
            .setText(num(math.round(vsi, 10)));
602
        if (vsi > 4500)
603
            vsi = 4500;
604
        elsif (vsi < -4500)
605
            vsi = -4500;
606
        me.screenElements.VSI
607
            .setTranslation(0, vsi * -0.03465);
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
608
        settimer(func me.updateVSI(), 0.1);
animation VSI
Sébastien MARQUE authored on 2017-03-10
609
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
610
#}}}
animation IAS
Sébastien MARQUE authored on 2017-03-10
611

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
612
    updateIAS: func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
613
# animates the IAS lint (PFD) {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
614
        var ias = data.ias;
animation IAS
Sébastien MARQUE authored on 2017-03-10
615
        if (ias >= 10)
616
            me.screenElements.Speed110
617
                .setText(sprintf("% 2u",num(math.floor(ias/10))));
618
        else
619
            me.screenElements.Speed110
620
                .setText('');
621
        me.screenElements.SpeedLint1
622
            .setTranslation(0,(math.mod(ias,10) + (ias >= 10)*10) * 36);
623
        me.screenElements.SpeedTape
624
            .setTranslation(0,ias * 5.711);
put Vspeeds in common data s...
Sébastien MARQUE authored on 2017-04-11
625
        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
626
            me._ias_already_exceeded = 1;
627
            me.screenElements['IAS-bg']
628
                .setColorFill(1,0,0);
629
        }
put Vspeeds in common data s...
Sébastien MARQUE authored on 2017-04-11
630
        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
631
            me._ias_already_exceeded = 0;
632
            me.screenElements['IAS-bg']
633
                .setColorFill(0,0,0);
634
        }
add V-speeds bugs
Sébastien MARQUE authored on 2017-04-04
635
        foreach (var v; ['Vx', 'Vy', 'Vr', 'Vglide']) {
put Vspeeds in common data s...
Sébastien MARQUE authored on 2017-04-11
636
            if (me.device.data[v ~ '-visible'] and abs(data[v] - ias) < 30)
add V-speeds bugs
Sébastien MARQUE authored on 2017-04-04
637
                me.screenElements['IAS-' ~ v]
put Vspeeds in common data s...
Sébastien MARQUE authored on 2017-04-11
638
                    .setTranslation(0, (ias - data[v]) * 5.711)
add V-speeds bugs
Sébastien MARQUE authored on 2017-04-04
639
                    .show();
640
            else
641
                me.screenElements['IAS-' ~ v]
642
                    .hide();
643
        }
644

            
trends animation
Sébastien MARQUE authored on 2017-03-13
645
        var now = systime();
646
        # estimated speed in 6s
647
        var Sy = 6 * (ias - me._last_ias_kt) / (now - me._last_ias_s);
648
        if (abs(Sy) > 30)
649
            Sy = 30 * abs(Sy)/Sy; # = -30 or 30
650
        me.screenElements['Airspeed-Trend-Indicator']
651
            .setScale(1,Sy)
652
            .setTranslation(0, -284.5 * (Sy - 1));
653
        me._last_ias_kt = ias;
654
        me._last_ias_s = now;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
655
        settimer(func me.updateIAS(), 0.1);
animation IAS
Sébastien MARQUE authored on 2017-03-10
656
    },
trends animation
Sébastien MARQUE authored on 2017-03-13
657
    _last_ias_kt : 0,
658
    _last_ias_s : systime(),
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
659
    _ias_already_exceeded : 0,
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
660
#}}}
animation ALT
Sébastien MARQUE authored on 2017-03-11
661

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
662
    updateTAS: func {
663
# updates the True Airspeed and GroundSpeed indicators {{{
664
        me.screenElements['TAS-text']
665
            .setText(sprintf('%iKT', getprop('/instrumentation/airspeed-indicator/true-speed-kt')));
666
        me.screenElements['GSPD-text']
667
            .setText(sprintf('%iKT', getprop('/velocities/groundspeed-kt')));
668
        settimer(func me.updateTAS(), 0.5);
669
    },
670
#}}}
671

            
672
    updateALT: func () {
673
# animates the altitude lint (PFD) {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
674
        var alt = data.alt;
animation ALT
Sébastien MARQUE authored on 2017-03-11
675
        if (alt < 0)
676
            me.screenElements.Alt11100
677
                .setText(sprintf("% 3i",math.ceil(alt/100)));
678
        elsif (alt < 100)
679
            me.screenElements.Alt11100
680
                .setText('');
681
        else
682
            me.screenElements.Alt11100
683
                .setText(sprintf("% 3i",math.floor(alt/100)));
684
        me.screenElements.AltLint00011
685
            .setTranslation(0,math.fmod(alt,100) * 1.24);
686

            
687
        # From Farmin/G1000 http://wiki.flightgear.org/Project_Farmin/FG1000
688
        if (alt> -1000 and alt< 1000000) {
689
            var Offset10 = 0;
690
            var Offset100 = 0;
691
            var Offset1000 = 0;
692
            if (alt< 0) {
693
                var Ne = 1;
694
                var alt= -alt;
695
            }
696
            else
697
                var Ne = 0;
698

            
699
            var Alt10       = math.mod(alt,100);
700
            var Alt100      = int(math.mod(alt/100,10));
701
            var Alt1000     = int(math.mod(alt/1000,10));
702
            var Alt10000    = int(math.mod(alt/10000,10));
703
            var Alt20       = math.mod(Alt10,20)/20;
704
            if (Alt10 >= 80)
705
                var Alt100 += Alt20;
706

            
707
            if (Alt10 >= 80 and Alt100 >= 9)
708
                var Alt1000 += Alt20;
709

            
710
            if (Alt10 >= 80 and Alt100 >= 9 and Alt1000 >= 9)
711
                var Alt10000 += Alt20;
712

            
713
            if (alt> 100)
714
                var Offset10 = 100;
715

            
716
            if (alt> 1000)
717
                var Offset100 = 10;
718

            
719
            if (alt> 10000)
720
                var Offset1000 = 10;
721

            
722
            if (!Ne) {
723
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*0.57375);
724
                var altCentral = (int(alt/100)*100);
725
            }
726
            elsif (Ne) {
727
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*-0.57375);
728
                var altCentral = -(int(alt/100)*100);
729
            }
730
            me.screenElements["AltBigC"].setText("");
731
            me.screenElements["AltSmallC"].setText("");
732
            for (var place = 1; place <= 6; place += 1) {
733
                var altUP = altCentral + (place*100);
734
                var offset = -30.078;
735
                if (altUP < 0) {
736
                    var altUP = -altUP;
737
                    var prefix = "-";
738
                    var offset += 15.039;
739
                }
740
                else
741
                    var prefix = "";
742

            
743
                if (altUP == 0) {
744
                    var AltBigUP    = "";
745
                    var AltSmallUP  = "0";
746

            
747
                }
748
                elsif (math.mod(altUP,500) == 0 and altUP != 0) {
749
                    var AltBigUP    = sprintf(prefix~"%1d", altUP);
750
                    var AltSmallUP  = "";
751
                }
752
                elsif (altUP < 1000 and (math.mod(altUP,500))) {
753
                    var AltBigUP    = "";
754
                    var AltSmallUP  = sprintf(prefix~"%1d", int(math.mod(altUP,1000)));
755
                    var offset = -30.078;
756
                }
757
                elsif ((altUP < 10000) and (altUP >= 1000) and (math.mod(altUP,500))) {
758
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
759
                    var AltSmallUP  = sprintf("%1d", int(math.mod(altUP,1000)));
760
                    var offset += 15.039;
761
                }
762
                else {
763
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
764
                    var mod = int(math.mod(altUP,1000));
765
                    var AltSmallUP  = sprintf("%1d", mod);
766
                    var offset += 30.078;
767
                }
768

            
769
                me.screenElements["AltBigU"~place].setText(AltBigUP);
770
                me.screenElements["AltSmallU"~place].setText(AltSmallUP);
771
                me.screenElements["AltSmallU"~place].setTranslation(offset,0);
772
                var altDOWN = altCentral - (place*100);
773
                var offset = -30.078;
774
                if (altDOWN < 0) {
775
                    var altDOWN = -altDOWN;
776
                    var prefix = "-";
777
                    var offset += 15.039;
778
                }
779
                else
780
                    var prefix = "";
781

            
782
                if (altDOWN == 0) {
783
                    var AltBigDOWN  = "";
784
                    var AltSmallDOWN    = "0";
785
                }
786
                elsif (math.mod(altDOWN,500) == 0 and altDOWN != 0) {
787
                    var AltBigDOWN  = sprintf(prefix~"%1d", altDOWN);
788
                    var AltSmallDOWN    = "";
789
                }
790
                elsif (altDOWN < 1000 and (math.mod(altDOWN,500))) {
791
                    var AltBigDOWN  = "";
792
                    var AltSmallDOWN    = sprintf(prefix~"%1d", int(math.mod(altDOWN,1000)));
793
                    var offset = -30.078;
794
                }
795
                elsif ((altDOWN < 10000) and (altDOWN >= 1000) and (math.mod(altDOWN,500))) {
796
                    var AltBigDOWN  = sprintf(prefix~"%1d", int(altDOWN/1000));
797
                    var AltSmallDOWN    = sprintf("%1d", int(math.mod(altDOWN,1000)));
798
                    var offset += 15.039;
799
                }
800
                else {
801
                    var AltBigDOWN  = sprintf(prefix~"%1d", int(altDOWN/1000));
802
                    var mod = int(math.mod(altDOWN,1000));
803
                    var AltSmallDOWN    = sprintf("%1d", mod);
804
                    var offset += 30.078;
805
                }
806
                me.screenElements["AltBigD"~place].setText(AltBigDOWN);
807
                me.screenElements["AltSmallD"~place].setText(AltSmallDOWN);
808
                me.screenElements["AltSmallD"~place].setTranslation(offset,0);
809
            }
810
        }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
811
        me.updateSelectedALT();
trends animation
Sébastien MARQUE authored on 2017-03-13
812
        var now = systime();
813
        # altitude in 6s
814
        var Sy = .3 * (alt - me._last_alt_ft) / (now - me._last_alt_s); # scale = 1/20ft
815
        if (abs(Sy) > 15)
816
            Sy = 15 * abs(Sy)/Sy; # = -15 or 15
817
        me.screenElements['Altitude-Trend-Indicator']
818
            .setScale(1,Sy)
819
            .setTranslation(0, -284.5 * (Sy - 1));
820
        me._last_alt_ft = alt;
821
        me._last_alt_s = now;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
822
        settimer(func me.updateALT(), 0.2);
animation ALT
Sébastien MARQUE authored on 2017-03-11
823
    },
trends animation
Sébastien MARQUE authored on 2017-03-13
824
    _last_alt_ft : 0,
825
    _last_alt_s  : systime(),
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
826
#}}}
animation HSI
Sébastien MARQUE authored on 2017-03-11
827

            
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
828
    updateBARO : func () {
829
# update BARO widget {{{
830
        var fmt = me._baro_unit == 'inhg' ? '%.2f%s' : '%i%s';
831
        me.screenElements['BARO-text']
832
            .setText(sprintf(fmt,
833
                        getprop('/instrumentation/altimeter/setting-' ~ me._baro_unit),
834
                        me._baro_unit == 'inhg' ? 'in' : 'hPa')
835
                );
836
    },
837
    _baro_unit : 'inhg',
838
#}}}
839

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
840
    updateHSI : func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
841
# rotates the compass (PFD) {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
842
        var hdg = data.hdg;
animation HSI
Sébastien MARQUE authored on 2017-03-11
843
        me.screenElements.Rose
844
            .setRotation(-hdg * D2R);
845
        me.screenElements['HDG-text']
846
            .setText(sprintf("%03u°", hdg));
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
847
        settimer(func me.updateHSI(), 0.1);
animation HSI
Sébastien MARQUE authored on 2017-03-11
848
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
849
#}}}
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
850

            
removes unecessary listeners
Sébastien MARQUE authored on 2017-04-08
851
    updateHDG : func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
852
# moves the heading bug and display heading-deg for 3 seconds (PFD) {{{
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
853
        if (me.device.role == 'MFD')
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
854
            return;
removes unecessary listeners
Sébastien MARQUE authored on 2017-04-08
855
        var hdg = getprop('/instrumentation/zkv1000/afcs/heading-bug-deg');
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
856
        me.screenElements['Heading-bug']
857
            .setRotation(hdg * D2R);
858
        me.screenElements['SelectedHDG-bg']
859
            .show();
860
        me.screenElements['SelectedHDG-bgtext']
861
            .show();
862
        me.screenElements['SelectedHDG-text']
863
            .setText(sprintf('%03d°%s', hdg, ''))
864
            .show();
865
        me.addTimer(3, ['SelectedHDG-text', 'SelectedHDG-bgtext', 'SelectedHDG-bg']);
866
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
867
#}}}
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
868

            
adds CDI
Sébastien MARQUE authored on 2017-03-18
869
    updateCRS : func () {
anime CRS
Sébastien MARQUE authored on 2017-03-13
870
# TODO: update display for NAV/GPS/BRG courses {{{
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
871
        if (me.device.role == 'MFD')
anime CRS
Sébastien MARQUE authored on 2017-03-13
872
            return;
adds CDI
Sébastien MARQUE authored on 2017-03-18
873
        var source = getprop('/instrumentation/zkv1000/cdi/source');
874
        if (source == 'OFF')
875
            return;
876
        var crs = getprop('/instrumentation/zkv1000/cdi/course');
877
        if (crs == nil)
878
            return;
anime CRS
Sébastien MARQUE authored on 2017-03-13
879
        me.screenElements['SelectedCRS-bg']
880
            .show();
881
        me.screenElements['SelectedCRS-bgtext']
882
            .show();
883
        me.screenElements['SelectedCRS-text']
884
            .setText(sprintf('%03d°%s', crs, ''))
adds CDI
Sébastien MARQUE authored on 2017-03-18
885
            .setColor(source == 'GPS' ? me.colors.magenta : me.colors.green)
anime CRS
Sébastien MARQUE authored on 2017-03-13
886
            .show();
887
        me.addTimer(3, ['SelectedCRS-text', 'SelectedCRS-bgtext', 'SelectedCRS-bg']);
888
    },
889
#}}}
890

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
891
    updateSelectedALT : func {
892
# animation for altitude section, called via updatedALT {{{
creates flightdeck hash to p...
Sébastien MARQUE authored on 2017-04-07
893
        if (! me.screenElements['SelectedALT'].getVisible())
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
894
            return;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
895
        var selected_alt = getprop('/instrumentation/zkv1000/afcs/selected-alt-ft');
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
896
        var delta_alt = data.alt - selected_alt;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
897
        if (abs(delta_alt) > 300)
898
            delta_alt = 300 * abs(delta_alt)/delta_alt;
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
899
        me.screenElements['SelectedALT-symbol']
900
            .setVisible(abs(delta_alt) > 100);
901
        me.screenElements['SelectedALT-bg']
902
            .setVisible(abs(delta_alt) > 100);
903
        me.screenElements['SelectedALT-text']
904
            .setText(sprintf("%i", selected_alt))
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
905
            .setVisible(abs(delta_alt) > 100);
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
906
        me.screenElements['SelectedALT-bug']
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
907
            .setTranslation(0, delta_alt * 0.567); # 170/300 = 0.567
908
    },
909
#}}}
910

            
adds CDI
Sébastien MARQUE authored on 2017-03-18
911
    updateCDI : func {
912
# animation for CDI {{{
913
        var source = getprop('/instrumentation/zkv1000/cdi/source');
914
        if (source == 'OFF') {
915
            foreach (var s; ['GPS', 'NAV1', 'NAV2'])
916
                foreach (var t; ['pointer', 'CDI'])
917
                    me.screenElements[s ~ '-' ~ t].hide();
918
            me.screenElements['CDI-GPS-ANN-text'].hide();
919
            me.screenElements['CDI-GPS-XTK-text'].hide();
920
            me.screenElements['CDI-SRC-text'].hide();
921
            me.screenElements['CDI'].hide();
922
        }
923
        else {
924
            var course = getprop('/instrumentation/zkv1000/cdi/course');
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
925
            var rot = (course - data.hdg) * D2R;
adds CDI
Sébastien MARQUE authored on 2017-03-18
926
            me.screenElements['CDI']
makes the CDI available
Sébastien MARQUE authored on 2017-03-23
927
                .setRotation(rot)
adds CDI
Sébastien MARQUE authored on 2017-03-18
928
                .show();
929
            me.screenElements['GPS-CTI']
animates GPS-CTI
Sébastien MARQUE authored on 2017-03-24
930
                .setVisible(getprop('/instrumentation/gps/wp/wp[1]/valid'))
931
                .setRotation(getprop('/instrumentation/gps/wp/wp[1]/course-deviation-deg') * D2R);
adds CDI
Sébastien MARQUE authored on 2017-03-18
932
            me.screenElements['GPS-CTI-diamond']
animates GPS-CTI
Sébastien MARQUE authored on 2017-03-24
933
                .setVisible(getprop('/instrumentation/gps/wp/wp[1]/valid'))
934
                .setRotation(getprop('/instrumentation/gps/wp/wp[1]/course-deviation-deg') * D2R);
adds CDI
Sébastien MARQUE authored on 2017-03-18
935
            foreach (var s; ['GPS', 'NAV1', 'NAV2']) {
936
                me.screenElements[s ~ '-pointer']
937
                    .setRotation(rot)
938
                    .setVisible(source == s);
939
                me.screenElements[s ~ '-CDI']
940
                    .setVisible(source == s);
941
                foreach (var f; ['FROM', 'TO'])
942
                    me.screenElements[s ~ '-' ~ f]
makes the CDI available
Sébastien MARQUE authored on 2017-03-23
943
                        .setVisible(s == source and getprop('/instrumentation/zkv1000/cdi/' ~ f ~ '-flag'));
adds CDI
Sébastien MARQUE authored on 2017-03-18
944
                me.screenElements['CDI-SRC-text']
945
                    .setText(source)
946
                    .setColor(source == 'GPS' ? me.colors.magenta : me.colors.green)
947
                    .show();
948
            }
makes the CDI available
Sébastien MARQUE authored on 2017-03-23
949
            var deflection = getprop('/instrumentation/zkv1000/cdi/course-deflection');
950
            if (left(source, 3) == 'NAV')
951
                var scale = deflection / 4;
952
            else { # GPS
953
                # TODO: deviation depending of the flight phase
954
                # for now fixed 1 dot = 1 nm course error
955
                var abs_deflection = abs(deflection);
956
                me.screenElements['CDI-GPS-XTK-text']
957
                    .setText(sprintf('XTK %iNM', abs_deflection))
958
                    .setVisible(abs_deflection > 2.4);
959
                var scale = deflection / 2;
960
            }
961
            scale = (abs(scale) > 1.2) ? 1.2 : scale;
962
            me.screenElements[source ~ '-CDI']
963
                .setTranslation(65 * scale, 0);
964
            settimer(func me.updateCDI(), 0.3);
adds CDI
Sébastien MARQUE authored on 2017-03-18
965
        }
966
    },
967
#}}}
968

            
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
969
    _updateRadio: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
970
# common parts for NAV/LOC/COMM radios{{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
971
        # arg[0]._r = <comm|nav>
972
        if (contains(arg[0], "active")) {
973
            if (arg[0]['active'] == 'none') {
974
                me.screenElements[arg[0]._r ~ '1-selected-freq']
975
                    .setColor(1,1,1);
976
                me.screenElements[arg[0]._r ~ '2-selected-freq']
977
                    .setColor(1,1,1);
978
            }
979
            else {
980
                me.screenElements[arg[0]._r ~ arg[0]['active'] ~ '-selected-freq']
981
                    .setColor(0,1,0);
982
                me.screenElements[arg[0]._r ~ arg[0].inactive ~ '-selected-freq']
983
                    .setColor(1,1,1);
984
            }
985
        }
986
        if (contains(arg[0], 'tune')) {
987
            # n = 0 -> NAV1/COMM1
988
            # n = 1 -> NAV1/COMM2
989
            me.screenElements[arg[0]._r ~ '-freq-switch']
990
                .setTranslation(0, arg[0].tune * 25);
991
            me.screenElements[arg[0]._r ~ (arg[0].tune + 1) ~ '-standby-freq']
992
                .setColor(0,1,1);
993
            me.screenElements[arg[0]._r ~ ((arg[0].tune == 0) + 1) ~ '-standby-freq']
994
                .setColor(1,1,1);
995
        }
996
        if (contains(arg[0], 'refresh')) {
small stuff
Sébastien MARQUE authored on 2017-03-22
997
            # refresh only one line: NAV1/COMM1 or NAV2/COMM2
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
998
            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
999
            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-selected-freq']
1000
                .setText(sprintf(fmt, getprop('/instrumentation/'
1001
                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/selected-mhz')));
1002
            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-standby-freq']
1003
                .setText(sprintf(fmt, getprop('/instrumentation/'
1004
                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/standby-mhz')));
1005
        }
1006
        if (contains(arg[0], 'set')) {
1007
            # positionne la valeur modifiée, les listeners "trigguent" en permanence ces propriétés, donc exit
1008
            var n = getprop('/instrumentation/zkv1000/radios/' ~ arg[0]._r ~ '-tune');
1009
            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
1010
            me.screenElements[arg[0]._r ~ (n + 1) ~ '-standby-freq']
fix freq display while setti...
Sébastien MARQUE authored on 2017-03-16
1011
                .setText(sprintf(fmt, getprop('/instrumentation/' ~ arg[0]._r ~ '[' ~ n ~ ']/frequencies/standby-mhz')));
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1012
        }
1013
        if (contains(arg[0], 'auto')) {
1014
            # pour rafraichir automagiquement, toutes les deux secondes un refresh pour un NAV
1015
            var radio = arg[0].auto;
1016
            me._updateRadio({refresh: 1, _r: radio});
1017
            settimer(func me._updateRadio({refresh: 2, _r: radio}), 1);
1018
            settimer(func me._updateRadio({auto: radio}), 2);
1019
        }
1020
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
1021
#}}}
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1022

            
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1023
    updateNAV : func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
1024
# update NAV/LOC rodios display upper left (PFD/MFD){{{
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1025
        # made active via menu
1026
        if (contains(arg[0], "active")) {
adds CDI
Sébastien MARQUE authored on 2017-03-18
1027
            arg[0]._r = 'nav';
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1028
            if (arg[0]['active'] == 'none') {
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1029
                me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1030
                me.screenElements['nav1-id']
1031
                    .setColor(1,1,1);
1032
                me.screenElements['nav2-id']
1033
                    .setColor(1,1,1);
1034
                me.screenElements['NAV1-pointer']
1035
                    .hide();
1036
                me.screenElements['NAV2-pointer']
1037
                    .hide();
1038
            }
1039
            else {
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1040
                arg[0].inactive = (arg[0]['active'] == 1) + 1;
1041
                me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1042
                me.screenElements['nav' ~ arg[0]['active'] ~ '-id']
1043
                    .setColor(0,1,0);
1044
                me.screenElements['NAV' ~ arg[0]['active'] ~ '-pointer']
1045
                    .show();
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1046
                me.screenElements['nav' ~ arg[0].inactive ~ '-id']
1047
                    .setColor(1,1,1);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1048
#                me.screenElements['HDI']
1049
#                    .setRotation();
1050
#                me.screenElements['NAV' ~ inactive ~ '-pointer']
1051
#                    .hide();
1052
#                foreach (var e; [ 'FROM', 'TO', 'CDI' ])
1053
#                    me.screenElements['NAV' ~ inactive ~ '-' ~ e]
1054
#                        .hide();
1055
            }
1056
        }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1057
        elsif (contains(arg[0], 'nav-id')) {
Correction swap NAV tuning
Sébastien MARQUE authored on 2017-03-12
1058
            # 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
1059
            if (arg[0].val == nil)
1060
                arg[0].val = '';
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1061
            me.screenElements["nav" ~ arg[0]['nav-id'] ~ "-id"]
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1062
                    .setText(arg[0].val);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1063
        }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1064
        else {
1065
            arg[0]._r = 'nav';
1066
            me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1067
        }
1068
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
1069
#}}}
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1070

            
1071
    updateCOMM: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
1072
# update COMM radios display upper right (PFD/MFD){{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1073
        arg[0]._r = 'comm';
1074
        me._updateRadio(arg[0]);
1075
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
1076
#}}}
anime time display
Sébastien MARQUE authored on 2017-03-13
1077

            
1078
    updateTIME : func {
1079
# updates the displayed time botoom left {{{
1080
        me.screenElements['TIME-text']
1081
            .setText(getprop('/sim/time/gmt-string'));
1082
        settimer(func me.updateTIME(), 1);
1083
    },
1084
#}}}
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1085

            
adds transponder
Sébastien MARQUE authored on 2017-03-17
1086
    updateXPDR : func {
1087
# updates transponder display {{{
1088
        for (var d = 0; d < 4; d+=1)
1089
            me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
1090
                .setText(sprintf('%i', getprop('/instrumentation/transponder/inputs/digit[' ~ d ~ ']')));
1091
        var tuning = getprop('/instrumentation/zkv1000/radios/xpdr-tuning-digit');
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
1092
        var fms = getprop('/instrumentation/zkv1000/radios/xpdr-tuning-fms-method');
1093
        for (var d = 0; d < 4; d+=1)
1094
            me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
1095
                .setColor(1,1,1);
1096
        if (tuning != nil) {
1097
            me.screenElements['XPDR-DIGIT-' ~ tuning ~ '-text']
1098
                .setColor(0,1,1);
1099
            if (fms)
1100
                me.screenElements['XPDR-DIGIT-' ~ (tuning - 1) ~ '-text']
1101
                    .setColor(0,1,1);
1102
        }
adds transponder
Sébastien MARQUE authored on 2017-03-17
1103
        else {
1104
            if (getprop('/instrumentation/transponder/ident'))
1105
                var mode = 'IDENT';
1106
            else
1107
                var mode = getprop('/instrumentation/zkv1000/radio/xpdr-mode');
1108
            var wow = getprop('/gear/gear/wow');
1109
            if (! wow and mode != 'STBY')
1110
                var color = [0, 1, 0];
1111
            else
1112
                var color = [1, 1, 1];
1113
            for (var d = 0; d < 4; d+=1)
1114
                me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
1115
                    .setColor(color);
1116
            me.screenElements['XPDR-MODE-text']
1117
                .setColor(color)
1118
                .setText(mode);
1119
        }
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
1120
    },
adds transponder
Sébastien MARQUE authored on 2017-03-17
1121
#}}}
1122

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1123
    updateOAT : func {
1124
# update OAT display on normal and reversionnary modes (every 3s) {{{
1125
        var tmp = getprop('/environment/temperature-deg' ~ me._oat_unit);
1126
        me.screenElements['OAT-text']
1127
            .setText(sprintf((abs(tmp) < 10) ? "%.1f %s" : "%i %s", tmp, (me._oat_unit == 'c') ? '°C' : 'F'));
1128
        settimer(func me.updateOAT(), 3);
1129
    },
1130
    _oat_unit : 'c',
1131
#}}}
1132

            
1133
    updateWindData : func {
1134
# update the window text and arrows for OPTN1/2 {{{
1135
        if (me._winddata_optn == 0)
1136
            return;
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
1137
        if (data.ias < 30) {
improves WindData display
Sébastien MARQUE authored on 2017-03-16
1138
            me.screenElements['WindData-NODATA']
1139
                .hide();
1140
            var wind_hdg = getprop('/environment/wind-from-heading-deg');
1141
            var wind_spd = getprop('/environment/wind-speed-kt');
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
1142
            var alpha = wind_hdg - data.hdg;
improves WindData display
Sébastien MARQUE authored on 2017-03-16
1143
            if (me._winddata_optn == 1) {
1144
                me.screenElements['WindData-OPTN1-HDG']
1145
                    .setRotation((alpha + 180) * D2R)
1146
                    .show();
1147
                me.screenElements['WindData-OPTN1-HDG-text']
1148
                    .setText(sprintf("%03i°", wind_hdg))
1149
                    .show();
1150
                me.screenElements['WindData-OPTN1-SPD-text']
1151
                    .setText(int(wind_spd) ~ 'KT')
1152
                    .show();
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1153
            }
improves WindData display
Sébastien MARQUE authored on 2017-03-16
1154
            else { # me._winddata_optn == 2
1155
                alpha *= D2R;
1156
                var Vt = wind_spd * math.sin(alpha);
1157
                var Ve = wind_spd * math.cos(alpha);
1158
                if (Vt != 0) {
1159
                    me.screenElements['WindData-OPTN2-crosswind-text']
1160
                        .setText(sprintf('%i', abs(Vt)))
1161
                        .show();
1162
                    me.screenElements['WindData-OPTN2-crosswind']
1163
                        .setScale(-abs(Vt)/Vt, 1)
1164
                        .setTranslation(-35 * (abs(Vt)/Vt + 1), 0)
1165
                        .show();
1166
                }
1167
                if (Ve != 0) {
1168
                    me.screenElements['WindData-OPTN2-headwind-text']
1169
                        .setText(sprintf('%i', abs(Ve)))
1170
                        .show();
1171
                    me.screenElements['WindData-OPTN2-headwind']
1172
                        .setScale(1, abs(Ve)/Ve)
1173
                        .setTranslation(0, 515 * (1 - abs(Ve)/Ve))
1174
                        .show();
1175
                }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1176
            }
1177
        }
improves WindData display
Sébastien MARQUE authored on 2017-03-16
1178
        else {
1179
            foreach (var e; [
1180
                    'WindData-OPTN1-HDG',
1181
                    'WindData-OPTN1-HDG-text',
1182
                    'WindData-OPTN1-SPD-text',
1183
                    'WindData-OPTN2-crosswind-text',
1184
                    'WindData-OPTN2-crosswind',
1185
                    'WindData-OPTN2-headwind-text',
1186
                    'WindData-OPTN2-headwind'
1187
            ])
1188
                me.screenElements[e].hide();
1189
            me.screenElements['WindData-NODATA'].show();
1190
        }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1191
        settimer(func me.updateWindData(), 0.5);
1192
    },
1193
    _winddata_optn : 0,
1194
#}}}
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1195

            
adds AOA display
Sébastien MARQUE authored on 2017-04-15
1196
    updateAOA : func {
1197
# update Angle Of Attack {{{
1198
        if (me.device.data.aoa == 0)
1199
            return;
1200
        var color = [1,1,1];
1201
        var norm = data.aoa / data['stall-aoa'];
nicer AOA display
Sébastien MARQUE authored on 2017-04-16
1202
        me.screenElements['AOA-text']
1203
            .setText(sprintf('% .1f', norm));
adds AOA display
Sébastien MARQUE authored on 2017-04-15
1204
        if (norm > 1) norm = 1;
1205
        if (norm > 0.9)
1206
            color = [1,0,0];
1207
        elsif (norm > 0.7)
1208
            color = [1,1,0];
1209
        elsif (norm < 0) {
1210
            norm = 0;
1211
            color = [1,0,0];
1212
        }
1213
        me.screenElements['AOA-needle']
1214
            .setRotation(-norm * math.pi)
nicer AOA display
Sébastien MARQUE authored on 2017-04-16
1215
            .setColorFill(color);
1216
        me.screenElements['AOA-text']
adds AOA display
Sébastien MARQUE authored on 2017-04-15
1217
            .setColor(color);
1218
        settimer(func me.updateAOA(), 0.1);
1219
    },
1220
# }}}
1221

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

            
1227
            var dev = radios.getNode(source).getValue();
1228
            var el  = 'BRG' ~ brg;
1229
            if (dev != 'OFF') {
1230
                var info = {
1231
                    pointer : nil,
1232
                    id : 'NO DATA',
1233
                    hdg : nil,
1234
                    dst : '--.-NM'
1235
                };
1236
                if (left(dev, 3) == 'NAV') {
1237
                    info.pointer = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/in-range');
1238
                    if (info.pointer) {
1239
                        info.id  = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/nav-id');
1240
                        info.hdg = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/heading-deg');
1241
                        info.dst = sprintf('%.1d', getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/nav-distance') / 1852); # m -> /1852
1242
                    }
1243
                }
1244
                elsif (dev == 'GPS') {
1245
                    info.pointer = props.getNode('/instrumentation/gps/wp').getChild('wp[1])');
1246
                    if (info.pointer) {
1247
                        info.id  = getprop('/instrumentation/gps/wp/wp[1]/ID');
1248
                        info.hdg = getprop('/instrumentation/gps/wp/wp[1]/bearing-mag-deg');
1249
                        info.dst = sprintf('%.1d', getprop('/instrumentation/gps/wp/wp[1]/distance-nm'));
1250
                    }
1251
                }
1252
                else { # there are 2 available ADF in FG, but instrument manage only 1
1253
                    info.pointer = getprop('/instrumentation/adf/in-range');
1254
                    if (info.pointer) {
1255
                        info.id  = getprop('/instrumentation/adf/ident');
1256
                        info.hdg = getprop('/instrumentation/adf/indicated-bearing-deg');
1257
                    }
1258
                }
1259

            
1260
                if (info.pointer)
1261
                    me.screenElements[el ~ '-pointer']
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
1262
                        .setRotation(-info.hdg - data.hdg * D2R)
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1263
                        .show();
1264
                else
1265
                    me.screenElements[el ~ '-pointer']
1266
                        .hide();
1267
                me.screenElements[el ~ '-SRC-text']
1268
                    .setText(dev);
1269
                me.screenElements[el ~ '-DST-text']
1270
                    .setText(info.dst);
1271
                me.screenElements[el ~ '-WPID-text']
1272
                    .setText(info.id);
1273
                me.screenElements['BRG' ~ brg]
1274
                    .show();
1275
            }
1276
            else {
1277
                me.screenElements['BRG' ~ brg]
1278
                    .hide();
1279
            }
1280
        }
colorize BRG1/2 when needed,...
Sébastien MARQUE authored on 2017-03-21
1281
        settimer(func me.updateBRG(), 0.5);
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1282
    },
some added comments
Sébastien MARQUE authored on 2017-03-18
1283
#}}}
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
1284

            
adds OMI to PFD
Sébastien MARQUE authored on 2017-03-23
1285
    updateOMI : func {
1286
# display marker baecon Outer, Middle, Inner {{{
1287
        var marker = nil;
1288
        foreach (var m; ['outer', 'middle', 'inner'])
1289
            if (getprop('/instrumentation/marker-beacon/' ~ m)) {
1290
                marker = m;
1291
                me.screenElements['OMI']
1292
                    .show();
1293
                break;
1294
            }
1295
        if (marker != nil) {
1296
            me.screenElements['MarkerText']
1297
                .setText(me._omi_data[marker].t)
1298
                .show();
1299
            me.screenElements['MarkerBG']
1300
                .setColorFill(me._omi_data[marker].bg)
1301
                .show();
1302
        }
1303
        else
1304
            me.screenElements['OMI']
1305
                .hide();
1306
        settimer(func me.updateOMI(), 1);
1307
    },
1308
    _omi_data : {
1309
        'outer':  {t: 'O', bg: [0,1,1]},
1310
        'middle': {t: 'M', bg: [1,1,1]},
1311
        'inner':  {t: 'I', bg: [1,1,0]},
1312
    },
1313
#}}}
animation texts EIS + power ...
Sébastien MARQUE authored on 2017-03-19
1314
};
1315

            
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
1316
var keyMap = {
add new vim folds
Sébastien MARQUE authored on 2017-03-15
1317
# softkeys map for PFD and MFD {{{
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
1318
    PFD : {
1319
        first : 1,
1320
        texts : ['INSET', 'SENSOR', 'PFD', 'OBS', 'CDI', 'DME', 'XPDR', 'IDENT', 'TMR/REF', 'NRST' ],
1321
        INSET : {
1322
            texts : ['OFF', 'DCLTR', 'WXLGND', 'TRAFFIC', 'TOPO', 'TERRAIN', 'STRMSCP', 'NEXRAD-C', 'XM LTNG', 'METAR'],
1323
        },
1324
        SENSOR : {
1325
            first : 2,
1326
            texts : [ 'ADC1', 'ADC2', '', 'AHRS1', 'AHRS2'],
1327
        },
1328
        PFD : {
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1329
            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
1330
            'SYN VIS' : {
1331
                texts : [ 'PATHWAY', 'SYN TERR', 'HR2NHDG', 'APTSIGNS', 'FPM'],
1332
            },
1333
            'AOA/WIND' : {
1334
                first : 4,
1335
                texts : ['AOA', 'WIND'],
1336
                AOA : {
1337
                    first : 5,
1338
                    texts : ['AOA ON', 'AOA AUTO'],
1339
                },
1340
                WIND : {
1341
                    first : 2,
1342
                    texts : ['OPTN1', 'OPTN2', '', 'OFF'],
1343
                },
1344
            },
1345
            'HSI FMT' : {
1346
                first : 6,
1347
                texts : ['360 HSI', 'ARC HSI'],
1348
            },
1349
            'ALT UNIT' : {
1350
                first : 5,
1351
                texts : ['METERS', '', 'IN', 'HPA'],
1352
            },
1353
        },
1354
        XPDR : {
1355
            first : 2,
1356
            texts : ['STBY', 'ON', 'ALT', '', 'VFR', 'CODE', 'IDENT'],
1357
            CODE : {
1358
                texts : ['0', '1', '2', '3', '4', '5', '6', '7', 'IDENT', 'BKSP'],
1359
            },
1360
        },
1361
    },
1362
    MFD : {
1363
        texts : ['ENGINE', '', 'MAP', '', '', '', '', '', '', 'DCLTR', 'SHW CHRT', 'CHKLIST'],
1364
        MAP : {
1365
            texts: ['TRAFFIC', 'PROFILE', 'TOPO', 'TERRAIN', 'AIRWAYS', 'STRMSCP','NEXRAD-C', 'XM LTNG', 'METAR', 'LEGEND', 'BACK'],
1366
        },
1367
        CHKLIST : {
1368
            texts : ['ENGINE', '', '', '', '', 'DONE', '', '', '', '', 'EXIT', 'EMERGCY'],
1369
        },
1370
        ENGINE : {
1371
            texts : ['ENGINE', 'ANTI-ICE', '', 'DCLTR', '', 'ASSIST', '', '', '', '', 'FUEL'],
1372
            'ANTI-ICE' : {
1373
                texts : ['LEFT', 'AUTO', 'RIGHT', '', '', '', '', '', '', '', '', 'BACK'],
1374
            },
1375
            FUEL : {
1376
                first : 1,
1377
                texts : ['FULL', 'TABS', '', '', '', '', '', '', '', 'UNDO', 'ENTER'],
1378
            },
1379
        },
1380
    },
1381
};
adds AOA display
Sébastien MARQUE authored on 2017-04-15
1382
if (data['stall-aoa'] == 9999)
1383
    keyMap.PFD.PFD['AOA/WIND'].texts = ['', 'WIND'];
add new vim folds
Sébastien MARQUE authored on 2017-03-15
1384
#}}}