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