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