comment on the folds
|
1 |
# vim: set foldmethod=marker foldmarker={{{,}}} : |
commit initial
|
2 |
var displayClass = { |
pass device pointer to displ...
|
3 |
new: func(device, role) { |
commit initial
|
4 |
var m = { parents: [ displayClass ] }; |
cosmétique: folding pour les...
|
5 | |
commit initial
|
6 |
m.display = canvas.new({ |
7 |
"name" : role, |
|
8 |
"size" : [1024, 768], |
|
9 |
"view" : [1024, 768], |
|
10 |
"mipmapping": 1 |
|
11 |
}); |
|
12 |
m.display.addPlacement({ |
|
13 |
"node": "Screen", |
|
14 |
"parent": role |
|
15 |
}); |
|
16 |
m.display.setColorBackground(0,0,0); |
|
17 |
m.role = role; |
|
pass device pointer to displ...
|
18 |
m.device = device; |
écriture du wrapper pour le ...
|
19 |
m.screenElements = {}; |
commit initial
|
20 | |
21 |
return m; |
|
22 |
}, |
|
23 | ||
ajoute un timer pour cacher ...
|
24 |
timers : {}, |
25 | ||
26 |
timerTrigger : func { |
|
27 |
var now = systime(); |
|
28 |
foreach (var id; keys(me.timers)) { |
|
29 |
if (me.timers[id] < now) { |
|
30 |
me.screenElements[id].hide(); |
|
31 |
delete(me.timers, id); |
|
32 |
} |
|
33 |
} |
|
34 |
settimer(func me.timerTrigger(), 1); |
|
35 |
}, |
|
36 | ||
37 |
addTimer : func (duration, element) { |
|
38 |
if (typeof(element) == 'scalar') |
|
39 |
element = [ element ]; |
|
40 |
var end = systime() + duration; |
|
41 |
foreach (var e; element) |
|
42 |
me.timers[e] = end; |
|
43 |
}, |
|
44 | ||
commit initial
|
45 |
loadsvg : func () { |
46 |
me.screen = me.display.createGroup(); |
|
47 |
me.screen.hide(); |
|
48 |
canvas.parsesvg(me.screen, "Aircraft/Instruments-3d/zkv1000/Systems/screen.svg"); |
|
49 |
}, |
|
50 | ||
51 |
_showInitProgress : func (p,t) { |
|
cosmétique: folding pour les...
|
52 |
#{{{ |
commit initial
|
53 |
p.setText(t); |
54 |
if (zkv.getNode(me.role ~ 'init').getValue() != 0) { |
|
55 |
if (size(t) >= 10) t = ''; |
|
56 |
settimer(func { me._showInitProgress(p, t ~ '.'); }, 0.1); |
|
57 |
} |
|
58 |
else { |
|
59 |
me.progress.hide(); |
|
60 |
me.screen.show(); |
|
séparation configuration PFD...
|
61 |
var groups = { |
animation VSI
|
62 |
show : [ |
commit initial
|
63 |
'SoftKeysTexts', |
64 |
'COMM', |
|
65 |
'NAV', |
|
ajout COMM, et factorisation...
|
66 |
'nav-freq-switch', |
67 |
'comm-freq-switch', |
|
séparation configuration PFD...
|
68 |
], |
69 |
text: [ |
|
70 |
'nav1-standby-freq', 'nav1-selected-freq', 'nav1-id', |
|
71 |
'nav2-standby-freq', 'nav2-selected-freq', 'nav2-id', |
|
ajout COMM, et factorisation...
|
72 |
'comm1-standby-freq', 'comm1-selected-freq', |
73 |
'comm2-standby-freq', 'comm2-selected-freq', |
|
séparation configuration PFD...
|
74 |
], |
ajout COMM, et factorisation...
|
75 |
hide : [ ], |
séparation configuration PFD...
|
76 |
clip: [ ], |
77 |
}; |
|
78 |
if (me.role == 'PFD') { |
|
79 |
append(groups.show, |
|
commit initial
|
80 |
'XPDR-TIME', |
AI disponible
|
81 |
'FlightInstruments', |
82 |
'Horizon', |
|
AI disponible, avec bankPoin...
|
83 |
'bankPointer', |
animation VSI
|
84 |
'VSI', |
animation HSI
|
85 |
'Rose', |
animation HDG bug
|
86 |
'Heading-bug', |
87 |
'PFD-Widgets', |
|
trends animation
|
88 |
'Trends', |
89 |
'Airspeed-Trend-Indicator', |
|
90 |
'Altitude-Trend-Indicator', |
|
séparation configuration PFD...
|
91 |
); |
92 |
append(groups.hide, |
|
NAV disponible (hors CDI)
|
93 |
'CDI', |
animation HSI
|
94 |
'NAV1-pointer', |
95 |
'NAV2-pointer', |
|
96 |
'GPS-pointer', |
|
97 |
'Bearing1', |
|
98 |
'Bearing2', |
|
animation HDG bug
|
99 |
'SelectedHDG-bg', |
100 |
'SelectedHDG-bgtext', |
|
101 |
'SelectedHDG-text', |
|
102 |
'SelectedCRS-bg', |
|
103 |
'SelectedCRS-bgtext', |
|
104 |
'SelectedCRS-text', |
|
105 |
'SelectedALT', |
|
106 |
'TAS', |
|
107 |
'GSPD', |
|
108 |
'OAT', |
|
109 |
'BARO', |
|
110 |
'WindData', |
|
111 |
'Reversionnary', |
|
112 |
'Annunciation', |
|
113 |
'Comparator', |
|
114 |
'BRG1', |
|
115 |
'BRG2', |
|
116 |
'DME1', |
|
117 |
'PFD-Map', |
|
118 |
'PFD-Multilines' |
|
séparation configuration PFD...
|
119 |
); |
120 |
append(groups.clip, |
|
animation IAS
|
121 |
'SpeedLint1', |
animation ALT
|
122 |
'SpeedTape', |
123 |
'LintAlt', |
|
124 |
'AltLint00011' |
|
125 |
); |
|
séparation configuration PFD...
|
126 |
append(groups.text, |
anime time display
|
127 |
'TIME-text', |
séparation configuration PFD...
|
128 |
'VSIText', |
129 |
'Speed110', |
|
130 |
'Alt11100', |
|
131 |
'HDG-text', |
|
132 |
'AltBigC', 'AltSmallC' |
|
133 |
); |
|
134 |
for (var place = 1; place <= 6; place +=1) { |
|
135 |
append(groups.text, |
|
136 |
'AltBigU' ~ place, |
|
137 |
'AltSmallU' ~ place, |
|
138 |
'AltBigD' ~ place, |
|
139 |
'AltSmallD' ~ place |
|
140 |
); |
|
141 |
} |
|
animation ALT
|
142 |
} |
séparation configuration PFD...
|
143 |
else |
144 |
append(groups.show, 'Header'); |
|
145 | ||
146 |
me.loadGroup(groups); |
|
animation ALT
|
147 | |
séparation configuration PFD...
|
148 |
if (me.role == 'PFD') { |
149 |
me.updateAI(getprop('/orientation/roll-deg'),getprop('orientation/pitch-deg')); |
|
150 |
me.updateVSI(getprop('/instrumentation/vertical-speed-indicator/indicated-speed-fpm')); |
|
151 |
me.updateIAS(getprop('/velocities/airspeed-kt')); |
|
152 |
me.updateALT(getprop('instrumentation/altimeter/indicated-altitude-ft')); |
|
153 |
me.updateHSI(getprop('orientation/heading-deg')); |
|
anime time display
|
154 |
me.updateTIME(); |
ajoute un timer pour cacher ...
|
155 |
me.timerTrigger(); |
séparation configuration PFD...
|
156 |
} |
ajout COMM, et factorisation...
|
157 |
me._updateRadio({auto:'nav'}); |
158 |
me._updateRadio({auto:'comm'}); |
|
commit initial
|
159 |
me.progress.removeAllChildren(); |
160 |
me.progress = nil; |
|
161 |
me.showInitProgress = nil; |
|
162 |
me._showInitProgress = nil; |
|
163 |
zkv.removeChild(me.role ~ 'init'); |
|
164 |
} |
|
165 |
}, |
|
cosmétique: folding pour les...
|
166 |
#}}} |
commit initial
|
167 | |
168 |
showInitProgress : func (role) { |
|
cosmétique: folding pour les...
|
169 |
#{{{ |
commit initial
|
170 |
me.progress = me.display.createGroup(); |
171 |
me.progress.show(); |
|
172 |
me.progress.createChild("text", role ~ " title") |
|
173 |
.setTranslation(512, 384) |
|
174 |
.setAlignment("center-center") |
|
175 |
.setFont("LiberationFonts/LiberationSans-Italic.ttf") |
|
176 |
.setFontSize(64, 1) |
|
177 |
.setColor(1,1,1) |
|
178 |
.setText("ZKV1000 " ~ role ~ " init"); |
|
179 | ||
180 |
zkv.getNode(role ~ 'init',1).setIntValue(1); |
|
181 | ||
182 |
me._showInitProgress(me.progress.createChild("text", role ~ "progress") |
|
183 |
.setTranslation(512, 484) |
|
184 |
.setAlignment("center-center") |
|
185 |
.setFont("LiberationFonts/LiberationSans-Bold.ttf") |
|
186 |
.setFontSize(128, 1) |
|
187 |
.setColor(1,0,0), '.'); |
|
188 |
}, |
|
cosmétique: folding pour les...
|
189 |
#}}} |
commit initial
|
190 | |
écriture du wrapper pour le ...
|
191 |
loadGroup : func (h) { |
cosmétique: folding pour les...
|
192 |
#{{{ |
écriture du wrapper pour le ...
|
193 |
if (typeof(h) != 'hash') { |
194 |
msg_dbg(sprintf("%s need a hash, but get a %s from %s", |
|
195 |
caller(0)[0], |
|
196 |
typeof(h), |
|
197 |
caller(1)[0])); |
|
198 |
return; |
|
commit initial
|
199 |
} |
écriture du wrapper pour le ...
|
200 |
var setMethod = func (e, t) { |
201 |
if (t == 'hide') |
|
202 |
me.screenElements[e].hide(); |
|
203 |
elsif (t == 'show') |
|
204 |
me.screenElements[e].show(); |
|
AI disponible
|
205 |
elsif (t == 'rot' or t == 'trans') { |
206 |
if (! contains(me.screenElements[e], t)) |
|
207 |
me.screenElements[e][t] = me.screenElements[e].createTransform(); |
|
208 |
} |
|
209 |
elsif (t == 'clip') { |
|
210 |
if (contains(me.clips, e)) |
|
211 |
me.screenElements[e].set("clip", me.clips[e]); |
|
212 |
else |
|
213 |
print('no defined clip for ' ~ e); |
|
214 |
} |
|
animation VSI
|
215 |
elsif (t == 'text') { |
216 |
if (contains(me.texts, e)) { |
|
217 |
if (contains(me.texts[e], 'alignment')) |
|
218 |
me.screenElements[e].setAlignment(me.texts[e].alignment); |
|
219 |
if (contains(me.texts[e], 'default')) |
|
220 |
me.screenElements[e].setText(me.texts[e].default); |
|
NAV disponible (hors CDI)
|
221 |
if (contains(me.texts[e], 'color')) |
222 |
me.screenElements[e].setColor(me.texts[e].color); |
|
animation VSI
|
223 |
} |
clean pre-merge
|
224 |
# else |
225 |
# print('no text format for ' ~ e); |
|
animation VSI
|
226 |
} |
commit initial
|
227 |
else |
écriture du wrapper pour le ...
|
228 |
print('unknown method ' ~ t); |
229 |
}; |
|
230 |
foreach (var todo; keys(h)) { |
|
231 |
if (typeof(h[todo]) != 'vector') h[todo] = [ h[todo] ]; |
|
232 |
foreach (var id; h[todo]) { |
|
233 |
if (! contains(me.screenElements, id)) { |
|
234 |
me.screenElements[id] = me.screen.getElementById(id); |
|
235 |
if (me.screenElements[id] != nil) |
|
236 |
setMethod(id, todo); |
|
237 |
else |
|
238 |
print('SVG ID ' ~ id ~ ' not found'); |
|
239 |
} |
|
240 |
else |
|
241 |
setMethod(id, todo); |
|
242 |
} |
|
commit initial
|
243 |
} |
244 |
}, |
|
cosmétique: folding pour les...
|
245 |
#}}} |
AI disponible
|
246 | |
247 |
clips : { |
|
cosmétique: folding pour les...
|
248 |
#{{{ |
clean pre-merge
|
249 |
PitchScale : "rect(70,664,370,256)", |
250 |
SpeedLint1 : "rect(252,226,318,204)", |
|
251 |
SpeedTape : "rect(115,239,455,156)", |
|
252 |
LintAlt : "rect(115,808,455,704)", |
|
animation ALT
|
253 |
AltLint00011 : "rect(252,804,318,771)", |
AI disponible
|
254 |
}, |
cosmétique: folding pour les...
|
255 |
#}}} |
AI disponible
|
256 | |
animation VSI
|
257 |
texts : { |
cosmétique: folding pour les...
|
258 |
#{{{ |
animation VSI
|
259 |
VSIText : { |
260 |
alignment: "right-bottom", default : num('0'), |
|
261 |
}, |
|
animation IAS
|
262 |
Speed110 : { |
NAV disponible (hors CDI)
|
263 |
alignment : 'left-bottom' |
animation IAS
|
264 |
}, |
animation ALT (2)
|
265 |
Alt11100 : { |
NAV disponible (hors CDI)
|
266 |
alignment:'left-bottom' |
animation ALT (2)
|
267 |
}, |
clean pre-merge
|
268 |
"HDG-text" : { |
269 |
default: '---°' |
|
270 |
}, |
|
NAV disponible (hors CDI)
|
271 |
'nav1-standby-freq' : { |
272 |
color: [0, 1, 1], |
|
273 |
}, |
|
274 |
'nav1-id' : { |
|
275 |
default: '' |
|
276 |
}, |
|
277 |
'nav2-id' : { |
|
278 |
default: '' |
|
279 |
}, |
|
animation VSI
|
280 |
}, |
cosmétique: folding pour les...
|
281 |
#}}} |
animation VSI
|
282 | |
AI disponible, avec bankPoin...
|
283 |
updateAI: func(roll,pitch){ |
cosmétique: folding pour les...
|
284 |
#{{{ |
AI disponible
|
285 |
if (pitch > 80) |
286 |
pitch = 80; |
|
clean pre-merge
|
287 |
elsif (pitch < -80) |
AI disponible
|
288 |
pitch = -80; |
289 |
me.screenElements.Horizon |
|
290 |
.setRotation(-roll * D2R) |
|
291 |
.setTranslation(0, pitch * 6.8571428); |
|
AI disponible, avec bankPoin...
|
292 |
me.screenElements.bankPointer |
293 |
.setRotation(-roll * D2R); |
|
294 |
settimer(func me.updateAI(getprop('/orientation/roll-deg'),getprop('orientation/pitch-deg')), 0.1); |
|
AI disponible
|
295 |
}, |
cosmétique: folding pour les...
|
296 |
#}}} |
animation VSI
|
297 | |
298 |
updateVSI: func (vsi) { |
|
comment on the folds
|
299 |
# animate VSI {{{ |
animation VSI
|
300 |
me.screenElements.VSIText |
301 |
.setText(num(math.round(vsi, 10))); |
|
302 |
if (vsi > 4500) |
|
303 |
vsi = 4500; |
|
304 |
elsif (vsi < -4500) |
|
305 |
vsi = -4500; |
|
306 |
me.screenElements.VSI |
|
307 |
.setTranslation(0, vsi * -0.03465); |
|
308 |
settimer(func me.updateVSI(getprop('/instrumentation/vertical-speed-indicator/indicated-speed-fpm')), 0.1); |
|
309 |
}, |
|
cosmétique: folding pour les...
|
310 |
#}}} |
animation IAS
|
311 | |
312 |
updateIAS: func (ias) { |
|
comment on the folds
|
313 |
# animates the IAS lint (PFD) {{{ |
animation IAS
|
314 |
if (ias >= 10) |
315 |
me.screenElements.Speed110 |
|
316 |
.setText(sprintf("% 2u",num(math.floor(ias/10)))); |
|
317 |
else |
|
318 |
me.screenElements.Speed110 |
|
319 |
.setText(''); |
|
320 |
me.screenElements.SpeedLint1 |
|
321 |
.setTranslation(0,(math.mod(ias,10) + (ias >= 10)*10) * 36); |
|
322 |
me.screenElements.SpeedTape |
|
323 |
.setTranslation(0,ias * 5.711); |
|
trends animation
|
324 |
var now = systime(); |
325 |
# estimated speed in 6s |
|
326 |
var Sy = 6 * (ias - me._last_ias_kt) / (now - me._last_ias_s); |
|
327 |
if (abs(Sy) > 30) |
|
328 |
Sy = 30 * abs(Sy)/Sy; # = -30 or 30 |
|
329 |
me.screenElements['Airspeed-Trend-Indicator'] |
|
330 |
.setScale(1,Sy) |
|
331 |
.setTranslation(0, -284.5 * (Sy - 1)); |
|
332 |
me._last_ias_kt = ias; |
|
333 |
me._last_ias_s = now; |
|
animation IAS
|
334 |
settimer(func me.updateIAS(getprop('/velocities/airspeed-kt')), 0.1); |
335 |
}, |
|
trends animation
|
336 |
_last_ias_kt : 0, |
337 |
_last_ias_s : systime(), |
|
cosmétique: folding pour les...
|
338 |
#}}} |
animation ALT
|
339 | |
340 |
updateALT: func (alt) { |
|
comment on the folds
|
341 |
# animates the altitude lint (PFD) trent to do {{{ |
animation ALT
|
342 |
if (alt < 0) |
343 |
me.screenElements.Alt11100 |
|
344 |
.setText(sprintf("% 3i",math.ceil(alt/100))); |
|
345 |
elsif (alt < 100) |
|
346 |
me.screenElements.Alt11100 |
|
347 |
.setText(''); |
|
348 |
else |
|
349 |
me.screenElements.Alt11100 |
|
350 |
.setText(sprintf("% 3i",math.floor(alt/100))); |
|
351 |
me.screenElements.AltLint00011 |
|
352 |
.setTranslation(0,math.fmod(alt,100) * 1.24); |
|
353 | ||
354 |
# From Farmin/G1000 http://wiki.flightgear.org/Project_Farmin/FG1000 |
|
355 |
if (alt> -1000 and alt< 1000000) { |
|
356 |
var Offset10 = 0; |
|
357 |
var Offset100 = 0; |
|
358 |
var Offset1000 = 0; |
|
359 |
if (alt< 0) { |
|
360 |
var Ne = 1; |
|
361 |
var alt= -alt; |
|
362 |
} |
|
363 |
else |
|
364 |
var Ne = 0; |
|
365 | ||
366 |
var Alt10 = math.mod(alt,100); |
|
367 |
var Alt100 = int(math.mod(alt/100,10)); |
|
368 |
var Alt1000 = int(math.mod(alt/1000,10)); |
|
369 |
var Alt10000 = int(math.mod(alt/10000,10)); |
|
370 |
var Alt20 = math.mod(Alt10,20)/20; |
|
371 |
if (Alt10 >= 80) |
|
372 |
var Alt100 += Alt20; |
|
373 | ||
374 |
if (Alt10 >= 80 and Alt100 >= 9) |
|
375 |
var Alt1000 += Alt20; |
|
376 | ||
377 |
if (Alt10 >= 80 and Alt100 >= 9 and Alt1000 >= 9) |
|
378 |
var Alt10000 += Alt20; |
|
379 | ||
380 |
if (alt> 100) |
|
381 |
var Offset10 = 100; |
|
382 | ||
383 |
if (alt> 1000) |
|
384 |
var Offset100 = 10; |
|
385 | ||
386 |
if (alt> 10000) |
|
387 |
var Offset1000 = 10; |
|
388 | ||
389 |
if (!Ne) { |
|
390 |
me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*0.57375); |
|
391 |
var altCentral = (int(alt/100)*100); |
|
392 |
} |
|
393 |
elsif (Ne) { |
|
394 |
me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*-0.57375); |
|
395 |
var altCentral = -(int(alt/100)*100); |
|
396 |
} |
|
397 |
me.screenElements["AltBigC"].setText(""); |
|
398 |
me.screenElements["AltSmallC"].setText(""); |
|
399 |
for (var place = 1; place <= 6; place += 1) { |
|
400 |
var altUP = altCentral + (place*100); |
|
401 |
var offset = -30.078; |
|
402 |
if (altUP < 0) { |
|
403 |
var altUP = -altUP; |
|
404 |
var prefix = "-"; |
|
405 |
var offset += 15.039; |
|
406 |
} |
|
407 |
else |
|
408 |
var prefix = ""; |
|
409 | ||
410 |
if (altUP == 0) { |
|
411 |
var AltBigUP = ""; |
|
412 |
var AltSmallUP = "0"; |
|
413 | ||
414 |
} |
|
415 |
elsif (math.mod(altUP,500) == 0 and altUP != 0) { |
|
416 |
var AltBigUP = sprintf(prefix~"%1d", altUP); |
|
417 |
var AltSmallUP = ""; |
|
418 |
} |
|
419 |
elsif (altUP < 1000 and (math.mod(altUP,500))) { |
|
420 |
var AltBigUP = ""; |
|
421 |
var AltSmallUP = sprintf(prefix~"%1d", int(math.mod(altUP,1000))); |
|
422 |
var offset = -30.078; |
|
423 |
} |
|
424 |
elsif ((altUP < 10000) and (altUP >= 1000) and (math.mod(altUP,500))) { |
|
425 |
var AltBigUP = sprintf(prefix~"%1d", int(altUP/1000)); |
|
426 |
var AltSmallUP = sprintf("%1d", int(math.mod(altUP,1000))); |
|
427 |
var offset += 15.039; |
|
428 |
} |
|
429 |
else { |
|
430 |
var AltBigUP = sprintf(prefix~"%1d", int(altUP/1000)); |
|
431 |
var mod = int(math.mod(altUP,1000)); |
|
432 |
var AltSmallUP = sprintf("%1d", mod); |
|
433 |
var offset += 30.078; |
|
434 |
} |
|
435 | ||
436 |
me.screenElements["AltBigU"~place].setText(AltBigUP); |
|
437 |
me.screenElements["AltSmallU"~place].setText(AltSmallUP); |
|
438 |
me.screenElements["AltSmallU"~place].setTranslation(offset,0); |
|
439 |
var altDOWN = altCentral - (place*100); |
|
440 |
var offset = -30.078; |
|
441 |
if (altDOWN < 0) { |
|
442 |
var altDOWN = -altDOWN; |
|
443 |
var prefix = "-"; |
|
444 |
var offset += 15.039; |
|
445 |
} |
|
446 |
else |
|
447 |
var prefix = ""; |
|
448 | ||
449 |
if (altDOWN == 0) { |
|
450 |
var AltBigDOWN = ""; |
|
451 |
var AltSmallDOWN = "0"; |
|
452 |
} |
|
453 |
elsif (math.mod(altDOWN,500) == 0 and altDOWN != 0) { |
|
454 |
var AltBigDOWN = sprintf(prefix~"%1d", altDOWN); |
|
455 |
var AltSmallDOWN = ""; |
|
456 |
} |
|
457 |
elsif (altDOWN < 1000 and (math.mod(altDOWN,500))) { |
|
458 |
var AltBigDOWN = ""; |
|
459 |
var AltSmallDOWN = sprintf(prefix~"%1d", int(math.mod(altDOWN,1000))); |
|
460 |
var offset = -30.078; |
|
461 |
} |
|
462 |
elsif ((altDOWN < 10000) and (altDOWN >= 1000) and (math.mod(altDOWN,500))) { |
|
463 |
var AltBigDOWN = sprintf(prefix~"%1d", int(altDOWN/1000)); |
|
464 |
var AltSmallDOWN = sprintf("%1d", int(math.mod(altDOWN,1000))); |
|
465 |
var offset += 15.039; |
|
466 |
} |
|
467 |
else { |
|
468 |
var AltBigDOWN = sprintf(prefix~"%1d", int(altDOWN/1000)); |
|
469 |
var mod = int(math.mod(altDOWN,1000)); |
|
470 |
var AltSmallDOWN = sprintf("%1d", mod); |
|
471 |
var offset += 30.078; |
|
472 |
} |
|
473 |
me.screenElements["AltBigD"~place].setText(AltBigDOWN); |
|
474 |
me.screenElements["AltSmallD"~place].setText(AltSmallDOWN); |
|
475 |
me.screenElements["AltSmallD"~place].setTranslation(offset,0); |
|
476 |
} |
|
477 |
} |
|
trends animation
|
478 |
var now = systime(); |
479 |
# altitude in 6s |
|
480 |
var Sy = .3 * (alt - me._last_alt_ft) / (now - me._last_alt_s); # scale = 1/20ft |
|
481 |
if (abs(Sy) > 15) |
|
482 |
Sy = 15 * abs(Sy)/Sy; # = -15 or 15 |
|
483 |
me.screenElements['Altitude-Trend-Indicator'] |
|
484 |
.setScale(1,Sy) |
|
485 |
.setTranslation(0, -284.5 * (Sy - 1)); |
|
486 |
me._last_alt_ft = alt; |
|
487 |
me._last_alt_s = now; |
|
animation ALT
|
488 |
settimer(func me.updateALT(getprop('instrumentation/altimeter/indicated-altitude-ft')), 0.2); |
489 |
}, |
|
trends animation
|
490 |
_last_alt_ft : 0, |
491 |
_last_alt_s : systime(), |
|
cosmétique: folding pour les...
|
492 |
#}}} |
animation HSI
|
493 | |
494 |
updateHSI : func (hdg) { |
|
comment on the folds
|
495 |
# rotates the compass (PFD) {{{ |
animation HSI
|
496 |
me.screenElements.Rose |
497 |
.setRotation(-hdg * D2R); |
|
498 |
me.screenElements['HDG-text'] |
|
499 |
.setText(sprintf("%03u°", hdg)); |
|
500 |
settimer(func me.updateHSI(getprop('orientation/heading-deg')), 0.1); |
|
501 |
}, |
|
cosmétique: folding pour les...
|
502 |
#}}} |
NAV disponible (hors CDI)
|
503 | |
animation HDG bug
|
504 |
updateHDG : func (hdg) { |
comment on the folds
|
505 |
# moves the heading bug and display heading-deg for 3 seconds (PFD) {{{ |
animation HDG bug
|
506 |
if (me.role == 'MFD') |
507 |
return; |
|
508 |
me.screenElements['Heading-bug'] |
|
509 |
.setRotation(hdg * D2R); |
|
510 |
me.screenElements['SelectedHDG-bg'] |
|
511 |
.show(); |
|
512 |
me.screenElements['SelectedHDG-bgtext'] |
|
513 |
.show(); |
|
514 |
me.screenElements['SelectedHDG-text'] |
|
515 |
.setText(sprintf('%03d°%s', hdg, '')) |
|
516 |
.show(); |
|
517 |
me.addTimer(3, ['SelectedHDG-text', 'SelectedHDG-bgtext', 'SelectedHDG-bg']); |
|
518 |
}, |
|
cosmétique: folding pour les...
|
519 |
#}}} |
animation HDG bug
|
520 | |
anime CRS
|
521 |
updateCRS : func (crs) { |
522 |
# TODO: update display for NAV/GPS/BRG courses {{{ |
|
523 |
if (me.role == 'MFD') |
|
524 |
return; |
|
525 |
me.screenElements['SelectedCRS-bg'] |
|
526 |
.show(); |
|
527 |
me.screenElements['SelectedCRS-bgtext'] |
|
528 |
.show(); |
|
529 |
me.screenElements['SelectedCRS-text'] |
|
530 |
.setText(sprintf('%03d°%s', crs, '')) |
|
531 |
.show(); |
|
532 |
me.addTimer(3, ['SelectedCRS-text', 'SelectedCRS-bgtext', 'SelectedCRS-bg']); |
|
533 |
}, |
|
534 |
#}}} |
|
535 | ||
ajout COMM, et factorisation...
|
536 |
_updateRadio: func { |
comment on the folds
|
537 |
# common parts for NAV/LOC/COMM radios{{{ |
ajout COMM, et factorisation...
|
538 |
# arg[0]._r = <comm|nav> |
539 |
if (contains(arg[0], "active")) { |
|
540 |
if (arg[0]['active'] == 'none') { |
|
541 |
me.screenElements[arg[0]._r ~ '1-selected-freq'] |
|
542 |
.setColor(1,1,1); |
|
543 |
me.screenElements[arg[0]._r ~ '2-selected-freq'] |
|
544 |
.setColor(1,1,1); |
|
545 |
} |
|
546 |
else { |
|
547 |
me.screenElements[arg[0]._r ~ arg[0]['active'] ~ '-selected-freq'] |
|
548 |
.setColor(0,1,0); |
|
549 |
me.screenElements[arg[0]._r ~ arg[0].inactive ~ '-selected-freq'] |
|
550 |
.setColor(1,1,1); |
|
551 |
} |
|
552 |
} |
|
553 |
if (contains(arg[0], 'tune')) { |
|
554 |
# n = 0 -> NAV1/COMM1 |
|
555 |
# n = 1 -> NAV1/COMM2 |
|
556 |
me.screenElements[arg[0]._r ~ '-freq-switch'] |
|
557 |
.setTranslation(0, arg[0].tune * 25); |
|
558 |
me.screenElements[arg[0]._r ~ (arg[0].tune + 1) ~ '-standby-freq'] |
|
559 |
.setColor(0,1,1); |
|
560 |
me.screenElements[arg[0]._r ~ ((arg[0].tune == 0) + 1) ~ '-standby-freq'] |
|
561 |
.setColor(1,1,1); |
|
562 |
} |
|
563 |
if (contains(arg[0], 'refresh')) { |
|
564 |
# rafraichi une seule ligne NAV1/COMM1 ou NAV2/COMM2 |
|
565 |
var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f'; |
|
566 |
me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-selected-freq'] |
|
567 |
.setText(sprintf(fmt, getprop('/instrumentation/' |
|
568 |
~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/selected-mhz'))); |
|
569 |
me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-standby-freq'] |
|
570 |
.setText(sprintf(fmt, getprop('/instrumentation/' |
|
571 |
~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/standby-mhz'))); |
|
572 |
} |
|
573 |
if (contains(arg[0], 'set')) { |
|
574 |
# positionne la valeur modifiée, les listeners "trigguent" en permanence ces propriétés, donc exit |
|
575 |
var n = getprop('/instrumentation/zkv1000/radios/' ~ arg[0]._r ~ '-tune'); |
|
576 |
var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f'; |
|
577 |
me.screenElements[arg[0]._r ~ (n + 1) ~ '-standby-freq'] |
|
578 |
.setText(getprop('/instrumentation/' ~ arg[0]._r ~ '[' ~ n ~ ']/frequencies/standby-mhz')); |
|
579 |
} |
|
580 |
if (contains(arg[0], 'auto')) { |
|
581 |
# pour rafraichir automagiquement, toutes les deux secondes un refresh pour un NAV |
|
582 |
var radio = arg[0].auto; |
|
583 |
me._updateRadio({refresh: 1, _r: radio}); |
|
584 |
settimer(func me._updateRadio({refresh: 2, _r: radio}), 1); |
|
585 |
settimer(func me._updateRadio({auto: radio}), 2); |
|
586 |
} |
|
587 |
}, |
|
cosmétique: folding pour les...
|
588 |
#}}} |
ajout COMM, et factorisation...
|
589 | |
NAV disponible (hors CDI)
|
590 |
updateNAV : func { |
comment on the folds
|
591 |
# update NAV/LOC rodios display upper left (PFD/MFD){{{ |
NAV disponible (hors CDI)
|
592 |
# made active via menu |
593 |
if (contains(arg[0], "active")) { |
|
594 |
if (arg[0]['active'] == 'none') { |
|
ajout COMM, et factorisation...
|
595 |
arg[0]._r = 'nav'; |
596 |
me._updateRadio(arg[0]); |
|
NAV disponible (hors CDI)
|
597 |
me.screenElements['nav1-id'] |
598 |
.setColor(1,1,1); |
|
599 |
me.screenElements['nav2-id'] |
|
600 |
.setColor(1,1,1); |
|
601 |
me.screenElements['NAV1-pointer'] |
|
602 |
.hide(); |
|
603 |
me.screenElements['NAV2-pointer'] |
|
604 |
.hide(); |
|
605 |
} |
|
606 |
else { |
|
ajout COMM, et factorisation...
|
607 |
arg[0]._r = 'nav'; |
608 |
arg[0].inactive = (arg[0]['active'] == 1) + 1; |
|
609 |
me._updateRadio(arg[0]); |
|
NAV disponible (hors CDI)
|
610 |
me.screenElements['nav' ~ arg[0]['active'] ~ '-id'] |
611 |
.setColor(0,1,0); |
|
612 |
me.screenElements['NAV' ~ arg[0]['active'] ~ '-pointer'] |
|
613 |
.show(); |
|
ajout COMM, et factorisation...
|
614 |
me.screenElements['nav' ~ arg[0].inactive ~ '-id'] |
615 |
.setColor(1,1,1); |
|
NAV disponible (hors CDI)
|
616 |
# me.screenElements['HDI'] |
617 |
# .setRotation(); |
|
618 |
# me.screenElements['NAV' ~ inactive ~ '-pointer'] |
|
619 |
# .hide(); |
|
620 |
# foreach (var e; [ 'FROM', 'TO', 'CDI' ]) |
|
621 |
# me.screenElements['NAV' ~ inactive ~ '-' ~ e] |
|
622 |
# .hide(); |
|
623 |
} |
|
624 |
} |
|
ajout COMM, et factorisation...
|
625 |
elsif (contains(arg[0], 'nav-id')) { |
Correction swap NAV tuning
|
626 |
# TODO: récupérer la valeur via les paramètres transmis du listener |
ajout COMM, et factorisation...
|
627 |
if (arg[0].val == nil) |
628 |
arg[0].val = ''; |
|
NAV disponible (hors CDI)
|
629 |
me.screenElements["nav" ~ arg[0]['nav-id'] ~ "-id"] |
ajout COMM, et factorisation...
|
630 |
.setText(arg[0].val); |
NAV disponible (hors CDI)
|
631 |
} |
ajout COMM, et factorisation...
|
632 |
else { |
633 |
arg[0]._r = 'nav'; |
|
634 |
me._updateRadio(arg[0]); |
|
NAV disponible (hors CDI)
|
635 |
} |
636 |
}, |
|
cosmétique: folding pour les...
|
637 |
#}}} |
ajout COMM, et factorisation...
|
638 | |
639 |
updateCOMM: func { |
|
comment on the folds
|
640 |
# update COMM radios display upper right (PFD/MFD){{{ |
ajout COMM, et factorisation...
|
641 |
arg[0]._r = 'comm'; |
642 |
me._updateRadio(arg[0]); |
|
643 |
}, |
|
cosmétique: folding pour les...
|
644 |
#}}} |
anime time display
|
645 | |
646 |
updateTIME : func { |
|
647 |
# updates the displayed time botoom left {{{ |
|
648 |
me.screenElements['TIME-text'] |
|
649 |
.setText(getprop('/sim/time/gmt-string')); |
|
650 |
settimer(func me.updateTIME(), 1); |
|
651 |
}, |
|
652 |
#}}} |
|
commit initial
|
653 |
}; |