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 |
}; |
|
softkeys are available now
|
78 | |
79 |
for (var k = 0; k < 12; k += 1) |
|
80 |
append(groups.text, sprintf("SoftKey%02i-text", k)); |
|
81 | ||
séparation configuration PFD...
|
82 |
if (me.role == 'PFD') { |
83 |
append(groups.show, |
|
commit initial
|
84 |
'XPDR-TIME', |
AI disponible
|
85 |
'FlightInstruments', |
86 |
'Horizon', |
|
AI disponible, avec bankPoin...
|
87 |
'bankPointer', |
animation VSI
|
88 |
'VSI', |
animation HSI
|
89 |
'Rose', |
animation HDG bug
|
90 |
'Heading-bug', |
91 |
'PFD-Widgets', |
|
trends animation
|
92 |
'Trends', |
93 |
'Airspeed-Trend-Indicator', |
|
94 |
'Altitude-Trend-Indicator', |
|
séparation configuration PFD...
|
95 |
); |
96 |
append(groups.hide, |
|
NAV disponible (hors CDI)
|
97 |
'CDI', |
animation HSI
|
98 |
'NAV1-pointer', |
99 |
'NAV2-pointer', |
|
100 |
'GPS-pointer', |
|
101 |
'Bearing1', |
|
102 |
'Bearing2', |
|
animation HDG bug
|
103 |
'SelectedHDG-bg', |
104 |
'SelectedHDG-bgtext', |
|
105 |
'SelectedHDG-text', |
|
106 |
'SelectedCRS-bg', |
|
107 |
'SelectedCRS-bgtext', |
|
108 |
'SelectedCRS-text', |
|
109 |
'SelectedALT', |
|
110 |
'TAS', |
|
111 |
'GSPD', |
|
112 |
'OAT', |
|
113 |
'BARO', |
|
114 |
'WindData', |
|
115 |
'Reversionnary', |
|
116 |
'Annunciation', |
|
117 |
'Comparator', |
|
118 |
'BRG1', |
|
119 |
'BRG2', |
|
120 |
'DME1', |
|
121 |
'PFD-Map', |
|
122 |
'PFD-Multilines' |
|
séparation configuration PFD...
|
123 |
); |
124 |
append(groups.clip, |
|
animation IAS
|
125 |
'SpeedLint1', |
animation ALT
|
126 |
'SpeedTape', |
127 |
'LintAlt', |
|
128 |
'AltLint00011' |
|
129 |
); |
|
séparation configuration PFD...
|
130 |
append(groups.text, |
anime time display
|
131 |
'TIME-text', |
séparation configuration PFD...
|
132 |
'VSIText', |
133 |
'Speed110', |
|
134 |
'Alt11100', |
|
135 |
'HDG-text', |
|
136 |
'AltBigC', 'AltSmallC' |
|
137 |
); |
|
138 |
for (var place = 1; place <= 6; place +=1) { |
|
139 |
append(groups.text, |
|
140 |
'AltBigU' ~ place, |
|
141 |
'AltSmallU' ~ place, |
|
142 |
'AltBigD' ~ place, |
|
143 |
'AltSmallD' ~ place |
|
144 |
); |
|
145 |
} |
|
animation ALT
|
146 |
} |
séparation configuration PFD...
|
147 |
else |
148 |
append(groups.show, 'Header'); |
|
149 | ||
150 |
me.loadGroup(groups); |
|
animation ALT
|
151 | |
séparation configuration PFD...
|
152 |
if (me.role == 'PFD') { |
153 |
me.updateAI(getprop('/orientation/roll-deg'),getprop('orientation/pitch-deg')); |
|
154 |
me.updateVSI(getprop('/instrumentation/vertical-speed-indicator/indicated-speed-fpm')); |
|
155 |
me.updateIAS(getprop('/velocities/airspeed-kt')); |
|
156 |
me.updateALT(getprop('instrumentation/altimeter/indicated-altitude-ft')); |
|
157 |
me.updateHSI(getprop('orientation/heading-deg')); |
|
anime time display
|
158 |
me.updateTIME(); |
ajoute un timer pour cacher ...
|
159 |
me.timerTrigger(); |
séparation configuration PFD...
|
160 |
} |
ajout COMM, et factorisation...
|
161 |
me._updateRadio({auto:'nav'}); |
162 |
me._updateRadio({auto:'comm'}); |
|
softkeys are available now
|
163 |
me.updateSoftKeys(); |
commit initial
|
164 |
me.progress.removeAllChildren(); |
165 |
me.progress = nil; |
|
166 |
me.showInitProgress = nil; |
|
167 |
me._showInitProgress = nil; |
|
168 |
zkv.removeChild(me.role ~ 'init'); |
|
169 |
} |
|
170 |
}, |
|
cosmétique: folding pour les...
|
171 |
#}}} |
commit initial
|
172 | |
173 |
showInitProgress : func (role) { |
|
cosmétique: folding pour les...
|
174 |
#{{{ |
commit initial
|
175 |
me.progress = me.display.createGroup(); |
176 |
me.progress.show(); |
|
177 |
me.progress.createChild("text", role ~ " title") |
|
178 |
.setTranslation(512, 384) |
|
179 |
.setAlignment("center-center") |
|
180 |
.setFont("LiberationFonts/LiberationSans-Italic.ttf") |
|
181 |
.setFontSize(64, 1) |
|
182 |
.setColor(1,1,1) |
|
183 |
.setText("ZKV1000 " ~ role ~ " init"); |
|
184 | ||
185 |
zkv.getNode(role ~ 'init',1).setIntValue(1); |
|
186 | ||
187 |
me._showInitProgress(me.progress.createChild("text", role ~ "progress") |
|
188 |
.setTranslation(512, 484) |
|
189 |
.setAlignment("center-center") |
|
190 |
.setFont("LiberationFonts/LiberationSans-Bold.ttf") |
|
191 |
.setFontSize(128, 1) |
|
192 |
.setColor(1,0,0), '.'); |
|
193 |
}, |
|
cosmétique: folding pour les...
|
194 |
#}}} |
commit initial
|
195 | |
écriture du wrapper pour le ...
|
196 |
loadGroup : func (h) { |
cosmétique: folding pour les...
|
197 |
#{{{ |
écriture du wrapper pour le ...
|
198 |
if (typeof(h) != 'hash') { |
199 |
msg_dbg(sprintf("%s need a hash, but get a %s from %s", |
|
200 |
caller(0)[0], |
|
201 |
typeof(h), |
|
202 |
caller(1)[0])); |
|
203 |
return; |
|
commit initial
|
204 |
} |
écriture du wrapper pour le ...
|
205 |
var setMethod = func (e, t) { |
206 |
if (t == 'hide') |
|
207 |
me.screenElements[e].hide(); |
|
208 |
elsif (t == 'show') |
|
209 |
me.screenElements[e].show(); |
|
AI disponible
|
210 |
elsif (t == 'rot' or t == 'trans') { |
211 |
if (! contains(me.screenElements[e], t)) |
|
212 |
me.screenElements[e][t] = me.screenElements[e].createTransform(); |
|
213 |
} |
|
214 |
elsif (t == 'clip') { |
|
215 |
if (contains(me.clips, e)) |
|
216 |
me.screenElements[e].set("clip", me.clips[e]); |
|
217 |
else |
|
218 |
print('no defined clip for ' ~ e); |
|
219 |
} |
|
animation VSI
|
220 |
elsif (t == 'text') { |
221 |
if (contains(me.texts, e)) { |
|
222 |
if (contains(me.texts[e], 'alignment')) |
|
223 |
me.screenElements[e].setAlignment(me.texts[e].alignment); |
|
224 |
if (contains(me.texts[e], 'default')) |
|
225 |
me.screenElements[e].setText(me.texts[e].default); |
|
NAV disponible (hors CDI)
|
226 |
if (contains(me.texts[e], 'color')) |
227 |
me.screenElements[e].setColor(me.texts[e].color); |
|
animation VSI
|
228 |
} |
clean pre-merge
|
229 |
# else |
230 |
# print('no text format for ' ~ e); |
|
animation VSI
|
231 |
} |
commit initial
|
232 |
else |
écriture du wrapper pour le ...
|
233 |
print('unknown method ' ~ t); |
234 |
}; |
|
235 |
foreach (var todo; keys(h)) { |
|
236 |
if (typeof(h[todo]) != 'vector') h[todo] = [ h[todo] ]; |
|
237 |
foreach (var id; h[todo]) { |
|
238 |
if (! contains(me.screenElements, id)) { |
|
239 |
me.screenElements[id] = me.screen.getElementById(id); |
|
240 |
if (me.screenElements[id] != nil) |
|
241 |
setMethod(id, todo); |
|
242 |
else |
|
243 |
print('SVG ID ' ~ id ~ ' not found'); |
|
244 |
} |
|
245 |
else |
|
246 |
setMethod(id, todo); |
|
247 |
} |
|
commit initial
|
248 |
} |
249 |
}, |
|
cosmétique: folding pour les...
|
250 |
#}}} |
AI disponible
|
251 | |
252 |
clips : { |
|
cosmétique: folding pour les...
|
253 |
#{{{ |
clean pre-merge
|
254 |
PitchScale : "rect(70,664,370,256)", |
255 |
SpeedLint1 : "rect(252,226,318,204)", |
|
256 |
SpeedTape : "rect(115,239,455,156)", |
|
257 |
LintAlt : "rect(115,808,455,704)", |
|
animation ALT
|
258 |
AltLint00011 : "rect(252,804,318,771)", |
AI disponible
|
259 |
}, |
cosmétique: folding pour les...
|
260 |
#}}} |
AI disponible
|
261 | |
animation VSI
|
262 |
texts : { |
cosmétique: folding pour les...
|
263 |
#{{{ |
animation VSI
|
264 |
VSIText : { |
265 |
alignment: "right-bottom", default : num('0'), |
|
266 |
}, |
|
animation IAS
|
267 |
Speed110 : { |
NAV disponible (hors CDI)
|
268 |
alignment : 'left-bottom' |
animation IAS
|
269 |
}, |
animation ALT (2)
|
270 |
Alt11100 : { |
NAV disponible (hors CDI)
|
271 |
alignment:'left-bottom' |
animation ALT (2)
|
272 |
}, |
clean pre-merge
|
273 |
"HDG-text" : { |
274 |
default: '---°' |
|
275 |
}, |
|
NAV disponible (hors CDI)
|
276 |
'nav1-standby-freq' : { |
277 |
color: [0, 1, 1], |
|
278 |
}, |
|
279 |
'nav1-id' : { |
|
280 |
default: '' |
|
281 |
}, |
|
282 |
'nav2-id' : { |
|
283 |
default: '' |
|
284 |
}, |
|
animation VSI
|
285 |
}, |
cosmétique: folding pour les...
|
286 |
#}}} |
animation VSI
|
287 | |
softkeys are available now
|
288 |
updateSoftKeys : func { |
289 |
# update SoftKeys boxes {{{ |
|
290 |
# grey background code = #353939 |
|
291 |
# on PFD the last boxes are always BACK and ALERTS |
|
292 |
if (me.role == 'PFD') { |
|
293 |
me.screenElements[sprintf("SoftKey%02i-text", 11)] |
|
294 |
.setText('ALERTS'); |
|
295 |
if (size(me.device.softkeys.path) != 0) |
|
296 |
me.screenElements[sprintf("SoftKey%02i-text", 10)] |
|
297 |
.setText('BACK'); |
|
298 |
} |
|
299 | ||
300 |
var path = keyMap[me.role]; |
|
301 |
foreach (var p; me.device.softkeys.path) |
|
302 |
path = path[p]; |
|
303 | ||
304 |
# feeding with empty menus the first boxes |
|
305 |
var start = (contains(path, 'first')) ? path.first : 0; |
|
306 |
for (var k = 0; k < start; k+=1) { |
|
307 |
me.screenElements[sprintf("SoftKey%02i-text", k)] |
|
308 |
.setText(''); |
|
309 |
} |
|
310 |
# filling with the content the next boxes |
|
311 |
forindex (var k; path.texts) { |
|
312 |
var i = k + start; |
|
313 |
me.screenElements[sprintf("SoftKey%02i-text", i)] |
|
314 |
.setText(path.texts[k]); |
|
315 |
} |
|
316 |
# feeding the last boxes with empty string |
|
317 |
var end = (me.role == 'PFD') ? 10 : 12; |
|
318 |
if (size(path.texts) + start < end) { |
|
319 |
start = size(path.texts) + start; |
|
320 |
for (var k = start; k < end; k += 1) |
|
321 |
me.screenElements[sprintf("SoftKey%02i-text", k)] |
|
322 |
.setText(''); |
|
323 |
} |
|
324 |
}, |
|
325 |
#}}} |
|
326 | ||
AI disponible, avec bankPoin...
|
327 |
updateAI: func(roll,pitch){ |
cosmétique: folding pour les...
|
328 |
#{{{ |
AI disponible
|
329 |
if (pitch > 80) |
330 |
pitch = 80; |
|
clean pre-merge
|
331 |
elsif (pitch < -80) |
AI disponible
|
332 |
pitch = -80; |
333 |
me.screenElements.Horizon |
|
334 |
.setRotation(-roll * D2R) |
|
335 |
.setTranslation(0, pitch * 6.8571428); |
|
AI disponible, avec bankPoin...
|
336 |
me.screenElements.bankPointer |
337 |
.setRotation(-roll * D2R); |
|
338 |
settimer(func me.updateAI(getprop('/orientation/roll-deg'),getprop('orientation/pitch-deg')), 0.1); |
|
AI disponible
|
339 |
}, |
cosmétique: folding pour les...
|
340 |
#}}} |
animation VSI
|
341 | |
342 |
updateVSI: func (vsi) { |
|
comment on the folds
|
343 |
# animate VSI {{{ |
animation VSI
|
344 |
me.screenElements.VSIText |
345 |
.setText(num(math.round(vsi, 10))); |
|
346 |
if (vsi > 4500) |
|
347 |
vsi = 4500; |
|
348 |
elsif (vsi < -4500) |
|
349 |
vsi = -4500; |
|
350 |
me.screenElements.VSI |
|
351 |
.setTranslation(0, vsi * -0.03465); |
|
352 |
settimer(func me.updateVSI(getprop('/instrumentation/vertical-speed-indicator/indicated-speed-fpm')), 0.1); |
|
353 |
}, |
|
cosmétique: folding pour les...
|
354 |
#}}} |
animation IAS
|
355 | |
356 |
updateIAS: func (ias) { |
|
comment on the folds
|
357 |
# animates the IAS lint (PFD) {{{ |
animation IAS
|
358 |
if (ias >= 10) |
359 |
me.screenElements.Speed110 |
|
360 |
.setText(sprintf("% 2u",num(math.floor(ias/10)))); |
|
361 |
else |
|
362 |
me.screenElements.Speed110 |
|
363 |
.setText(''); |
|
364 |
me.screenElements.SpeedLint1 |
|
365 |
.setTranslation(0,(math.mod(ias,10) + (ias >= 10)*10) * 36); |
|
366 |
me.screenElements.SpeedTape |
|
367 |
.setTranslation(0,ias * 5.711); |
|
trends animation
|
368 |
var now = systime(); |
369 |
# estimated speed in 6s |
|
370 |
var Sy = 6 * (ias - me._last_ias_kt) / (now - me._last_ias_s); |
|
371 |
if (abs(Sy) > 30) |
|
372 |
Sy = 30 * abs(Sy)/Sy; # = -30 or 30 |
|
373 |
me.screenElements['Airspeed-Trend-Indicator'] |
|
374 |
.setScale(1,Sy) |
|
375 |
.setTranslation(0, -284.5 * (Sy - 1)); |
|
376 |
me._last_ias_kt = ias; |
|
377 |
me._last_ias_s = now; |
|
animation IAS
|
378 |
settimer(func me.updateIAS(getprop('/velocities/airspeed-kt')), 0.1); |
379 |
}, |
|
trends animation
|
380 |
_last_ias_kt : 0, |
381 |
_last_ias_s : systime(), |
|
cosmétique: folding pour les...
|
382 |
#}}} |
animation ALT
|
383 | |
384 |
updateALT: func (alt) { |
|
comment on the folds
|
385 |
# animates the altitude lint (PFD) trent to do {{{ |
animation ALT
|
386 |
if (alt < 0) |
387 |
me.screenElements.Alt11100 |
|
388 |
.setText(sprintf("% 3i",math.ceil(alt/100))); |
|
389 |
elsif (alt < 100) |
|
390 |
me.screenElements.Alt11100 |
|
391 |
.setText(''); |
|
392 |
else |
|
393 |
me.screenElements.Alt11100 |
|
394 |
.setText(sprintf("% 3i",math.floor(alt/100))); |
|
395 |
me.screenElements.AltLint00011 |
|
396 |
.setTranslation(0,math.fmod(alt,100) * 1.24); |
|
397 | ||
398 |
# From Farmin/G1000 http://wiki.flightgear.org/Project_Farmin/FG1000 |
|
399 |
if (alt> -1000 and alt< 1000000) { |
|
400 |
var Offset10 = 0; |
|
401 |
var Offset100 = 0; |
|
402 |
var Offset1000 = 0; |
|
403 |
if (alt< 0) { |
|
404 |
var Ne = 1; |
|
405 |
var alt= -alt; |
|
406 |
} |
|
407 |
else |
|
408 |
var Ne = 0; |
|
409 | ||
410 |
var Alt10 = math.mod(alt,100); |
|
411 |
var Alt100 = int(math.mod(alt/100,10)); |
|
412 |
var Alt1000 = int(math.mod(alt/1000,10)); |
|
413 |
var Alt10000 = int(math.mod(alt/10000,10)); |
|
414 |
var Alt20 = math.mod(Alt10,20)/20; |
|
415 |
if (Alt10 >= 80) |
|
416 |
var Alt100 += Alt20; |
|
417 | ||
418 |
if (Alt10 >= 80 and Alt100 >= 9) |
|
419 |
var Alt1000 += Alt20; |
|
420 | ||
421 |
if (Alt10 >= 80 and Alt100 >= 9 and Alt1000 >= 9) |
|
422 |
var Alt10000 += Alt20; |
|
423 | ||
424 |
if (alt> 100) |
|
425 |
var Offset10 = 100; |
|
426 | ||
427 |
if (alt> 1000) |
|
428 |
var Offset100 = 10; |
|
429 | ||
430 |
if (alt> 10000) |
|
431 |
var Offset1000 = 10; |
|
432 | ||
433 |
if (!Ne) { |
|
434 |
me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*0.57375); |
|
435 |
var altCentral = (int(alt/100)*100); |
|
436 |
} |
|
437 |
elsif (Ne) { |
|
438 |
me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*-0.57375); |
|
439 |
var altCentral = -(int(alt/100)*100); |
|
440 |
} |
|
441 |
me.screenElements["AltBigC"].setText(""); |
|
442 |
me.screenElements["AltSmallC"].setText(""); |
|
443 |
for (var place = 1; place <= 6; place += 1) { |
|
444 |
var altUP = altCentral + (place*100); |
|
445 |
var offset = -30.078; |
|
446 |
if (altUP < 0) { |
|
447 |
var altUP = -altUP; |
|
448 |
var prefix = "-"; |
|
449 |
var offset += 15.039; |
|
450 |
} |
|
451 |
else |
|
452 |
var prefix = ""; |
|
453 | ||
454 |
if (altUP == 0) { |
|
455 |
var AltBigUP = ""; |
|
456 |
var AltSmallUP = "0"; |
|
457 | ||
458 |
} |
|
459 |
elsif (math.mod(altUP,500) == 0 and altUP != 0) { |
|
460 |
var AltBigUP = sprintf(prefix~"%1d", altUP); |
|
461 |
var AltSmallUP = ""; |
|
462 |
} |
|
463 |
elsif (altUP < 1000 and (math.mod(altUP,500))) { |
|
464 |
var AltBigUP = ""; |
|
465 |
var AltSmallUP = sprintf(prefix~"%1d", int(math.mod(altUP,1000))); |
|
466 |
var offset = -30.078; |
|
467 |
} |
|
468 |
elsif ((altUP < 10000) and (altUP >= 1000) and (math.mod(altUP,500))) { |
|
469 |
var AltBigUP = sprintf(prefix~"%1d", int(altUP/1000)); |
|
470 |
var AltSmallUP = sprintf("%1d", int(math.mod(altUP,1000))); |
|
471 |
var offset += 15.039; |
|
472 |
} |
|
473 |
else { |
|
474 |
var AltBigUP = sprintf(prefix~"%1d", int(altUP/1000)); |
|
475 |
var mod = int(math.mod(altUP,1000)); |
|
476 |
var AltSmallUP = sprintf("%1d", mod); |
|
477 |
var offset += 30.078; |
|
478 |
} |
|
479 | ||
480 |
me.screenElements["AltBigU"~place].setText(AltBigUP); |
|
481 |
me.screenElements["AltSmallU"~place].setText(AltSmallUP); |
|
482 |
me.screenElements["AltSmallU"~place].setTranslation(offset,0); |
|
483 |
var altDOWN = altCentral - (place*100); |
|
484 |
var offset = -30.078; |
|
485 |
if (altDOWN < 0) { |
|
486 |
var altDOWN = -altDOWN; |
|
487 |
var prefix = "-"; |
|
488 |
var offset += 15.039; |
|
489 |
} |
|
490 |
else |
|
491 |
var prefix = ""; |
|
492 | ||
493 |
if (altDOWN == 0) { |
|
494 |
var AltBigDOWN = ""; |
|
495 |
var AltSmallDOWN = "0"; |
|
496 |
} |
|
497 |
elsif (math.mod(altDOWN,500) == 0 and altDOWN != 0) { |
|
498 |
var AltBigDOWN = sprintf(prefix~"%1d", altDOWN); |
|
499 |
var AltSmallDOWN = ""; |
|
500 |
} |
|
501 |
elsif (altDOWN < 1000 and (math.mod(altDOWN,500))) { |
|
502 |
var AltBigDOWN = ""; |
|
503 |
var AltSmallDOWN = sprintf(prefix~"%1d", int(math.mod(altDOWN,1000))); |
|
504 |
var offset = -30.078; |
|
505 |
} |
|
506 |
elsif ((altDOWN < 10000) and (altDOWN >= 1000) and (math.mod(altDOWN,500))) { |
|
507 |
var AltBigDOWN = sprintf(prefix~"%1d", int(altDOWN/1000)); |
|
508 |
var AltSmallDOWN = sprintf("%1d", int(math.mod(altDOWN,1000))); |
|
509 |
var offset += 15.039; |
|
510 |
} |
|
511 |
else { |
|
512 |
var AltBigDOWN = sprintf(prefix~"%1d", int(altDOWN/1000)); |
|
513 |
var mod = int(math.mod(altDOWN,1000)); |
|
514 |
var AltSmallDOWN = sprintf("%1d", mod); |
|
515 |
var offset += 30.078; |
|
516 |
} |
|
517 |
me.screenElements["AltBigD"~place].setText(AltBigDOWN); |
|
518 |
me.screenElements["AltSmallD"~place].setText(AltSmallDOWN); |
|
519 |
me.screenElements["AltSmallD"~place].setTranslation(offset,0); |
|
520 |
} |
|
521 |
} |
|
trends animation
|
522 |
var now = systime(); |
523 |
# altitude in 6s |
|
524 |
var Sy = .3 * (alt - me._last_alt_ft) / (now - me._last_alt_s); # scale = 1/20ft |
|
525 |
if (abs(Sy) > 15) |
|
526 |
Sy = 15 * abs(Sy)/Sy; # = -15 or 15 |
|
527 |
me.screenElements['Altitude-Trend-Indicator'] |
|
528 |
.setScale(1,Sy) |
|
529 |
.setTranslation(0, -284.5 * (Sy - 1)); |
|
530 |
me._last_alt_ft = alt; |
|
531 |
me._last_alt_s = now; |
|
animation ALT
|
532 |
settimer(func me.updateALT(getprop('instrumentation/altimeter/indicated-altitude-ft')), 0.2); |
533 |
}, |
|
trends animation
|
534 |
_last_alt_ft : 0, |
535 |
_last_alt_s : systime(), |
|
cosmétique: folding pour les...
|
536 |
#}}} |
animation HSI
|
537 | |
538 |
updateHSI : func (hdg) { |
|
comment on the folds
|
539 |
# rotates the compass (PFD) {{{ |
animation HSI
|
540 |
me.screenElements.Rose |
541 |
.setRotation(-hdg * D2R); |
|
542 |
me.screenElements['HDG-text'] |
|
543 |
.setText(sprintf("%03u°", hdg)); |
|
544 |
settimer(func me.updateHSI(getprop('orientation/heading-deg')), 0.1); |
|
545 |
}, |
|
cosmétique: folding pour les...
|
546 |
#}}} |
NAV disponible (hors CDI)
|
547 | |
animation HDG bug
|
548 |
updateHDG : func (hdg) { |
comment on the folds
|
549 |
# moves the heading bug and display heading-deg for 3 seconds (PFD) {{{ |
animation HDG bug
|
550 |
if (me.role == 'MFD') |
551 |
return; |
|
552 |
me.screenElements['Heading-bug'] |
|
553 |
.setRotation(hdg * D2R); |
|
554 |
me.screenElements['SelectedHDG-bg'] |
|
555 |
.show(); |
|
556 |
me.screenElements['SelectedHDG-bgtext'] |
|
557 |
.show(); |
|
558 |
me.screenElements['SelectedHDG-text'] |
|
559 |
.setText(sprintf('%03d°%s', hdg, '')) |
|
560 |
.show(); |
|
561 |
me.addTimer(3, ['SelectedHDG-text', 'SelectedHDG-bgtext', 'SelectedHDG-bg']); |
|
562 |
}, |
|
cosmétique: folding pour les...
|
563 |
#}}} |
animation HDG bug
|
564 | |
anime CRS
|
565 |
updateCRS : func (crs) { |
566 |
# TODO: update display for NAV/GPS/BRG courses {{{ |
|
567 |
if (me.role == 'MFD') |
|
568 |
return; |
|
569 |
me.screenElements['SelectedCRS-bg'] |
|
570 |
.show(); |
|
571 |
me.screenElements['SelectedCRS-bgtext'] |
|
572 |
.show(); |
|
573 |
me.screenElements['SelectedCRS-text'] |
|
574 |
.setText(sprintf('%03d°%s', crs, '')) |
|
575 |
.show(); |
|
576 |
me.addTimer(3, ['SelectedCRS-text', 'SelectedCRS-bgtext', 'SelectedCRS-bg']); |
|
577 |
}, |
|
578 |
#}}} |
|
579 | ||
ajout COMM, et factorisation...
|
580 |
_updateRadio: func { |
comment on the folds
|
581 |
# common parts for NAV/LOC/COMM radios{{{ |
ajout COMM, et factorisation...
|
582 |
# arg[0]._r = <comm|nav> |
583 |
if (contains(arg[0], "active")) { |
|
584 |
if (arg[0]['active'] == 'none') { |
|
585 |
me.screenElements[arg[0]._r ~ '1-selected-freq'] |
|
586 |
.setColor(1,1,1); |
|
587 |
me.screenElements[arg[0]._r ~ '2-selected-freq'] |
|
588 |
.setColor(1,1,1); |
|
589 |
} |
|
590 |
else { |
|
591 |
me.screenElements[arg[0]._r ~ arg[0]['active'] ~ '-selected-freq'] |
|
592 |
.setColor(0,1,0); |
|
593 |
me.screenElements[arg[0]._r ~ arg[0].inactive ~ '-selected-freq'] |
|
594 |
.setColor(1,1,1); |
|
595 |
} |
|
596 |
} |
|
597 |
if (contains(arg[0], 'tune')) { |
|
598 |
# n = 0 -> NAV1/COMM1 |
|
599 |
# n = 1 -> NAV1/COMM2 |
|
600 |
me.screenElements[arg[0]._r ~ '-freq-switch'] |
|
601 |
.setTranslation(0, arg[0].tune * 25); |
|
602 |
me.screenElements[arg[0]._r ~ (arg[0].tune + 1) ~ '-standby-freq'] |
|
603 |
.setColor(0,1,1); |
|
604 |
me.screenElements[arg[0]._r ~ ((arg[0].tune == 0) + 1) ~ '-standby-freq'] |
|
605 |
.setColor(1,1,1); |
|
606 |
} |
|
607 |
if (contains(arg[0], 'refresh')) { |
|
608 |
# rafraichi une seule ligne NAV1/COMM1 ou NAV2/COMM2 |
|
609 |
var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f'; |
|
610 |
me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-selected-freq'] |
|
611 |
.setText(sprintf(fmt, getprop('/instrumentation/' |
|
612 |
~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/selected-mhz'))); |
|
613 |
me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-standby-freq'] |
|
614 |
.setText(sprintf(fmt, getprop('/instrumentation/' |
|
615 |
~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/standby-mhz'))); |
|
616 |
} |
|
617 |
if (contains(arg[0], 'set')) { |
|
618 |
# positionne la valeur modifiée, les listeners "trigguent" en permanence ces propriétés, donc exit |
|
619 |
var n = getprop('/instrumentation/zkv1000/radios/' ~ arg[0]._r ~ '-tune'); |
|
620 |
var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f'; |
|
621 |
me.screenElements[arg[0]._r ~ (n + 1) ~ '-standby-freq'] |
|
622 |
.setText(getprop('/instrumentation/' ~ arg[0]._r ~ '[' ~ n ~ ']/frequencies/standby-mhz')); |
|
623 |
} |
|
624 |
if (contains(arg[0], 'auto')) { |
|
625 |
# pour rafraichir automagiquement, toutes les deux secondes un refresh pour un NAV |
|
626 |
var radio = arg[0].auto; |
|
627 |
me._updateRadio({refresh: 1, _r: radio}); |
|
628 |
settimer(func me._updateRadio({refresh: 2, _r: radio}), 1); |
|
629 |
settimer(func me._updateRadio({auto: radio}), 2); |
|
630 |
} |
|
631 |
}, |
|
cosmétique: folding pour les...
|
632 |
#}}} |
ajout COMM, et factorisation...
|
633 | |
NAV disponible (hors CDI)
|
634 |
updateNAV : func { |
comment on the folds
|
635 |
# update NAV/LOC rodios display upper left (PFD/MFD){{{ |
NAV disponible (hors CDI)
|
636 |
# made active via menu |
637 |
if (contains(arg[0], "active")) { |
|
638 |
if (arg[0]['active'] == 'none') { |
|
ajout COMM, et factorisation...
|
639 |
arg[0]._r = 'nav'; |
640 |
me._updateRadio(arg[0]); |
|
NAV disponible (hors CDI)
|
641 |
me.screenElements['nav1-id'] |
642 |
.setColor(1,1,1); |
|
643 |
me.screenElements['nav2-id'] |
|
644 |
.setColor(1,1,1); |
|
645 |
me.screenElements['NAV1-pointer'] |
|
646 |
.hide(); |
|
647 |
me.screenElements['NAV2-pointer'] |
|
648 |
.hide(); |
|
649 |
} |
|
650 |
else { |
|
ajout COMM, et factorisation...
|
651 |
arg[0]._r = 'nav'; |
652 |
arg[0].inactive = (arg[0]['active'] == 1) + 1; |
|
653 |
me._updateRadio(arg[0]); |
|
NAV disponible (hors CDI)
|
654 |
me.screenElements['nav' ~ arg[0]['active'] ~ '-id'] |
655 |
.setColor(0,1,0); |
|
656 |
me.screenElements['NAV' ~ arg[0]['active'] ~ '-pointer'] |
|
657 |
.show(); |
|
ajout COMM, et factorisation...
|
658 |
me.screenElements['nav' ~ arg[0].inactive ~ '-id'] |
659 |
.setColor(1,1,1); |
|
NAV disponible (hors CDI)
|
660 |
# me.screenElements['HDI'] |
661 |
# .setRotation(); |
|
662 |
# me.screenElements['NAV' ~ inactive ~ '-pointer'] |
|
663 |
# .hide(); |
|
664 |
# foreach (var e; [ 'FROM', 'TO', 'CDI' ]) |
|
665 |
# me.screenElements['NAV' ~ inactive ~ '-' ~ e] |
|
666 |
# .hide(); |
|
667 |
} |
|
668 |
} |
|
ajout COMM, et factorisation...
|
669 |
elsif (contains(arg[0], 'nav-id')) { |
Correction swap NAV tuning
|
670 |
# TODO: récupérer la valeur via les paramètres transmis du listener |
ajout COMM, et factorisation...
|
671 |
if (arg[0].val == nil) |
672 |
arg[0].val = ''; |
|
NAV disponible (hors CDI)
|
673 |
me.screenElements["nav" ~ arg[0]['nav-id'] ~ "-id"] |
ajout COMM, et factorisation...
|
674 |
.setText(arg[0].val); |
NAV disponible (hors CDI)
|
675 |
} |
ajout COMM, et factorisation...
|
676 |
else { |
677 |
arg[0]._r = 'nav'; |
|
678 |
me._updateRadio(arg[0]); |
|
NAV disponible (hors CDI)
|
679 |
} |
680 |
}, |
|
cosmétique: folding pour les...
|
681 |
#}}} |
ajout COMM, et factorisation...
|
682 | |
683 |
updateCOMM: func { |
|
comment on the folds
|
684 |
# update COMM radios display upper right (PFD/MFD){{{ |
ajout COMM, et factorisation...
|
685 |
arg[0]._r = 'comm'; |
686 |
me._updateRadio(arg[0]); |
|
687 |
}, |
|
cosmétique: folding pour les...
|
688 |
#}}} |
anime time display
|
689 | |
690 |
updateTIME : func { |
|
691 |
# updates the displayed time botoom left {{{ |
|
692 |
me.screenElements['TIME-text'] |
|
693 |
.setText(getprop('/sim/time/gmt-string')); |
|
694 |
settimer(func me.updateTIME(), 1); |
|
695 |
}, |
|
696 |
#}}} |
|
commit initial
|
697 |
}; |
softkeys are available now
|
698 | |
699 |
var keyMap = { |
|
700 |
PFD : { |
|
701 |
first : 1, |
|
702 |
texts : ['INSET', 'SENSOR', 'PFD', 'OBS', 'CDI', 'DME', 'XPDR', 'IDENT', 'TMR/REF', 'NRST' ], |
|
703 |
INSET : { |
|
704 |
texts : ['OFF', 'DCLTR', 'WXLGND', 'TRAFFIC', 'TOPO', 'TERRAIN', 'STRMSCP', 'NEXRAD-C', 'XM LTNG', 'METAR'], |
|
705 |
}, |
|
706 |
SENSOR : { |
|
707 |
first : 2, |
|
708 |
texts : [ 'ADC1', 'ADC2', '', 'AHRS1', 'AHRS2'], |
|
709 |
}, |
|
710 |
PFD : { |
|
711 |
texts : [ 'SYN VIS', 'DFLTS', 'AOA/WIND', 'DME', 'BRG', 'HSI FMT', '', '', 'ALT UNIT', 'STD BARO' ], |
|
712 |
'SYN VIS' : { |
|
713 |
texts : [ 'PATHWAY', 'SYN TERR', 'HR2NHDG', 'APTSIGNS', 'FPM'], |
|
714 |
}, |
|
715 |
'AOA/WIND' : { |
|
716 |
first : 4, |
|
717 |
texts : ['AOA', 'WIND'], |
|
718 |
AOA : { |
|
719 |
first : 5, |
|
720 |
texts : ['AOA ON', 'AOA AUTO'], |
|
721 |
}, |
|
722 |
WIND : { |
|
723 |
first : 2, |
|
724 |
texts : ['OPTN1', 'OPTN2', '', 'OFF'], |
|
725 |
}, |
|
726 |
}, |
|
727 |
'HSI FMT' : { |
|
728 |
first : 6, |
|
729 |
texts : ['360 HSI', 'ARC HSI'], |
|
730 |
}, |
|
731 |
'ALT UNIT' : { |
|
732 |
first : 5, |
|
733 |
texts : ['METERS', '', 'IN', 'HPA'], |
|
734 |
}, |
|
735 |
}, |
|
736 |
XPDR : { |
|
737 |
first : 2, |
|
738 |
texts : ['STBY', 'ON', 'ALT', '', 'VFR', 'CODE', 'IDENT'], |
|
739 |
CODE : { |
|
740 |
texts : ['0', '1', '2', '3', '4', '5', '6', '7', 'IDENT', 'BKSP'], |
|
741 |
}, |
|
742 |
}, |
|
743 |
}, |
|
744 |
MFD : { |
|
745 |
texts : ['ENGINE', '', 'MAP', '', '', '', '', '', '', 'DCLTR', 'SHW CHRT', 'CHKLIST'], |
|
746 |
MAP : { |
|
747 |
texts: ['TRAFFIC', 'PROFILE', 'TOPO', 'TERRAIN', 'AIRWAYS', 'STRMSCP','NEXRAD-C', 'XM LTNG', 'METAR', 'LEGEND', 'BACK'], |
|
748 |
}, |
|
749 |
CHKLIST : { |
|
750 |
texts : ['ENGINE', '', '', '', '', 'DONE', '', '', '', '', 'EXIT', 'EMERGCY'], |
|
751 |
}, |
|
752 |
ENGINE : { |
|
753 |
texts : ['ENGINE', 'ANTI-ICE', '', 'DCLTR', '', 'ASSIST', '', '', '', '', 'FUEL'], |
|
754 |
'ANTI-ICE' : { |
|
755 |
texts : ['LEFT', 'AUTO', 'RIGHT', '', '', '', '', '', '', '', '', 'BACK'], |
|
756 |
}, |
|
757 |
FUEL : { |
|
758 |
first : 1, |
|
759 |
texts : ['FULL', 'TABS', '', '', '', '', '', '', '', 'UNDO', 'ENTER'], |
|
760 |
}, |
|
761 |
}, |
|
762 |
}, |
|
763 |
}; |