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) { |
add new vim folds
|
4 |
# the contructor {{{ |
commit initial
|
5 |
var m = { parents: [ displayClass ] }; |
cosmétique: folding pour les...
|
6 | |
commit initial
|
7 |
m.display = canvas.new({ |
8 |
"name" : role, |
|
9 |
"size" : [1024, 768], |
|
10 |
"view" : [1024, 768], |
|
11 |
"mipmapping": 1 |
|
12 |
}); |
|
13 |
m.display.addPlacement({ |
|
14 |
"node": "Screen", |
|
15 |
"parent": role |
|
16 |
}); |
|
17 |
m.display.setColorBackground(0,0,0); |
|
18 |
m.role = role; |
|
pass device pointer to displ...
|
19 |
m.device = device; |
écriture du wrapper pour le ...
|
20 |
m.screenElements = {}; |
commit initial
|
21 | |
Softkeys revert to the previ...
|
22 |
m.timers2 = {}; # tho old timer implementation use already a named timer hash |
23 |
# Softkeys revert to the previous level after 45 seconds of inactivity. |
|
24 |
m.softkeys_inactivity_delay = 45; |
|
25 | ||
adds Map on MFD
|
26 |
if (role == 'MFD') { |
27 |
m.MFDMapTiles = MapTiles.new(m.display); |
|
28 |
m.MFDMapNavDisplay = MapNavDisplay.new(m.display); |
|
29 |
} |
|
30 | ||
commit initial
|
31 |
return m; |
32 |
}, |
|
add new vim folds
|
33 |
#}}} |
commit initial
|
34 | |
add new vim folds
|
35 |
# timers stuff {{{ |
ajoute un timer pour cacher ...
|
36 |
timers : {}, |
37 | ||
38 |
timerTrigger : func { |
|
39 |
var now = systime(); |
|
40 |
foreach (var id; keys(me.timers)) { |
|
41 |
if (me.timers[id] < now) { |
|
42 |
me.screenElements[id].hide(); |
|
43 |
delete(me.timers, id); |
|
44 |
} |
|
45 |
} |
|
46 |
settimer(func me.timerTrigger(), 1); |
|
47 |
}, |
|
48 | ||
49 |
addTimer : func (duration, element) { |
|
50 |
if (typeof(element) == 'scalar') |
|
51 |
element = [ element ]; |
|
52 |
var end = systime() + duration; |
|
53 |
foreach (var e; element) |
|
54 |
me.timers[e] = end; |
|
55 |
}, |
|
add new vim folds
|
56 |
#}}} |
ajoute un timer pour cacher ...
|
57 | |
commit initial
|
58 |
loadsvg : func () { |
59 |
me.screen = me.display.createGroup(); |
|
60 |
me.screen.hide(); |
|
61 |
canvas.parsesvg(me.screen, "Aircraft/Instruments-3d/zkv1000/Systems/screen.svg"); |
|
62 |
}, |
|
63 | ||
64 |
_showInitProgress : func (p,t) { |
|
cosmétique: folding pour les...
|
65 |
#{{{ |
commit initial
|
66 |
p.setText(t); |
67 |
if (zkv.getNode(me.role ~ 'init').getValue() != 0) { |
|
68 |
if (size(t) >= 10) t = ''; |
|
69 |
settimer(func { me._showInitProgress(p, t ~ '.'); }, 0.1); |
|
70 |
} |
|
71 |
else { |
|
72 |
me.progress.hide(); |
|
73 |
me.screen.show(); |
|
séparation configuration PFD...
|
74 |
var groups = { |
animation VSI
|
75 |
show : [ |
makes header visible on MFD ...
|
76 |
'Header', |
commit initial
|
77 |
'SoftKeysTexts', |
78 |
'COMM', |
|
79 |
'NAV', |
|
ajout COMM, et factorisation...
|
80 |
'nav-freq-switch', |
81 |
'comm-freq-switch', |
|
séparation configuration PFD...
|
82 |
], |
83 |
text: [ |
|
84 |
'nav1-standby-freq', 'nav1-selected-freq', 'nav1-id', |
|
85 |
'nav2-standby-freq', 'nav2-selected-freq', 'nav2-id', |
|
ajout COMM, et factorisation...
|
86 |
'comm1-standby-freq', 'comm1-selected-freq', |
87 |
'comm2-standby-freq', 'comm2-selected-freq', |
|
séparation configuration PFD...
|
88 |
], |
ajout COMM, et factorisation...
|
89 |
hide : [ ], |
séparation configuration PFD...
|
90 |
clip: [ ], |
91 |
}; |
|
softkeys are available now
|
92 | |
add softkeys colors
|
93 |
for (var k = 0; k < 12; k += 1) { |
softkeys are available now
|
94 |
append(groups.text, sprintf("SoftKey%02i-text", k)); |
add softkeys colors
|
95 |
append(groups.show, sprintf("SoftKey%02i-bg", k)); |
96 |
} |
|
softkeys are available now
|
97 | |
séparation configuration PFD...
|
98 |
if (me.role == 'PFD') { |
99 |
append(groups.show, |
|
commit initial
|
100 |
'XPDR-TIME', |
AI disponible
|
101 |
'FlightInstruments', |
102 |
'Horizon', |
|
AI disponible, avec bankPoin...
|
103 |
'bankPointer', |
animation VSI
|
104 |
'VSI', |
animation HSI
|
105 |
'Rose', |
animation HDG bug
|
106 |
'Heading-bug', |
107 |
'PFD-Widgets', |
|
trends animation
|
108 |
'Trends', |
109 |
'Airspeed-Trend-Indicator', |
|
110 |
'Altitude-Trend-Indicator', |
|
adds OAT, TAS, GSPD, WindDat...
|
111 |
'OAT', |
112 |
'IAS-bg', |
|
113 |
'TAS', |
|
114 |
'GSPD', |
|
adds BARO settings
|
115 |
'BARO-bg', |
séparation configuration PFD...
|
116 |
); |
117 |
append(groups.hide, |
|
adds EIS
|
118 |
'EIS', |
NAV disponible (hors CDI)
|
119 |
'CDI', |
adds CDI
|
120 |
'NAV1-pointer', 'NAV1-CDI', 'NAV1-FROM', 'NAV1-TO', |
121 |
'NAV2-pointer', 'NAV2-CDI', 'NAV2-FROM', 'NAV2-TO', |
|
122 |
'GPS-pointer', 'GPS-CDI', 'GPS-CTI', 'GPS-CTI-diamond', 'GPS-FROM', 'GPS-TO', |
|
adds BRG1/2 animation
|
123 |
'BRG1-pointer', |
124 |
'BRG2-pointer', |
|
animation HDG bug
|
125 |
'SelectedHDG-bg', |
126 |
'SelectedHDG-bgtext', |
|
127 |
'SelectedHDG-text', |
|
128 |
'SelectedCRS-bg', |
|
129 |
'SelectedCRS-bgtext', |
|
130 |
'SelectedCRS-text', |
|
fix Selected Altitude displa...
|
131 |
'SelectedALT', 'SelectedALT-bug', 'SelectedALT-bg', 'SelectedALT-symbol', |
animation HDG bug
|
132 |
'TAS', |
133 |
'GSPD', |
|
134 |
'WindData', |
|
135 |
'Reversionnary', |
|
136 |
'Annunciation', |
|
137 |
'Comparator', |
|
138 |
'BRG1', |
|
139 |
'BRG2', |
|
140 |
'DME1', |
|
141 |
'PFD-Map', |
|
adds OAT, TAS, GSPD, WindDat...
|
142 |
'PFD-Multilines', |
improves WindData display
|
143 |
'WindData', 'WindData-OPTN1', 'WindData-OPTN2', 'WindData-OPTN1-HDG', 'WindData-OPTN2-symbol', 'WindData-OPTN2-headwind', 'WindData-OPTN2-crosswind', 'WindData-NODATA', |
séparation configuration PFD...
|
144 |
); |
145 |
append(groups.clip, |
|
animation IAS
|
146 |
'SpeedLint1', |
animation ALT
|
147 |
'SpeedTape', |
148 |
'LintAlt', |
|
149 |
'AltLint00011' |
|
150 |
); |
|
séparation configuration PFD...
|
151 |
append(groups.text, |
fix Selected Altitude displa...
|
152 |
'SelectedALT-text', |
adds OAT, TAS, GSPD, WindDat...
|
153 |
'TAS-text', |
154 |
'GSPD-text', |
|
anime time display
|
155 |
'TIME-text', |
adds OAT, TAS, GSPD, WindDat...
|
156 |
'OAT-text', |
séparation configuration PFD...
|
157 |
'VSIText', |
158 |
'Speed110', |
|
159 |
'Alt11100', |
|
160 |
'HDG-text', |
|
adds BARO settings
|
161 |
'BARO-text', |
adds CDI
|
162 |
'CDI-SRC-text', 'CDI-GPS-ANN-text', 'CDI-GPS-XTK-text', |
adds BRG1/2 animation
|
163 |
'BRG1-pointer', 'BRG1-SRC-text', 'BRG1-DST-text', 'BRG1-WPID-text', |
164 |
'BRG2-pointer', 'BRG2-SRC-text', 'BRG2-DST-text', 'BRG2-WPID-text', |
|
adds OAT, TAS, GSPD, WindDat...
|
165 |
'WindData-OPTN1-HDG-text', 'WindData-OPTN1-SPD-text', |
166 |
'WindData-OPTN2-crosswind-text', 'WindData-OPTN2-headwind-text', |
|
adds transponder
|
167 |
'XPDR-MODE-text', 'XPDR-DIGIT-3-text', 'XPDR-DIGIT-2-text', 'XPDR-DIGIT-1-text', 'XPDR-DIGIT-0-text', |
séparation configuration PFD...
|
168 |
'AltBigC', 'AltSmallC' |
169 |
); |
|
170 |
for (var place = 1; place <= 6; place +=1) { |
|
171 |
append(groups.text, |
|
172 |
'AltBigU' ~ place, |
|
173 |
'AltSmallU' ~ place, |
|
174 |
'AltBigD' ~ place, |
|
175 |
'AltSmallD' ~ place |
|
176 |
); |
|
177 |
} |
|
animation ALT
|
178 |
} |
adds EIS
|
179 |
else { |
animation texts EIS + power ...
|
180 |
append(groups.show, 'EIS', 'POWER-pointer'); |
181 |
append(groups.text, |
|
182 |
'RPM-text', 'EGT-text', 'CHT-text', 'FUEL-USED-text', |
|
183 |
'FUEL-FLOW-text', 'MAN-Hg-text', 'POWER-PERCENT-text', |
|
184 |
'RPM-text', 'BUS-V-text', 'BATT-text', 'PSI-text', |
|
185 |
'OIL-TEMP-text' |
|
186 |
); |
|
adds EIS
|
187 |
} |
séparation configuration PFD...
|
188 | |
189 |
me.loadGroup(groups); |
|
animation ALT
|
190 | |
séparation configuration PFD...
|
191 |
if (me.role == 'PFD') { |
refresh of vital information...
|
192 |
me.update20Hz(); |
193 |
me.update1Hz(); |
|
adds OAT, TAS, GSPD, WindDat...
|
194 |
me.updateAI(); |
195 |
me.updateVSI(); |
|
196 |
me.updateIAS(); |
|
197 |
me.updateALT(); |
|
198 |
me.updateHSI(); |
|
anime time display
|
199 |
me.updateTIME(); |
adds OAT, TAS, GSPD, WindDat...
|
200 |
me.updateOAT(); |
201 |
me.updateTAS(); |
|
adds BRG1/2 animation
|
202 |
me.updateBRG(); |
adds transponder
|
203 |
me.updateXPDR(); |
adds BARO settings
|
204 |
me.updateBARO(); |
ajoute un timer pour cacher ...
|
205 |
me.timerTrigger(); |
séparation configuration PFD...
|
206 |
} |
animation texts EIS + power ...
|
207 |
else { |
208 |
me.updateEIS(); |
|
adds Map on MFD
|
209 |
me.MFDMapNavDisplay.showMap(); |
210 |
me.MFDMapTiles.initialize_grid(); |
|
211 |
me.MFDMapTiles.update_timer.start(); |
|
animation texts EIS + power ...
|
212 |
} |
ajout COMM, et factorisation...
|
213 |
me._updateRadio({auto:'nav'}); |
214 |
me._updateRadio({auto:'comm'}); |
|
Softkeys revert to the previ...
|
215 |
me.softkeys_inactivity(); |
softkeys are available now
|
216 |
me.updateSoftKeys(); |
commit initial
|
217 |
me.progress.removeAllChildren(); |
218 |
me.progress = nil; |
|
219 |
me.showInitProgress = nil; |
|
220 |
me._showInitProgress = nil; |
|
221 |
zkv.removeChild(me.role ~ 'init'); |
|
222 |
} |
|
223 |
}, |
|
cosmétique: folding pour les...
|
224 |
#}}} |
commit initial
|
225 | |
226 |
showInitProgress : func (role) { |
|
cosmétique: folding pour les...
|
227 |
#{{{ |
commit initial
|
228 |
me.progress = me.display.createGroup(); |
229 |
me.progress.show(); |
|
230 |
me.progress.createChild("text", role ~ " title") |
|
231 |
.setTranslation(512, 384) |
|
232 |
.setAlignment("center-center") |
|
233 |
.setFont("LiberationFonts/LiberationSans-Italic.ttf") |
|
234 |
.setFontSize(64, 1) |
|
235 |
.setColor(1,1,1) |
|
236 |
.setText("ZKV1000 " ~ role ~ " init"); |
|
237 | ||
238 |
zkv.getNode(role ~ 'init',1).setIntValue(1); |
|
239 | ||
240 |
me._showInitProgress(me.progress.createChild("text", role ~ "progress") |
|
241 |
.setTranslation(512, 484) |
|
242 |
.setAlignment("center-center") |
|
243 |
.setFont("LiberationFonts/LiberationSans-Bold.ttf") |
|
244 |
.setFontSize(128, 1) |
|
245 |
.setColor(1,0,0), '.'); |
|
246 |
}, |
|
cosmétique: folding pour les...
|
247 |
#}}} |
commit initial
|
248 | |
some added comments
|
249 |
colors : { |
250 |
# set of predefined colors {{{ |
|
251 |
green : [0, 1, 0], |
|
252 |
white : [1, 1, 1], |
|
253 |
black : [0, 0, 0], |
|
254 |
lightblue : [0, 1, 1], |
|
255 |
darkblue : [0, 0, 1], |
|
256 |
red : [1, 0, 0], |
|
adds CDI
|
257 |
magenta : [1, 0, 1], |
some added comments
|
258 |
}, |
259 |
#}}} |
|
260 | ||
écriture du wrapper pour le ...
|
261 |
loadGroup : func (h) { |
cosmétique: folding pour les...
|
262 |
#{{{ |
écriture du wrapper pour le ...
|
263 |
if (typeof(h) != 'hash') { |
264 |
msg_dbg(sprintf("%s need a hash, but get a %s from %s", |
|
265 |
caller(0)[0], |
|
266 |
typeof(h), |
|
267 |
caller(1)[0])); |
|
268 |
return; |
|
commit initial
|
269 |
} |
écriture du wrapper pour le ...
|
270 |
var setMethod = func (e, t) { |
271 |
if (t == 'hide') |
|
272 |
me.screenElements[e].hide(); |
|
273 |
elsif (t == 'show') |
|
274 |
me.screenElements[e].show(); |
|
AI disponible
|
275 |
elsif (t == 'rot' or t == 'trans') { |
276 |
if (! contains(me.screenElements[e], t)) |
|
277 |
me.screenElements[e][t] = me.screenElements[e].createTransform(); |
|
278 |
} |
|
279 |
elsif (t == 'clip') { |
|
280 |
if (contains(me.clips, e)) |
|
281 |
me.screenElements[e].set("clip", me.clips[e]); |
|
282 |
else |
|
printlog with adapted level ...
|
283 |
printlog('warn', 'no defined clip for ' ~ e); |
AI disponible
|
284 |
} |
animation VSI
|
285 |
elsif (t == 'text') { |
286 |
if (contains(me.texts, e)) { |
|
287 |
if (contains(me.texts[e], 'alignment')) |
|
288 |
me.screenElements[e].setAlignment(me.texts[e].alignment); |
|
289 |
if (contains(me.texts[e], 'default')) |
|
290 |
me.screenElements[e].setText(me.texts[e].default); |
|
NAV disponible (hors CDI)
|
291 |
if (contains(me.texts[e], 'color')) |
292 |
me.screenElements[e].setColor(me.texts[e].color); |
|
adds CDI
|
293 |
if (contains(me.texts[e], 'visible')) |
294 |
me.screenElements[e].setVisible(me.texts[e].visible); |
|
animation VSI
|
295 |
} |
printlog with adapted level ...
|
296 |
else |
297 |
printlog('debug', 'no text format for ' ~ e); |
|
animation VSI
|
298 |
} |
commit initial
|
299 |
else |
printlog with adapted level ...
|
300 |
printlog('warn', 'unknown method ' ~ t); |
écriture du wrapper pour le ...
|
301 |
}; |
302 |
foreach (var todo; keys(h)) { |
|
303 |
if (typeof(h[todo]) != 'vector') h[todo] = [ h[todo] ]; |
|
304 |
foreach (var id; h[todo]) { |
|
305 |
if (! contains(me.screenElements, id)) { |
|
306 |
me.screenElements[id] = me.screen.getElementById(id); |
|
307 |
if (me.screenElements[id] != nil) |
|
308 |
setMethod(id, todo); |
|
309 |
else |
|
printlog with adapted level ...
|
310 |
printlog('warn', 'SVG ID ' ~ id ~ ' not found'); |
écriture du wrapper pour le ...
|
311 |
} |
312 |
else |
|
313 |
setMethod(id, todo); |
|
314 |
} |
|
commit initial
|
315 |
} |
316 |
}, |
|
cosmétique: folding pour les...
|
317 |
#}}} |
AI disponible
|
318 | |
319 |
clips : { |
|
cosmétique: folding pour les...
|
320 |
#{{{ |
clean pre-merge
|
321 |
PitchScale : "rect(70,664,370,256)", |
322 |
SpeedLint1 : "rect(252,226,318,204)", |
|
323 |
SpeedTape : "rect(115,239,455,156)", |
|
324 |
LintAlt : "rect(115,808,455,704)", |
|
animation ALT
|
325 |
AltLint00011 : "rect(252,804,318,771)", |
AI disponible
|
326 |
}, |
cosmétique: folding pour les...
|
327 |
#}}} |
AI disponible
|
328 | |
animation VSI
|
329 |
texts : { |
cosmétique: folding pour les...
|
330 |
#{{{ |
animation VSI
|
331 |
VSIText : { |
332 |
alignment: "right-bottom", default : num('0'), |
|
333 |
}, |
|
animation IAS
|
334 |
Speed110 : { |
NAV disponible (hors CDI)
|
335 |
alignment : 'left-bottom' |
animation IAS
|
336 |
}, |
animation ALT (2)
|
337 |
Alt11100 : { |
NAV disponible (hors CDI)
|
338 |
alignment:'left-bottom' |
animation ALT (2)
|
339 |
}, |
clean pre-merge
|
340 |
"HDG-text" : { |
341 |
default: '---°' |
|
342 |
}, |
|
NAV disponible (hors CDI)
|
343 |
'nav1-standby-freq' : { |
344 |
color: [0, 1, 1], |
|
345 |
}, |
|
346 |
'nav1-id' : { |
|
347 |
default: '' |
|
348 |
}, |
|
349 |
'nav2-id' : { |
|
350 |
default: '' |
|
351 |
}, |
|
adds CDI
|
352 |
'CDI-GPS-ANN-text' : { |
353 |
visible : 0 |
|
354 |
}, |
|
355 |
'CDI-GPS-XTK-text' : { |
|
356 |
visible : 0 |
|
357 |
}, |
|
358 |
'CDI-SRC-text' : { |
|
359 |
visible : 0 |
|
360 |
}, |
|
adds BARO settings
|
361 |
'BARO-text' : { |
362 |
alignment : 'left-bottom', |
|
363 |
} |
|
some added comments
|
364 |
# 'TAS-text' : { |
365 |
# alignment : 'right-bottom', |
|
366 |
# }, |
|
367 |
# 'GSPD-text' : { |
|
368 |
# alignment : 'right-bottom', |
|
369 |
# }, |
|
animation VSI
|
370 |
}, |
cosmétique: folding pour les...
|
371 |
#}}} |
animation VSI
|
372 | |
Softkeys revert to the previ...
|
373 |
softkeys_inactivity : func { |
374 |
# automagically back to previous level after some delay {{{ |
|
375 |
me.timers2.softkeys_inactivity = maketimer ( |
|
376 |
me.softkeys_inactivity_delay, |
|
377 |
func { |
|
378 |
pop(me.device.softkeys.path); |
|
379 |
me.updateSoftKeys(); |
|
380 |
}, me); |
|
381 |
me.timers2.softkeys_inactivity.singleShot = 1; |
|
382 |
}, |
|
383 |
#}}} |
|
384 | ||
add softkeys colors
|
385 |
setSoftKeyColor : func (n, active, alert = 0) { |
386 |
# set colors for active softkeys {{{ |
|
387 |
var sftk = sprintf('SoftKey%02i-', n); |
|
388 |
if (active) { |
|
389 |
var bg = alert ? 1 : 0.5; |
|
390 |
me.screenElements[sftk ~ 'bg'] |
|
391 |
.setColorFill(bg,bg,bg); |
|
392 |
me.screenElements[sftk ~ 'text'] |
|
393 |
.setColor(0,0,0); |
|
394 |
} |
|
395 |
else { |
|
396 |
me.screenElements[sftk ~ 'bg'] |
|
397 |
.setColorFill(0,0,0); |
|
398 |
me.screenElements[sftk ~ 'text'] |
|
399 |
.setColor(1,1,1); |
|
400 |
} |
|
401 |
}, |
|
402 |
#}}} |
|
403 | ||
softkeys are available now
|
404 |
updateSoftKeys : func { |
405 |
# update SoftKeys boxes {{{ |
|
406 |
# on PFD the last boxes are always BACK and ALERTS |
|
407 |
if (me.role == 'PFD') { |
|
408 |
me.screenElements[sprintf("SoftKey%02i-text", 11)] |
|
409 |
.setText('ALERTS'); |
|
410 |
if (size(me.device.softkeys.path) != 0) |
|
411 |
me.screenElements[sprintf("SoftKey%02i-text", 10)] |
|
412 |
.setText('BACK'); |
|
413 |
} |
|
414 | ||
415 |
var path = keyMap[me.role]; |
|
416 |
foreach (var p; me.device.softkeys.path) |
|
417 |
path = path[p]; |
|
418 | ||
419 |
# feeding with empty menus the first boxes |
|
420 |
var start = (contains(path, 'first')) ? path.first : 0; |
|
421 |
for (var k = 0; k < start; k+=1) { |
|
422 |
me.screenElements[sprintf("SoftKey%02i-text", k)] |
|
423 |
.setText(''); |
|
424 |
} |
|
425 |
# filling with the content the next boxes |
|
426 |
forindex (var k; path.texts) { |
|
427 |
var i = k + start; |
|
428 |
me.screenElements[sprintf("SoftKey%02i-text", i)] |
|
429 |
.setText(path.texts[k]); |
|
430 |
} |
|
431 |
# feeding the last boxes with empty string |
|
432 |
var end = (me.role == 'PFD') ? 10 : 12; |
|
433 |
if (size(path.texts) + start < end) { |
|
434 |
start = size(path.texts) + start; |
|
435 |
for (var k = start; k < end; k += 1) |
|
436 |
me.screenElements[sprintf("SoftKey%02i-text", k)] |
|
437 |
.setText(''); |
|
438 |
} |
|
Softkeys revert to the previ...
|
439 | |
440 |
if (size(me.device.softkeys.path)) |
|
441 |
me.timers2.softkeys_inactivity.restart(me.softkeys_inactivity_delay); |
|
442 |
else |
|
443 |
me.timers2.softkeys_inactivity.stop(); |
|
softkeys are available now
|
444 |
}, |
445 |
#}}} |
|
446 | ||
refresh of vital information...
|
447 |
update20Hz : func { |
448 |
# 20Hz updates roll, pitch, VSI, IAS, altitude and HDG {{{ |
|
adds OAT, TAS, GSPD, WindDat...
|
449 |
me._updated_roll = getprop('/orientation/roll-deg'); |
450 |
me._updated_pitch = getprop('orientation/pitch-deg'); |
|
451 |
me._updated_vsi = getprop('/instrumentation/vertical-speed-indicator/indicated-speed-fpm'); |
|
452 |
me._updated_ias = getprop('/velocities/airspeed-kt'); |
|
453 |
me._updated_alt = getprop('/instrumentation/altimeter/indicated-altitude-ft'); |
|
454 |
me._updated_hdg = getprop('/orientation/heading-deg'); |
|
refresh of vital information...
|
455 |
settimer(func me.update20Hz(), 0.05); |
adds OAT, TAS, GSPD, WindDat...
|
456 |
}, |
457 |
_updated_roll : 0, |
|
458 |
_updated_pitch : 0, |
|
459 |
_updated_vsi : 0, |
|
460 |
_updated_ias : 0, |
|
461 |
_updated_alt : 0, |
|
462 |
_updated_hdg : 0, |
|
463 |
#}}} |
|
464 | ||
refresh of vital information...
|
465 |
update1Hz : func { |
466 |
# 1Hz updates {{{ |
|
467 |
me._updated_wow = getprop('/gear/gear/wow'); |
|
468 |
settimer(func me.update20Hz(), 1); |
|
469 |
}, |
|
470 |
_updated_wow : 1, |
|
471 |
#}}} |
|
472 | ||
adds OAT, TAS, GSPD, WindDat...
|
473 |
updateAI: func(){ |
cosmétique: folding pour les...
|
474 |
#{{{ |
adds OAT, TAS, GSPD, WindDat...
|
475 |
var pitch = me._updated_pitch; |
476 |
var roll = me._updated_roll; |
|
AI disponible
|
477 |
if (pitch > 80) |
478 |
pitch = 80; |
|
clean pre-merge
|
479 |
elsif (pitch < -80) |
AI disponible
|
480 |
pitch = -80; |
481 |
me.screenElements.Horizon |
|
fix AI animation
|
482 |
.setCenter(459, 282.8 - 6.849 * pitch) |
AI disponible
|
483 |
.setRotation(-roll * D2R) |
fix AI animation
|
484 |
.setTranslation(0, pitch * 6.849); |
AI disponible, avec bankPoin...
|
485 |
me.screenElements.bankPointer |
486 |
.setRotation(-roll * D2R); |
|
adds OAT, TAS, GSPD, WindDat...
|
487 |
settimer(func me.updateAI(), 0.1); |
AI disponible
|
488 |
}, |
cosmétique: folding pour les...
|
489 |
#}}} |
animation VSI
|
490 | |
adds OAT, TAS, GSPD, WindDat...
|
491 |
updateVSI: func () { |
comment on the folds
|
492 |
# animate VSI {{{ |
adds OAT, TAS, GSPD, WindDat...
|
493 |
var vsi = me._updated_vsi; |
animation VSI
|
494 |
me.screenElements.VSIText |
495 |
.setText(num(math.round(vsi, 10))); |
|
496 |
if (vsi > 4500) |
|
497 |
vsi = 4500; |
|
498 |
elsif (vsi < -4500) |
|
499 |
vsi = -4500; |
|
500 |
me.screenElements.VSI |
|
501 |
.setTranslation(0, vsi * -0.03465); |
|
adds OAT, TAS, GSPD, WindDat...
|
502 |
settimer(func me.updateVSI(), 0.1); |
animation VSI
|
503 |
}, |
cosmétique: folding pour les...
|
504 |
#}}} |
animation IAS
|
505 | |
adds OAT, TAS, GSPD, WindDat...
|
506 |
updateIAS: func () { |
comment on the folds
|
507 |
# animates the IAS lint (PFD) {{{ |
adds OAT, TAS, GSPD, WindDat...
|
508 |
var ias = me._updated_ias; |
animation IAS
|
509 |
if (ias >= 10) |
510 |
me.screenElements.Speed110 |
|
511 |
.setText(sprintf("% 2u",num(math.floor(ias/10)))); |
|
512 |
else |
|
513 |
me.screenElements.Speed110 |
|
514 |
.setText(''); |
|
515 |
me.screenElements.SpeedLint1 |
|
516 |
.setTranslation(0,(math.mod(ias,10) + (ias >= 10)*10) * 36); |
|
517 |
me.screenElements.SpeedTape |
|
518 |
.setTranslation(0,ias * 5.711); |
|
adds OAT, TAS, GSPD, WindDat...
|
519 |
if (ias > me._ias_vne and ! me._ias_already_exceeded) { # easier than .getColorFill |
520 |
me._ias_already_exceeded = 1; |
|
521 |
me.screenElements['IAS-bg'] |
|
522 |
.setColorFill(1,0,0); |
|
523 |
} |
|
524 |
elsif (ias < me._ias_vne and me._ias_already_exceeded) { # easier than .getColorFill |
|
525 |
me._ias_already_exceeded = 0; |
|
526 |
me.screenElements['IAS-bg'] |
|
527 |
.setColorFill(0,0,0); |
|
528 |
} |
|
trends animation
|
529 |
var now = systime(); |
530 |
# estimated speed in 6s |
|
531 |
var Sy = 6 * (ias - me._last_ias_kt) / (now - me._last_ias_s); |
|
532 |
if (abs(Sy) > 30) |
|
533 |
Sy = 30 * abs(Sy)/Sy; # = -30 or 30 |
|
534 |
me.screenElements['Airspeed-Trend-Indicator'] |
|
535 |
.setScale(1,Sy) |
|
536 |
.setTranslation(0, -284.5 * (Sy - 1)); |
|
537 |
me._last_ias_kt = ias; |
|
538 |
me._last_ias_s = now; |
|
adds OAT, TAS, GSPD, WindDat...
|
539 |
settimer(func me.updateIAS(), 0.1); |
animation IAS
|
540 |
}, |
trends animation
|
541 |
_last_ias_kt : 0, |
542 |
_last_ias_s : systime(), |
|
adds OAT, TAS, GSPD, WindDat...
|
543 |
_ias_vne : 999, |
544 |
_ias_already_exceeded : 0, |
|
cosmétique: folding pour les...
|
545 |
#}}} |
animation ALT
|
546 | |
adds OAT, TAS, GSPD, WindDat...
|
547 |
updateTAS: func { |
548 |
# updates the True Airspeed and GroundSpeed indicators {{{ |
|
549 |
me.screenElements['TAS-text'] |
|
550 |
.setText(sprintf('%iKT', getprop('/instrumentation/airspeed-indicator/true-speed-kt'))); |
|
551 |
me.screenElements['GSPD-text'] |
|
552 |
.setText(sprintf('%iKT', getprop('/velocities/groundspeed-kt'))); |
|
553 |
settimer(func me.updateTAS(), 0.5); |
|
554 |
}, |
|
555 |
#}}} |
|
556 | ||
557 |
updateALT: func () { |
|
558 |
# animates the altitude lint (PFD) {{{ |
|
559 |
var alt = me._updated_alt; |
|
animation ALT
|
560 |
if (alt < 0) |
561 |
me.screenElements.Alt11100 |
|
562 |
.setText(sprintf("% 3i",math.ceil(alt/100))); |
|
563 |
elsif (alt < 100) |
|
564 |
me.screenElements.Alt11100 |
|
565 |
.setText(''); |
|
566 |
else |
|
567 |
me.screenElements.Alt11100 |
|
568 |
.setText(sprintf("% 3i",math.floor(alt/100))); |
|
569 |
me.screenElements.AltLint00011 |
|
570 |
.setTranslation(0,math.fmod(alt,100) * 1.24); |
|
571 | ||
572 |
# From Farmin/G1000 http://wiki.flightgear.org/Project_Farmin/FG1000 |
|
573 |
if (alt> -1000 and alt< 1000000) { |
|
574 |
var Offset10 = 0; |
|
575 |
var Offset100 = 0; |
|
576 |
var Offset1000 = 0; |
|
577 |
if (alt< 0) { |
|
578 |
var Ne = 1; |
|
579 |
var alt= -alt; |
|
580 |
} |
|
581 |
else |
|
582 |
var Ne = 0; |
|
583 | ||
584 |
var Alt10 = math.mod(alt,100); |
|
585 |
var Alt100 = int(math.mod(alt/100,10)); |
|
586 |
var Alt1000 = int(math.mod(alt/1000,10)); |
|
587 |
var Alt10000 = int(math.mod(alt/10000,10)); |
|
588 |
var Alt20 = math.mod(Alt10,20)/20; |
|
589 |
if (Alt10 >= 80) |
|
590 |
var Alt100 += Alt20; |
|
591 | ||
592 |
if (Alt10 >= 80 and Alt100 >= 9) |
|
593 |
var Alt1000 += Alt20; |
|
594 | ||
595 |
if (Alt10 >= 80 and Alt100 >= 9 and Alt1000 >= 9) |
|
596 |
var Alt10000 += Alt20; |
|
597 | ||
598 |
if (alt> 100) |
|
599 |
var Offset10 = 100; |
|
600 | ||
601 |
if (alt> 1000) |
|
602 |
var Offset100 = 10; |
|
603 | ||
604 |
if (alt> 10000) |
|
605 |
var Offset1000 = 10; |
|
606 | ||
607 |
if (!Ne) { |
|
608 |
me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*0.57375); |
|
609 |
var altCentral = (int(alt/100)*100); |
|
610 |
} |
|
611 |
elsif (Ne) { |
|
612 |
me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*-0.57375); |
|
613 |
var altCentral = -(int(alt/100)*100); |
|
614 |
} |
|
615 |
me.screenElements["AltBigC"].setText(""); |
|
616 |
me.screenElements["AltSmallC"].setText(""); |
|
617 |
for (var place = 1; place <= 6; place += 1) { |
|
618 |
var altUP = altCentral + (place*100); |
|
619 |
var offset = -30.078; |
|
620 |
if (altUP < 0) { |
|
621 |
var altUP = -altUP; |
|
622 |
var prefix = "-"; |
|
623 |
var offset += 15.039; |
|
624 |
} |
|
625 |
else |
|
626 |
var prefix = ""; |
|
627 | ||
628 |
if (altUP == 0) { |
|
629 |
var AltBigUP = ""; |
|
630 |
var AltSmallUP = "0"; |
|
631 | ||
632 |
} |
|
633 |
elsif (math.mod(altUP,500) == 0 and altUP != 0) { |
|
634 |
var AltBigUP = sprintf(prefix~"%1d", altUP); |
|
635 |
var AltSmallUP = ""; |
|
636 |
} |
|
637 |
elsif (altUP < 1000 and (math.mod(altUP,500))) { |
|
638 |
var AltBigUP = ""; |
|
639 |
var AltSmallUP = sprintf(prefix~"%1d", int(math.mod(altUP,1000))); |
|
640 |
var offset = -30.078; |
|
641 |
} |
|
642 |
elsif ((altUP < 10000) and (altUP >= 1000) and (math.mod(altUP,500))) { |
|
643 |
var AltBigUP = sprintf(prefix~"%1d", int(altUP/1000)); |
|
644 |
var AltSmallUP = sprintf("%1d", int(math.mod(altUP,1000))); |
|
645 |
var offset += 15.039; |
|
646 |
} |
|
647 |
else { |
|
648 |
var AltBigUP = sprintf(prefix~"%1d", int(altUP/1000)); |
|
649 |
var mod = int(math.mod(altUP,1000)); |
|
650 |
var AltSmallUP = sprintf("%1d", mod); |
|
651 |
var offset += 30.078; |
|
652 |
} |
|
653 | ||
654 |
me.screenElements["AltBigU"~place].setText(AltBigUP); |
|
655 |
me.screenElements["AltSmallU"~place].setText(AltSmallUP); |
|
656 |
me.screenElements["AltSmallU"~place].setTranslation(offset,0); |
|
657 |
var altDOWN = altCentral - (place*100); |
|
658 |
var offset = -30.078; |
|
659 |
if (altDOWN < 0) { |
|
660 |
var altDOWN = -altDOWN; |
|
661 |
var prefix = "-"; |
|
662 |
var offset += 15.039; |
|
663 |
} |
|
664 |
else |
|
665 |
var prefix = ""; |
|
666 | ||
667 |
if (altDOWN == 0) { |
|
668 |
var AltBigDOWN = ""; |
|
669 |
var AltSmallDOWN = "0"; |
|
670 |
} |
|
671 |
elsif (math.mod(altDOWN,500) == 0 and altDOWN != 0) { |
|
672 |
var AltBigDOWN = sprintf(prefix~"%1d", altDOWN); |
|
673 |
var AltSmallDOWN = ""; |
|
674 |
} |
|
675 |
elsif (altDOWN < 1000 and (math.mod(altDOWN,500))) { |
|
676 |
var AltBigDOWN = ""; |
|
677 |
var AltSmallDOWN = sprintf(prefix~"%1d", int(math.mod(altDOWN,1000))); |
|
678 |
var offset = -30.078; |
|
679 |
} |
|
680 |
elsif ((altDOWN < 10000) and (altDOWN >= 1000) and (math.mod(altDOWN,500))) { |
|
681 |
var AltBigDOWN = sprintf(prefix~"%1d", int(altDOWN/1000)); |
|
682 |
var AltSmallDOWN = sprintf("%1d", int(math.mod(altDOWN,1000))); |
|
683 |
var offset += 15.039; |
|
684 |
} |
|
685 |
else { |
|
686 |
var AltBigDOWN = sprintf(prefix~"%1d", int(altDOWN/1000)); |
|
687 |
var mod = int(math.mod(altDOWN,1000)); |
|
688 |
var AltSmallDOWN = sprintf("%1d", mod); |
|
689 |
var offset += 30.078; |
|
690 |
} |
|
691 |
me.screenElements["AltBigD"~place].setText(AltBigDOWN); |
|
692 |
me.screenElements["AltSmallD"~place].setText(AltSmallDOWN); |
|
693 |
me.screenElements["AltSmallD"~place].setTranslation(offset,0); |
|
694 |
} |
|
695 |
} |
|
adds OAT, TAS, GSPD, WindDat...
|
696 |
me.updateSelectedALT(); |
trends animation
|
697 |
var now = systime(); |
698 |
# altitude in 6s |
|
699 |
var Sy = .3 * (alt - me._last_alt_ft) / (now - me._last_alt_s); # scale = 1/20ft |
|
700 |
if (abs(Sy) > 15) |
|
701 |
Sy = 15 * abs(Sy)/Sy; # = -15 or 15 |
|
702 |
me.screenElements['Altitude-Trend-Indicator'] |
|
703 |
.setScale(1,Sy) |
|
704 |
.setTranslation(0, -284.5 * (Sy - 1)); |
|
705 |
me._last_alt_ft = alt; |
|
706 |
me._last_alt_s = now; |
|
adds OAT, TAS, GSPD, WindDat...
|
707 |
settimer(func me.updateALT(), 0.2); |
animation ALT
|
708 |
}, |
trends animation
|
709 |
_last_alt_ft : 0, |
710 |
_last_alt_s : systime(), |
|
cosmétique: folding pour les...
|
711 |
#}}} |
animation HSI
|
712 | |
adds BARO settings
|
713 |
updateBARO : func () { |
714 |
# update BARO widget {{{ |
|
715 |
var fmt = me._baro_unit == 'inhg' ? '%.2f%s' : '%i%s'; |
|
716 |
me.screenElements['BARO-text'] |
|
717 |
.setText(sprintf(fmt, |
|
718 |
getprop('/instrumentation/altimeter/setting-' ~ me._baro_unit), |
|
719 |
me._baro_unit == 'inhg' ? 'in' : 'hPa') |
|
720 |
); |
|
721 |
}, |
|
722 |
_baro_unit : 'inhg', |
|
723 |
#}}} |
|
724 | ||
adds OAT, TAS, GSPD, WindDat...
|
725 |
updateHSI : func () { |
comment on the folds
|
726 |
# rotates the compass (PFD) {{{ |
adds OAT, TAS, GSPD, WindDat...
|
727 |
var hdg = me._updated_hdg; |
animation HSI
|
728 |
me.screenElements.Rose |
729 |
.setRotation(-hdg * D2R); |
|
730 |
me.screenElements['HDG-text'] |
|
731 |
.setText(sprintf("%03u°", hdg)); |
|
adds OAT, TAS, GSPD, WindDat...
|
732 |
settimer(func me.updateHSI(), 0.1); |
animation HSI
|
733 |
}, |
cosmétique: folding pour les...
|
734 |
#}}} |
NAV disponible (hors CDI)
|
735 | |
animation HDG bug
|
736 |
updateHDG : func (hdg) { |
comment on the folds
|
737 |
# moves the heading bug and display heading-deg for 3 seconds (PFD) {{{ |
animation HDG bug
|
738 |
if (me.role == 'MFD') |
739 |
return; |
|
740 |
me.screenElements['Heading-bug'] |
|
741 |
.setRotation(hdg * D2R); |
|
742 |
me.screenElements['SelectedHDG-bg'] |
|
743 |
.show(); |
|
744 |
me.screenElements['SelectedHDG-bgtext'] |
|
745 |
.show(); |
|
746 |
me.screenElements['SelectedHDG-text'] |
|
747 |
.setText(sprintf('%03d°%s', hdg, '')) |
|
748 |
.show(); |
|
749 |
me.addTimer(3, ['SelectedHDG-text', 'SelectedHDG-bgtext', 'SelectedHDG-bg']); |
|
750 |
}, |
|
cosmétique: folding pour les...
|
751 |
#}}} |
animation HDG bug
|
752 | |
adds CDI
|
753 |
updateCRS : func () { |
anime CRS
|
754 |
# TODO: update display for NAV/GPS/BRG courses {{{ |
755 |
if (me.role == 'MFD') |
|
756 |
return; |
|
adds CDI
|
757 |
var source = getprop('/instrumentation/zkv1000/cdi/source'); |
758 |
if (source == 'OFF') |
|
759 |
return; |
|
760 |
var crs = getprop('/instrumentation/zkv1000/cdi/course'); |
|
761 |
if (crs == nil) |
|
762 |
return; |
|
anime CRS
|
763 |
me.screenElements['SelectedCRS-bg'] |
764 |
.show(); |
|
765 |
me.screenElements['SelectedCRS-bgtext'] |
|
766 |
.show(); |
|
767 |
me.screenElements['SelectedCRS-text'] |
|
768 |
.setText(sprintf('%03d°%s', crs, '')) |
|
adds CDI
|
769 |
.setColor(source == 'GPS' ? me.colors.magenta : me.colors.green) |
anime CRS
|
770 |
.show(); |
771 |
me.addTimer(3, ['SelectedCRS-text', 'SelectedCRS-bgtext', 'SelectedCRS-bg']); |
|
772 |
}, |
|
773 |
#}}} |
|
774 | ||
adds OAT, TAS, GSPD, WindDat...
|
775 |
updateSelectedALT : func { |
776 |
# animation for altitude section, called via updatedALT {{{ |
|
fix Selected Altitude displa...
|
777 |
if (! device[0].display.screenElements['SelectedALT'].getVisible()) |
778 |
return; |
|
adds OAT, TAS, GSPD, WindDat...
|
779 |
var selected_alt = getprop('/instrumentation/zkv1000/afcs/selected-alt-ft'); |
780 |
var delta_alt = me._updated_alt - selected_alt; |
|
781 |
if (abs(delta_alt) > 300) |
|
782 |
delta_alt = 300 * abs(delta_alt)/delta_alt; |
|
fix Selected Altitude displa...
|
783 |
me.screenElements['SelectedALT-symbol'] |
784 |
.setVisible(abs(delta_alt) > 100); |
|
785 |
me.screenElements['SelectedALT-bg'] |
|
786 |
.setVisible(abs(delta_alt) > 100); |
|
787 |
me.screenElements['SelectedALT-text'] |
|
788 |
.setText(sprintf("%i", selected_alt)) |
|
adds OAT, TAS, GSPD, WindDat...
|
789 |
.setVisible(abs(delta_alt) > 100); |
fix Selected Altitude displa...
|
790 |
me.screenElements['SelectedALT-bug'] |
adds OAT, TAS, GSPD, WindDat...
|
791 |
.setTranslation(0, delta_alt * 0.567); # 170/300 = 0.567 |
792 |
}, |
|
793 |
#}}} |
|
794 | ||
adds CDI
|
795 |
updateCDI : func { |
796 |
# animation for CDI {{{ |
|
797 |
var source = getprop('/instrumentation/zkv1000/cdi/source'); |
|
798 |
if (source == 'OFF') { |
|
799 |
foreach (var s; ['GPS', 'NAV1', 'NAV2']) |
|
800 |
foreach (var t; ['pointer', 'CDI']) |
|
801 |
me.screenElements[s ~ '-' ~ t].hide(); |
|
802 |
me.screenElements['CDI-GPS-ANN-text'].hide(); |
|
803 |
me.screenElements['CDI-GPS-XTK-text'].hide(); |
|
804 |
me.screenElements['CDI-SRC-text'].hide(); |
|
805 |
me.screenElements['CDI'].hide(); |
|
806 |
} |
|
807 |
else { |
|
808 |
var course = getprop('/instrumentation/zkv1000/cdi/course'); |
|
809 |
me.screenElements['CDI'] |
|
810 |
.show(); |
|
811 |
me.screenElements['GPS-CTI'] |
|
812 |
.setVisible(source == 'GPS'); |
|
813 |
me.screenElements['GPS-CTI-diamond'] |
|
814 |
.setVisible(source == 'GPS'); |
|
815 |
foreach (var s; ['GPS', 'NAV1', 'NAV2']) { |
|
816 |
var rot = (course - me._updated_hdg) * D2R; |
|
817 |
me.screenElements[s ~ '-pointer'] |
|
818 |
.setRotation(rot) |
|
819 |
.setVisible(source == s); |
|
820 |
me.screenElements[s ~ '-CDI'] |
|
821 |
.setVisible(source == s); |
|
822 |
foreach (var f; ['FROM', 'TO']) |
|
823 |
me.screenElements[s ~ '-' ~ f] |
|
824 |
.setVisible(s == source and getprop('/instrumentation/zkv1000/cdi/', f, '-flag')); |
|
825 |
me.screenElements['CDI-SRC-text'] |
|
826 |
.setText(source) |
|
827 |
.setColor(source == 'GPS' ? me.colors.magenta : me.colors.green) |
|
828 |
.show(); |
|
829 |
var deflection = getprop('/instrumentation/zkv1000/cdi/course-deflection'); |
|
830 |
if (left(source, 3) == 'NAV') { |
|
831 |
var scale = deflection / 4; |
|
832 |
scale = (abs(scale) > 1.2) ? 1.2 : scale; |
|
833 |
} |
|
834 |
else { |
|
835 |
me.screenElements['CDI-SRC-text'] |
|
836 |
.setText('GPS') |
|
837 |
.setColor(1,0,1); |
|
838 |
} |
|
839 |
me.screenElements[source ~ '-CDI'] |
|
840 |
.setTranslation(65 * scale, 0); |
|
841 |
} |
|
842 |
settimer(func me.updateCDI(), 0.5); |
|
843 |
} |
|
844 |
}, |
|
845 |
#}}} |
|
846 | ||
ajout COMM, et factorisation...
|
847 |
_updateRadio: func { |
comment on the folds
|
848 |
# common parts for NAV/LOC/COMM radios{{{ |
ajout COMM, et factorisation...
|
849 |
# arg[0]._r = <comm|nav> |
850 |
if (contains(arg[0], "active")) { |
|
851 |
if (arg[0]['active'] == 'none') { |
|
852 |
me.screenElements[arg[0]._r ~ '1-selected-freq'] |
|
853 |
.setColor(1,1,1); |
|
854 |
me.screenElements[arg[0]._r ~ '2-selected-freq'] |
|
855 |
.setColor(1,1,1); |
|
856 |
} |
|
857 |
else { |
|
858 |
me.screenElements[arg[0]._r ~ arg[0]['active'] ~ '-selected-freq'] |
|
859 |
.setColor(0,1,0); |
|
860 |
me.screenElements[arg[0]._r ~ arg[0].inactive ~ '-selected-freq'] |
|
861 |
.setColor(1,1,1); |
|
862 |
} |
|
863 |
} |
|
864 |
if (contains(arg[0], 'tune')) { |
|
865 |
# n = 0 -> NAV1/COMM1 |
|
866 |
# n = 1 -> NAV1/COMM2 |
|
867 |
me.screenElements[arg[0]._r ~ '-freq-switch'] |
|
868 |
.setTranslation(0, arg[0].tune * 25); |
|
869 |
me.screenElements[arg[0]._r ~ (arg[0].tune + 1) ~ '-standby-freq'] |
|
870 |
.setColor(0,1,1); |
|
871 |
me.screenElements[arg[0]._r ~ ((arg[0].tune == 0) + 1) ~ '-standby-freq'] |
|
872 |
.setColor(1,1,1); |
|
873 |
} |
|
874 |
if (contains(arg[0], 'refresh')) { |
|
small stuff
|
875 |
# refresh only one line: NAV1/COMM1 or NAV2/COMM2 |
ajout COMM, et factorisation...
|
876 |
var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f'; |
877 |
me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-selected-freq'] |
|
878 |
.setText(sprintf(fmt, getprop('/instrumentation/' |
|
879 |
~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/selected-mhz'))); |
|
880 |
me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-standby-freq'] |
|
881 |
.setText(sprintf(fmt, getprop('/instrumentation/' |
|
882 |
~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/standby-mhz'))); |
|
883 |
} |
|
884 |
if (contains(arg[0], 'set')) { |
|
885 |
# positionne la valeur modifiée, les listeners "trigguent" en permanence ces propriétés, donc exit |
|
886 |
var n = getprop('/instrumentation/zkv1000/radios/' ~ arg[0]._r ~ '-tune'); |
|
887 |
var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f'; |
|
888 |
me.screenElements[arg[0]._r ~ (n + 1) ~ '-standby-freq'] |
|
fix freq display while setti...
|
889 |
.setText(sprintf(fmt, getprop('/instrumentation/' ~ arg[0]._r ~ '[' ~ n ~ ']/frequencies/standby-mhz'))); |
ajout COMM, et factorisation...
|
890 |
} |
891 |
if (contains(arg[0], 'auto')) { |
|
892 |
# pour rafraichir automagiquement, toutes les deux secondes un refresh pour un NAV |
|
893 |
var radio = arg[0].auto; |
|
894 |
me._updateRadio({refresh: 1, _r: radio}); |
|
895 |
settimer(func me._updateRadio({refresh: 2, _r: radio}), 1); |
|
896 |
settimer(func me._updateRadio({auto: radio}), 2); |
|
897 |
} |
|
898 |
}, |
|
cosmétique: folding pour les...
|
899 |
#}}} |
ajout COMM, et factorisation...
|
900 | |
NAV disponible (hors CDI)
|
901 |
updateNAV : func { |
comment on the folds
|
902 |
# update NAV/LOC rodios display upper left (PFD/MFD){{{ |
NAV disponible (hors CDI)
|
903 |
# made active via menu |
904 |
if (contains(arg[0], "active")) { |
|
adds CDI
|
905 |
arg[0]._r = 'nav'; |
NAV disponible (hors CDI)
|
906 |
if (arg[0]['active'] == 'none') { |
ajout COMM, et factorisation...
|
907 |
me._updateRadio(arg[0]); |
NAV disponible (hors CDI)
|
908 |
me.screenElements['nav1-id'] |
909 |
.setColor(1,1,1); |
|
910 |
me.screenElements['nav2-id'] |
|
911 |
.setColor(1,1,1); |
|
912 |
me.screenElements['NAV1-pointer'] |
|
913 |
.hide(); |
|
914 |
me.screenElements['NAV2-pointer'] |
|
915 |
.hide(); |
|
916 |
} |
|
917 |
else { |
|
ajout COMM, et factorisation...
|
918 |
arg[0].inactive = (arg[0]['active'] == 1) + 1; |
919 |
me._updateRadio(arg[0]); |
|
NAV disponible (hors CDI)
|
920 |
me.screenElements['nav' ~ arg[0]['active'] ~ '-id'] |
921 |
.setColor(0,1,0); |
|
922 |
me.screenElements['NAV' ~ arg[0]['active'] ~ '-pointer'] |
|
923 |
.show(); |
|
ajout COMM, et factorisation...
|
924 |
me.screenElements['nav' ~ arg[0].inactive ~ '-id'] |
925 |
.setColor(1,1,1); |
|
NAV disponible (hors CDI)
|
926 |
# me.screenElements['HDI'] |
927 |
# .setRotation(); |
|
928 |
# me.screenElements['NAV' ~ inactive ~ '-pointer'] |
|
929 |
# .hide(); |
|
930 |
# foreach (var e; [ 'FROM', 'TO', 'CDI' ]) |
|
931 |
# me.screenElements['NAV' ~ inactive ~ '-' ~ e] |
|
932 |
# .hide(); |
|
933 |
} |
|
934 |
} |
|
ajout COMM, et factorisation...
|
935 |
elsif (contains(arg[0], 'nav-id')) { |
Correction swap NAV tuning
|
936 |
# TODO: récupérer la valeur via les paramètres transmis du listener |
ajout COMM, et factorisation...
|
937 |
if (arg[0].val == nil) |
938 |
arg[0].val = ''; |
|
NAV disponible (hors CDI)
|
939 |
me.screenElements["nav" ~ arg[0]['nav-id'] ~ "-id"] |
ajout COMM, et factorisation...
|
940 |
.setText(arg[0].val); |
NAV disponible (hors CDI)
|
941 |
} |
ajout COMM, et factorisation...
|
942 |
else { |
943 |
arg[0]._r = 'nav'; |
|
944 |
me._updateRadio(arg[0]); |
|
NAV disponible (hors CDI)
|
945 |
} |
946 |
}, |
|
cosmétique: folding pour les...
|
947 |
#}}} |
ajout COMM, et factorisation...
|
948 | |
949 |
updateCOMM: func { |
|
comment on the folds
|
950 |
# update COMM radios display upper right (PFD/MFD){{{ |
ajout COMM, et factorisation...
|
951 |
arg[0]._r = 'comm'; |
952 |
me._updateRadio(arg[0]); |
|
953 |
}, |
|
cosmétique: folding pour les...
|
954 |
#}}} |
anime time display
|
955 | |
956 |
updateTIME : func { |
|
957 |
# updates the displayed time botoom left {{{ |
|
958 |
me.screenElements['TIME-text'] |
|
959 |
.setText(getprop('/sim/time/gmt-string')); |
|
960 |
settimer(func me.updateTIME(), 1); |
|
961 |
}, |
|
962 |
#}}} |
|
adds OAT, TAS, GSPD, WindDat...
|
963 | |
adds transponder
|
964 |
updateXPDR : func { |
965 |
# updates transponder display {{{ |
|
966 |
for (var d = 0; d < 4; d+=1) |
|
967 |
me.screenElements['XPDR-DIGIT-' ~ d ~ '-text'] |
|
968 |
.setText(sprintf('%i', getprop('/instrumentation/transponder/inputs/digit[' ~ d ~ ']'))); |
|
969 |
var tuning = getprop('/instrumentation/zkv1000/radios/xpdr-tuning-digit'); |
|
XPDR settings via knob or so...
|
970 |
var fms = getprop('/instrumentation/zkv1000/radios/xpdr-tuning-fms-method'); |
971 |
for (var d = 0; d < 4; d+=1) |
|
972 |
me.screenElements['XPDR-DIGIT-' ~ d ~ '-text'] |
|
973 |
.setColor(1,1,1); |
|
974 |
if (tuning != nil) { |
|
975 |
me.screenElements['XPDR-DIGIT-' ~ tuning ~ '-text'] |
|
976 |
.setColor(0,1,1); |
|
977 |
if (fms) |
|
978 |
me.screenElements['XPDR-DIGIT-' ~ (tuning - 1) ~ '-text'] |
|
979 |
.setColor(0,1,1); |
|
980 |
} |
|
adds transponder
|
981 |
else { |
982 |
if (getprop('/instrumentation/transponder/ident')) |
|
983 |
var mode = 'IDENT'; |
|
984 |
else |
|
985 |
var mode = getprop('/instrumentation/zkv1000/radio/xpdr-mode'); |
|
986 |
var wow = getprop('/gear/gear/wow'); |
|
987 |
if (! wow and mode != 'STBY') |
|
988 |
var color = [0, 1, 0]; |
|
989 |
else |
|
990 |
var color = [1, 1, 1]; |
|
991 |
for (var d = 0; d < 4; d+=1) |
|
992 |
me.screenElements['XPDR-DIGIT-' ~ d ~ '-text'] |
|
993 |
.setColor(color); |
|
994 |
me.screenElements['XPDR-MODE-text'] |
|
995 |
.setColor(color) |
|
996 |
.setText(mode); |
|
997 |
} |
|
XPDR settings via knob or so...
|
998 |
}, |
adds transponder
|
999 |
#}}} |
1000 | ||
adds OAT, TAS, GSPD, WindDat...
|
1001 |
updateOAT : func { |
1002 |
# update OAT display on normal and reversionnary modes (every 3s) {{{ |
|
1003 |
var tmp = getprop('/environment/temperature-deg' ~ me._oat_unit); |
|
1004 |
me.screenElements['OAT-text'] |
|
1005 |
.setText(sprintf((abs(tmp) < 10) ? "%.1f %s" : "%i %s", tmp, (me._oat_unit == 'c') ? '°C' : 'F')); |
|
1006 |
settimer(func me.updateOAT(), 3); |
|
1007 |
}, |
|
1008 |
_oat_unit : 'c', |
|
1009 |
#}}} |
|
1010 | ||
1011 |
updateWindData : func { |
|
1012 |
# update the window text and arrows for OPTN1/2 {{{ |
|
1013 |
if (me._winddata_optn == 0) |
|
1014 |
return; |
|
improves WindData display
|
1015 |
if (me._updated_ias < 30) { |
1016 |
me.screenElements['WindData-NODATA'] |
|
1017 |
.hide(); |
|
1018 |
var wind_hdg = getprop('/environment/wind-from-heading-deg'); |
|
1019 |
var wind_spd = getprop('/environment/wind-speed-kt'); |
|
1020 |
var alpha = wind_hdg - me._updated_hdg; |
|
1021 |
if (me._winddata_optn == 1) { |
|
1022 |
me.screenElements['WindData-OPTN1-HDG'] |
|
1023 |
.setRotation((alpha + 180) * D2R) |
|
1024 |
.show(); |
|
1025 |
me.screenElements['WindData-OPTN1-HDG-text'] |
|
1026 |
.setText(sprintf("%03i°", wind_hdg)) |
|
1027 |
.show(); |
|
1028 |
me.screenElements['WindData-OPTN1-SPD-text'] |
|
1029 |
.setText(int(wind_spd) ~ 'KT') |
|
1030 |
.show(); |
|
adds OAT, TAS, GSPD, WindDat...
|
1031 |
} |
improves WindData display
|
1032 |
else { # me._winddata_optn == 2 |
1033 |
alpha *= D2R; |
|
1034 |
var Vt = wind_spd * math.sin(alpha); |
|
1035 |
var Ve = wind_spd * math.cos(alpha); |
|
1036 |
if (Vt != 0) { |
|
1037 |
me.screenElements['WindData-OPTN2-crosswind-text'] |
|
1038 |
.setText(sprintf('%i', abs(Vt))) |
|
1039 |
.show(); |
|
1040 |
me.screenElements['WindData-OPTN2-crosswind'] |
|
1041 |
.setScale(-abs(Vt)/Vt, 1) |
|
1042 |
.setTranslation(-35 * (abs(Vt)/Vt + 1), 0) |
|
1043 |
.show(); |
|
1044 |
} |
|
1045 |
if (Ve != 0) { |
|
1046 |
me.screenElements['WindData-OPTN2-headwind-text'] |
|
1047 |
.setText(sprintf('%i', abs(Ve))) |
|
1048 |
.show(); |
|
1049 |
me.screenElements['WindData-OPTN2-headwind'] |
|
1050 |
.setScale(1, abs(Ve)/Ve) |
|
1051 |
.setTranslation(0, 515 * (1 - abs(Ve)/Ve)) |
|
1052 |
.show(); |
|
1053 |
} |
|
adds OAT, TAS, GSPD, WindDat...
|
1054 |
} |
1055 |
} |
|
improves WindData display
|
1056 |
else { |
1057 |
foreach (var e; [ |
|
1058 |
'WindData-OPTN1-HDG', |
|
1059 |
'WindData-OPTN1-HDG-text', |
|
1060 |
'WindData-OPTN1-SPD-text', |
|
1061 |
'WindData-OPTN2-crosswind-text', |
|
1062 |
'WindData-OPTN2-crosswind', |
|
1063 |
'WindData-OPTN2-headwind-text', |
|
1064 |
'WindData-OPTN2-headwind' |
|
1065 |
]) |
|
1066 |
me.screenElements[e].hide(); |
|
1067 |
me.screenElements['WindData-NODATA'].show(); |
|
1068 |
} |
|
adds OAT, TAS, GSPD, WindDat...
|
1069 |
settimer(func me.updateWindData(), 0.5); |
1070 |
}, |
|
1071 |
_winddata_optn : 0, |
|
1072 |
#}}} |
|
adds BRG1/2 animation
|
1073 | |
1074 |
updateBRG : func { |
|
some added comments
|
1075 |
# displays and update BRG1/2 {{{ |
adds BRG1/2 animation
|
1076 |
foreach (var brg; [1, 2]) { |
1077 |
var source = 'brg' ~ brg ~ '-source'; |
|
1078 | ||
1079 |
var dev = radios.getNode(source).getValue(); |
|
1080 |
var el = 'BRG' ~ brg; |
|
1081 |
if (dev != 'OFF') { |
|
colorize BRG1/2 when needed,...
|
1082 |
if (size(me.device.softkeys.path) == 1 and me.device.softkeys.path[0] == 'PFD') |
1083 |
me.setSoftKeyColor(brg == 1 ? 4 : 6, 1); |
|
1084 |
else |
|
1085 |
me.setSoftKeyColor(brg == 1 ? 4 : 6, 0); |
|
adds BRG1/2 animation
|
1086 |
var info = { |
1087 |
pointer : nil, |
|
1088 |
id : 'NO DATA', |
|
1089 |
hdg : nil, |
|
1090 |
dst : '--.-NM' |
|
1091 |
}; |
|
1092 |
if (left(dev, 3) == 'NAV') { |
|
1093 |
info.pointer = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/in-range'); |
|
1094 |
if (info.pointer) { |
|
1095 |
info.id = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/nav-id'); |
|
1096 |
info.hdg = getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/heading-deg'); |
|
1097 |
info.dst = sprintf('%.1d', getprop('/instrumentation/nav[' ~ (brg - 1) ~ ']/nav-distance') / 1852); # m -> /1852 |
|
1098 |
} |
|
1099 |
} |
|
1100 |
elsif (dev == 'GPS') { |
|
1101 |
info.pointer = props.getNode('/instrumentation/gps/wp').getChild('wp[1])'); |
|
1102 |
if (info.pointer) { |
|
1103 |
info.id = getprop('/instrumentation/gps/wp/wp[1]/ID'); |
|
1104 |
info.hdg = getprop('/instrumentation/gps/wp/wp[1]/bearing-mag-deg'); |
|
1105 |
info.dst = sprintf('%.1d', getprop('/instrumentation/gps/wp/wp[1]/distance-nm')); |
|
1106 |
} |
|
1107 |
} |
|
1108 |
else { # there are 2 available ADF in FG, but instrument manage only 1 |
|
1109 |
info.pointer = getprop('/instrumentation/adf/in-range'); |
|
1110 |
if (info.pointer) { |
|
1111 |
info.id = getprop('/instrumentation/adf/ident'); |
|
1112 |
info.hdg = getprop('/instrumentation/adf/indicated-bearing-deg'); |
|
1113 |
} |
|
1114 |
} |
|
1115 | ||
1116 |
if (info.pointer) |
|
1117 |
me.screenElements[el ~ '-pointer'] |
|
1118 |
.setRotation(-info.hdg-me._updated_hdg * D2R) |
|
1119 |
.show(); |
|
1120 |
else |
|
1121 |
me.screenElements[el ~ '-pointer'] |
|
1122 |
.hide(); |
|
1123 |
me.screenElements[el ~ '-SRC-text'] |
|
1124 |
.setText(dev); |
|
1125 |
me.screenElements[el ~ '-DST-text'] |
|
1126 |
.setText(info.dst); |
|
1127 |
me.screenElements[el ~ '-WPID-text'] |
|
1128 |
.setText(info.id); |
|
1129 |
me.screenElements['BRG' ~ brg] |
|
1130 |
.show(); |
|
1131 |
} |
|
1132 |
else { |
|
colorize BRG1/2 when needed,...
|
1133 |
me.setSoftKeyColor(brg == 1 ? 4 : 6, 0); |
adds BRG1/2 animation
|
1134 |
me.screenElements['BRG' ~ brg] |
1135 |
.hide(); |
|
1136 |
} |
|
1137 |
} |
|
colorize BRG1/2 when needed,...
|
1138 |
settimer(func me.updateBRG(), 0.5); |
adds BRG1/2 animation
|
1139 |
}, |
some added comments
|
1140 |
#}}} |
softkeys are available now
|
1141 | |
animation texts EIS + power ...
|
1142 |
updateEIS : func { |
1143 |
# displays Engine Informations System {{{ |
|
1144 |
var power = getprop('/controls/engines/engine/throttle') * getprop('/engines/engine/running'); |
|
1145 |
me.screenElements['POWER-pointer'] |
|
1146 |
.setRotation(D2R * 140 * power); |
|
1147 |
me.screenElements['POWER-PERCENT-text'] |
|
1148 |
.setText(sprintf('%u', power)); |
|
1149 |
me.screenElements['RPM-text'] |
|
1150 |
.setText(sprintf(math.round(getprop('/engines/engine/rpm'), 50))); |
|
1151 |
me.screenElements['MAN-Hg-text'] |
|
1152 |
.setText(sprintf('%.1d', getprop('/engines/engine/mp-inhg'))); |
|
1153 |
me.screenElements['FUEL-FLOW-text'] |
|
1154 |
.setText(sprintf('%.1f', getprop('/engines/engine/fuel-flow-gph'))); |
|
1155 |
if (math.mod(me._eis_count, 10) == 0) { |
|
1156 |
var psi = getprop('/engines/engine/oil-pressure-psi'); |
|
1157 |
me.screenElements['PSI-text'] |
|
1158 |
.setText(psi == nil ? '--' : sprintf('%u', psi)); |
|
1159 |
me.screenElements['OIL-TEMP-text'] |
|
1160 |
.setText(sprintf('%i', getprop('/engines/engine/oil-temperature-degf'))); |
|
1161 |
var used_fuel = getprop('/instrumentation/zkv1000/eis/fuel-qty-at-start') |
|
1162 |
- getprop('/consumables/fuel/tank/level-gal_us') |
|
1163 |
- getprop('/consumables/fuel/tank[1]/level-gal_us'); |
|
1164 |
me.screenElements['FUEL-USED-text'] |
|
1165 |
.setText(sprintf('%.1d', used_fuel > 0 ? used_fuel : 0)); |
|
1166 |
me.screenElements['BUS-V-text'] |
|
1167 |
.setText(sprintf('%.1i', getprop('/systems/electrical/outputs/bus'))); |
|
1168 |
me.screenElements['BATT-text'] |
|
1169 |
.setText(sprintf('%+i', getprop('/systems/electrical/amps'))); |
|
1170 |
var cht = getprop('/engines/engine/cht-degf'); |
|
1171 |
me.screenElements['CHT-text'] |
|
1172 |
.setText(cht == nil ? '--' : sprintf('%i', cht)); |
|
1173 |
me.screenElements['EGT-text'] |
|
1174 |
.setText(sprintf('%i', getprop('/engines/engine/egt-degf'))); |
|
1175 |
} |
|
1176 |
settimer(func me.updateEIS(), 1); |
|
1177 |
me._eis_count += 1; |
|
1178 |
}, |
|
1179 |
_eis_count : 0, |
|
1180 |
#}}} |
|
1181 |
}; |
|
1182 | ||
softkeys are available now
|
1183 |
var keyMap = { |
add new vim folds
|
1184 |
# softkeys map for PFD and MFD {{{ |
softkeys are available now
|
1185 |
PFD : { |
1186 |
first : 1, |
|
1187 |
texts : ['INSET', 'SENSOR', 'PFD', 'OBS', 'CDI', 'DME', 'XPDR', 'IDENT', 'TMR/REF', 'NRST' ], |
|
1188 |
INSET : { |
|
1189 |
texts : ['OFF', 'DCLTR', 'WXLGND', 'TRAFFIC', 'TOPO', 'TERRAIN', 'STRMSCP', 'NEXRAD-C', 'XM LTNG', 'METAR'], |
|
1190 |
}, |
|
1191 |
SENSOR : { |
|
1192 |
first : 2, |
|
1193 |
texts : [ 'ADC1', 'ADC2', '', 'AHRS1', 'AHRS2'], |
|
1194 |
}, |
|
1195 |
PFD : { |
|
adds BRG1/2 animation
|
1196 |
texts : [ 'SYN VIS', 'DFLTS', 'AOA/WIND', 'DME', 'BRG1', 'HSI FMT', 'BRG2', '', 'ALT UNIT', 'STD BARO' ], |
softkeys are available now
|
1197 |
'SYN VIS' : { |
1198 |
texts : [ 'PATHWAY', 'SYN TERR', 'HR2NHDG', 'APTSIGNS', 'FPM'], |
|
1199 |
}, |
|
1200 |
'AOA/WIND' : { |
|
1201 |
first : 4, |
|
1202 |
texts : ['AOA', 'WIND'], |
|
1203 |
AOA : { |
|
1204 |
first : 5, |
|
1205 |
texts : ['AOA ON', 'AOA AUTO'], |
|
1206 |
}, |
|
1207 |
WIND : { |
|
1208 |
first : 2, |
|
1209 |
texts : ['OPTN1', 'OPTN2', '', 'OFF'], |
|
1210 |
}, |
|
1211 |
}, |
|
1212 |
'HSI FMT' : { |
|
1213 |
first : 6, |
|
1214 |
texts : ['360 HSI', 'ARC HSI'], |
|
1215 |
}, |
|
1216 |
'ALT UNIT' : { |
|
1217 |
first : 5, |
|
1218 |
texts : ['METERS', '', 'IN', 'HPA'], |
|
1219 |
}, |
|
1220 |
}, |
|
1221 |
XPDR : { |
|
1222 |
first : 2, |
|
1223 |
texts : ['STBY', 'ON', 'ALT', '', 'VFR', 'CODE', 'IDENT'], |
|
1224 |
CODE : { |
|
1225 |
texts : ['0', '1', '2', '3', '4', '5', '6', '7', 'IDENT', 'BKSP'], |
|
1226 |
}, |
|
1227 |
}, |
|
1228 |
}, |
|
1229 |
MFD : { |
|
1230 |
texts : ['ENGINE', '', 'MAP', '', '', '', '', '', '', 'DCLTR', 'SHW CHRT', 'CHKLIST'], |
|
1231 |
MAP : { |
|
1232 |
texts: ['TRAFFIC', 'PROFILE', 'TOPO', 'TERRAIN', 'AIRWAYS', 'STRMSCP','NEXRAD-C', 'XM LTNG', 'METAR', 'LEGEND', 'BACK'], |
|
1233 |
}, |
|
1234 |
CHKLIST : { |
|
1235 |
texts : ['ENGINE', '', '', '', '', 'DONE', '', '', '', '', 'EXIT', 'EMERGCY'], |
|
1236 |
}, |
|
1237 |
ENGINE : { |
|
1238 |
texts : ['ENGINE', 'ANTI-ICE', '', 'DCLTR', '', 'ASSIST', '', '', '', '', 'FUEL'], |
|
1239 |
'ANTI-ICE' : { |
|
1240 |
texts : ['LEFT', 'AUTO', 'RIGHT', '', '', '', '', '', '', '', '', 'BACK'], |
|
1241 |
}, |
|
1242 |
FUEL : { |
|
1243 |
first : 1, |
|
1244 |
texts : ['FULL', 'TABS', '', '', '', '', '', '', '', 'UNDO', 'ENTER'], |
|
1245 |
}, |
|
1246 |
}, |
|
1247 |
}, |
|
1248 |
}; |
|
add new vim folds
|
1249 |
#}}} |