zkv1000 / Nasal / display.nas /
Newer Older
1318 lines | 50.673kb
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',
autopilot status with separa...
Sébastien MARQUE authored on 2020-05-08
140
                    'ETE', 'ETE-text', 'DIS', 'DIS-text', 'LEG-text',
141
                    'LATMOD-Armed-text', 'LATMOD-Active-text',
142
                    'AP-Status-text', 'YD-Status-text',
143
                    'VERMOD-Active-text', 'VERMOD-Armed-text', 'VERMOD-Reference-text',
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
144
                    'AltBigC', 'AltSmallC'
adds some vim z-folds
Sébastien MARQUE authored on 2017-04-19
145
# }}}
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
146
                );
147
                for (var place = 1; place <= 6; place +=1) {
148
                    append(groups.text,
149
                        'AltBigU' ~ place,
150
                        'AltSmallU' ~ place,
151
                        'AltBigD' ~ place,
152
                        'AltSmallD' ~ place
153
                    );
154
                }
relocate SVG files in Models...
Sébastien MARQUE authored on 2017-12-31
155
                canvas.parsesvg(m.screen, data.zkv1000_reldir ~ 'Models/PFD.svg');
animation ALT
Sébastien MARQUE authored on 2017-03-11
156
            }
adds EIS
Sébastien MARQUE authored on 2017-03-18
157
            else {
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
158
                var eis_file = eis.getValue('type');
EIS now really specific to a...
Sébastien MARQUE authored on 2017-04-20
159
                if (eis_file == nil)
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
160
                    eis_file = eis.getValue('file');
EIS now really specific to a...
Sébastien MARQUE authored on 2017-04-20
161

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

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

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

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

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

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

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

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

            
229
# temporary Widget Display for HDG and CRS modification {{{
230

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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