zkv1000 / Nasal / display.nas /
Newer Older
1288 lines | 49.091kb
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',
adds some vim z-folds
Sébastien MARQUE authored on 2017-04-19
109
# }}}
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
110
                );
111
                append(groups.clip,
adds some vim z-folds
Sébastien MARQUE authored on 2017-04-19
112
# {{{
animation IAS
Sébastien MARQUE authored on 2017-03-10
113
                    'SpeedLint1',
animation ALT
Sébastien MARQUE authored on 2017-03-11
114
                    'SpeedTape',
115
                    'LintAlt',
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
116
                    'AltLint00011',
117
                    'PitchScale',
adds some vim z-folds
Sébastien MARQUE authored on 2017-04-19
118
# }}}
animation ALT
Sébastien MARQUE authored on 2017-03-11
119
                );
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
120
                append(groups.text,
adds some vim z-folds
Sébastien MARQUE authored on 2017-04-19
121
# {{{
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
122
                    'SelectedALT-text',
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
123
                    'TAS-text',
124
                    'GSPD-text',
anime time display
Sébastien MARQUE authored on 2017-03-13
125
                    'TIME-text',
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
126
                    'OAT-text',
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
127
                    'VSIText',
128
                    'Speed110',
129
                    'Alt11100',
130
                    'HDG-text',
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
131
                    'BARO-text',
adds CDI
Sébastien MARQUE authored on 2017-03-18
132
                    'CDI-SRC-text', 'CDI-GPS-ANN-text', 'CDI-GPS-XTK-text',
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
133
                    'BRG1-pointer', 'BRG1-SRC-text', 'BRG1-DST-text', 'BRG1-WPID-text',
134
                    'BRG2-pointer', 'BRG2-SRC-text', 'BRG2-DST-text', 'BRG2-WPID-text',
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
135
                    'WindData-OPTN1-HDG-text', 'WindData-OPTN1-SPD-text',
136
                    'WindData-OPTN2-crosswind-text', 'WindData-OPTN2-headwind-text',
adds transponder
Sébastien MARQUE authored on 2017-03-17
137
                    '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
138
                    'ETE', 'ETE-text', 'DIS', 'DIS-text', 'LEG-text',
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
139
                    'AltBigC', 'AltSmallC'
adds some vim z-folds
Sébastien MARQUE authored on 2017-04-19
140
# }}}
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
141
                );
142
                for (var place = 1; place <= 6; place +=1) {
143
                    append(groups.text,
144
                        'AltBigU' ~ place,
145
                        'AltSmallU' ~ place,
146
                        'AltBigD' ~ place,
147
                        'AltSmallD' ~ place
148
                    );
149
                }
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
150
                canvas.parsesvg(m.screen, data.zkv1000_reldir ~ 'Systems/PFD.svg');
animation ALT
Sébastien MARQUE authored on 2017-03-11
151
            }
adds EIS
Sébastien MARQUE authored on 2017-03-18
152
            else {
EIS now really specific to a...
Sébastien MARQUE authored on 2017-04-20
153
                var eis_file = getprop('/instrumentation/zkv1000/eis/type');
154
                if (eis_file == nil)
155
                    eis_file = getprop('/instrumentation/zkv1000/eis/file');
156

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
681
            if (Alt10 >= 80 and Alt100 >= 9)
682
                var Alt1000 += Alt20;
683

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

            
687
            if (alt> 100)
688
                var Offset10 = 100;
689

            
690
            if (alt> 1000)
691
                var Offset100 = 10;
692

            
693
            if (alt> 10000)
694
                var Offset1000 = 10;
695

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

            
717
                if (altUP == 0) {
718
                    var AltBigUP    = "";
719
                    var AltSmallUP  = "0";
720

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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