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