zkv1000 / Nasal / display.nas /
Newer Older
1306 lines | 49.438kb
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',
388
        }
some added comments
Sébastien MARQUE authored on 2017-03-18
389
#        'TAS-text' : {
390
#            alignment : 'right-bottom',
391
#        },
392
#        'GSPD-text' : {
393
#            alignment : 'right-bottom',
394
#        },
animation VSI
Sébastien MARQUE authored on 2017-03-10
395
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
396
#}}}
animation VSI
Sébastien MARQUE authored on 2017-03-10
397

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

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

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

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

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

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

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

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

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

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

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

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
647
    updateTAS: func {
648
# updates the True Airspeed and GroundSpeed indicators {{{
649
        me.screenElements['TAS-text']
650
            .setText(sprintf('%iKT', getprop('/instrumentation/airspeed-indicator/true-speed-kt')));
651
        me.screenElements['GSPD-text']
652
            .setText(sprintf('%iKT', getprop('/velocities/groundspeed-kt')));
653
        settimer(func me.updateTAS(), 0.5);
654
    },
655
#}}}
656

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

            
672
        # From Farmin/G1000 http://wiki.flightgear.org/Project_Farmin/FG1000
673
        if (alt> -1000 and alt< 1000000) {
674
            var Offset10 = 0;
675
            var Offset100 = 0;
676
            var Offset1000 = 0;
677
            if (alt< 0) {
678
                var Ne = 1;
679
                var alt= -alt;
680
            }
681
            else
682
                var Ne = 0;
683

            
684
            var Alt10       = math.mod(alt,100);
685
            var Alt100      = int(math.mod(alt/100,10));
686
            var Alt1000     = int(math.mod(alt/1000,10));
687
            var Alt10000    = int(math.mod(alt/10000,10));
688
            var Alt20       = math.mod(Alt10,20)/20;
689
            if (Alt10 >= 80)
690
                var Alt100 += Alt20;
691

            
692
            if (Alt10 >= 80 and Alt100 >= 9)
693
                var Alt1000 += Alt20;
694

            
695
            if (Alt10 >= 80 and Alt100 >= 9 and Alt1000 >= 9)
696
                var Alt10000 += Alt20;
697

            
698
            if (alt> 100)
699
                var Offset10 = 100;
700

            
701
            if (alt> 1000)
702
                var Offset100 = 10;
703

            
704
            if (alt> 10000)
705
                var Offset1000 = 10;
706

            
707
            if (!Ne) {
708
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*0.57375);
709
                var altCentral = (int(alt/100)*100);
710
            }
711
            elsif (Ne) {
712
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*-0.57375);
713
                var altCentral = -(int(alt/100)*100);
714
            }
715
            me.screenElements["AltBigC"].setText("");
716
            me.screenElements["AltSmallC"].setText("");
717
            for (var place = 1; place <= 6; place += 1) {
718
                var altUP = altCentral + (place*100);
719
                var offset = -30.078;
720
                if (altUP < 0) {
721
                    var altUP = -altUP;
722
                    var prefix = "-";
723
                    var offset += 15.039;
724
                }
725
                else
726
                    var prefix = "";
727

            
728
                if (altUP == 0) {
729
                    var AltBigUP    = "";
730
                    var AltSmallUP  = "0";
731

            
732
                }
733
                elsif (math.mod(altUP,500) == 0 and altUP != 0) {
734
                    var AltBigUP    = sprintf(prefix~"%1d", altUP);
735
                    var AltSmallUP  = "";
736
                }
737
                elsif (altUP < 1000 and (math.mod(altUP,500))) {
738
                    var AltBigUP    = "";
739
                    var AltSmallUP  = sprintf(prefix~"%1d", int(math.mod(altUP,1000)));
740
                    var offset = -30.078;
741
                }
742
                elsif ((altUP < 10000) and (altUP >= 1000) and (math.mod(altUP,500))) {
743
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
744
                    var AltSmallUP  = sprintf("%1d", int(math.mod(altUP,1000)));
745
                    var offset += 15.039;
746
                }
747
                else {
748
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
749
                    var mod = int(math.mod(altUP,1000));
750
                    var AltSmallUP  = sprintf("%1d", mod);
751
                    var offset += 30.078;
752
                }
753

            
754
                me.screenElements["AltBigU"~place].setText(AltBigUP);
755
                me.screenElements["AltSmallU"~place].setText(AltSmallUP);
756
                me.screenElements["AltSmallU"~place].setTranslation(offset,0);
757
                var altDOWN = altCentral - (place*100);
758
                var offset = -30.078;
759
                if (altDOWN < 0) {
760
                    var altDOWN = -altDOWN;
761
                    var prefix = "-";
762
                    var offset += 15.039;
763
                }
764
                else
765
                    var prefix = "";
766

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

            
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
820
    updateBARO : func () {
821
# update BARO widget {{{
822
        var fmt = me._baro_unit == 'inhg' ? '%.2f%s' : '%i%s';
823
        me.screenElements['BARO-text']
824
            .setText(sprintf(fmt,
825
                        getprop('/instrumentation/altimeter/setting-' ~ me._baro_unit),
826
                        me._baro_unit == 'inhg' ? 'in' : 'hPa')
827
                );
828
    },
829
    _baro_unit : 'inhg',
830
#}}}
831

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

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

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

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

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

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

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

            
1063
    updateCOMM: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
1064
# update COMM radios display upper right (PFD/MFD){{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1065
        arg[0]._r = 'comm';
1066
        me._updateRadio(arg[0]);
1067
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
1068
#}}}
anime time display
Sébastien MARQUE authored on 2017-03-13
1069

            
1070
    updateTIME : func {
1071
# updates the displayed time botoom left {{{
1072
        me.screenElements['TIME-text']
1073
            .setText(getprop('/sim/time/gmt-string'));
1074
        settimer(func me.updateTIME(), 1);
1075
    },
1076
#}}}
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1077

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

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

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

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

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

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

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

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