zkv1000 / Nasal / display.nas /
Newer Older
1291 lines | 49.205kb
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,
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
9
                "size"      : [1280, 1280],
10
                "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
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
16
            });
commit initial
Sébastien MARQUE authored on 2017-03-07
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 = {};
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
21
        m.screen = m.display
22
            .createGroup()
23
            .show();
commit initial
Sébastien MARQUE authored on 2017-03-07
24

            
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
25
        m.timers2 = {}; # tho old timer implementation use already a named timer hash
26
        # Softkeys revert to the previous level after 45 seconds of inactivity.
27
        m.softkeys_inactivity_delay = 45;
28

            
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
29
            var groups = {
animation VSI
Sébastien MARQUE authored on 2017-03-10
30
                show : [
makes header visible on MFD ...
Sébastien MARQUE authored on 2017-03-18
31
                    'Header',
commit initial
Sébastien MARQUE authored on 2017-03-07
32
                    'SoftKeysTexts', 
33
                    'COMM', 
34
                    'NAV', 
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
35
                    'nav-freq-switch',
36
                    'comm-freq-switch',
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
37
                ],
38
                text: [
39
                    'nav1-standby-freq', 'nav1-selected-freq', 'nav1-id',
40
                    'nav2-standby-freq', 'nav2-selected-freq', 'nav2-id',
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
41
                    'comm1-standby-freq', 'comm1-selected-freq',
42
                    'comm2-standby-freq', 'comm2-selected-freq',
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
43
                ],
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
44
                hide : [ 'Failures', 'NAV-COMM-Failures' ],
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
45
                clip: [ ],
46
            };
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
47

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

            
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
53
            if (m.device.role == 'PFD') {
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
54
                append(groups.show,
adds some vim z-folds
Sébastien MARQUE authored on 2017-04-19
55
# {{{
commit initial
Sébastien MARQUE authored on 2017-03-07
56
                    'XPDR-TIME', 
AI disponible
Sébastien MARQUE authored on 2017-03-10
57
                    'FlightInstruments',
58
                    'Horizon',
AI disponible, avec bankPoin...
Sébastien MARQUE authored on 2017-03-10
59
                    'bankPointer',
animation VSI
Sébastien MARQUE authored on 2017-03-10
60
                    'VSI',
animation HSI
Sébastien MARQUE authored on 2017-03-11
61
                    'Rose',
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
62
                    'Heading-bug',
63
                    'PFD-Widgets',
trends animation
Sébastien MARQUE authored on 2017-03-13
64
                    'Trends',
65
                    'Airspeed-Trend-Indicator',
66
                    'Altitude-Trend-Indicator',
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
67
                    'OAT',
68
                    'IAS-bg',
69
                    'TAS',
70
                    'GSPD',
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
71
                    'BARO-bg',
adds slipskid animation
Sébastien MARQUE authored on 2017-03-24
72
                    'SlipSkid',
add V-speeds bugs
Sébastien MARQUE authored on 2017-04-04
73
                    'IAS-Vx', 'IAS-Vy', 'IAS-Vr', 'IAS-Vglide',
adds some vim z-folds
Sébastien MARQUE authored on 2017-04-19
74
# }}}
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
75
                );
76
                append(groups.hide,
adds some vim z-folds
Sébastien MARQUE authored on 2017-04-19
77
# {{{
adds EIS
Sébastien MARQUE authored on 2017-03-18
78
                    'EIS',
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
79
                    'CDI',
adds OMI to PFD
Sébastien MARQUE authored on 2017-03-23
80
                    'OMI', 'MarkerBG', 'MarkerText',
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
81
                    'VDI',
adds CDI
Sébastien MARQUE authored on 2017-03-18
82
                    'NAV1-pointer', 'NAV1-CDI', 'NAV1-FROM', 'NAV1-TO',
83
                    'NAV2-pointer', 'NAV2-CDI', 'NAV2-FROM', 'NAV2-TO',
84
                    '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
85
                    'BRG1-pointer',
86
                    'BRG2-pointer',
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
87
                    'SelectedHDG-bg',
88
                    'SelectedHDG-bgtext',
89
                    'SelectedHDG-text',
90
                    'SelectedCRS-bg',
91
                    'SelectedCRS-bgtext',
92
                    'SelectedCRS-text',
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
93
                    'SelectedALT', 'SelectedALT-bug', 'SelectedALT-bg', 'SelectedALT-symbol',
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
94
                    'TAS',
95
                    'GSPD',
96
                    'WindData',
97
                    'Reversionnary',
98
                    'Annunciation',
99
                    'Comparator',
100
                    'BRG1',
101
                    'BRG2',
102
                    'DME1',
makes map available for PFD ...
Sébastien MARQUE authored on 2017-04-19
103
                    'PFD-Map-bg',
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
104
                    'PFD-Multilines',
hide orientation on Inset ma...
Sébastien MARQUE authored on 2017-05-24
105
                    'MapOrientation',
improves WindData display
Sébastien MARQUE authored on 2017-03-16
106
                    '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
107
                    'AOA', 'AOA-needle', 'AOA-text', 'AOA-approach',
add navigation infos on head...
Sébastien MARQUE authored on 2017-05-24
108
                    'MFD-navbox',
add TCAS
Sébastien MARQUE authored on 2017-12-21
109
                    'Traffic',
adds some vim z-folds
Sébastien MARQUE authored on 2017-04-19
110
# }}}
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
111
                );
112
                append(groups.clip,
adds some vim z-folds
Sébastien MARQUE authored on 2017-04-19
113
# {{{
animation IAS
Sébastien MARQUE authored on 2017-03-10
114
                    'SpeedLint1',
animation ALT
Sébastien MARQUE authored on 2017-03-11
115
                    'SpeedTape',
116
                    'LintAlt',
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
117
                    'AltLint00011',
118
                    'PitchScale',
adds some vim z-folds
Sébastien MARQUE authored on 2017-04-19
119
# }}}
animation ALT
Sébastien MARQUE authored on 2017-03-11
120
                );
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
121
                append(groups.text,
adds some vim z-folds
Sébastien MARQUE authored on 2017-04-19
122
# {{{
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
123
                    'SelectedALT-text',
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
124
                    'TAS-text',
125
                    'GSPD-text',
anime time display
Sébastien MARQUE authored on 2017-03-13
126
                    'TIME-text',
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
127
                    'OAT-text',
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
128
                    'VSIText',
129
                    'Speed110',
130
                    'Alt11100',
131
                    'HDG-text',
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
132
                    'BARO-text',
adds CDI
Sébastien MARQUE authored on 2017-03-18
133
                    'CDI-SRC-text', 'CDI-GPS-ANN-text', 'CDI-GPS-XTK-text',
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
134
                    'BRG1-pointer', 'BRG1-SRC-text', 'BRG1-DST-text', 'BRG1-WPID-text',
135
                    'BRG2-pointer', 'BRG2-SRC-text', 'BRG2-DST-text', 'BRG2-WPID-text',
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
136
                    'WindData-OPTN1-HDG-text', 'WindData-OPTN1-SPD-text',
137
                    'WindData-OPTN2-crosswind-text', 'WindData-OPTN2-headwind-text',
adds transponder
Sébastien MARQUE authored on 2017-03-17
138
                    'XPDR-MODE-text', 'XPDR-DIGIT-3-text', 'XPDR-DIGIT-2-text', 'XPDR-DIGIT-1-text', 'XPDR-DIGIT-0-text',
add navigation infos on head...
Sébastien MARQUE authored on 2017-05-24
139
                    'ETE', 'ETE-text', 'DIS', 'DIS-text', 'LEG-text',
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
140
                    'AltBigC', 'AltSmallC'
adds some vim z-folds
Sébastien MARQUE authored on 2017-04-19
141
# }}}
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
142
                );
143
                for (var place = 1; place <= 6; place +=1) {
144
                    append(groups.text,
145
                        'AltBigU' ~ place,
146
                        'AltSmallU' ~ place,
147
                        'AltBigD' ~ place,
148
                        'AltSmallD' ~ place
149
                    );
150
                }
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
151
                canvas.parsesvg(m.screen, data.zkv1000_reldir ~ 'Systems/PFD.svg');
animation ALT
Sébastien MARQUE authored on 2017-03-11
152
            }
adds EIS
Sébastien MARQUE authored on 2017-03-18
153
            else {
EIS now really specific to a...
Sébastien MARQUE authored on 2017-04-20
154
                var eis_file = getprop('/instrumentation/zkv1000/eis/type');
155
                if (eis_file == nil)
156
                    eis_file = getprop('/instrumentation/zkv1000/eis/file');
157

            
158
                if (eis_file != nil) {
159
                    if (find('/', eis_file) == -1)
160
                        eis_file = data.zkv1000_dir ~ 'Nasal/EIS/' ~ eis_file ~ '.nas';
161
                    elsif (split('/', eis_file)[0] == 'Aircraft') {
162
                        var path = split('/', eis_file);
163
                        if (getprop('/sim/fg-aircraft') != nil) {
164
                            eis_file = getprop('/sim/fg-aircraft');
165
                            for (var i = 1; i < size(path); i += 1)
166
                                eis_file ~= '/' ~ path[i];
167
                        }
168
                        else
169
                            eis_file = getprop('/sim/fg-root') ~ '/' ~ eis_file;
170
                    }
171
                }
172
                else
173
                    eis_file = data.zkv1000_dir ~ 'Nasal/EIS/none.nas';
174

            
175
                if (io.stat(eis_file) == nil
176
                and print(eis_file ~ ' not found'))
177
                    eis_file = data.zkv1000_dir ~ 'Nasal/EIS/none.nas';
178
                io.load_nasal(eis_file, 'zkv1000');
179

            
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
180
                if (contains(m.parents[0], 'showEIS'))
181
                    m.showEIS(groups);
add navigation infos on head...
Sébastien MARQUE authored on 2017-05-24
182

            
183
                append(groups.hide, 'PFD-navbox');
184
                for (var i=1; i <= 4; i+=1)
185
                    foreach (var t; ['ID', 'VAL'])
186
                        append(groups.text, 'DATA-FIELD' ~ i ~ '-' ~ t ~ '-text');
adds EIS
Sébastien MARQUE authored on 2017-03-18
187
            }
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
188

            
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
189
            canvas.parsesvg(m.screen, data.zkv1000_reldir ~ 'Systems/softkeys.svg');
190
            canvas.parsesvg(m.screen, data.zkv1000_reldir ~ 'Systems/header-nav-comm.svg');
animation ALT
Sébastien MARQUE authored on 2017-03-11
191

            
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
192
            m.loadGroup(groups);
193

            
194
            if (m.device.role == 'PFD') {
195
                m.device.data.aoa = 0;
196
                m.device.data['aoa-auto'] = 0;
197
                m.device.data.mapclip = {
198
                    top: math.ceil(m.screenElements['PFD-Map-bg'].getTransformedBounds()[1]) - 1,
199
                    right: math.ceil(m.screenElements['PFD-Map-bg'].getTransformedBounds()[2]) - 1,
200
                    bottom: math.ceil(m.screenElements['PFD-Map-bg'].getTransformedBounds()[3]) - 1,
201
                    left: math.ceil(m.screenElements['PFD-Map-bg'].getTransformedBounds()[0]) - 1,
makes map available for PFD ...
Sébastien MARQUE authored on 2017-04-19
202
                };
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
203
            }
animation texts EIS + power ...
Sébastien MARQUE authored on 2017-03-19
204
            else {
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
205
                m.device.data.mapclip = {
206
                    top: math.ceil(m.screenElements['Header'].getTransformedBounds()[3]),
207
                    right: m.display.get('view[0]'),
208
                    bottom: math.ceil(m.screenElements['SoftKeysTexts'].getTransformedBounds()[1]),
209
                    left: contains(m.screenElements, 'EIS') ? math.ceil(m.screenElements['EIS'].getTransformedBounds()[2]) : 0,
set MFD map size relative to...
Sébastien MARQUE authored on 2017-04-18
210
                };
makes map available for PFD ...
Sébastien MARQUE authored on 2017-04-19
211
            }
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
212
        return m;
213
    },
214
#}}}
makes map available for PFD ...
Sébastien MARQUE authored on 2017-04-19
215

            
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
216
# timers stuff {{{
217
    timers : {},
218

            
219
    timerTrigger : func {
220
        var now = systime();
221
        foreach (var id; keys(me.timers)) {
222
            if (me.timers[id] < now) {
223
                me.screenElements[id].hide();
224
                delete(me.timers, id);
225
            }
commit initial
Sébastien MARQUE authored on 2017-03-07
226
        }
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
227
        settimer(func me.timerTrigger(), 1);
228
    },
229

            
230
    addTimer : func (duration, element) {
231
        if (typeof(element) == 'scalar')
232
            element = [ element ];
233
        var end = systime() + duration;
234
        foreach (var e; element)
235
            me.timers[e] = end;
commit initial
Sébastien MARQUE authored on 2017-03-07
236
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
237
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
238

            
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
239
    showInitProgress : func {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
240
#{{{
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
241
        if (me.device.role == 'PFD') {
242
            me.updateAI();
243
            me.updateVSI();
244
            me.updateIAS();
245
            me.updateALT();
246
            me.updateHSI();
247
            me.updateTIME();
248
            me.updateOAT();
249
            me.updateTAS();
250
            me.updateBRG();
251
            me.updateXPDR();
252
            me.updateBARO();
253
            me.updateOMI();
254
            me.timerTrigger();
255
            me.screen.show();
256
        }
257
        else {
258
            me.updateEIS();
259
            io.load_nasal(data.zkv1000_dir ~ 'Nasal/MFD.pages.nas', 'zkv1000');
260
            me['page selected'] = 0;
261
            me.setMFDPages();
262
            me.device.buttons.MENU = me.device.buttons.MapMenu;
263
        }
commit initial
Sébastien MARQUE authored on 2017-03-07
264

            
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
265
        me.updateNAV({auto:'nav', tune: radios.getNode('nav-tune').getValue()});
266
        me.updateCOMM({auto:'comm', tune: radios.getNode('comm-tune').getValue()});
267
        me.softkeys_inactivity();
268
        me.updateSoftKeys();
add navigation infos on head...
Sébastien MARQUE authored on 2017-05-24
269
        me.updateNavigationBox();
commit initial
Sébastien MARQUE authored on 2017-03-07
270
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
271
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
272

            
some added comments
Sébastien MARQUE authored on 2017-03-18
273
    colors : {
274
# set of predefined colors {{{
275
        green : [0, 1, 0],
276
        white : [1, 1, 1],
277
        black : [0, 0, 0],
278
        lightblue : [0, 1, 1],
279
        darkblue : [0, 0, 1],
280
        red : [1, 0, 0],
adds CDI
Sébastien MARQUE authored on 2017-03-18
281
        magenta : [1, 0, 1],
some added comments
Sébastien MARQUE authored on 2017-03-18
282
    },
283
#}}}
284

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

            
343
    clips : {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
344
#{{{
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
345
        PitchScale   : "rect(70,664,370,256)",
346
        SpeedLint1   : "rect(252,226,318,204)",
347
        SpeedTape    : "rect(115,239,455,156)",
348
        LintAlt      : "rect(115,808,455,704)",
animation ALT
Sébastien MARQUE authored on 2017-03-11
349
        AltLint00011 : "rect(252,804,318,771)",
AI disponible
Sébastien MARQUE authored on 2017-03-10
350
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
351
#}}}
AI disponible
Sébastien MARQUE authored on 2017-03-10
352

            
animation VSI
Sébastien MARQUE authored on 2017-03-10
353
    texts : {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
354
#{{{
animation VSI
Sébastien MARQUE authored on 2017-03-10
355
        VSIText : {
356
            alignment: "right-bottom", default : num('0'),
357
        },
animation IAS
Sébastien MARQUE authored on 2017-03-10
358
        Speed110 : {
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
359
            alignment : 'left-bottom'
animation IAS
Sébastien MARQUE authored on 2017-03-10
360
        },
animation ALT (2)
Sébastien MARQUE authored on 2017-03-11
361
        Alt11100 : {
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
362
            alignment:'left-bottom'
animation ALT (2)
Sébastien MARQUE authored on 2017-03-11
363
        },
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
364
        "HDG-text" : {
365
            default: '---°'
366
        },
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
367
        'nav1-standby-freq' : {
368
            color: [0, 1, 1],
369
        },
370
        'nav1-id' : {
371
            default: ''
372
        },
373
        'nav2-id' : {
374
            default: ''
375
        },
adds CDI
Sébastien MARQUE authored on 2017-03-18
376
        'CDI-GPS-ANN-text' : {
377
            visible : 0
378
        },
379
        'CDI-GPS-XTK-text' : {
380
            visible : 0
381
        },
382
        'CDI-SRC-text' : {
383
            visible : 0
384
        },
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
385
        'BARO-text' : {
386
            alignment : 'left-bottom',
387
        }
some added comments
Sébastien MARQUE authored on 2017-03-18
388
#        'TAS-text' : {
389
#            alignment : 'right-bottom',
390
#        },
391
#        'GSPD-text' : {
392
#            alignment : 'right-bottom',
393
#        },
animation VSI
Sébastien MARQUE authored on 2017-03-10
394
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
395
#}}}
animation VSI
Sébastien MARQUE authored on 2017-03-10
396

            
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
397
    softkeys_inactivity : func {
398
# automagically back to previous level after some delay {{{
399
        me.timers2.softkeys_inactivity = maketimer (
400
            me.softkeys_inactivity_delay,
401
            func {
402
                pop(me.device.softkeys.path);
403
                me.updateSoftKeys();
404
            }, me);
405
        me.timers2.softkeys_inactivity.singleShot = 1;
406
    },
407
#}}}
408

            
softkey is implemented by de...
Sébastien MARQUE authored on 2017-12-21
409
    setSoftKeyColor : func (n, active, implemented = 1, alert = 0) {
add softkeys colors
Sébastien MARQUE authored on 2017-03-21
410
# set colors for active softkeys {{{
411
        var sftk = sprintf('SoftKey%02i-', n);
412
        if (active) {
413
            var bg = alert ? 1 : 0.5;
414
            me.screenElements[sftk ~ 'bg']
415
                .setColorFill(bg,bg,bg);
416
            me.screenElements[sftk ~ 'text']
417
                .setColor(0,0,0);
418
        }
419
        else {
not yet implemented softkeys...
Sébastien MARQUE authored on 2017-06-08
420
            var tc = implemented ? 1 : 0.5;
add softkeys colors
Sébastien MARQUE authored on 2017-03-21
421
            me.screenElements[sftk ~ 'bg']
422
                .setColorFill(0,0,0);
423
            me.screenElements[sftk ~ 'text']
not yet implemented softkeys...
Sébastien MARQUE authored on 2017-06-08
424
                .setColor(tc,tc,tc);
add softkeys colors
Sébastien MARQUE authored on 2017-03-21
425
        }
426
    },
427
#}}}
428

            
adds MFD menu for Aux/System...
Sébastien MARQUE authored on 2017-06-02
429
    updateNavigationBox : func (getDataFields = 0) {
add navigation infos on head...
Sébastien MARQUE authored on 2017-05-24
430
# update Navigation Box on MFD and PFD header {{{
431
        var route = me.device.map.layers.route;
432
        var fpSize = size(route.flightPlan);
433
        var navbox = {
434
            DTK: func {
435
                var dtk = getprop('/instrumentation/gps/wp/wp[1]/desired-course-deg');
436
                if (dtk == nil)
437
                    return '---°';
438
                else
439
                    return sprintf('%03i°', dtk);
440
            },
441
            ETE: func {
442
                if (fpSize == 0) return '--:--';
443
                var eteSeconds = getprop('/autopilot/route-manager/ete');
444
                var eteHours = math.floor(eteSeconds / 3600);
445
                var eteMinutes = int((eteSeconds - (eteHours * 3600)) / 60);
446
                return sprintf(eteHours > 99 ? '--:--' : '%02i:%02i', eteHours, eteMinutes);
447
            },
448
            DIS: func {
449
                if (fpSize == 0) return '---NM';
450
                var dist = getprop('/autopilot/route-manager/distance-remaining-nm');
451
                return sprintf(dist >= 100 ? '%i' : '%.1f', dist);
452
            },
453
            LEG: func {
454
                if (fpSize == 0) return '';
455
                var wp = route.flightPlan[route.currentLeg.index];
456
                return wp[0].name ~ ' > ' ~ wp[1].name;
457
            },
458
            GS : func return sprintf('%iKT', getprop('/velocities/groundspeed-kt')),
459
            TRK: func return sprintf('%03i°', getprop('/orientation/track-deg')),
460
            TAS: func return sprintf('%i', getprop('/instrumentation/airspeed-indicator/true-speed-kt')),
461
            BRG: func return '---°',
462
            END: func return '---NM',
463
            ESA: func return '-----',
464
            ETA: func return '--:--',
465
            FOB: func return '---lbs',
466
            ISA: func return '-----',
467
            LDG: func return '--:--',
468
            MSA: func return '----ft',
469
            TKE: func return '---°',
470
            VSR: func return '----',
471
            XTK: func return '---NM',
472
        };
adds MFD menu for Aux/System...
Sébastien MARQUE authored on 2017-06-02
473
        if (getDataFields)
474
            return keys(navbox);
add navigation infos on head...
Sébastien MARQUE authored on 2017-05-24
475
        if (me.device.role == 'MFD') {
476
            for (var i=1; i<=4; i+=1)
477
                me.screenElements['DATA-FIELD' ~ i ~ '-VAL-text']
478
                    .setText(
479
                        navbox[me.screenElements['DATA-FIELD' ~ i ~ '-ID-text'].get('text')]()
480
                    );
481
            settimer(func me.updateNavigationBox(), 0.6);
482
        }
483
        else { # PFD
484
            me.screenElements['ETE-text'].setText(navbox.ETE());
485
            me.screenElements['DIS-text'].setText(navbox.DIS());
486
            me.screenElements['LEG-text'].setText(navbox.LEG());
487
            settimer(func me.updateNavigationBox(), 0.3);
488
        }
489
    },
490
#}}}
491

            
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
492
    updateSoftKeys : func {
493
# update SoftKeys boxes {{{
494
        # on PFD the last boxes are always BACK and ALERTS
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
495
        if (me.device.role == 'PFD') {
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
496
            me.screenElements[sprintf("SoftKey%02i-text", 11)]
497
                .setText('ALERTS');
498
            if (size(me.device.softkeys.path) != 0)
499
                me.screenElements[sprintf("SoftKey%02i-text", 10)]
not yet implemented softkeys...
Sébastien MARQUE authored on 2017-06-08
500
                    .setText('BACK')
501
                    .setColor(1,1,1);
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
502
        }
503

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
504
        var path = keyMap[me.device.role];
not yet implemented softkeys...
Sébastien MARQUE authored on 2017-06-08
505
        var bindings = me.device.softkeys.bindings[me.device.role];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
506
        var pathid = '';
507
        foreach (var p; me.device.softkeys.path) {
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
508
            path = path[p];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
509
            pathid ~= p;
not yet implemented softkeys...
Sébastien MARQUE authored on 2017-06-08
510
            if (contains(bindings, p))
511
                bindings = bindings[p];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
512
        }
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
513

            
514
        # feeding with empty menus the first boxes
515
        var start = (contains(path, 'first')) ? path.first : 0;
516
        for (var k = 0; k < start; k+=1) {
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
517
            var sftk = sprintf("SoftKey%02i-", k);
518
            me.screenElements[sftk ~ 'text']
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
519
                .setText('');
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
520
            me.screenElements[sftk ~ 'bg']
521
                .setColorFill(0,0,0);
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
522
        }
523
        # filling with the content the next boxes
524
        forindex (var k; path.texts) {
525
            var i = k + start;
526
            me.screenElements[sprintf("SoftKey%02i-text", i)]
527
                .setText(path.texts[k]);
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
528
            me.setSoftKeyColor(i,
not yet implemented softkeys...
Sébastien MARQUE authored on 2017-06-08
529
                    contains(me.device.softkeys.colored, pathid ~ path.texts[k]),
530
                    contains(bindings, path.texts[k]));
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
531
        }
532
        # feeding the last boxes with empty string
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
533
        var end = (me.device.role == 'PFD') ? 10 : 12;
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
534
        if (size(path.texts) + start < end) {
535
            start = size(path.texts) + start;
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
536
            for (var k = start; k < end; k += 1) {
537
                var sftk = sprintf("SoftKey%02i-", k);
538
                me.screenElements[sftk ~ 'text']
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
539
                    .setText('');
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
540
                me.screenElements[sftk ~ 'bg']
541
                    .setColorFill(0,0,0);
542
            }
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
543
        }
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
544

            
545
        if (size(me.device.softkeys.path))
546
            me.timers2.softkeys_inactivity.restart(me.softkeys_inactivity_delay);
547
        else
548
            me.timers2.softkeys_inactivity.stop();
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
549
    },
550
#}}}
551

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
552
    updateAI: func(){
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
553
#{{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
554
        var pitch = data.pitch;
555
        var roll = data.roll;
AI disponible
Sébastien MARQUE authored on 2017-03-10
556
        if (pitch > 80)
557
            pitch = 80;
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
558
        elsif (pitch < -80)
AI disponible
Sébastien MARQUE authored on 2017-03-10
559
            pitch = -80;
560
        me.screenElements.Horizon
fix AI animation
Sébastien MARQUE authored on 2017-03-19
561
            .setCenter(459, 282.8 - 6.849 * pitch)
AI disponible
Sébastien MARQUE authored on 2017-03-10
562
            .setRotation(-roll * D2R)
fix AI animation
Sébastien MARQUE authored on 2017-03-19
563
            .setTranslation(0, pitch * 6.849);
AI disponible, avec bankPoin...
Sébastien MARQUE authored on 2017-03-10
564
        me.screenElements.bankPointer
565
            .setRotation(-roll * D2R);
adds slipskid animation
Sébastien MARQUE authored on 2017-03-24
566
        me.screenElements['SlipSkid']
567
            .setTranslation(getprop("/instrumentation/slip-skid-ball/indicated-slip-skid") * 10, 0);
add TCAS
Sébastien MARQUE authored on 2017-12-21
568
        me.screenElements['Traffic']
569
            .setVisible(size(data.tcas));
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
570
        settimer(func me.updateAI(), 0.1);
AI disponible
Sébastien MARQUE authored on 2017-03-10
571
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
572
#}}}
animation VSI
Sébastien MARQUE authored on 2017-03-10
573

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
574
    updateVSI: func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
575
# animate VSI {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
576
        var vsi = data.vsi;
animation VSI
Sébastien MARQUE authored on 2017-03-10
577
        me.screenElements.VSIText
578
            .setText(num(math.round(vsi, 10)));
579
        if (vsi > 4500)
580
            vsi = 4500;
581
        elsif (vsi < -4500)
582
            vsi = -4500;
583
        me.screenElements.VSI
584
            .setTranslation(0, vsi * -0.03465);
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
585
        settimer(func me.updateVSI(), 0.1);
animation VSI
Sébastien MARQUE authored on 2017-03-10
586
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
587
#}}}
animation IAS
Sébastien MARQUE authored on 2017-03-10
588

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
589
    updateIAS: func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
590
# animates the IAS lint (PFD) {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
591
        var ias = data.ias;
animation IAS
Sébastien MARQUE authored on 2017-03-10
592
        if (ias >= 10)
593
            me.screenElements.Speed110
594
                .setText(sprintf("% 2u",num(math.floor(ias/10))));
595
        else
596
            me.screenElements.Speed110
597
                .setText('');
598
        me.screenElements.SpeedLint1
599
            .setTranslation(0,(math.mod(ias,10) + (ias >= 10)*10) * 36);
600
        me.screenElements.SpeedTape
601
            .setTranslation(0,ias * 5.711);
put Vspeeds in common data s...
Sébastien MARQUE authored on 2017-04-11
602
        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
603
            me._ias_already_exceeded = 1;
604
            me.screenElements['IAS-bg']
605
                .setColorFill(1,0,0);
606
        }
put Vspeeds in common data s...
Sébastien MARQUE authored on 2017-04-11
607
        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
608
            me._ias_already_exceeded = 0;
609
            me.screenElements['IAS-bg']
610
                .setColorFill(0,0,0);
611
        }
add V-speeds bugs
Sébastien MARQUE authored on 2017-04-04
612
        foreach (var v; ['Vx', 'Vy', 'Vr', 'Vglide']) {
put Vspeeds in common data s...
Sébastien MARQUE authored on 2017-04-11
613
            if (me.device.data[v ~ '-visible'] and abs(data[v] - ias) < 30)
add V-speeds bugs
Sébastien MARQUE authored on 2017-04-04
614
                me.screenElements['IAS-' ~ v]
put Vspeeds in common data s...
Sébastien MARQUE authored on 2017-04-11
615
                    .setTranslation(0, (ias - data[v]) * 5.711)
add V-speeds bugs
Sébastien MARQUE authored on 2017-04-04
616
                    .show();
617
            else
618
                me.screenElements['IAS-' ~ v]
619
                    .hide();
620
        }
621

            
trends animation
Sébastien MARQUE authored on 2017-03-13
622
        var now = systime();
623
        # estimated speed in 6s
624
        var Sy = 6 * (ias - me._last_ias_kt) / (now - me._last_ias_s);
625
        if (abs(Sy) > 30)
626
            Sy = 30 * abs(Sy)/Sy; # = -30 or 30
627
        me.screenElements['Airspeed-Trend-Indicator']
628
            .setScale(1,Sy)
629
            .setTranslation(0, -284.5 * (Sy - 1));
630
        me._last_ias_kt = ias;
631
        me._last_ias_s = now;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
632
        settimer(func me.updateIAS(), 0.1);
animation IAS
Sébastien MARQUE authored on 2017-03-10
633
    },
trends animation
Sébastien MARQUE authored on 2017-03-13
634
    _last_ias_kt : 0,
635
    _last_ias_s : systime(),
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
636
    _ias_already_exceeded : 0,
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
637
#}}}
animation ALT
Sébastien MARQUE authored on 2017-03-11
638

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
639
    updateTAS: func {
640
# updates the True Airspeed and GroundSpeed indicators {{{
641
        me.screenElements['TAS-text']
642
            .setText(sprintf('%iKT', getprop('/instrumentation/airspeed-indicator/true-speed-kt')));
643
        me.screenElements['GSPD-text']
644
            .setText(sprintf('%iKT', getprop('/velocities/groundspeed-kt')));
645
        settimer(func me.updateTAS(), 0.5);
646
    },
647
#}}}
648

            
649
    updateALT: func () {
650
# animates the altitude lint (PFD) {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
651
        var alt = data.alt;
animation ALT
Sébastien MARQUE authored on 2017-03-11
652
        if (alt < 0)
653
            me.screenElements.Alt11100
654
                .setText(sprintf("% 3i",math.ceil(alt/100)));
655
        elsif (alt < 100)
656
            me.screenElements.Alt11100
657
                .setText('');
658
        else
659
            me.screenElements.Alt11100
660
                .setText(sprintf("% 3i",math.floor(alt/100)));
661
        me.screenElements.AltLint00011
662
            .setTranslation(0,math.fmod(alt,100) * 1.24);
663

            
664
        # From Farmin/G1000 http://wiki.flightgear.org/Project_Farmin/FG1000
665
        if (alt> -1000 and alt< 1000000) {
666
            var Offset10 = 0;
667
            var Offset100 = 0;
668
            var Offset1000 = 0;
669
            if (alt< 0) {
670
                var Ne = 1;
671
                var alt= -alt;
672
            }
673
            else
674
                var Ne = 0;
675

            
676
            var Alt10       = math.mod(alt,100);
677
            var Alt100      = int(math.mod(alt/100,10));
678
            var Alt1000     = int(math.mod(alt/1000,10));
679
            var Alt10000    = int(math.mod(alt/10000,10));
680
            var Alt20       = math.mod(Alt10,20)/20;
681
            if (Alt10 >= 80)
682
                var Alt100 += Alt20;
683

            
684
            if (Alt10 >= 80 and Alt100 >= 9)
685
                var Alt1000 += Alt20;
686

            
687
            if (Alt10 >= 80 and Alt100 >= 9 and Alt1000 >= 9)
688
                var Alt10000 += Alt20;
689

            
690
            if (alt> 100)
691
                var Offset10 = 100;
692

            
693
            if (alt> 1000)
694
                var Offset100 = 10;
695

            
696
            if (alt> 10000)
697
                var Offset1000 = 10;
698

            
699
            if (!Ne) {
700
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*0.57375);
701
                var altCentral = (int(alt/100)*100);
702
            }
703
            elsif (Ne) {
704
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*-0.57375);
705
                var altCentral = -(int(alt/100)*100);
706
            }
707
            me.screenElements["AltBigC"].setText("");
708
            me.screenElements["AltSmallC"].setText("");
709
            for (var place = 1; place <= 6; place += 1) {
710
                var altUP = altCentral + (place*100);
711
                var offset = -30.078;
712
                if (altUP < 0) {
713
                    var altUP = -altUP;
714
                    var prefix = "-";
715
                    var offset += 15.039;
716
                }
717
                else
718
                    var prefix = "";
719

            
720
                if (altUP == 0) {
721
                    var AltBigUP    = "";
722
                    var AltSmallUP  = "0";
723

            
724
                }
725
                elsif (math.mod(altUP,500) == 0 and altUP != 0) {
726
                    var AltBigUP    = sprintf(prefix~"%1d", altUP);
727
                    var AltSmallUP  = "";
728
                }
729
                elsif (altUP < 1000 and (math.mod(altUP,500))) {
730
                    var AltBigUP    = "";
731
                    var AltSmallUP  = sprintf(prefix~"%1d", int(math.mod(altUP,1000)));
732
                    var offset = -30.078;
733
                }
734
                elsif ((altUP < 10000) and (altUP >= 1000) and (math.mod(altUP,500))) {
735
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
736
                    var AltSmallUP  = sprintf("%1d", int(math.mod(altUP,1000)));
737
                    var offset += 15.039;
738
                }
739
                else {
740
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
741
                    var mod = int(math.mod(altUP,1000));
742
                    var AltSmallUP  = sprintf("%1d", mod);
743
                    var offset += 30.078;
744
                }
745

            
746
                me.screenElements["AltBigU"~place].setText(AltBigUP);
747
                me.screenElements["AltSmallU"~place].setText(AltSmallUP);
748
                me.screenElements["AltSmallU"~place].setTranslation(offset,0);
749
                var altDOWN = altCentral - (place*100);
750
                var offset = -30.078;
751
                if (altDOWN < 0) {
752
                    var altDOWN = -altDOWN;
753
                    var prefix = "-";
754
                    var offset += 15.039;
755
                }
756
                else
757
                    var prefix = "";
758

            
759
                if (altDOWN == 0) {
760
                    var AltBigDOWN  = "";
761
                    var AltSmallDOWN    = "0";
762
                }
763
                elsif (math.mod(altDOWN,500) == 0 and altDOWN != 0) {
764
                    var AltBigDOWN  = sprintf(prefix~"%1d", altDOWN);
765
                    var AltSmallDOWN    = "";
766
                }
767
                elsif (altDOWN < 1000 and (math.mod(altDOWN,500))) {
768
                    var AltBigDOWN  = "";
769
                    var AltSmallDOWN    = sprintf(prefix~"%1d", int(math.mod(altDOWN,1000)));
770
                    var offset = -30.078;
771
                }
772
                elsif ((altDOWN < 10000) and (altDOWN >= 1000) and (math.mod(altDOWN,500))) {
773
                    var AltBigDOWN  = sprintf(prefix~"%1d", int(altDOWN/1000));
774
                    var AltSmallDOWN    = sprintf("%1d", int(math.mod(altDOWN,1000)));
775
                    var offset += 15.039;
776
                }
777
                else {
778
                    var AltBigDOWN  = sprintf(prefix~"%1d", int(altDOWN/1000));
779
                    var mod = int(math.mod(altDOWN,1000));
780
                    var AltSmallDOWN    = sprintf("%1d", mod);
781
                    var offset += 30.078;
782
                }
783
                me.screenElements["AltBigD"~place].setText(AltBigDOWN);
784
                me.screenElements["AltSmallD"~place].setText(AltSmallDOWN);
785
                me.screenElements["AltSmallD"~place].setTranslation(offset,0);
786
            }
787
        }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
788
        me.updateSelectedALT();
trends animation
Sébastien MARQUE authored on 2017-03-13
789
        var now = systime();
790
        # altitude in 6s
791
        var Sy = .3 * (alt - me._last_alt_ft) / (now - me._last_alt_s); # scale = 1/20ft
792
        if (abs(Sy) > 15)
793
            Sy = 15 * abs(Sy)/Sy; # = -15 or 15
794
        me.screenElements['Altitude-Trend-Indicator']
795
            .setScale(1,Sy)
796
            .setTranslation(0, -284.5 * (Sy - 1));
797
        me._last_alt_ft = alt;
798
        me._last_alt_s = now;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
799
        settimer(func me.updateALT(), 0.2);
animation ALT
Sébastien MARQUE authored on 2017-03-11
800
    },
trends animation
Sébastien MARQUE authored on 2017-03-13
801
    _last_alt_ft : 0,
802
    _last_alt_s  : systime(),
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
803
#}}}
animation HSI
Sébastien MARQUE authored on 2017-03-11
804

            
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
805
    updateBARO : func () {
806
# update BARO widget {{{
807
        var fmt = me._baro_unit == 'inhg' ? '%.2f%s' : '%i%s';
808
        me.screenElements['BARO-text']
809
            .setText(sprintf(fmt,
810
                        getprop('/instrumentation/altimeter/setting-' ~ me._baro_unit),
811
                        me._baro_unit == 'inhg' ? 'in' : 'hPa')
812
                );
813
    },
814
    _baro_unit : 'inhg',
815
#}}}
816

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
817
    updateHSI : func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
818
# rotates the compass (PFD) {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
819
        var hdg = data.hdg;
animation HSI
Sébastien MARQUE authored on 2017-03-11
820
        me.screenElements.Rose
821
            .setRotation(-hdg * D2R);
822
        me.screenElements['HDG-text']
823
            .setText(sprintf("%03u°", hdg));
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
824
        settimer(func me.updateHSI(), 0.1);
animation HSI
Sébastien MARQUE authored on 2017-03-11
825
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
826
#}}}
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
827

            
removes unecessary listeners
Sébastien MARQUE authored on 2017-04-08
828
    updateHDG : func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
829
# moves the heading bug and display heading-deg for 3 seconds (PFD) {{{
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
830
        if (me.device.role == 'MFD')
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
831
            return;
removes unecessary listeners
Sébastien MARQUE authored on 2017-04-08
832
        var hdg = getprop('/instrumentation/zkv1000/afcs/heading-bug-deg');
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
833
        me.screenElements['Heading-bug']
834
            .setRotation(hdg * D2R);
835
        me.screenElements['SelectedHDG-bg']
836
            .show();
837
        me.screenElements['SelectedHDG-bgtext']
838
            .show();
839
        me.screenElements['SelectedHDG-text']
840
            .setText(sprintf('%03d°%s', hdg, ''))
841
            .show();
842
        me.addTimer(3, ['SelectedHDG-text', 'SelectedHDG-bgtext', 'SelectedHDG-bg']);
843
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
844
#}}}
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
845

            
adds CDI
Sébastien MARQUE authored on 2017-03-18
846
    updateCRS : func () {
anime CRS
Sébastien MARQUE authored on 2017-03-13
847
# TODO: update display for NAV/GPS/BRG courses {{{
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
848
        if (me.device.role == 'MFD')
anime CRS
Sébastien MARQUE authored on 2017-03-13
849
            return;
adds CDI
Sébastien MARQUE authored on 2017-03-18
850
        var source = getprop('/instrumentation/zkv1000/cdi/source');
851
        if (source == 'OFF')
852
            return;
853
        var crs = getprop('/instrumentation/zkv1000/cdi/course');
854
        if (crs == nil)
855
            return;
anime CRS
Sébastien MARQUE authored on 2017-03-13
856
        me.screenElements['SelectedCRS-bg']
857
            .show();
858
        me.screenElements['SelectedCRS-bgtext']
859
            .show();
860
        me.screenElements['SelectedCRS-text']
861
            .setText(sprintf('%03d°%s', crs, ''))
adds CDI
Sébastien MARQUE authored on 2017-03-18
862
            .setColor(source == 'GPS' ? me.colors.magenta : me.colors.green)
anime CRS
Sébastien MARQUE authored on 2017-03-13
863
            .show();
864
        me.addTimer(3, ['SelectedCRS-text', 'SelectedCRS-bgtext', 'SelectedCRS-bg']);
865
    },
866
#}}}
867

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
868
    updateSelectedALT : func {
869
# animation for altitude section, called via updatedALT {{{
creates flightdeck hash to p...
Sébastien MARQUE authored on 2017-04-07
870
        if (! me.screenElements['SelectedALT'].getVisible())
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
871
            return;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
872
        var selected_alt = getprop('/instrumentation/zkv1000/afcs/selected-alt-ft');
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
873
        var delta_alt = data.alt - selected_alt;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
874
        if (abs(delta_alt) > 300)
875
            delta_alt = 300 * abs(delta_alt)/delta_alt;
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
876
        me.screenElements['SelectedALT-symbol']
877
            .setVisible(abs(delta_alt) > 100);
878
        me.screenElements['SelectedALT-bg']
879
            .setVisible(abs(delta_alt) > 100);
880
        me.screenElements['SelectedALT-text']
881
            .setText(sprintf("%i", selected_alt))
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
882
            .setVisible(abs(delta_alt) > 100);
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
883
        me.screenElements['SelectedALT-bug']
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
884
            .setTranslation(0, delta_alt * 0.567); # 170/300 = 0.567
885
    },
886
#}}}
887

            
adds CDI
Sébastien MARQUE authored on 2017-03-18
888
    updateCDI : func {
889
# animation for CDI {{{
890
        var source = getprop('/instrumentation/zkv1000/cdi/source');
891
        if (source == 'OFF') {
892
            foreach (var s; ['GPS', 'NAV1', 'NAV2'])
893
                foreach (var t; ['pointer', 'CDI'])
894
                    me.screenElements[s ~ '-' ~ t].hide();
895
            me.screenElements['CDI-GPS-ANN-text'].hide();
896
            me.screenElements['CDI-GPS-XTK-text'].hide();
897
            me.screenElements['CDI-SRC-text'].hide();
898
            me.screenElements['CDI'].hide();
899
        }
900
        else {
901
            var course = getprop('/instrumentation/zkv1000/cdi/course');
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
902
            var rot = (course - data.hdg) * D2R;
adds CDI
Sébastien MARQUE authored on 2017-03-18
903
            me.screenElements['CDI']
makes the CDI available
Sébastien MARQUE authored on 2017-03-23
904
                .setRotation(rot)
adds CDI
Sébastien MARQUE authored on 2017-03-18
905
                .show();
906
            me.screenElements['GPS-CTI']
animates GPS-CTI
Sébastien MARQUE authored on 2017-03-24
907
                .setVisible(getprop('/instrumentation/gps/wp/wp[1]/valid'))
908
                .setRotation(getprop('/instrumentation/gps/wp/wp[1]/course-deviation-deg') * D2R);
adds CDI
Sébastien MARQUE authored on 2017-03-18
909
            me.screenElements['GPS-CTI-diamond']
animates GPS-CTI
Sébastien MARQUE authored on 2017-03-24
910
                .setVisible(getprop('/instrumentation/gps/wp/wp[1]/valid'))
911
                .setRotation(getprop('/instrumentation/gps/wp/wp[1]/course-deviation-deg') * D2R);
adds CDI
Sébastien MARQUE authored on 2017-03-18
912
            foreach (var s; ['GPS', 'NAV1', 'NAV2']) {
913
                me.screenElements[s ~ '-pointer']
914
                    .setRotation(rot)
915
                    .setVisible(source == s);
916
                me.screenElements[s ~ '-CDI']
917
                    .setVisible(source == s);
918
                foreach (var f; ['FROM', 'TO'])
919
                    me.screenElements[s ~ '-' ~ f]
makes the CDI available
Sébastien MARQUE authored on 2017-03-23
920
                        .setVisible(s == source and getprop('/instrumentation/zkv1000/cdi/' ~ f ~ '-flag'));
adds CDI
Sébastien MARQUE authored on 2017-03-18
921
                me.screenElements['CDI-SRC-text']
922
                    .setText(source)
923
                    .setColor(source == 'GPS' ? me.colors.magenta : me.colors.green)
924
                    .show();
925
            }
makes the CDI available
Sébastien MARQUE authored on 2017-03-23
926
            var deflection = getprop('/instrumentation/zkv1000/cdi/course-deflection');
927
            if (left(source, 3) == 'NAV')
928
                var scale = deflection / 4;
929
            else { # GPS
930
                # TODO: deviation depending of the flight phase
931
                # for now fixed 1 dot = 1 nm course error
932
                var abs_deflection = abs(deflection);
933
                me.screenElements['CDI-GPS-XTK-text']
934
                    .setText(sprintf('XTK %iNM', abs_deflection))
935
                    .setVisible(abs_deflection > 2.4);
936
                var scale = deflection / 2;
937
            }
938
            scale = (abs(scale) > 1.2) ? 1.2 : scale;
939
            me.screenElements[source ~ '-CDI']
940
                .setTranslation(65 * scale, 0);
941
            settimer(func me.updateCDI(), 0.3);
adds CDI
Sébastien MARQUE authored on 2017-03-18
942
        }
943
    },
944
#}}}
945

            
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
946
    _updateRadio: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
947
# common parts for NAV/LOC/COMM radios{{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
948
        # arg[0]._r = <comm|nav>
949
        if (contains(arg[0], "active")) {
950
            if (arg[0]['active'] == 'none') {
951
                me.screenElements[arg[0]._r ~ '1-selected-freq']
952
                    .setColor(1,1,1);
953
                me.screenElements[arg[0]._r ~ '2-selected-freq']
954
                    .setColor(1,1,1);
955
            }
956
            else {
957
                me.screenElements[arg[0]._r ~ arg[0]['active'] ~ '-selected-freq']
958
                    .setColor(0,1,0);
959
                me.screenElements[arg[0]._r ~ arg[0].inactive ~ '-selected-freq']
960
                    .setColor(1,1,1);
961
            }
962
        }
963
        if (contains(arg[0], 'tune')) {
964
            # n = 0 -> NAV1/COMM1
965
            # n = 1 -> NAV1/COMM2
966
            me.screenElements[arg[0]._r ~ '-freq-switch']
967
                .setTranslation(0, arg[0].tune * 25);
968
            me.screenElements[arg[0]._r ~ (arg[0].tune + 1) ~ '-standby-freq']
969
                .setColor(0,1,1);
970
            me.screenElements[arg[0]._r ~ ((arg[0].tune == 0) + 1) ~ '-standby-freq']
971
                .setColor(1,1,1);
972
        }
973
        if (contains(arg[0], 'refresh')) {
small stuff
Sébastien MARQUE authored on 2017-03-22
974
            # refresh only one line: NAV1/COMM1 or NAV2/COMM2
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
975
            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
976
            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-selected-freq']
977
                .setText(sprintf(fmt, getprop('/instrumentation/'
978
                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/selected-mhz')));
979
            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-standby-freq']
980
                .setText(sprintf(fmt, getprop('/instrumentation/'
981
                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/standby-mhz')));
982
        }
983
        if (contains(arg[0], 'set')) {
984
            # positionne la valeur modifiée, les listeners "trigguent" en permanence ces propriétés, donc exit
985
            var n = getprop('/instrumentation/zkv1000/radios/' ~ arg[0]._r ~ '-tune');
986
            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
987
            me.screenElements[arg[0]._r ~ (n + 1) ~ '-standby-freq']
fix freq display while setti...
Sébastien MARQUE authored on 2017-03-16
988
                .setText(sprintf(fmt, getprop('/instrumentation/' ~ arg[0]._r ~ '[' ~ n ~ ']/frequencies/standby-mhz')));
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
989
        }
990
        if (contains(arg[0], 'auto')) {
991
            # pour rafraichir automagiquement, toutes les deux secondes un refresh pour un NAV
992
            var radio = arg[0].auto;
993
            me._updateRadio({refresh: 1, _r: radio});
994
            settimer(func me._updateRadio({refresh: 2, _r: radio}), 1);
995
            settimer(func me._updateRadio({auto: radio}), 2);
996
        }
997
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
998
#}}}
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
999

            
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1000
    updateNAV : func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
1001
# update NAV/LOC rodios display upper left (PFD/MFD){{{
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1002
        # made active via menu
1003
        if (contains(arg[0], "active")) {
adds CDI
Sébastien MARQUE authored on 2017-03-18
1004
            arg[0]._r = 'nav';
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1005
            if (arg[0]['active'] == 'none') {
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1006
                me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1007
                me.screenElements['nav1-id']
1008
                    .setColor(1,1,1);
1009
                me.screenElements['nav2-id']
1010
                    .setColor(1,1,1);
1011
                me.screenElements['NAV1-pointer']
1012
                    .hide();
1013
                me.screenElements['NAV2-pointer']
1014
                    .hide();
1015
            }
1016
            else {
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1017
                arg[0].inactive = (arg[0]['active'] == 1) + 1;
1018
                me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1019
                me.screenElements['nav' ~ arg[0]['active'] ~ '-id']
1020
                    .setColor(0,1,0);
1021
                me.screenElements['NAV' ~ arg[0]['active'] ~ '-pointer']
1022
                    .show();
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1023
                me.screenElements['nav' ~ arg[0].inactive ~ '-id']
1024
                    .setColor(1,1,1);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1025
#                me.screenElements['HDI']
1026
#                    .setRotation();
1027
#                me.screenElements['NAV' ~ inactive ~ '-pointer']
1028
#                    .hide();
1029
#                foreach (var e; [ 'FROM', 'TO', 'CDI' ])
1030
#                    me.screenElements['NAV' ~ inactive ~ '-' ~ e]
1031
#                        .hide();
1032
            }
1033
        }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1034
        elsif (contains(arg[0], 'nav-id')) {
Correction swap NAV tuning
Sébastien MARQUE authored on 2017-03-12
1035
            # 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
1036
            if (arg[0].val == nil)
1037
                arg[0].val = '';
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1038
            me.screenElements["nav" ~ arg[0]['nav-id'] ~ "-id"]
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1039
                    .setText(arg[0].val);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1040
        }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1041
        else {
1042
            arg[0]._r = 'nav';
1043
            me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
1044
        }
1045
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
1046
#}}}
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1047

            
1048
    updateCOMM: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
1049
# update COMM radios display upper right (PFD/MFD){{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1050
        arg[0]._r = 'comm';
1051
        me._updateRadio(arg[0]);
1052
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
1053
#}}}
anime time display
Sébastien MARQUE authored on 2017-03-13
1054

            
1055
    updateTIME : func {
1056
# updates the displayed time botoom left {{{
1057
        me.screenElements['TIME-text']
1058
            .setText(getprop('/sim/time/gmt-string'));
1059
        settimer(func me.updateTIME(), 1);
1060
    },
1061
#}}}
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1062

            
adds transponder
Sébastien MARQUE authored on 2017-03-17
1063
    updateXPDR : func {
1064
# updates transponder display {{{
1065
        for (var d = 0; d < 4; d+=1)
1066
            me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
1067
                .setText(sprintf('%i', getprop('/instrumentation/transponder/inputs/digit[' ~ d ~ ']')));
1068
        var tuning = getprop('/instrumentation/zkv1000/radios/xpdr-tuning-digit');
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
1069
        var fms = getprop('/instrumentation/zkv1000/radios/xpdr-tuning-fms-method');
1070
        for (var d = 0; d < 4; d+=1)
1071
            me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
1072
                .setColor(1,1,1);
1073
        if (tuning != nil) {
1074
            me.screenElements['XPDR-DIGIT-' ~ tuning ~ '-text']
1075
                .setColor(0,1,1);
1076
            if (fms)
1077
                me.screenElements['XPDR-DIGIT-' ~ (tuning - 1) ~ '-text']
1078
                    .setColor(0,1,1);
1079
        }
adds transponder
Sébastien MARQUE authored on 2017-03-17
1080
        else {
1081
            if (getprop('/instrumentation/transponder/ident'))
1082
                var mode = 'IDENT';
1083
            else
1084
                var mode = getprop('/instrumentation/zkv1000/radio/xpdr-mode');
1085
            var wow = getprop('/gear/gear/wow');
1086
            if (! wow and mode != 'STBY')
1087
                var color = [0, 1, 0];
1088
            else
1089
                var color = [1, 1, 1];
1090
            for (var d = 0; d < 4; d+=1)
1091
                me.screenElements['XPDR-DIGIT-' ~ d ~ '-text']
1092
                    .setColor(color);
1093
            me.screenElements['XPDR-MODE-text']
1094
                .setColor(color)
1095
                .setText(mode);
1096
        }
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
1097
    },
adds transponder
Sébastien MARQUE authored on 2017-03-17
1098
#}}}
1099

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1100
    updateOAT : func {
1101
# update OAT display on normal and reversionnary modes (every 3s) {{{
1102
        var tmp = getprop('/environment/temperature-deg' ~ me._oat_unit);
1103
        me.screenElements['OAT-text']
1104
            .setText(sprintf((abs(tmp) < 10) ? "%.1f %s" : "%i %s", tmp, (me._oat_unit == 'c') ? '°C' : 'F'));
1105
        settimer(func me.updateOAT(), 3);
1106
    },
1107
    _oat_unit : 'c',
1108
#}}}
1109

            
1110
    updateWindData : func {
1111
# update the window text and arrows for OPTN1/2 {{{
1112
        if (me._winddata_optn == 0)
1113
            return;
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
1114
        if (data.ias < 30) {
improves WindData display
Sébastien MARQUE authored on 2017-03-16
1115
            me.screenElements['WindData-NODATA']
1116
                .hide();
1117
            var wind_hdg = getprop('/environment/wind-from-heading-deg');
1118
            var wind_spd = getprop('/environment/wind-speed-kt');
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
1119
            var alpha = wind_hdg - data.hdg;
improves WindData display
Sébastien MARQUE authored on 2017-03-16
1120
            if (me._winddata_optn == 1) {
1121
                me.screenElements['WindData-OPTN1-HDG']
1122
                    .setRotation((alpha + 180) * D2R)
1123
                    .show();
1124
                me.screenElements['WindData-OPTN1-HDG-text']
1125
                    .setText(sprintf("%03i°", wind_hdg))
1126
                    .show();
1127
                me.screenElements['WindData-OPTN1-SPD-text']
1128
                    .setText(int(wind_spd) ~ 'KT')
1129
                    .show();
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1130
            }
improves WindData display
Sébastien MARQUE authored on 2017-03-16
1131
            else { # me._winddata_optn == 2
1132
                alpha *= D2R;
1133
                var Vt = wind_spd * math.sin(alpha);
1134
                var Ve = wind_spd * math.cos(alpha);
1135
                if (Vt != 0) {
1136
                    me.screenElements['WindData-OPTN2-crosswind-text']
1137
                        .setText(sprintf('%i', abs(Vt)))
1138
                        .show();
1139
                    me.screenElements['WindData-OPTN2-crosswind']
1140
                        .setScale(-abs(Vt)/Vt, 1)
1141
                        .setTranslation(-35 * (abs(Vt)/Vt + 1), 0)
1142
                        .show();
1143
                }
1144
                if (Ve != 0) {
1145
                    me.screenElements['WindData-OPTN2-headwind-text']
1146
                        .setText(sprintf('%i', abs(Ve)))
1147
                        .show();
1148
                    me.screenElements['WindData-OPTN2-headwind']
1149
                        .setScale(1, abs(Ve)/Ve)
1150
                        .setTranslation(0, 515 * (1 - abs(Ve)/Ve))
1151
                        .show();
1152
                }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1153
            }
1154
        }
improves WindData display
Sébastien MARQUE authored on 2017-03-16
1155
        else {
1156
            foreach (var e; [
1157
                    'WindData-OPTN1-HDG',
1158
                    'WindData-OPTN1-HDG-text',
1159
                    'WindData-OPTN1-SPD-text',
1160
                    'WindData-OPTN2-crosswind-text',
1161
                    'WindData-OPTN2-crosswind',
1162
                    'WindData-OPTN2-headwind-text',
1163
                    'WindData-OPTN2-headwind'
1164
            ])
1165
                me.screenElements[e].hide();
1166
            me.screenElements['WindData-NODATA'].show();
1167
        }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1168
        settimer(func me.updateWindData(), 0.5);
1169
    },
1170
    _winddata_optn : 0,
1171
#}}}
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1172

            
adds AOA display
Sébastien MARQUE authored on 2017-04-15
1173
    updateAOA : func {
1174
# update Angle Of Attack {{{
1175
        if (me.device.data.aoa == 0)
1176
            return;
1177
        var color = [1,1,1];
1178
        var norm = data.aoa / data['stall-aoa'];
nicer AOA display
Sébastien MARQUE authored on 2017-04-16
1179
        me.screenElements['AOA-text']
1180
            .setText(sprintf('% .1f', norm));
adds AOA display
Sébastien MARQUE authored on 2017-04-15
1181
        if (norm > 1) norm = 1;
1182
        if (norm > 0.9)
1183
            color = [1,0,0];
1184
        elsif (norm > 0.7)
1185
            color = [1,1,0];
1186
        elsif (norm < 0) {
1187
            norm = 0;
1188
            color = [1,0,0];
1189
        }
1190
        me.screenElements['AOA-needle']
1191
            .setRotation(-norm * math.pi)
nicer AOA display
Sébastien MARQUE authored on 2017-04-16
1192
            .setColorFill(color);
1193
        me.screenElements['AOA-text']
adds AOA display
Sébastien MARQUE authored on 2017-04-15
1194
            .setColor(color);
1195
        settimer(func me.updateAOA(), 0.1);
1196
    },
1197
# }}}
1198

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

            
1204
            var dev = radios.getNode(source).getValue();
1205
            var el  = 'BRG' ~ brg;
1206
            if (dev != 'OFF') {
1207
                var info = {
1208
                    pointer : nil,
1209
                    id : 'NO DATA',
1210
                    hdg : nil,
1211
                    dst : '--.-NM'
1212
                };
1213
                if (left(dev, 3) == 'NAV') {
1214
                    info.pointer = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/in-range');
1215
                    if (info.pointer) {
1216
                        info.id  = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/nav-id');
1217
                        info.hdg = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/heading-deg');
1218
                        info.dst = sprintf('%.1d', getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/nav-distance') / 1852); # m -> /1852
1219
                    }
1220
                }
1221
                elsif (dev == 'GPS') {
1222
                    info.pointer = props.getNode('/instrumentation/gps/wp').getChild('wp[1])');
1223
                    if (info.pointer) {
1224
                        info.id  = getprop('/instrumentation/gps/wp/wp[1]/ID');
1225
                        info.hdg = getprop('/instrumentation/gps/wp/wp[1]/bearing-mag-deg');
1226
                        info.dst = sprintf('%.1d', getprop('/instrumentation/gps/wp/wp[1]/distance-nm'));
1227
                    }
1228
                }
1229
                else { # there are 2 available ADF in FG, but instrument manage only 1
1230
                    info.pointer = getprop('/instrumentation/adf/in-range');
1231
                    if (info.pointer) {
1232
                        info.id  = getprop('/instrumentation/adf/ident');
1233
                        info.hdg = getprop('/instrumentation/adf/indicated-bearing-deg');
1234
                    }
1235
                }
1236

            
1237
                if (info.pointer)
1238
                    me.screenElements[el ~ '-pointer']
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
1239
                        .setRotation(-info.hdg - data.hdg * D2R)
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1240
                        .show();
1241
                else
1242
                    me.screenElements[el ~ '-pointer']
1243
                        .hide();
1244
                me.screenElements[el ~ '-SRC-text']
1245
                    .setText(dev);
1246
                me.screenElements[el ~ '-DST-text']
1247
                    .setText(info.dst);
1248
                me.screenElements[el ~ '-WPID-text']
1249
                    .setText(info.id);
1250
                me.screenElements['BRG' ~ brg]
1251
                    .show();
1252
            }
1253
            else {
1254
                me.screenElements['BRG' ~ brg]
1255
                    .hide();
1256
            }
1257
        }
colorize BRG1/2 when needed,...
Sébastien MARQUE authored on 2017-03-21
1258
        settimer(func me.updateBRG(), 0.5);
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
1259
    },
some added comments
Sébastien MARQUE authored on 2017-03-18
1260
#}}}
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
1261

            
adds OMI to PFD
Sébastien MARQUE authored on 2017-03-23
1262
    updateOMI : func {
1263
# display marker baecon Outer, Middle, Inner {{{
1264
        var marker = nil;
1265
        foreach (var m; ['outer', 'middle', 'inner'])
1266
            if (getprop('/instrumentation/marker-beacon/' ~ m)) {
1267
                marker = m;
1268
                me.screenElements['OMI']
1269
                    .show();
1270
                break;
1271
            }
1272
        if (marker != nil) {
1273
            me.screenElements['MarkerText']
1274
                .setText(me._omi_data[marker].t)
1275
                .show();
1276
            me.screenElements['MarkerBG']
1277
                .setColorFill(me._omi_data[marker].bg)
1278
                .show();
1279
        }
1280
        else
1281
            me.screenElements['OMI']
1282
                .hide();
1283
        settimer(func me.updateOMI(), 1);
1284
    },
1285
    _omi_data : {
1286
        'outer':  {t: 'O', bg: [0,1,1]},
1287
        'middle': {t: 'M', bg: [1,1,1]},
1288
        'inner':  {t: 'I', bg: [1,1,0]},
1289
    },
1290
#}}}
animation texts EIS + power ...
Sébastien MARQUE authored on 2017-03-19
1291
};