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