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