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