zkv1000 / Nasal / display.nas /
Newer Older
1314 lines | 49.945kb
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
                }
relocate SVG files in Models...
Sébastien MARQUE authored on 2017-12-31
151
                canvas.parsesvg(m.screen, data.zkv1000_reldir ~ 'Models/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 {
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
154
                var eis_file = eis.getValue('type');
EIS now really specific to a...
Sébastien MARQUE authored on 2017-04-20
155
                if (eis_file == nil)
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
156
                    eis_file = eis.getValue('file');
EIS now really specific to a...
Sébastien MARQUE authored on 2017-04-20
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

            
relocate SVG files in Models...
Sébastien MARQUE authored on 2017-12-31
189
            canvas.parsesvg(m.screen, data.zkv1000_reldir ~ 'Models/softkeys.svg');
190
            canvas.parsesvg(m.screen, data.zkv1000_reldir ~ 'Models/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();
add brightness and lights co...
Sébastien MARQUE authored on 2020-04-27
256
            me.device.buttons.MENU = me.device.buttons.GlobalParams;
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
257
        }
258
        else {
259
            me.updateEIS();
260
            io.load_nasal(data.zkv1000_dir ~ 'Nasal/MFD.pages.nas', 'zkv1000');
261
            me['page selected'] = 0;
262
            me.setMFDPages();
263
            me.device.buttons.MENU = me.device.buttons.MapMenu;
264
        }
commit initial
Sébastien MARQUE authored on 2017-03-07
265

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

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

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

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

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

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

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

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

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

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
513
        var path = keyMap[me.device.role];
not yet implemented softkeys...
Sébastien MARQUE authored on 2017-06-08
514
        var bindings = me.device.softkeys.bindings[me.device.role];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
515
        var pathid = '';
516
        foreach (var p; me.device.softkeys.path) {
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
517
            path = path[p];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
518
            pathid ~= p;
not yet implemented softkeys...
Sébastien MARQUE authored on 2017-06-08
519
            if (contains(bindings, p))
520
                bindings = bindings[p];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
521
        }
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
522

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

            
554
        if (size(me.device.softkeys.path))
555
            me.timers2.softkeys_inactivity.restart(me.softkeys_inactivity_delay);
556
        else
557
            me.timers2.softkeys_inactivity.stop();
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
558
    },
559
#}}}
560

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

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

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

            
improve trends vor ALT and I...
Sébastien MARQUE authored on 2020-04-30
631
        var Sy = 0;
632
        for (var i = 8; i >= 0; i -= 1)
633
            me._last_ias_Sy[i+1] = me._last_ias_Sy[i];
trends animation
Sébastien MARQUE authored on 2017-03-13
634
        var now = systime();
635
        # estimated speed in 6s
improve trends vor ALT and I...
Sébastien MARQUE authored on 2020-04-30
636
        me._last_ias_Sy[0] = 6 * (ias - me._last_ias_kt) / (now - me._last_ias_s);
637
        foreach (var _Sy; me._last_ias_Sy)
638
            Sy += _Sy;
639
        Sy /= 10;
trends animation
Sébastien MARQUE authored on 2017-03-13
640
        if (abs(Sy) > 30)
641
            Sy = 30 * abs(Sy)/Sy; # = -30 or 30
642
        me.screenElements['Airspeed-Trend-Indicator']
643
            .setScale(1,Sy)
644
            .setTranslation(0, -284.5 * (Sy - 1));
645
        me._last_ias_kt = ias;
646
        me._last_ias_s = now;
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
647
        settimer(func me.updateIAS(), 0.1);
animation IAS
Sébastien MARQUE authored on 2017-03-10
648
    },
trends animation
Sébastien MARQUE authored on 2017-03-13
649
    _last_ias_kt : 0,
650
    _last_ias_s : systime(),
improve trends vor ALT and I...
Sébastien MARQUE authored on 2020-04-30
651
    _last_ias_Sy : [0,0,0,0,0,0,0,0,0,0],
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
652
    _ias_already_exceeded : 0,
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
653
#}}}
animation ALT
Sébastien MARQUE authored on 2017-03-11
654

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

            
665
    updateALT: func () {
666
# animates the altitude lint (PFD) {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
667
        var alt = data.alt;
animation ALT
Sébastien MARQUE authored on 2017-03-11
668
        if (alt < 0)
669
            me.screenElements.Alt11100
fix altitude indicator
Sébastien MARQUE authored on 2020-05-03
670
                .setText(sprintf("%3d",math.ceil(alt/100)));
animation ALT
Sébastien MARQUE authored on 2017-03-11
671
        elsif (alt < 100)
672
            me.screenElements.Alt11100
673
                .setText('');
674
        else
675
            me.screenElements.Alt11100
fix altitude indicator
Sébastien MARQUE authored on 2020-05-03
676
                .setText(sprintf("%3i",math.floor(alt/100)));
animation ALT
Sébastien MARQUE authored on 2017-03-11
677
        me.screenElements.AltLint00011
678
            .setTranslation(0,math.fmod(alt,100) * 1.24);
679

            
680
        # From Farmin/G1000 http://wiki.flightgear.org/Project_Farmin/FG1000
681
        if (alt> -1000 and alt< 1000000) {
682
            var Offset10 = 0;
683
            var Offset100 = 0;
684
            var Offset1000 = 0;
685
            if (alt< 0) {
686
                var Ne = 1;
687
                var alt= -alt;
688
            }
689
            else
690
                var Ne = 0;
691

            
692
            var Alt10       = math.mod(alt,100);
693
            var Alt100      = int(math.mod(alt/100,10));
694
            var Alt1000     = int(math.mod(alt/1000,10));
695
            var Alt10000    = int(math.mod(alt/10000,10));
696
            var Alt20       = math.mod(Alt10,20)/20;
697
            if (Alt10 >= 80)
698
                var Alt100 += Alt20;
699

            
700
            if (Alt10 >= 80 and Alt100 >= 9)
701
                var Alt1000 += Alt20;
702

            
703
            if (Alt10 >= 80 and Alt100 >= 9 and Alt1000 >= 9)
704
                var Alt10000 += Alt20;
705

            
706
            if (alt> 100)
707
                var Offset10 = 100;
708

            
709
            if (alt> 1000)
710
                var Offset100 = 10;
711

            
712
            if (alt> 10000)
713
                var Offset1000 = 10;
714

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

            
736
                if (altUP == 0) {
737
                    var AltBigUP    = "";
738
                    var AltSmallUP  = "0";
739

            
740
                }
741
                elsif (math.mod(altUP,500) == 0 and altUP != 0) {
742
                    var AltBigUP    = sprintf(prefix~"%1d", altUP);
743
                    var AltSmallUP  = "";
744
                }
745
                elsif (altUP < 1000 and (math.mod(altUP,500))) {
746
                    var AltBigUP    = "";
747
                    var AltSmallUP  = sprintf(prefix~"%1d", int(math.mod(altUP,1000)));
748
                    var offset = -30.078;
749
                }
750
                elsif ((altUP < 10000) and (altUP >= 1000) and (math.mod(altUP,500))) {
751
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
752
                    var AltSmallUP  = sprintf("%1d", int(math.mod(altUP,1000)));
753
                    var offset += 15.039;
754
                }
755
                else {
756
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
757
                    var mod = int(math.mod(altUP,1000));
758
                    var AltSmallUP  = sprintf("%1d", mod);
759
                    var offset += 30.078;
760
                }
761

            
762
                me.screenElements["AltBigU"~place].setText(AltBigUP);
763
                me.screenElements["AltSmallU"~place].setText(AltSmallUP);
764
                me.screenElements["AltSmallU"~place].setTranslation(offset,0);
765
                var altDOWN = altCentral - (place*100);
766
                var offset = -30.078;
767
                if (altDOWN < 0) {
768
                    var altDOWN = -altDOWN;
769
                    var prefix = "-";
770
                    var offset += 15.039;
771
                }
772
                else
773
                    var prefix = "";
774

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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