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

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

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

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

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

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

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

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

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

            
relocate SVG files in Models...
Sébastien MARQUE authored on 2017-12-31
190
            canvas.parsesvg(m.screen, data.zkv1000_reldir ~ 'Models/softkeys.svg');
191
            canvas.parsesvg(m.screen, data.zkv1000_reldir ~ 'Models/header-nav-comm.svg');
animation ALT
Sébastien MARQUE authored on 2017-03-11
192

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

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

            
replace settimer by maketime...
Sébastien MARQUE authored on 2020-05-06
217
    off: func {
218
        foreach(var timer; keys(me.timers2)) {
219
            me.timers2[timer].stop();
220
            delete(me.timers2, timer);
221
        }
222
        me.screen.del();
223
        me.display.del();
224
    },
225

            
226
# temporary Widget Display for HDG and CRS modification {{{
227

            
228
    temporaryWidgetDisplay : {},
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
229

            
230
    timerTrigger : func {
231
        var now = systime();
replace settimer by maketime...
Sébastien MARQUE authored on 2020-05-06
232
        foreach (var id; keys(me.temporaryWidgetDisplay)) {
233
            if (me.temporaryWidgetDisplay[id] < now) {
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
234
                me.screenElements[id].hide();
replace settimer by maketime...
Sébastien MARQUE authored on 2020-05-06
235
                delete(me.temporaryWidgetDisplay, id);
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
236
            }
commit initial
Sébastien MARQUE authored on 2017-03-07
237
        }
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
238
    },
239

            
240
    addTimer : func (duration, element) {
241
        if (typeof(element) == 'scalar')
242
            element = [ element ];
243
        var end = systime() + duration;
244
        foreach (var e; element)
replace settimer by maketime...
Sébastien MARQUE authored on 2020-05-06
245
            me.temporaryWidgetDisplay[e] = end;
commit initial
Sébastien MARQUE authored on 2017-03-07
246
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
247
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
248

            
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
249
    showInitProgress : func {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
250
#{{{
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
251
        if (me.device.role == 'PFD') {
replace settimer by maketime...
Sébastien MARQUE authored on 2020-05-06
252
            me.timers.updateAI     = maketimer(0.1, me, me.updateAI     );
253
            me.timers.updateVSI    = maketimer(0.1, me, me.updateVSI    );
254
            me.timers.updateIAS    = maketimer(0.1, me, me.updateIAS    );
255
            me.timers.updateALT    = maketimer(0.2, me, me.updateALT    );
256
            me.timers.updateHSI    = maketimer(0.2, me, me.updateHSI    );
257
            me.timers.updateTIME   = maketimer(1.0, me, me.updateTIME   );
258
            me.timers.updateOAT    = maketimer(3.0, me, me.updateOAT    );
259
            me.timers.updateTAS    = maketimer(0.5, me, me.updateTAS    );
260
            me.timers.updateBRG    = maketimer(0.5, me, me.updateBRG    );
261
            me.timers.updateXPDR   = maketimer(0,   me, me.updateXPDR   ); me.timers.updateXPDR.singleShot=1;
262
            me.timers.updateBARO   = maketimer(0,   me, me.updateBARO   ); me.timers.updateBARO.singleShot=1;
263
            me.timers.updateOMI    = maketimer(1.0, me, me.updateOMI    );
264
            me.timers.timerTrigger = maketimer(1.0, me, me.timerTrigger );
265

            
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
266
            me.screen.show();
add brightness and lights co...
Sébastien MARQUE authored on 2020-04-27
267
            me.device.buttons.MENU = me.device.buttons.GlobalParams;
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
268
        }
269
        else {
270
            me.updateEIS();
271
            io.load_nasal(data.zkv1000_dir ~ 'Nasal/MFD.pages.nas', 'zkv1000');
272
            me['page selected'] = 0;
273
            me.setMFDPages();
274
            me.device.buttons.MENU = me.device.buttons.MapMenu;
275
        }
commit initial
Sébastien MARQUE authored on 2017-03-07
276

            
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
277
        me.updateNAV({auto:'nav', tune: radios.getNode('nav-tune').getValue()});
278
        me.updateCOMM({auto:'comm', tune: radios.getNode('comm-tune').getValue()});
279
        me.softkeys_inactivity();
280
        me.updateSoftKeys();
replace settimer by maketime...
Sébastien MARQUE authored on 2020-05-06
281
        me.timers.updateNavigationBox = maketimer(me.device.role == 'MFD' ? 0.6 : 0.3, me, me.updateNavigationBox);
282

            
283
        foreach (var timer; keys(me.timers))
284
            me.timers[timer].start();
commit initial
Sébastien MARQUE authored on 2017-03-07
285
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
286
#}}}
commit initial
Sébastien MARQUE authored on 2017-03-07
287

            
some added comments
Sébastien MARQUE authored on 2017-03-18
288
    colors : {
289
# set of predefined colors {{{
290
        green : [0, 1, 0],
291
        white : [1, 1, 1],
292
        black : [0, 0, 0],
293
        lightblue : [0, 1, 1],
294
        darkblue : [0, 0, 1],
295
        red : [1, 0, 0],
adds CDI
Sébastien MARQUE authored on 2017-03-18
296
        magenta : [1, 0, 1],
some added comments
Sébastien MARQUE authored on 2017-03-18
297
    },
298
#}}}
299

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

            
358
    clips : {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
359
#{{{
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
360
        PitchScale   : "rect(70,664,370,256)",
361
        SpeedLint1   : "rect(252,226,318,204)",
362
        SpeedTape    : "rect(115,239,455,156)",
363
        LintAlt      : "rect(115,808,455,704)",
animation ALT
Sébastien MARQUE authored on 2017-03-11
364
        AltLint00011 : "rect(252,804,318,771)",
AI disponible
Sébastien MARQUE authored on 2017-03-10
365
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
366
#}}}
AI disponible
Sébastien MARQUE authored on 2017-03-10
367

            
animation VSI
Sébastien MARQUE authored on 2017-03-10
368
    texts : {
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
369
#{{{
animation VSI
Sébastien MARQUE authored on 2017-03-10
370
        VSIText : {
371
            alignment: "right-bottom", default : num('0'),
372
        },
animation IAS
Sébastien MARQUE authored on 2017-03-10
373
        Speed110 : {
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
374
            alignment : 'left-bottom'
animation IAS
Sébastien MARQUE authored on 2017-03-10
375
        },
animation ALT (2)
Sébastien MARQUE authored on 2017-03-11
376
        Alt11100 : {
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
377
            alignment:'left-bottom'
animation ALT (2)
Sébastien MARQUE authored on 2017-03-11
378
        },
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
379
        "HDG-text" : {
380
            default: '---°'
381
        },
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
382
        'nav1-standby-freq' : {
383
            color: [0, 1, 1],
384
        },
385
        'nav1-id' : {
386
            default: ''
387
        },
388
        'nav2-id' : {
389
            default: ''
390
        },
adds CDI
Sébastien MARQUE authored on 2017-03-18
391
        'CDI-GPS-ANN-text' : {
392
            visible : 0
393
        },
394
        'CDI-GPS-XTK-text' : {
395
            visible : 0
396
        },
397
        'CDI-SRC-text' : {
398
            visible : 0
399
        },
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
400
        'BARO-text' : {
401
            alignment : 'left-bottom',
improve route info display
Sébastien MARQUE authored on 2020-05-03
402
        },
403
        'LEG-text' : {
404
            alignment : 'center-center',
405
        },
adds AFCS
Sébastien MARQUE authored on 2020-05-06
406
        'AP-text' : {
407
            alignment : 'left-center',
408
            color : [0, 1, 1],
409
        },
some added comments
Sébastien MARQUE authored on 2017-03-18
410
#        'TAS-text' : {
411
#            alignment : 'right-bottom',
412
#        },
413
#        'GSPD-text' : {
414
#            alignment : 'right-bottom',
415
#        },
animation VSI
Sébastien MARQUE authored on 2017-03-10
416
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
417
#}}}
animation VSI
Sébastien MARQUE authored on 2017-03-10
418

            
Softkeys revert to the previ...
Sébastien MARQUE authored on 2017-03-21
419
    softkeys_inactivity : func {
420
# automagically back to previous level after some delay {{{
421
        me.timers2.softkeys_inactivity = maketimer (
422
            me.softkeys_inactivity_delay,
423
            func {
424
                pop(me.device.softkeys.path);
425
                me.updateSoftKeys();
426
            }, me);
427
        me.timers2.softkeys_inactivity.singleShot = 1;
428
    },
429
#}}}
430

            
softkey is implemented by de...
Sébastien MARQUE authored on 2017-12-21
431
    setSoftKeyColor : func (n, active, implemented = 1, alert = 0) {
add softkeys colors
Sébastien MARQUE authored on 2017-03-21
432
# set colors for active softkeys {{{
433
        var sftk = sprintf('SoftKey%02i-', n);
434
        if (active) {
435
            var bg = alert ? 1 : 0.5;
436
            me.screenElements[sftk ~ 'bg']
437
                .setColorFill(bg,bg,bg);
438
            me.screenElements[sftk ~ 'text']
439
                .setColor(0,0,0);
440
        }
441
        else {
not yet implemented softkeys...
Sébastien MARQUE authored on 2017-06-08
442
            var tc = implemented ? 1 : 0.5;
add softkeys colors
Sébastien MARQUE authored on 2017-03-21
443
            me.screenElements[sftk ~ 'bg']
444
                .setColorFill(0,0,0);
445
            me.screenElements[sftk ~ 'text']
not yet implemented softkeys...
Sébastien MARQUE authored on 2017-06-08
446
                .setColor(tc,tc,tc);
add softkeys colors
Sébastien MARQUE authored on 2017-03-21
447
        }
448
    },
449
#}}}
450

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

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

            
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
528
        var path = keyMap[me.device.role];
not yet implemented softkeys...
Sébastien MARQUE authored on 2017-06-08
529
        var bindings = me.device.softkeys.bindings[me.device.role];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
530
        var pathid = '';
531
        foreach (var p; me.device.softkeys.path) {
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
532
            path = path[p];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
533
            pathid ~= p;
not yet implemented softkeys...
Sébastien MARQUE authored on 2017-06-08
534
            if (contains(bindings, p))
535
                bindings = bindings[p];
improves softkeys coloring
Sébastien MARQUE authored on 2017-04-15
536
        }
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
537

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

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

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

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

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

            
improve trends vor ALT and I...
Sébastien MARQUE authored on 2020-04-30
644
        var Sy = 0;
645
        for (var i = 8; i >= 0; i -= 1)
646
            me._last_ias_Sy[i+1] = me._last_ias_Sy[i];
trends animation
Sébastien MARQUE authored on 2017-03-13
647
        var now = systime();
648
        # estimated speed in 6s
improve trends vor ALT and I...
Sébastien MARQUE authored on 2020-04-30
649
        me._last_ias_Sy[0] = 6 * (ias - me._last_ias_kt) / (now - me._last_ias_s);
650
        foreach (var _Sy; me._last_ias_Sy)
651
            Sy += _Sy;
652
        Sy /= 10;
trends animation
Sébastien MARQUE authored on 2017-03-13
653
        if (abs(Sy) > 30)
654
            Sy = 30 * abs(Sy)/Sy; # = -30 or 30
655
        me.screenElements['Airspeed-Trend-Indicator']
656
            .setScale(1,Sy)
657
            .setTranslation(0, -284.5 * (Sy - 1));
658
        me._last_ias_kt = ias;
659
        me._last_ias_s = now;
animation IAS
Sébastien MARQUE authored on 2017-03-10
660
    },
trends animation
Sébastien MARQUE authored on 2017-03-13
661
    _last_ias_kt : 0,
662
    _last_ias_s : systime(),
improve trends vor ALT and I...
Sébastien MARQUE authored on 2020-04-30
663
    _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
664
    _ias_already_exceeded : 0,
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
665
#}}}
animation ALT
Sébastien MARQUE authored on 2017-03-11
666

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

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

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

            
703
            var Alt10       = math.mod(alt,100);
704
            var Alt100      = int(math.mod(alt/100,10));
705
            var Alt1000     = int(math.mod(alt/1000,10));
706
            var Alt10000    = int(math.mod(alt/10000,10));
707
            var Alt20       = math.mod(Alt10,20)/20;
708
            if (Alt10 >= 80)
709
                var Alt100 += Alt20;
710

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

            
714
            if (Alt10 >= 80 and Alt100 >= 9 and Alt1000 >= 9)
715
                var Alt10000 += Alt20;
716

            
717
            if (alt> 100)
718
                var Offset10 = 100;
719

            
720
            if (alt> 1000)
721
                var Offset100 = 10;
722

            
723
            if (alt> 10000)
724
                var Offset1000 = 10;
725

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

            
747
                if (altUP == 0) {
748
                    var AltBigUP    = "";
749
                    var AltSmallUP  = "0";
750

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

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

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

            
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
838
    updateBARO : func () {
839
# update BARO widget {{{
840
        var fmt = me._baro_unit == 'inhg' ? '%.2f%s' : '%i%s';
841
        me.screenElements['BARO-text']
842
            .setText(sprintf(fmt,
843
                        getprop('/instrumentation/altimeter/setting-' ~ me._baro_unit),
844
                        me._baro_unit == 'inhg' ? 'in' : 'hPa')
845
                );
846
    },
847
    _baro_unit : 'inhg',
848
#}}}
849

            
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
850
    updateHSI : func () {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
851
# rotates the compass (PFD) {{{
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
852
        var hdg = data.hdg;
animation HSI
Sébastien MARQUE authored on 2017-03-11
853
        me.screenElements.Rose
854
            .setRotation(-hdg * D2R);
855
        me.screenElements['HDG-text']
856
            .setText(sprintf("%03u°", hdg));
857
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
858
#}}}
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
859

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

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

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

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

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

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

            
1080
    updateCOMM: func {
comment on the folds
Sébastien MARQUE authored on 2017-03-13
1081
# update COMM radios display upper right (PFD/MFD){{{
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
1082
        arg[0]._r = 'comm';
1083
        me._updateRadio(arg[0]);
1084
    },
cosmétique: folding pour les...
Sébastien MARQUE authored on 2017-03-13
1085
#}}}
anime time display
Sébastien MARQUE authored on 2017-03-13
1086

            
1087
    updateTIME : func {
1088
# updates the displayed time botoom left {{{
1089
        me.screenElements['TIME-text']
1090
            .setText(getprop('/sim/time/gmt-string'));
1091
    },
1092
#}}}
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
1093

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

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

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

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

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

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

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

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