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); |
|
264 |
setprop('/instrumentation/zkv1000/radio/xpdr-mode', 'STBY'); |
|
265 |
me.device.display.updateXPDR(); |
|
266 |
}, |
|
267 |
ON : func { |
|
268 |
setprop('/instrumentation/transponder/ident', 1); |
|
269 |
setprop('/instrumentation/transponder/knob-mode', 4); |
|
270 |
setprop('/instrumentation/zkv1000/radio/xpdr-mode', 'ON'); |
|
271 |
me.device.display.updateXPDR(); |
|
272 |
}, |
|
273 |
ALT : func { |
|
274 |
setprop('/instrumentation/transponder/ident', 1); |
|
275 |
setprop('/instrumentation/transponder/knob-mode', 5); |
|
276 |
setprop('/instrumentation/zkv1000/radio/xpdr-mode', 'ALT'); |
|
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) { |
|
XPDR settings via knob or so...
|
288 |
if (getprop('/instrumentation/zkv1000/radios/xpdr-tuning-fms-method')) |
289 |
return; |
|
290 |
me.device.display.timers2.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 { |
|
300 |
setprop('/instrumentation/zkv1000/radios/xpdr-tuning-digit', 3); |
|
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); |
|
XPDR settings via knob or so...
|
313 |
if (d == 1) { |
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); |
349 |
me.device.display.timers2.softkeys_inactivity.restart(me.device.display.softkeys_inactivity_delay); |
|
adds transponder
|
350 |
call(me.bindings.PFD.IDENT, [], me); |
351 |
}, |
|
352 |
BKSP: func { |
|
XPDR settings via knob or so...
|
353 |
if (getprop('/instrumentation/zkv1000/radios/xpdr-tuning-fms-method')) |
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', |
|
374 |
sprintf('%s', getprop('/instrumentation/zkv1000/radios/xpdr-backup-code'))); |
|
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; |
|
388 |
me.device.display.timers2.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 |
392 |
me.device.display.timers2.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(); |
|
adds transponder
|
398 |
var tuning = getprop('/instrument/zkv1000/radios/xpdr-tuning-digit'); |
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 { |
|
411 |
if (getprop('/instrumentation/zkv1000/radio/xpdr-mode') == 'STBY') |
|
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'}, |
TMR/REF available
|
506 |
{text: sprintf('Vx %3iKT', alerts.getNode('Vx').getValue()), type: 'normal', scrollgroup:0}, |
507 |
{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')}, |
|
508 |
{text: sprintf('Vy %3iKT', alerts.getNode('Vy').getValue()), type: 'normal', scrollgroup:1}, |
|
509 |
{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')}, |
|
510 |
{text: sprintf('Vr %3iKT', alerts.getNode('Vr').getValue()), type: 'normal', scrollgroup:2}, |
|
511 |
{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')}, |
|
512 |
{text: sprintf('Vglide %3iKT', alerts.getNode('Vglide').getValue()), type: 'normal', scrollgroup:3}, |
|
513 |
{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
|
514 |
{type: 'separator'}, |
515 |
{text: 'MINIMUMS', type: 'normal'}, |
|
TMR/REF available
|
516 |
{text: ' OFF >', type: 'editable', choices: [' OFF >', '< BARO >','<TEMP COMP'], callback: func}, |
TMR/REF window adaptation
|
517 |
{text: ' 1000FT', type: 'editable', format: '% 5iFT', factor: 100, callback: func}, |
518 |
], |
|
519 |
{ # scrolling info, see menu.nas |
|
520 |
lines : 3, |
|
521 |
columns : 2, |
|
522 |
} |
|
TMR/REF window
|
523 |
); |
524 |
me.device.knobs.FmsInner = me.device.knobs.MenuSettings; |
|
525 |
me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu; |
|
TMR/REF available
|
526 |
me.device.buttons.ENT = me.device.buttons.ValidateTMRREF; |
527 |
me.device.buttons.FMS = me.device.buttons.ValidateTMRREF; |
|
528 |
me.device.buttons.CLR = me.device.buttons.ClearTMRREF; |
|
TMR/REF window
|
529 |
} |
530 |
else { |
|
TMR/REF available
|
531 |
me.device.buttons.ClearTMRREF(); |
TMR/REF window
|
532 |
} |
533 |
}, |
|
softkeys are available now
|
534 |
}, |
535 |
MFD : { |
|
536 |
ENGINE: { |
|
537 |
FUEL: { |
|
538 |
UNDO: func { |
|
539 |
pop(me.path); |
|
540 |
me.device.display.updateSoftKeys(); |
|
541 |
}, |
|
542 |
ENTER: func { |
|
543 |
pop(me.path); |
|
544 |
me.device.display.updateSoftKeys(); |
|
545 |
}, |
|
546 |
}, |
|
547 |
ENGINE: func { |
|
548 |
me.path = []; |
|
549 |
me.device.display.updateSoftKeys(); |
|
550 |
}, |
|
551 |
}, |
|
add missing exit to MFD/CHKL...
|
552 |
CHKLIST : { |
553 |
EXIT: func { |
|
554 |
me.path = []; |
|
555 |
me.device.display.updateSoftKeys(); |
|
556 |
}, |
|
557 |
}, |
|
add TCAS
|
558 |
MAP: { |
559 |
TRAFFIC: func { |
|
improve the selection of dis...
|
560 |
call(me.bindings.PFD.INSET.declutter, ['MAPTRAFFIC', 'tcas', 0], me); |
561 |
}, |
|
562 |
ROUTE: func { |
|
563 |
call(me.bindings.PFD.INSET.declutter, ['MAPROUTE', 'route', 1], me); |
|
564 |
}, |
|
565 |
TERRAIN: func { |
|
566 |
call(me.bindings.PFD.INSET.declutter, ['MAPTERRAIN', 'tiles', 3], me); |
|
567 |
}, |
|
568 |
NAVAIDS: { |
|
569 |
ALL: func { |
|
570 |
call(me.bindings.PFD.INSET.NAVAIDS.ALL, [ 'MAPNAVAIDS' ], me); |
|
571 |
}, |
|
572 |
VOR: func { |
|
573 |
call(me.bindings.PFD.INSET.NAVAIDS.declutter, ['MAPNAVAIDSVOR', 'VOR', 2], me); |
|
574 |
}, |
|
575 |
TACAN: func { |
|
576 |
call(me.bindings.PFD.INSET.NAVAIDS.declutter, ['MAPNAVAIDSTACAN', 'TACAN', 3], me); |
|
577 |
}, |
|
578 |
NDB: func { |
|
579 |
call(me.bindings.PFD.INSET.NAVAIDS.declutter, ['MAPNAVAIDSNDB', 'NDB', 4], me); |
|
580 |
}, |
|
581 |
DME: func { |
|
582 |
call(me.bindings.PFD.INSET.NAVAIDS.declutter, ['MAPNAVAIDSDME', 'DME', 5], me); |
|
583 |
}, |
|
584 |
APT: func { |
|
585 |
call(me.bindings.PFD.INSET.NAVAIDS.declutter, ['MAPNAVAIDSAPT', 'airport', 6], me); |
|
586 |
}, |
|
add TCAS
|
587 |
}, |
588 |
}, |
|
softkeys are available now
|
589 |
}, |
commit initial
|
590 |
}, |
591 |
}; |
|
massive code reorganisation ...
|
592 | |
593 |
var keyMap = { |
|
vim folds
|
594 |
# softkeys map for PFD and MFD {{{1 |
595 |
# PFD {{{2 |
|
massive code reorganisation ...
|
596 |
PFD : { |
597 |
first : 1, |
|
598 |
texts : ['INSET', 'SENSOR', 'PFD', 'OBS', 'CDI', 'DME', 'XPDR', 'IDENT', 'TMR/REF', 'NRST' ], |
|
599 |
INSET : { |
|
improve the selection of dis...
|
600 |
texts : ['OFF', '', 'TRAFFIC', 'ROUTE', 'TOPO', 'TERRAIN', 'NAVAIDS', 'METAR'], |
601 |
NAVAIDS : { |
|
602 |
first : 2, |
|
603 |
texts : ['VOR', 'TACAN', 'NDB', 'DME', 'APT', '', 'ALL'], |
|
604 |
}, |
|
massive code reorganisation ...
|
605 |
}, |
606 |
SENSOR : { |
|
607 |
first : 2, |
|
608 |
texts : [ 'ADC1', 'ADC2', '', 'AHRS1', 'AHRS2'], |
|
609 |
}, |
|
610 |
PFD : { |
|
611 |
texts : [ 'SYN VIS', 'DFLTS', 'AOA/WIND', 'DME', 'BRG1', 'HSI FMT', 'BRG2', '', 'ALT UNIT', 'STD BARO' ], |
|
612 |
'SYN VIS' : { |
|
613 |
texts : [ 'PATHWAY', 'SYN TERR', 'HR2NHDG', 'APTSIGNS', 'FPM'], |
|
614 |
}, |
|
615 |
'AOA/WIND' : { |
|
616 |
first : 4, |
|
617 |
texts : ['AOA', 'WIND'], |
|
618 |
AOA : { |
|
619 |
first : 5, |
|
620 |
texts : ['AOA ON', 'AOA AUTO'], |
|
621 |
}, |
|
622 |
WIND : { |
|
623 |
first : 2, |
|
624 |
texts : ['OPTN1', 'OPTN2', '', 'OFF'], |
|
625 |
}, |
|
626 |
}, |
|
627 |
'HSI FMT' : { |
|
628 |
first : 6, |
|
629 |
texts : ['360 HSI', 'ARC HSI'], |
|
630 |
}, |
|
631 |
'ALT UNIT' : { |
|
632 |
first : 5, |
|
633 |
texts : ['METERS', '', 'IN', 'HPA'], |
|
634 |
}, |
|
635 |
}, |
|
636 |
XPDR : { |
|
637 |
first : 2, |
|
638 |
texts : ['STBY', 'ON', 'ALT', '', 'VFR', 'CODE', 'IDENT'], |
|
639 |
CODE : { |
|
640 |
texts : ['0', '1', '2', '3', '4', '5', '6', '7', 'IDENT', 'BKSP'], |
|
641 |
}, |
|
642 |
}, |
|
643 |
}, |
|
vim folds
|
644 |
#}}}2 |
645 |
# MFD {{{2 |
|
massive code reorganisation ...
|
646 |
MFD : { |
647 |
texts : ['ENGINE', '', 'MAP', '', '', '', '', '', '', 'DCLTR', 'SHW CHRT', 'CHKLIST'], |
|
648 |
MAP : { |
|
improve the selection of dis...
|
649 |
texts : ['TRAFFIC', 'ROUTE', 'TOPO', 'TERRAIN', 'NAVAIDS', '','', '', '', '', 'BACK'], |
650 |
NAVAIDS : { |
|
651 |
first : 2, |
|
652 |
texts : ['VOR', 'TACAN', 'NDB', 'DME', 'APT', '', 'ALL', '', '', 'BACK' ], |
|
653 |
}, |
|
massive code reorganisation ...
|
654 |
}, |
655 |
CHKLIST : { |
|
656 |
texts : ['ENGINE', '', '', '', '', 'DONE', '', '', '', '', 'EXIT', 'EMERGCY'], |
|
657 |
}, |
|
658 |
ENGINE : { |
|
659 |
texts : ['ENGINE', 'ANTI-ICE', '', 'DCLTR', '', 'ASSIST', '', '', '', '', 'FUEL'], |
|
660 |
'ANTI-ICE' : { |
|
661 |
texts : ['LEFT', 'AUTO', 'RIGHT', '', '', '', '', '', '', '', '', 'BACK'], |
|
662 |
}, |
|
663 |
FUEL : { |
|
664 |
first : 1, |
|
665 |
texts : ['FULL', 'TABS', '', '', '', '', '', '', '', 'UNDO', 'ENTER'], |
|
666 |
}, |
|
667 |
}, |
|
668 |
}, |
|
vim folds
|
669 |
#}}}2 |
massive code reorganisation ...
|
670 |
}; |
671 |
if (data['stall-aoa'] == 9999) |
|
672 |
keyMap.PFD.PFD['AOA/WIND'].texts = ['', 'WIND']; |
|
vim folds
|
673 |
#}}}1 |