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