massive code reorganisation ...
|
1 |
# vim: set foldmethod=marker foldmarker={{{,}}} : |
commit initial
|
2 |
var softkeysClass = { |
improves role/name variables...
|
3 |
new : func (device) { |
commit initial
|
4 |
var m = { parents: [ softkeysClass ] }; |
softkeys are available now
|
5 |
m.device = device; |
6 |
m.path = []; |
|
improves softkeys coloring
|
7 |
m.colored = {}; |
commit initial
|
8 |
return m; |
9 |
}, |
|
10 | ||
softkeys are available now
|
11 |
SoftKey : func (n, a) { |
12 |
# released key not yet managed |
|
13 |
if (a == 1) |
|
14 |
return; |
|
15 | ||
16 |
var key = me.device.display.screenElements[sprintf("SoftKey%02i-text",n)].get('text'); |
|
17 |
if (key == '' or key == nil) |
|
18 |
return; |
|
19 | ||
improves role/name variables...
|
20 |
var path = keyMap[me.device.role]; |
softkeys are available now
|
21 |
foreach(var p; me.path) { |
22 |
if (contains(path, p)) |
|
23 |
path = path[p]; |
|
24 |
else |
|
25 |
break; |
|
commit initial
|
26 |
} |
27 | ||
improves role/name variables...
|
28 |
var bindings = me.bindings[me.device.role]; |
softkeys are available now
|
29 |
foreach(var p; me.path) { |
30 |
if (contains(bindings, p)) |
|
31 |
bindings = bindings[p]; |
|
32 |
else |
|
33 |
break; |
|
commit initial
|
34 |
} |
35 | ||
softkeys are available now
|
36 |
if (contains(path, key)) { |
37 |
append(me.path, key); |
|
fix issue with some menus
|
38 |
if (contains(bindings, key)) |
39 |
if (contains(bindings[key], 'hook')) |
|
40 |
call(bindings[key].hook, [], me); |
|
softkeys are available now
|
41 |
me.device.display.updateSoftKeys(); |
commit initial
|
42 |
} |
softkeys are available now
|
43 |
elsif (contains(bindings, key)) { |
44 |
call(bindings[key], [], me); |
|
commit initial
|
45 |
} |
softkeys are available now
|
46 |
elsif (key == 'BACK') { |
47 |
pop(me.path); |
|
48 |
me.device.display.updateSoftKeys(); |
|
commit initial
|
49 |
} |
show the complete path menu ...
|
50 |
else { |
51 |
var list_path = ''; |
|
52 |
foreach(var p; me.path) list_path ~= p ~ '/'; |
|
53 |
print(me.device.role ~ ':' ~ list_path ~ key ~ ' : not yet implemented'); |
|
54 |
} |
|
softkeys are available now
|
55 |
}, |
56 | ||
57 |
bindings : { |
|
58 |
PFD : { |
|
59 |
INSET: { |
|
60 |
OFF: func { |
|
separates maps code
|
61 |
me.device.map.setVisible(0); |
PFD INSET map available
|
62 |
me.device.display.screenElements['PFD-Map-bg'].hide(); |
63 |
}, |
|
add TCAS
|
64 |
TRAFFIC: func { |
improve the selection of dis...
|
65 |
call(me.bindings.PFD.INSET.declutter, ['INSETTRAFFIC', 'tcas', 2], me); |
66 |
}, |
|
67 |
ROUTE: func { |
|
68 |
call(me.bindings.PFD.INSET.declutter, ['INSETROUTE', 'route', 3], me); |
|
69 |
}, |
|
70 |
TERRAIN: func { |
|
71 |
call(me.bindings.PFD.INSET.declutter, ['INSETTERRAIN', 'tiles', 5], me); |
|
72 |
}, |
|
73 |
NAVAIDS: { |
|
74 |
ALL: func (root_id = 'INSETNAVAIDS') { |
|
75 |
if (contains(me.colored, root_id ~ 'ALL')) |
|
76 |
foreach (var n; [ 'ALL', 'VOR', 'DME', 'NDB', 'TACAN', 'APT' ]) |
|
77 |
delete(me.colored, root_id ~ n); |
|
78 |
else |
|
79 |
foreach (var n; [ 'ALL', 'VOR', 'DME', 'NDB', 'TACAN', 'APT' ]) |
|
80 |
me.colored[root_id ~ n] = 1; |
|
81 |
me.device.display.updateSoftKeys(); |
|
82 |
foreach (var n; [ 'VOR', 'TACAN', 'NDB', 'DME' ]) |
|
83 |
me.device.map.layers.navaids._can[n] |
|
84 |
.setVisible(contains(me.colored, root_id ~ n)); |
|
85 |
me.device.map.layers.navaids._can.airport |
|
86 |
.setVisible(contains(me.colored, root_id ~ 'APT')); |
|
87 |
}, |
|
88 |
VOR: func { |
|
89 |
call(me.bindings.PFD.INSET.NAVAIDS.declutter, ['INSETNAVAIDSVOR', 'VOR', 2], me); |
|
90 |
}, |
|
91 |
TACAN: func { |
|
92 |
call(me.bindings.PFD.INSET.NAVAIDS.declutter, ['INSETNAVAIDSTACAN', 'TACAN', 3], me); |
|
93 |
}, |
|
94 |
NDB: func { |
|
95 |
call(me.bindings.PFD.INSET.NAVAIDS.declutter, ['INSETNAVAIDSNDB', 'NDB', 4], me); |
|
96 |
}, |
|
97 |
DME: func { |
|
98 |
call(me.bindings.PFD.INSET.NAVAIDS.declutter, ['INSETNAVAIDSDME', 'DME', 5], me); |
|
99 |
}, |
|
100 |
APT: func { |
|
101 |
call(me.bindings.PFD.INSET.NAVAIDS.declutter, ['INSETNAVAIDSAPT', 'airport', 6], me); |
|
102 |
}, |
|
103 |
declutter: func (id, type) { |
|
104 |
if (contains(me.colored, id)) { |
|
105 |
delete(me.colored, id); |
|
106 |
if (me.device.role == 'PFD') |
|
107 |
delete(me.colored, 'INSETNAVAIDSALL'); |
|
108 |
if (me.device.role == 'MFD') |
|
109 |
delete(me.colored, 'MAPNAVAIDSALL'); |
|
110 |
} |
|
111 |
else |
|
112 |
me.colored[id] = 1; |
|
113 |
me.device.display.updateSoftKeys(); |
|
114 |
me.device.map.layers.navaids._can[type] |
|
115 |
.setVisible(contains(me.colored, id)); |
|
116 |
}, |
|
117 |
}, |
|
118 |
declutter: func (id, layer) { |
|
119 |
if (contains(me.colored, id)) |
|
120 |
delete(me.colored, id); |
|
add TCAS
|
121 |
else |
improve the selection of dis...
|
122 |
me.colored[id] = 1; |
add TCAS
|
123 |
me.device.display.updateSoftKeys(); |
improve the selection of dis...
|
124 |
me.device.map.layers[layer] |
125 |
.setVisible(contains(me.colored, id)); |
|
add TCAS
|
126 |
}, |
PFD INSET map available
|
127 |
hook : func { |
128 |
me.device.display.screenElements['PFD-Map-bg'].show(); |
|
separates maps code
|
129 |
me.device.map.setVisible(1); |
130 |
me.device.map.update(); |
|
softkeys are available now
|
131 |
}, |
132 |
}, |
|
133 |
PFD: { |
|
adds OAT, TAS, GSPD, WindDat...
|
134 |
'AOA/WIND' : { |
adds AOA display
|
135 |
AOA : { |
136 |
'AOA ON' : func { |
|
137 |
if (me.device.data['aoa-auto']) |
|
138 |
return; |
|
139 |
me.device.data.aoa = ! me.device.data.aoa; |
|
nicer AOA display
|
140 |
foreach (var e; ['AOA', 'AOA-needle', 'AOA-text']) |
141 |
me.device.display.screenElements[e] |
|
142 |
.setVisible(me.device.data.aoa); |
|
143 |
me.device.display.screenElements['AOA-approach'] |
|
144 |
.setVisible(me.device.data.aoa and contains(data, 'approach-aoa')); |
|
adds AOA display
|
145 |
me.device.display.updateAOA(); |
146 |
me.device.display.setSoftKeyColor(5 ,me.device.data.aoa); |
|
147 |
if (me.device.data.aoa) |
|
148 |
me.colored['PFDAOA/WINDAOAAOA ON'] = 1; |
|
149 |
else |
|
150 |
delete(me.colored, 'PFDAOA/WINDAOAAOA ON'); |
|
151 |
}, |
|
152 |
'AOA AUTO' : func { |
|
153 |
if (me.device.data.aoa) |
|
154 |
return; |
|
155 |
me.device.data['aoa-auto'] = ! me.device.data['aoa-auto']; |
|
156 |
me.device.display.setSoftKeyColor(6 ,me.device.data['aoa-auto']); |
|
157 |
if (me.device.data['aoa-auto']) { |
|
158 |
me.colored['PFDAOA/WINDAOAAOA AUTO'] = 1; |
|
159 |
if (!contains(me.device.timers, 'aoa')) |
|
160 |
me.device.timers.aoa = maketimer(1, |
|
161 |
func { |
|
162 |
var v = getprop('/gear/gear/position-norm') == 1 |
|
163 |
and getprop('/surfaces-positions/flap-pos-norm') != 0; |
|
nicer AOA display
|
164 |
foreach (var e; ['AOA', 'AOA-needle', 'AOA-text']) |
165 |
me.device.display.screenElements[e] |
|
166 |
.setVisible(v); |
|
167 |
me.device.display.screenElements['AOA-approach'] |
|
168 |
.setVisible(v and contains(data, 'approach-aoa')); |
|
adds AOA display
|
169 |
}, me); |
170 |
me.device.timers.aoa.start(); |
|
171 |
} |
|
172 |
else { |
|
173 |
delete(me.colored, 'PFDAOA/WINDAOAAOA AUTO'); |
|
174 |
me.device.timers.aoa.stop(); |
|
175 |
me.device.data.aoa = 0; |
|
176 |
me.device.display.screenElements['AOA'] |
|
177 |
.hide(); |
|
178 |
} |
|
179 |
}, |
|
nicer AOA display
|
180 |
hook : func { |
181 |
if (contains(data,'approach-aoa')) |
|
182 |
me.device.display.screenElements['AOA-approach'] |
|
183 |
.setRotation(-data['approach-aoa']/data['stall-aoa']*math.pi); |
|
184 |
}, |
|
adds AOA display
|
185 |
}, |
adds OAT, TAS, GSPD, WindDat...
|
186 |
WIND : { |
187 |
OPTN1 : func { |
|
188 |
me.device.display._winddata_optn = 1; |
|
189 |
me.device.display.screenElements['WindData'].show(); |
|
190 |
me.device.display.screenElements['WindData-OPTN1'].show(); |
|
191 |
me.device.display.screenElements['WindData-OPTN1-HDG'].show(); |
|
192 |
me.device.display.screenElements['WindData-OPTN2'].hide(); |
|
193 |
me.device.display.updateWindData(); |
|
uses the new coloration for ...
|
194 |
me.device.display.setSoftKeyColor(2, 1); |
195 |
me.colored['PFDAOA/WINDWINDOPTN1'] = 1; |
|
196 |
me.device.display.setSoftKeyColor(3, 0); |
|
197 |
delete(me.colored, 'PFDAOA/WINDWINDOPTN2'); |
|
adds OAT, TAS, GSPD, WindDat...
|
198 |
}, |
199 |
OPTN2 : func { |
|
200 |
me.device.display._winddata_optn = 2; |
|
201 |
me.device.display.screenElements['WindData'].show(); |
|
202 |
me.device.display.screenElements['WindData-OPTN1'].hide(); |
|
203 |
me.device.display.screenElements['WindData-OPTN2'].show(); |
|
204 |
me.device.display.screenElements['WindData-OPTN2-symbol'].show(); |
|
205 |
me.device.display.screenElements['WindData-OPTN2-headwind'].show(); |
|
206 |
me.device.display.screenElements['WindData-OPTN2-crosswind'].show(); |
|
207 |
me.device.display.updateWindData(); |
|
uses the new coloration for ...
|
208 |
me.device.display.setSoftKeyColor(2, 0); |
209 |
delete(me.colored, 'PFDAOA/WINDWINDOPTN1'); |
|
210 |
me.device.display.setSoftKeyColor(3, 1); |
|
211 |
me.colored['PFDAOA/WINDWINDOPTN2'] = 1; |
|
adds OAT, TAS, GSPD, WindDat...
|
212 |
}, |
213 |
OFF : func { |
|
214 |
me.device.display._winddata_optn = 0; |
|
215 |
me.device.display.screenElements['WindData'].hide(); |
|
216 |
me.device.display.screenElements['WindData-OPTN1'].hide(); |
|
217 |
me.device.display.screenElements['WindData-OPTN2'].hide(); |
|
uses the new coloration for ...
|
218 |
me.device.display.setSoftKeyColor(2, 0); |
219 |
delete(me.colored, 'PFDAOA/WINDWINDOPTN1'); |
|
220 |
me.device.display.setSoftKeyColor(3, 0); |
|
221 |
delete(me.colored, 'PFDAOA/WINDWINDOPTN2'); |
|
adds OAT, TAS, GSPD, WindDat...
|
222 |
}, |
223 |
}, |
|
224 |
}, |
|
adds BRG1/2 animation
|
225 |
BRG1 : func (brg = 1){ |
226 |
var source = 'brg' ~ brg ~ '-source'; |
|
227 |
var list = ['NAV' ~ brg, 'GPS', 'ADF', 'OFF']; |
|
228 |
var index = std.Vector |
|
229 |
.new(list) |
|
230 |
.index(radios.getNode(source).getValue()); |
|
231 |
var next = (index == size(list) -1) ? 0 : index + 1; |
|
232 |
radios.getNode(source).setValue(list[next]); |
|
uses the new coloration for ...
|
233 |
if (list[next] != 'OFF') { |
234 |
me.device.display.setSoftKeyColor(brg == 1 ? 4 : 6, 1); |
|
235 |
me.colored['PFDBRG' ~ brg] = 1; |
|
236 |
} |
|
237 |
else { |
|
238 |
me.device.display.setSoftKeyColor(brg == 1 ? 4 : 6, 0); |
|
239 |
delete(me.colored, 'PFDBRG' ~ brg); |
|
240 |
} |
|
adds BRG1/2 animation
|
241 |
}, |
242 |
BRG2 : func { |
|
243 |
call(me.bindings.PFD.PFD.BRG1, [ 2 ], me); |
|
244 |
}, |
|
adds BARO settings
|
245 |
'STD BARO' : func { |
246 |
setprop('/instrumentation/altimeter/setting-inhg', 29.92); |
|
247 |
me.device.display.updateBARO(); |
|
248 |
pop(me.path); |
|
249 |
me.device.display.updateSoftKeys(); |
|
250 |
}, |
|
251 |
IN : func { |
|
252 |
me.device.display._baro_unit = 'inhg'; |
|
253 |
me.device.display.updateBARO(); |
|
254 |
}, |
|
255 |
HPA : func { |
|
256 |
me.device.display._baro_unit = 'hpa'; |
|
257 |
me.device.display.updateBARO(); |
|
258 |
}, |
|
softkeys are available now
|
259 |
}, |
260 |
XPDR: { |
|
adds transponder
|
261 |
STBY : func { |
262 |
setprop('/instrumentation/transponder/ident', 0); |
|
263 |
setprop('/instrumentation/transponder/knob-mode', 1); |
|
remove hardcoded properties ...
|
264 |
radios.setValue('xpdr-mode', 'STBY'); |
adds transponder
|
265 |
me.device.display.updateXPDR(); |
266 |
}, |
|
267 |
ON : func { |
|
268 |
setprop('/instrumentation/transponder/ident', 1); |
|
269 |
setprop('/instrumentation/transponder/knob-mode', 4); |
|
remove hardcoded properties ...
|
270 |
radios.setValue('xpdr-mode', 'ON'); |
adds transponder
|
271 |
me.device.display.updateXPDR(); |
272 |
}, |
|
273 |
ALT : func { |
|
274 |
setprop('/instrumentation/transponder/ident', 1); |
|
275 |
setprop('/instrumentation/transponder/knob-mode', 5); |
|
remove hardcoded properties ...
|
276 |
radios.setValue('xpdr-mode', 'ALT'); |
adds transponder
|
277 |
me.device.display.updateXPDR(); |
278 |
}, |
|
279 |
VFR : func { |
|
280 |
setprop('/instrumentation/transponder/id-code', '1200'); |
|
281 |
me.device.display.updateXPDR(); |
|
282 |
}, |
|
283 |
IDENT : func { |
|
284 |
call(me.bindings.PFD.IDENT, [], me); |
|
285 |
}, |
|
286 |
CODE : { |
|
287 |
'0' : func (n = 0) { |
|
remove hardcoded properties ...
|
288 |
if (radios.getValue('xpdr-tuning-fms-method')) |
XPDR settings via knob or so...
|
289 |
return; |
old timers2 removed
|
290 |
me.device.display.timers.softkeys_inactivity.stop(); |
Softkeys revert to the previ...
|
291 |
me.bindings.PFD.XPDR.CODE.inactivity.restart(me.device.display.softkeys_inactivity_delay); |
XPDR settings via knob or so...
|
292 |
# disable FMS knob entering method |
293 |
me.device.knobs.FmsInner = void; |
|
294 |
# When entering the code, the next softkey in sequence |
|
295 |
# must be pressed within 10 seconds, or the entry is cancelled |
|
296 |
# and restored to the previous code |
|
297 |
if (!contains(me.bindings.PFD.XPDR.CODE, 'on_change_inactivity')) { |
|
298 |
me.bindings.PFD.XPDR.CODE.on_change_inactivity = maketimer(10, |
|
299 |
func { |
|
remove hardcoded properties ...
|
300 |
radios.setValue('xpdr-tuning-digit', 3); |
XPDR settings via knob or so...
|
301 |
me.device.knobs.FmsInner = me.device.knobs.XPDRCodeSetDigits; |
302 |
me.device.knobs.FmsOuter = me.device.knobs.XPDRCodeNextDigits; |
|
303 |
call(me.bindings.PFD.XPDR.CODE.restore, [], me); |
|
304 |
}); |
|
305 |
me.bindings.PFD.XPDR.CODE.on_change_inactivity.singleShot = 1; |
|
306 |
me.bindings.PFD.XPDR.CODE.on_change_inactivity.start(); |
|
307 |
} |
|
308 |
else |
|
309 |
me.bindings.PFD.XPDR.CODE.on_change_inactivity.restart(10); |
|
adds transponder
|
310 |
var tuning = radios.getNode('xpdr-tuning-digit'); |
311 |
var d = tuning.getValue(); |
|
312 |
setprop('/instrumentation/transponder/inputs/digit[' ~ d ~ ']', n); |
|
fix not able to set 4th digi...
|
313 |
if (d == 0) { |
XPDR settings via knob or so...
|
314 |
if (!contains(me.bindings.PFD.XPDR.CODE, 'on_change_auto_validation')) |
315 |
me.bindings.PFD.XPDR.CODE.on_change_auto_validation = maketimer(5, |
|
316 |
func call(me.bindings.PFD.IDENT, [], me)); |
|
317 |
me.bindings.PFD.XPDR.CODE.on_change_auto_validation.singleShot = 1; |
|
318 |
me.bindings.PFD.XPDR.CODE.on_change_auto_validation.start(); |
|
319 |
} |
|
320 |
else { |
|
321 |
d -= 1; |
|
322 |
tuning.setValue(d); |
|
323 |
} |
|
adds transponder
|
324 |
me.device.display.updateXPDR(); |
325 |
}, |
|
326 |
'1' : func { |
|
327 |
call(me.bindings.PFD.XPDR.CODE['0'], [ 1 ], me); |
|
328 |
}, |
|
329 |
'2' : func { |
|
330 |
call(me.bindings.PFD.XPDR.CODE['0'], [ 2 ], me); |
|
331 |
}, |
|
332 |
'3' : func { |
|
333 |
call(me.bindings.PFD.XPDR.CODE['0'], [ 3 ], me); |
|
334 |
}, |
|
335 |
'4' : func { |
|
336 |
call(me.bindings.PFD.XPDR.CODE['0'], [ 4 ], me); |
|
337 |
}, |
|
338 |
'5' : func { |
|
339 |
call(me.bindings.PFD.XPDR.CODE['0'], [ 5 ], me); |
|
340 |
}, |
|
341 |
'6' : func { |
|
342 |
call(me.bindings.PFD.XPDR.CODE['0'], [ 6 ], me); |
|
343 |
}, |
|
344 |
'7' : func { |
|
345 |
call(me.bindings.PFD.XPDR.CODE['0'], [ 7 ], me); |
|
346 |
}, |
|
softkeys are available now
|
347 |
IDENT: func { |
Softkeys revert to the previ...
|
348 |
me.bindings.PFD.XPDR.CODE.inactivity.restart(me.device.display.softkeys_inactivity_delay); |
old timers2 removed
|
349 |
me.device.display.timers.softkeys_inactivity.restart(me.device.display.softkeys_inactivity_delay); |
adds transponder
|
350 |
call(me.bindings.PFD.IDENT, [], me); |
351 |
}, |
|
352 |
BKSP: func { |
|
remove hardcoded properties ...
|
353 |
if (radios.getValue('xpdr-tuning-fms-method')) |
XPDR settings via knob or so...
|
354 |
return; |
355 |
if (contains(me.bindings.PFD.XPDR.CODE, 'on_change_inactivity')) |
|
356 |
me.bindings.PFD.XPDR.CODE.on_change_inactivity.restart(10); |
|
357 |
if (contains(me.bindings.PFD.XPDR.CODE, 'on_change_auto_validation')) |
|
358 |
me.bindings.PFD.XPDR.CODE.on_change_auto_validation.stop(); |
|
adds transponder
|
359 |
var tuning = radios.getNode('xpdr-tuning-digit'); |
360 |
var d = tuning.getValue(); |
|
XPDR settings via knob or so...
|
361 |
if (d < 3) { |
362 |
d += 1; |
|
363 |
tuning.setValue(d); |
|
364 |
} |
|
adds transponder
|
365 |
me.device.display.updateXPDR(); |
softkeys are available now
|
366 |
}, |
adds transponder
|
367 |
BACK : func (inactive = 0) { |
XPDR settings via knob or so...
|
368 |
call(me.bindings.PFD.XPDR.CODE.restore, [], me); |
adds transponder
|
369 |
pop(me.path); |
XPDR settings via knob or so...
|
370 |
call(me.bindings.PFD.XPDR.CODE.exit, [me.path], me); |
371 |
}, |
|
372 |
restore : func { |
|
373 |
setprop('/instrumentation/transponder/id-code', |
|
remove hardcoded properties ...
|
374 |
sprintf('%s', radios.getValue('xpdr-backup-code'))); |
XPDR settings via knob or so...
|
375 |
me.device.display.updateXPDR(); |
adds transponder
|
376 |
}, |
377 |
exit : func (p) { |
|
Softkeys revert to the previ...
|
378 |
if (contains(me.bindings.PFD.XPDR.CODE, 'inactivity')) # does not exists if IDENT pressed from top-level |
379 |
me.bindings.PFD.XPDR.CODE.inactivity.stop(); |
|
adds transponder
|
380 |
radios.removeChild('xpdr-tuning-digit', 0); |
381 |
radios.removeChild('xpdr-backup-code', 0); |
|
XPDR settings via knob or so...
|
382 |
radios.removeChild('xpdr-tuning-fms-method', 0); |
adds transponder
|
383 |
me.path = p; |
384 |
me.device.display.updateXPDR(); |
|
softkeys are available now
|
385 |
me.device.display.updateSoftKeys(); |
XPDR settings via knob or so...
|
386 |
me.device.knobs.FmsInner = void; |
387 |
me.device.knobs.FmsOuter = void; |
|
old timers2 removed
|
388 |
me.device.display.timers.softkeys_inactivity.restart(me.device.display.softkeys_inactivity_delay); |
softkeys are available now
|
389 |
}, |
adds transponder
|
390 |
hook : func { |
XPDR settings via knob or so...
|
391 |
# this level has its own timer as we may need to revert changes, and got different timers |
old timers2 removed
|
392 |
me.device.display.timers.softkeys_inactivity.stop(); |
Softkeys revert to the previ...
|
393 |
me.bindings.PFD.XPDR.CODE.inactivity = maketimer( |
394 |
me.device.display.softkeys_inactivity_delay, |
|
XPDR settings via knob or so...
|
395 |
func call(me.bindings.PFD.XPDR.CODE.BACK, [], me)); |
Softkeys revert to the previ...
|
396 |
me.bindings.PFD.XPDR.CODE.inactivity.singleShot = 1; |
397 |
me.bindings.PFD.XPDR.CODE.inactivity.start(); |
|
remove hardcoded properties ...
|
398 |
var tuning = radios.getValue('xpdr-tuning-digit'); |
adds transponder
|
399 |
if (tuning == nil) { |
400 |
radios.getNode('xpdr-tuning-digit', 1).setValue(3); |
|
401 |
radios.getNode('xpdr-backup-code', 1).setValue(getprop('/instrumentation/transponder/id-code')); |
|
XPDR settings via knob or so...
|
402 |
radios.getNode('xpdr-tuning-fms-method', 1).setValue(0); |
adds transponder
|
403 |
me.device.display.updateXPDR(); |
404 |
} |
|
XPDR settings via knob or so...
|
405 |
me.device.knobs.FmsInner = me.device.knobs.XPDRCodeSetDigits; |
406 |
me.device.knobs.FmsOuter = me.device.knobs.XPDRCodeNextDigits; |
|
adds transponder
|
407 |
}, |
softkeys are available now
|
408 |
}, |
adds transponder
|
409 |
}, |
410 |
IDENT : func { |
|
remove hardcoded properties ...
|
411 |
if (radios.getValue('xpdr-mode') == 'STBY') |
adds transponder
|
412 |
return; |
413 |
setprop('/instrumentation/transponder/ident', 1); |
|
414 |
me.bindings.PFD.XPDR.ident = maketimer(18, |
|
415 |
func { |
|
416 |
setprop('/instrumentation/transponder/ident', 0); |
|
417 |
me.device.display.updateXPDR(); |
|
418 |
}); |
|
419 |
me.bindings.PFD.XPDR.ident.singleShot = 1; |
|
420 |
me.bindings.PFD.XPDR.ident.start(); |
|
XPDR settings via knob or so...
|
421 |
call(me.bindings.PFD.XPDR.CODE.exit, [], me); |
softkeys are available now
|
422 |
}, |
adds CDI
|
423 |
CDI : func { |
424 |
var list = ['OFF']; |
|
425 |
if (getprop('/instrumentation/gps/route-distance-nm') != nil) |
|
426 |
append(list, 'GPS'); |
|
427 |
if (getprop('/instrumentation/nav/in-range') != nil) |
|
428 |
append(list, 'NAV1'); |
|
429 |
if (getprop('/instrumentation/nav[1]/in-range') != nil) |
|
430 |
append(list, 'NAV2'); |
|
431 |
var index = std.Vector |
|
432 |
.new(list) |
|
433 |
.index(cdi.getNode('source').getValue()); |
|
434 |
var next = (index == size(list) -1) ? 0 : index + 1; |
|
435 |
cdi.getNode('source').setValue(list[next]); |
|
436 |
CDIfromSOURCE(list[next]); |
|
437 |
me.device.display.updateCDI(); |
|
438 |
}, |
|
TMR/REF window
|
439 |
'TMR/REF' : func { |
440 |
if (!contains(me.device.windows.state, 'TMR/REF')) { |
|
TMR/REF available
|
441 |
var Vspeed_visiblity = func (id, selected, Vspeed) |
442 |
me.device.data[Vspeed ~ '-visible'] = |
|
443 |
me.device.windows.state[id].objects[selected].text |
|
444 |
== |
|
445 |
me.device.windows.state[id].objects[selected].choices[0]; |
|
446 |
var GenericTimer = func (id, selected) { |
|
447 |
var action = me.device.windows.state[id].objects[selected].text; |
|
448 |
if (action == 'START?') { |
|
449 |
me.device.data.TMRrevert = 0; |
|
450 |
me.device.data.TMRlast = getprop('/sim/time/elapsed-sec') - 1; |
|
451 |
me.device.data.TMRreset = me.device.windows.state[id].objects[selected - 2].text; |
|
452 |
me.device.data.TMRtimer = maketimer(1, func { |
|
453 |
var (hh, mm, ss) = split(':', |
|
454 |
me.device.windows.state[id].objects[selected - 2].text); |
|
455 |
var direction = -1; |
|
456 |
if ((me.device.windows.state[id].objects[selected - 1].text |
|
457 |
== |
|
458 |
me.device.windows.state[id].objects[selected - 1].choices[0]) |
|
459 |
or me.device.data.TMRrevert) |
|
460 |
direction = 1; |
|
461 |
var now = getprop('/sim/time/elapsed-sec'); |
|
462 |
var dt = int(now - me.device.data.TMRlast) * direction; |
|
463 |
me.device.data.TMRlast = now; |
|
464 |
var val = HMS(hh, mm, ss, dt); |
|
465 |
me.device.windows.state[id].objects[selected - 2].text = val; |
|
466 |
me.device.windows.window[id ~ '-' ~ (selected -2)] |
|
467 |
.setText(val); |
|
468 |
if (val == '00:00:00' and direction == -1) |
|
469 |
me.device.data.TMRrevert = 1; |
|
470 |
}, me); |
|
471 |
me.device.data.TMRtimer.start(); |
|
472 |
action = 'STOP?'; |
|
473 |
} |
|
474 |
elsif (action == 'STOP?') { |
|
475 |
me.device.data.TMRtimer.stop(); |
|
476 |
action = 'RESET?'; |
|
477 |
} |
|
478 |
elsif (action == 'RESET?') { |
|
479 |
action = 'START?'; |
|
480 |
if ((me.device.windows.state[id].objects[selected - 1].text |
|
481 |
== |
|
482 |
me.device.windows.state[id].objects[selected - 1].choices[1]) |
|
483 |
and !me.device.data.TMRrevert) |
|
484 |
var val = me.device.data.TMRreset; |
|
485 |
else |
|
486 |
var val = '00:00:00'; |
|
487 |
me.device.windows.state[id].objects[selected - 2].text = val; |
|
488 |
me.device.windows.window[id ~ '-' ~ (selected -2)] |
|
489 |
.setText(val); |
|
490 |
} |
|
491 |
me.device.windows.window[me.device.windows.selected] |
|
492 |
.setText(action); |
|
493 |
me.device.windows.state[id].objects[selected].text = action; |
|
494 |
}; |
|
TMR/REF window
|
495 |
me.device.windows.draw( |
496 |
'TMR/REF', |
|
497 |
{x: 720, y: 535, w: 300, l: 5, sep: 3}, |
|
TMR/REF window adaptation
|
498 |
[ # objects infos |
TMR/REF window
|
499 |
{text: 'REFERENCES', type: 'title'}, |
500 |
{type: 'separator'}, |
|
501 |
{text: 'TIMER', type: 'normal'}, |
|
502 |
{text: '00:00:00', type: 'selected|time', }, |
|
TMR/REF available
|
503 |
{text: ' UP >', type: 'editable', choices: [' UP >', '<DOWN ']}, |
504 |
{text: 'START?', type: 'editable|end-of-line', callback: func (id, selected) GenericTimer(id, selected)}, |
|
TMR/REF window
|
505 |
{type: 'separator'}, |
fix non-set values
|
506 |
{text: sprintf('Vx %3iKT', |
507 |
alerts.getNode('Vx') != nil ? alerts.getValue('Vx') : 0), type: 'normal', scrollgroup:0}, |
|
TMR/REF available
|
508 |
{text: me.device.data['Vx-visible'] ? ' ON >' : '< OFF ', type: 'editable|immediate|end-of-line', choices: [' ON >', '< OFF '], scrollgroup:0, callback: func (id, selected) Vspeed_visiblity(id, selected, 'Vx')}, |
fix non-set values
|
509 |
{text: sprintf('Vy %3iKT', |
510 |
alerts.getNode('Vy') != nil ? alerts.getValue('Vy') : 0), type: 'normal', scrollgroup:1}, |
|
TMR/REF available
|
511 |
{text: me.device.data['Vy-visible'] ? ' ON >' : '< OFF ', type: 'editable|immediate|end-of-line', choices: [' ON >', '< OFF '], scrollgroup:1, callback: func (id, selected) Vspeed_visiblity(id, selected, 'Vy')}, |
fix non-set values
|
512 |
{text: sprintf('Vr %3iKT', |
513 |
alerts.getNode('Vr') != nil ? alerts.getValue('Vr') : 0), type: 'normal', scrollgroup:2}, |
|
TMR/REF available
|
514 |
{text: me.device.data['Vr-visible'] ? ' ON >' : '< OFF ', type: 'editable|immediate|end-of-line', choices: [' ON >', '< OFF '], scrollgroup:2, callback: func (id, selected) Vspeed_visiblity(id, selected, 'Vr')}, |
fix non-set values
|
515 |
{text: sprintf('Vglide %3iKT', |
516 |
alerts.getNode('Vglide') != nil ? alerts.getValue('Vglide') : 0), type: 'normal', scrollgroup:3}, |
|
TMR/REF available
|
517 |
{text: me.device.data['Vglide-visible'] ? ' ON >' : '< OFF ', type: 'editable|immediate|end-of-line', choices: [' ON >', '< OFF '], scrollgroup:3, callback: func (id, selected) Vspeed_visiblity(id, selected, 'Vglide')}, |
TMR/REF window
|
518 |
{type: 'separator'}, |
519 |
{text: 'MINIMUMS', type: 'normal'}, |
|
TMR/REF available
|
520 |
{text: ' OFF >', type: 'editable', choices: [' OFF >', '< BARO >','<TEMP COMP'], callback: func}, |
TMR/REF window adaptation
|
521 |
{text: ' 1000FT', type: 'editable', format: '% 5iFT', factor: 100, callback: func}, |
522 |
], |
|
523 |
{ # scrolling info, see menu.nas |
|
524 |
lines : 3, |
|
525 |
columns : 2, |
|
526 |
} |
|
TMR/REF window
|
527 |
); |
528 |
me.device.knobs.FmsInner = me.device.knobs.MenuSettings; |
|
529 |
me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu; |
|
TMR/REF available
|
530 |
me.device.buttons.ENT = me.device.buttons.ValidateTMRREF; |
531 |
me.device.buttons.FMS = me.device.buttons.ValidateTMRREF; |
|
532 |
me.device.buttons.CLR = me.device.buttons.ClearTMRREF; |
|
TMR/REF window
|
533 |
} |
534 |
else { |
|
TMR/REF available
|
535 |
me.device.buttons.ClearTMRREF(); |
TMR/REF window
|
536 |
} |
537 |
}, |
|
add PFD/NRST softkey
|
538 |
NRST: { |
539 |
_displayNearest: func (type, where) { |
|
540 |
var id = 'PFD NRST'; |
|
541 |
me.device.display.updateSoftKeys(); |
|
542 |
me.device.windows.del(id); |
|
543 |
var results = []; |
|
544 |
var list = []; |
|
545 |
if (type == 'apt') { |
|
546 |
results = findAirportsWithinRange(100); |
|
547 |
} |
|
548 |
else { |
|
549 |
results = findNavaidsWithinRange(100, type); |
|
550 |
} |
|
fix issue in PFD/OMNI
|
551 |
if (where != 'OMNI') { |
add PFD/NRST softkey
|
552 |
var norm_360 = func (a) return math.periodic(0, 360, a); |
553 |
if (where == 'FRONT') var side = norm_360(data.hdg); |
|
554 |
elsif (where == 'RIGHT') var side = norm_360(data.hdg + 90); |
|
555 |
elsif (where == 'LEFT') var side = norm_360(data.hdg - 90); |
|
556 |
elsif (where == 'REAR') var side = norm_360(data.hdg + 180); |
|
557 |
foreach (var n; results) { |
|
558 |
var (course, dist) = courseAndDistance(n); |
|
559 |
var angle = 180 - abs(abs(course - side) - 180); |
|
560 |
if (angle < 50) { |
|
561 |
append(list, [n, course, dist]); |
|
562 |
if (size(list) == 5) |
|
563 |
break; |
|
564 |
} |
|
565 |
} |
|
566 |
} |
|
567 |
else { |
|
568 |
foreach (var n; results) { |
|
569 |
var (course, dist) = courseAndDistance(n); |
|
570 |
append(list, [n, course, dist]); |
|
571 |
if (size(list) == 5) |
|
572 |
break; |
|
573 |
} |
|
574 |
} |
|
575 |
var obj_infos = [ |
|
576 |
{ text: sprintf('NEAREST %s (%s)', string.uc(type), where), type: 'title' }, |
|
577 |
{ type: 'separator' } |
|
578 |
]; |
|
579 |
var firstEntry = 1; |
|
580 |
foreach (var n; list) { |
|
581 |
append(obj_infos, { |
|
582 |
text: sprintf('%s (%s)', n[0].id, n[0].name), |
|
583 |
type: (firstEntry ? 'selected' : 'editable') ~ '|end-of-line', |
|
584 |
dto: n[0], |
|
585 |
}); |
|
586 |
append(obj_infos, { |
|
587 |
text: sprintf('%s %03i° %3iNM', utf8.chstr(9658), n[1], n[2]), |
|
588 |
type: 'normal|end-of-line' |
|
589 |
}); |
|
590 |
firstEntry = 0; |
|
591 |
} |
|
592 |
me.device.knobs.FmsInner = me.device.knobs.NavigateMenu; |
|
593 |
me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu; |
|
594 |
me.device.buttons.ENT = me.device.buttons.ValidateTMRREF; |
|
595 |
me.device.buttons.CLR = func { |
|
596 |
me.device.windows.del(id); |
|
597 |
me.device.knobs.FmsOuter = func; |
|
598 |
me.device.knobs.FmsInner = func; |
|
599 |
foreach (var b; ['ENT', 'CLR', 'MENU']) |
|
600 |
me.device.buttons[b] = func; |
|
601 |
} |
|
602 |
me.device.windows.draw( id, {autogeom: 1}, obj_infos ); |
|
603 |
}, |
|
604 |
############################################################################################################ |
|
605 |
# THIS CODE SHOULD REPLACE THE LINES BELOW (in new()), but it makes all call with the same args (apt, RIGHT) |
|
606 |
############################################################################################################ |
|
607 |
# if (m.device.role == 'PFD') |
|
608 |
# foreach (var dir; keyMap.PFD.NRST.texts) { |
|
609 |
# m.bindings.PFD.NRST[dir] = {}; |
|
610 |
# foreach (var type; keyMap.PFD.NRST.OMNI.texts) { |
|
611 |
# m.bindings.PFD.NRST[dir][type] = func { |
|
612 |
# call(m.bindings.PFD.NRST._displayNearest, [string.lc(type), dir], m) |
|
613 |
# }; |
|
614 |
# } |
|
615 |
# } |
|
616 |
############################################################################################################ |
|
617 |
OMNI: { |
|
618 |
APT: func { call(me.bindings.PFD.NRST._displayNearest, ['apt', 'OMNI'], me) }, |
|
619 |
VOR: func { call(me.bindings.PFD.NRST._displayNearest, ['vor', 'OMNI'], me) }, |
|
620 |
NDB: func { call(me.bindings.PFD.NRST._displayNearest, ['ndb', 'OMNI'], me) }, |
|
621 |
FIX: func { call(me.bindings.PFD.NRST._displayNearest, ['fix', 'OMNI'], me) }, |
|
622 |
}, |
|
623 |
FRONT: { |
|
624 |
APT: func { call(me.bindings.PFD.NRST._displayNearest, ['apt', 'FRONT'], me) }, |
|
625 |
VOR: func { call(me.bindings.PFD.NRST._displayNearest, ['vor', 'FRONT'], me) }, |
|
626 |
NDB: func { call(me.bindings.PFD.NRST._displayNearest, ['ndb', 'FRONT'], me) }, |
|
627 |
FIX: func { call(me.bindings.PFD.NRST._displayNearest, ['fix', 'FRONT'], me) }, |
|
628 |
}, |
|
629 |
RIGHT: { |
|
630 |
APT: func { call(me.bindings.PFD.NRST._displayNearest, ['apt', 'RIGHT'], me) }, |
|
631 |
VOR: func { call(me.bindings.PFD.NRST._displayNearest, ['vor', 'RIGHT'], me) }, |
|
632 |
NDB: func { call(me.bindings.PFD.NRST._displayNearest, ['ndb', 'RIGHT'], me) }, |
|
633 |
FIX: func { call(me.bindings.PFD.NRST._displayNearest, ['fix', 'RIGHT'], me) }, |
|
634 |
}, |
|
635 |
REAR: { |
|
636 |
APT: func { call(me.bindings.PFD.NRST._displayNearest, ['apt', 'REAR'], me) }, |
|
637 |
VOR: func { call(me.bindings.PFD.NRST._displayNearest, ['vor', 'REAR'], me) }, |
|
638 |
NDB: func { call(me.bindings.PFD.NRST._displayNearest, ['ndb', 'REAR'], me) }, |
|
639 |
FIX: func { call(me.bindings.PFD.NRST._displayNearest, ['fix', 'REAR'], me) }, |
|
640 |
}, |
|
641 |
LEFT: { |
|
642 |
APT: func { call(me.bindings.PFD.NRST._displayNearest, ['apt', 'LEFT'], me) }, |
|
643 |
VOR: func { call(me.bindings.PFD.NRST._displayNearest, ['vor', 'LEFT'], me) }, |
|
644 |
NDB: func { call(me.bindings.PFD.NRST._displayNearest, ['ndb', 'LEFT'], me) }, |
|
645 |
FIX: func { call(me.bindings.PFD.NRST._displayNearest, ['fix', 'LEFT'], me) }, |
|
646 |
}, |
|
647 |
}, |
|
softkeys are available now
|
648 |
}, |
649 |
MFD : { |
|
650 |
ENGINE: { |
|
651 |
FUEL: { |
|
652 |
UNDO: func { |
|
653 |
pop(me.path); |
|
654 |
me.device.display.updateSoftKeys(); |
|
655 |
}, |
|
656 |
ENTER: func { |
|
657 |
pop(me.path); |
|
658 |
me.device.display.updateSoftKeys(); |
|
659 |
}, |
|
660 |
}, |
|
661 |
ENGINE: func { |
|
662 |
me.path = []; |
|
663 |
me.device.display.updateSoftKeys(); |
|
664 |
}, |
|
665 |
}, |
|
add missing exit to MFD/CHKL...
|
666 |
CHKLIST : { |
add checklists management
|
667 |
_showCheckList: func (id, selected) { |
668 |
var tabulate = func (l, r, t = 3, c = '.') { |
|
669 |
var s = ''; |
|
670 |
for (var i = 0; i < (l - r) + t; i += 1) s ~= c; |
|
671 |
return s; |
|
672 |
} |
|
673 | ||
674 |
var groupIndex = me.device.windows.state[id].objects[selected].groupIndex; |
|
675 |
var checklistIndex = me.device.windows.state[id].objects[selected].checklistIndex; |
|
676 | ||
677 |
if (contains(me.device.windows.state[id].objects[selected], 'pageIndex')) |
|
678 |
pageIndex = me.device.windows.state[id].objects[selected].pageIndex; |
|
679 |
else |
|
680 |
pageIndex = -1; |
|
681 | ||
682 |
var title = ''; |
|
683 |
if (contains(me.device.windows.state[id].objects[selected], 'checklistTitle')) |
|
684 |
title = me.device.windows.state[id].objects[selected].checklistTitle; |
|
685 |
else |
|
686 |
title = me.device.windows.state[id].objects[selected].text; |
|
687 | ||
688 |
me.device.windows.del(id); |
|
689 | ||
690 |
if (groupIndex < 0) |
|
691 |
checklistNode = props.globals.getNode("/sim/checklists") |
|
692 |
.getChild('checklist', checklistIndex); |
|
693 |
else |
|
694 |
checklistNode = props.globals.getNode("/sim/checklists") |
|
695 |
.getChild("group", groupIndex) |
|
696 |
.getChild('checklist', checklistIndex); |
|
697 | ||
698 |
var pages = checklistNode.getChildren('page'); |
|
699 | ||
700 |
if (size(pages) and pageIndex == -1) |
|
701 |
pageIndex = 0; |
|
702 | ||
703 |
_previous_text = ' < PREVIOUS '; |
|
704 |
_next_text = ' NEXT > '; |
|
705 | ||
706 |
var obj_infos = []; |
|
707 |
var length = size(_previous_text ~ _next_text); |
|
708 |
var length_cache = []; |
|
709 |
if (size(pages)) |
|
710 |
checklistNode = pages[pageIndex]; |
|
711 | ||
712 |
append(obj_infos, { |
|
713 |
text: sprintf('%s%s', |
|
714 |
title, |
|
715 |
size(pages) > 1 ? sprintf(' %d / %d', |
|
716 |
pageIndex + 1, |
|
717 |
size(pages)) : ''), |
|
718 |
type: 'title' |
|
719 |
}); |
|
720 | ||
721 |
append(obj_infos, {type: 'separator'}); |
|
722 | ||
723 |
forindex (var i; checklistNode.getChildren('item')) { |
|
724 |
var l = size(checklistNode.getChild('item', i).getValue('name')); |
|
725 |
if (checklistNode.getChild('item', i).getChild('value') != nil) |
|
726 |
l += size(checklistNode.getChild('item', i).getValue('value')); |
|
727 |
append(length_cache, l); |
|
728 |
if (l > length) |
|
729 |
length = l; |
|
730 |
} |
|
731 | ||
732 |
forindex (var i; checklistNode.getChildren('item')) { |
|
733 |
var text = pages[pageIndex].getChild('item', i).getValue('name'); |
|
734 |
var item_val = ''; |
|
735 |
if (pages[pageIndex].getChild('item', i).getChild('value') != nil) |
|
736 |
item_val = pages[pageIndex].getChild('item', i).getValue('value'); |
|
737 |
if (item_val != '') |
|
738 |
text ~= tabulate(length, length_cache[i]); |
|
739 |
text ~= item_val; |
|
740 | ||
741 |
append(obj_infos, { |
|
742 |
text: text, |
|
743 |
groupIndex: groupIndex, |
|
744 |
checklistIndex: checklistIndex, |
|
745 |
pageIndex: pageIndex, |
|
746 |
type: 'normal|end-of-line' |
|
747 |
}); |
|
748 |
} |
|
749 | ||
750 |
append(obj_infos, {type: 'separator'}); |
|
751 | ||
752 |
if (pageIndex and size(pages)) |
|
753 |
append(obj_infos, { |
|
754 |
text: _previous_text, |
|
755 |
groupIndex: groupIndex, |
|
756 |
checklistIndex: checklistIndex, |
|
757 |
pageIndex: pageIndex - 1, |
|
758 |
checklistTitle: title, |
|
759 |
type: (pageIndex + 1 < size(pages)) ? 'editable' : 'selected', |
|
760 |
callback: func (id, selected) call(me.device.softkeys.bindings.MFD.CHKLIST._showCheckList, [id, selected], me) |
|
761 |
}); |
|
762 |
else |
|
763 |
append(obj_infos, { |
|
764 |
text: tabulate(length, size(_next_text), 0, ' '), |
|
765 |
type: 'normal' |
|
766 |
}); |
|
767 | ||
768 |
if (pageIndex + 1 < size(pages)) { |
|
769 |
if (pageIndex and size(pages)) |
|
770 |
append(obj_infos, { |
|
771 |
text: tabulate(length, size(_previous_text ~ _next_text), 0, ' '), |
|
772 |
type: 'normal', |
|
773 |
}); |
|
774 |
append(obj_infos, { |
|
775 |
text: _next_text, |
|
776 |
groupIndex: groupIndex, |
|
777 |
checklistIndex: checklistIndex, |
|
778 |
pageIndex: pageIndex + 1, |
|
779 |
checklistTitle: title, |
|
780 |
type: 'selected|end-of-line', |
|
781 |
callback: func (id, selected) call(me.device.softkeys.bindings.MFD.CHKLIST._showCheckList, [id, selected], me) |
|
782 |
}); |
|
783 |
} |
|
784 | ||
785 |
me.device.knobs.FmsInner = me.device.knobs.NavigateMenu; |
|
786 |
me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu; |
|
787 |
me.device.buttons.ENT = me.device.buttons.ValidateTMRREF; |
|
788 |
me.device.buttons.CLR = func { |
|
789 |
me.device.windows.del(id); |
|
790 |
me.device.knobs.FmsOuter = func; |
|
791 |
me.device.knobs.FmsInner = func; |
|
792 |
foreach (var b; ['ENT', 'CLR']) |
|
793 |
me.device.buttons[b] = func; |
|
794 |
me.device.buttons.MENU = func; |
|
795 |
} |
|
796 |
me.device.windows.draw( id, {autogeom: 1}, obj_infos ); |
|
797 |
}, |
|
798 |
LIST: func { |
|
799 |
# nested function as checklist lists may be organized by group |
|
800 |
var listChecklists = func (id, selected) { |
|
801 |
var groupIndex = me.device.windows.state[id].objects[selected].groupIndex; |
|
802 | ||
803 |
me.device.windows.del(id); |
|
804 | ||
805 |
var checklists = []; |
|
806 |
var firstEntry = 1; |
|
807 |
if (groupIndex == -1) |
|
808 |
checklists = props.globals.getNode("/sim/checklists") |
|
809 |
.getChildren('checklist'); |
|
810 |
else |
|
811 |
checklists = props.globals.getNode("/sim/checklists") |
|
812 |
.getChild("group", groupIndex) |
|
813 |
.getChildren('checklist'); |
|
814 |
var checklistsQty = size(checklists); |
|
815 |
var obj_infos = []; |
|
816 | ||
817 |
if (checklistsQty) { |
|
818 |
forindex (var c; checklists) { |
|
819 |
if (string.uc(checklists[c].getValue('title')) == 'EMERGENCY') { |
|
820 |
checklistsQty -= 1; |
|
821 |
continue; |
|
822 |
} |
|
823 |
var title = checklists[c].getValue('title'); |
|
824 |
append(obj_infos, { |
|
825 |
text: title, |
|
826 |
groupIndex: groupIndex, |
|
827 |
checklistIndex: c, |
|
828 |
checklistTitle: title, |
|
829 |
type: (firstEntry ? 'selected' : 'editable') ~ '|end-of-line', |
|
830 |
callback: func (id, selected) call(me.device.softkeys.bindings.MFD.CHKLIST._showCheckList, [id, selected], me) |
|
831 |
}); |
|
832 |
if (checklistsQty == 1) { # see comments below for groups |
|
833 |
call(me.device.softkeys.bindings.MFD.CHKLIST._showCheckList, [groupIndex, 0], me); |
|
834 |
return; |
|
835 |
} |
|
836 |
elsif (checklistsQty == 0) |
|
837 |
return; |
|
838 |
firstEntry = 0; |
|
839 |
} |
|
840 |
} |
|
841 | ||
842 |
id ~= ' CHECKLISTS'; |
|
843 |
me.device.knobs.FmsInner = me.device.knobs.NavigateMenu; |
|
844 |
me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu; |
|
845 |
me.device.buttons.ENT = me.device.buttons.ValidateTMRREF; |
|
846 |
me.device.buttons.CLR = func { |
|
847 |
me.device.windows.del(id); |
|
848 |
me.device.knobs.FmsOuter = func; |
|
849 |
me.device.knobs.FmsInner = func; |
|
850 |
foreach (var b; ['ENT', 'CLR']) |
|
851 |
me.device.buttons[b] = func; |
|
852 |
me.device.buttons.MENU = func; |
|
853 |
} |
|
854 |
me.device.windows.draw(id, {autogeom: 1}, obj_infos); |
|
855 |
} |
|
856 | ||
857 |
var windowId = 'CHKLIST LIST'; |
|
858 |
if (contains(me.device.windows.state, windowId)) |
|
859 |
me.device.windows.del(windowId); |
|
860 | ||
861 |
var obj_infos = []; |
|
862 |
var firstEntry = 1; |
|
863 |
var groups = props.globals.getNode("/sim/checklists").getChildren("group"); |
|
864 |
var groupsQty = size(groups); |
|
865 | ||
866 |
if (groupsQty) { |
|
867 |
forindex (var g; groups) { |
|
868 |
# emergency checklists are listed in their own menu |
|
869 |
if (string.uc(groups[g].getValue('name')) == 'EMERGENCY') { |
|
870 |
groupsQty -= 1; |
|
871 |
continue; |
|
872 |
} |
|
873 |
# the key groupIndex isn't used by the display system |
|
874 |
# we use it to keep the information of group node's index |
|
875 |
append(obj_infos, { |
|
876 |
text: groups[g].getValue('name'), |
|
877 |
groupIndex: g, |
|
878 |
type: (firstEntry ? 'selected' : 'editable') ~ '|end-of-line', |
|
879 |
callback: func (id, selected) listChecklists(id, selected) }); |
|
880 |
firstEntry = 0; |
|
881 |
# if there are only one group left, let display it directly |
|
882 |
if (groupsQty == 1) { |
|
883 |
listChecklists(windowId, 0); |
|
884 |
return; |
|
885 |
} |
|
886 |
elsif (groupsQty == 0) { |
|
887 |
return; |
|
888 |
} |
|
889 |
} |
|
890 |
} |
|
891 |
else { |
|
892 |
listChecklists(windowId, -1); |
|
893 |
return; |
|
894 |
} |
|
895 | ||
896 |
me.device.knobs.FmsInner = me.device.knobs.NavigateMenu; |
|
897 |
me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu; |
|
898 |
me.device.buttons.ENT = me.device.buttons.ValidateTMRREF; |
|
899 |
me.device.buttons.CLR = func { |
|
900 |
me.device.windows.del(windowId); |
|
901 |
me.device.knobs.FmsOuter = func; |
|
902 |
me.device.knobs.FmsInner = func; |
|
903 |
foreach (var b; ['ENT', 'CLR']) |
|
904 |
me.device.buttons[b] = func; |
|
905 |
me.device.buttons.MENU = func; |
|
906 |
} |
|
907 |
me.device.windows.draw(windowId, {autogeom: 1}, obj_infos); |
|
908 |
}, |
|
909 |
EMERGCY: func { |
|
910 |
# nested function as checklist lists may be organized by group |
|
911 |
var listChecklists = func (groupIndex) { |
|
912 |
var checklists = []; |
|
913 |
var firstEntry = 1; |
|
914 |
if (groupIndex == -1) |
|
915 |
checklists = props.globals.getNode("/sim/checklists") |
|
916 |
.getChildren('checklist'); |
|
917 |
else |
|
918 |
checklists = props.globals.getNode("/sim/checklists") |
|
919 |
.getChild("group", groupIndex) |
|
920 |
.getChildren('checklist'); |
|
921 |
var checklistsQty = size(checklists); |
|
922 |
var obj_infos = []; |
|
923 |
var firstEntry = 1; |
|
924 | ||
925 |
if (checklistsQty) { |
|
926 |
forindex (var c; checklists) { |
|
927 |
if (groupIndex < 0 and string.uc(checklists[c].getValue('title')) != 'EMERGENCY') { |
|
928 |
checklistsQty -= 1; |
|
929 |
continue; |
|
930 |
} |
|
931 |
append(obj_infos, { |
|
932 |
text: checklists[c].getValue('title'), |
|
933 |
groupIndex: groupIndex, |
|
934 |
checklistIndex: c, |
|
935 |
type: (firstEntry ? 'selected' : 'editable') ~ '|end-of-line', |
|
936 |
callback: func (id, selected) call(me.device.softkeys.bindings.MFD.CHKLIST._showCheckList, [id, selected], me) |
|
937 |
}); |
|
938 |
firstEntry = 0; |
|
939 |
} |
|
940 |
} |
|
941 |
id = 'EMERGENCY CHECKLISTS'; |
|
942 |
me.device.knobs.FmsInner = me.device.knobs.NavigateMenu; |
|
943 |
me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu; |
|
944 |
me.device.buttons.ENT = me.device.buttons.ValidateTMRREF; |
|
945 |
me.device.buttons.CLR = func { |
|
946 |
me.device.windows.del(id); |
|
947 |
me.device.knobs.FmsOuter = func; |
|
948 |
me.device.knobs.FmsInner = func; |
|
949 |
foreach (var b; ['ENT', 'CLR']) |
|
950 |
me.device.buttons[b] = func; |
|
951 |
me.device.buttons.MENU = func; |
|
952 |
} |
|
953 |
me.device.windows.draw(id, {autogeom: 1}, obj_infos); |
|
954 |
if (checklistsQty == 1) { # see comments below for groups |
|
955 |
call(me.device.softkeys.bindings.MFD.CHKLIST._showCheckList, [groupIndex, 0], me); |
|
956 |
return; |
|
957 |
} |
|
958 |
elsif (checklistsQty == 0) |
|
959 |
call(me.device.buttons.CLR, [0], me); |
|
960 |
return; |
|
961 |
} |
|
962 | ||
963 |
var windowId = 'CHKLIST EMERGCY'; |
|
964 |
if (contains(me.device.windows.state, windowId)) |
|
965 |
me.device.windows.del(windowId); |
|
966 | ||
967 |
var groups = props.globals.getNode("/sim/checklists").getChildren("group"); |
|
968 | ||
969 |
var emergency_group_found = 0; |
|
970 |
if (size(groups)) { |
|
971 |
forindex (var g; groups) { |
|
972 |
# emergency checklists are listed in their own menu |
|
973 |
# we support only one emergency checklists group named EMERGENCY (case insensitive) |
|
974 |
if (string.uc(groups[g].getValue('name')) != 'EMERGENCY') |
|
975 |
continue; |
|
976 |
listChecklists(g); |
|
977 |
emergency_group_found = !emergency_group_found; |
|
978 |
break; |
|
979 |
} |
|
980 |
} |
|
981 | ||
982 |
if (!emergency_group_found) |
|
983 |
listChecklists(-1); |
|
984 |
}, |
|
add missing exit to MFD/CHKL...
|
985 |
EXIT: func { |
986 |
me.path = []; |
|
987 |
me.device.display.updateSoftKeys(); |
|
988 |
}, |
|
989 |
}, |
|
add TCAS
|
990 |
MAP: { |
991 |
TRAFFIC: func { |
|
improve the selection of dis...
|
992 |
call(me.bindings.PFD.INSET.declutter, ['MAPTRAFFIC', 'tcas', 0], me); |
993 |
}, |
|
994 |
ROUTE: func { |
|
995 |
call(me.bindings.PFD.INSET.declutter, ['MAPROUTE', 'route', 1], me); |
|
996 |
}, |
|
997 |
TERRAIN: func { |
|
998 |
call(me.bindings.PFD.INSET.declutter, ['MAPTERRAIN', 'tiles', 3], me); |
|
999 |
}, |
|
1000 |
NAVAIDS: { |
|
1001 |
ALL: func { |
|
1002 |
call(me.bindings.PFD.INSET.NAVAIDS.ALL, [ 'MAPNAVAIDS' ], me); |
|
1003 |
}, |
|
1004 |
VOR: func { |
|
1005 |
call(me.bindings.PFD.INSET.NAVAIDS.declutter, ['MAPNAVAIDSVOR', 'VOR', 2], me); |
|
1006 |
}, |
|
1007 |
TACAN: func { |
|
1008 |
call(me.bindings.PFD.INSET.NAVAIDS.declutter, ['MAPNAVAIDSTACAN', 'TACAN', 3], me); |
|
1009 |
}, |
|
1010 |
NDB: func { |
|
1011 |
call(me.bindings.PFD.INSET.NAVAIDS.declutter, ['MAPNAVAIDSNDB', 'NDB', 4], me); |
|
1012 |
}, |
|
1013 |
DME: func { |
|
1014 |
call(me.bindings.PFD.INSET.NAVAIDS.declutter, ['MAPNAVAIDSDME', 'DME', 5], me); |
|
1015 |
}, |
|
1016 |
APT: func { |
|
1017 |
call(me.bindings.PFD.INSET.NAVAIDS.declutter, ['MAPNAVAIDSAPT', 'airport', 6], me); |
|
1018 |
}, |
|
add TCAS
|
1019 |
}, |
1020 |
}, |
|
softkeys are available now
|
1021 |
}, |
commit initial
|
1022 |
}, |
1023 |
}; |
|
massive code reorganisation ...
|
1024 | |
1025 |
var keyMap = { |
|
vim folds
|
1026 |
# softkeys map for PFD and MFD {{{1 |
1027 |
# PFD {{{2 |
|
massive code reorganisation ...
|
1028 |
PFD : { |
1029 |
first : 1, |
|
1030 |
texts : ['INSET', 'SENSOR', 'PFD', 'OBS', 'CDI', 'DME', 'XPDR', 'IDENT', 'TMR/REF', 'NRST' ], |
|
1031 |
INSET : { |
|
improve the selection of dis...
|
1032 |
texts : ['OFF', '', 'TRAFFIC', 'ROUTE', 'TOPO', 'TERRAIN', 'NAVAIDS', 'METAR'], |
1033 |
NAVAIDS : { |
|
1034 |
first : 2, |
|
1035 |
texts : ['VOR', 'TACAN', 'NDB', 'DME', 'APT', '', 'ALL'], |
|
1036 |
}, |
|
massive code reorganisation ...
|
1037 |
}, |
1038 |
SENSOR : { |
|
1039 |
first : 2, |
|
1040 |
texts : [ 'ADC1', 'ADC2', '', 'AHRS1', 'AHRS2'], |
|
1041 |
}, |
|
1042 |
PFD : { |
|
1043 |
texts : [ 'SYN VIS', 'DFLTS', 'AOA/WIND', 'DME', 'BRG1', 'HSI FMT', 'BRG2', '', 'ALT UNIT', 'STD BARO' ], |
|
1044 |
'SYN VIS' : { |
|
1045 |
texts : [ 'PATHWAY', 'SYN TERR', 'HR2NHDG', 'APTSIGNS', 'FPM'], |
|
1046 |
}, |
|
1047 |
'AOA/WIND' : { |
|
1048 |
first : 4, |
|
1049 |
texts : ['AOA', 'WIND'], |
|
1050 |
AOA : { |
|
1051 |
first : 5, |
|
1052 |
texts : ['AOA ON', 'AOA AUTO'], |
|
1053 |
}, |
|
1054 |
WIND : { |
|
1055 |
first : 2, |
|
1056 |
texts : ['OPTN1', 'OPTN2', '', 'OFF'], |
|
1057 |
}, |
|
1058 |
}, |
|
1059 |
'HSI FMT' : { |
|
1060 |
first : 6, |
|
1061 |
texts : ['360 HSI', 'ARC HSI'], |
|
1062 |
}, |
|
1063 |
'ALT UNIT' : { |
|
1064 |
first : 5, |
|
1065 |
texts : ['METERS', '', 'IN', 'HPA'], |
|
1066 |
}, |
|
1067 |
}, |
|
1068 |
XPDR : { |
|
1069 |
first : 2, |
|
1070 |
texts : ['STBY', 'ON', 'ALT', '', 'VFR', 'CODE', 'IDENT'], |
|
1071 |
CODE : { |
|
1072 |
texts : ['0', '1', '2', '3', '4', '5', '6', '7', 'IDENT', 'BKSP'], |
|
1073 |
}, |
|
1074 |
}, |
|
add PFD/NRST softkey
|
1075 |
NRST : { |
1076 |
first : 4, |
|
1077 |
texts : ['OMNI', 'REAR', 'FRONT', 'LEFT', 'RIGHT', 'RANGE'], |
|
1078 |
RANGE : { |
|
1079 |
first : 7, |
|
1080 |
texts : ['MIN', 'MAX' ], |
|
1081 |
MIN : { first: 3, texts : ['0NM', '10NM', '30NM', '50NM'] }, |
|
1082 |
MAX : { fisrt: 3, texts : ['200NM', '150NM', '100NM', '50NM'] }, |
|
1083 |
}, |
|
1084 |
OMNI : { texts: ['NDB', 'FIX', 'VOR', 'APT'] }, # that will be mirrored later |
|
1085 |
}, |
|
massive code reorganisation ...
|
1086 |
}, |
vim folds
|
1087 |
#}}}2 |
1088 |
# MFD {{{2 |
|
massive code reorganisation ...
|
1089 |
MFD : { |
1090 |
texts : ['ENGINE', '', 'MAP', '', '', '', '', '', '', 'DCLTR', 'SHW CHRT', 'CHKLIST'], |
|
1091 |
MAP : { |
|
improve the selection of dis...
|
1092 |
texts : ['TRAFFIC', 'ROUTE', 'TOPO', 'TERRAIN', 'NAVAIDS', '','', '', '', '', 'BACK'], |
1093 |
NAVAIDS : { |
|
1094 |
first : 2, |
|
1095 |
texts : ['VOR', 'TACAN', 'NDB', 'DME', 'APT', '', 'ALL', '', '', 'BACK' ], |
|
1096 |
}, |
|
massive code reorganisation ...
|
1097 |
}, |
1098 |
CHKLIST : { |
|
add checklists management
|
1099 |
texts : ['ENGINE', '', '', '', 'LIST', 'DONE', '', '', '', '', 'EXIT', 'EMERGCY'], |
massive code reorganisation ...
|
1100 |
}, |
1101 |
ENGINE : { |
|
1102 |
texts : ['ENGINE', 'ANTI-ICE', '', 'DCLTR', '', 'ASSIST', '', '', '', '', 'FUEL'], |
|
1103 |
'ANTI-ICE' : { |
|
1104 |
texts : ['LEFT', 'AUTO', 'RIGHT', '', '', '', '', '', '', '', '', 'BACK'], |
|
1105 |
}, |
|
1106 |
FUEL : { |
|
1107 |
first : 1, |
|
1108 |
texts : ['FULL', 'TABS', '', '', '', '', '', '', '', 'UNDO', 'ENTER'], |
|
1109 |
}, |
|
1110 |
}, |
|
1111 |
}, |
|
vim folds
|
1112 |
#}}}2 |
massive code reorganisation ...
|
1113 |
}; |
1114 |
if (data['stall-aoa'] == 9999) |
|
1115 |
keyMap.PFD.PFD['AOA/WIND'].texts = ['', 'WIND']; |
|
add checklists management
|
1116 |
if (props.globals.getNode('/sim/checklists') == nil) { |
1117 |
keyMap.MFD.texts[11] = ''; |
|
1118 |
delete(keyMap.MFD, 'CHKLIST'); |
|
1119 |
} |
|
add PFD/NRST softkey
|
1120 |
foreach (var d; ['FRONT', 'REAR', 'LEFT', 'RIGHT']) { |
1121 |
keyMap.PFD.NRST[d] = keyMap.PFD.NRST.OMNI; |
|
1122 |
} |
|
vim folds
|
1123 |
#}}}1 |