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