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 |
}, |
|
64 |
hook : func { |
|
65 |
me.device.display.screenElements['PFD-Map-bg'].show(); |
|
separates maps code
|
66 |
me.device.map.setVisible(1); |
67 |
me.device.map.update(); |
|
softkeys are available now
|
68 |
}, |
69 |
}, |
|
70 |
PFD: { |
|
adds OAT, TAS, GSPD, WindDat...
|
71 |
'AOA/WIND' : { |
adds AOA display
|
72 |
AOA : { |
73 |
'AOA ON' : func { |
|
74 |
if (me.device.data['aoa-auto']) |
|
75 |
return; |
|
76 |
me.device.data.aoa = ! me.device.data.aoa; |
|
nicer AOA display
|
77 |
foreach (var e; ['AOA', 'AOA-needle', 'AOA-text']) |
78 |
me.device.display.screenElements[e] |
|
79 |
.setVisible(me.device.data.aoa); |
|
80 |
me.device.display.screenElements['AOA-approach'] |
|
81 |
.setVisible(me.device.data.aoa and contains(data, 'approach-aoa')); |
|
adds AOA display
|
82 |
me.device.display.updateAOA(); |
83 |
me.device.display.setSoftKeyColor(5 ,me.device.data.aoa); |
|
84 |
if (me.device.data.aoa) |
|
85 |
me.colored['PFDAOA/WINDAOAAOA ON'] = 1; |
|
86 |
else |
|
87 |
delete(me.colored, 'PFDAOA/WINDAOAAOA ON'); |
|
88 |
}, |
|
89 |
'AOA AUTO' : func { |
|
90 |
if (me.device.data.aoa) |
|
91 |
return; |
|
92 |
me.device.data['aoa-auto'] = ! me.device.data['aoa-auto']; |
|
93 |
me.device.display.setSoftKeyColor(6 ,me.device.data['aoa-auto']); |
|
94 |
if (me.device.data['aoa-auto']) { |
|
95 |
me.colored['PFDAOA/WINDAOAAOA AUTO'] = 1; |
|
96 |
if (!contains(me.device.timers, 'aoa')) |
|
97 |
me.device.timers.aoa = maketimer(1, |
|
98 |
func { |
|
99 |
var v = getprop('/gear/gear/position-norm') == 1 |
|
100 |
and getprop('/surfaces-positions/flap-pos-norm') != 0; |
|
nicer AOA display
|
101 |
foreach (var e; ['AOA', 'AOA-needle', 'AOA-text']) |
102 |
me.device.display.screenElements[e] |
|
103 |
.setVisible(v); |
|
104 |
me.device.display.screenElements['AOA-approach'] |
|
105 |
.setVisible(v and contains(data, 'approach-aoa')); |
|
adds AOA display
|
106 |
}, me); |
107 |
me.device.timers.aoa.start(); |
|
108 |
} |
|
109 |
else { |
|
110 |
delete(me.colored, 'PFDAOA/WINDAOAAOA AUTO'); |
|
111 |
me.device.timers.aoa.stop(); |
|
112 |
me.device.data.aoa = 0; |
|
113 |
me.device.display.screenElements['AOA'] |
|
114 |
.hide(); |
|
115 |
} |
|
116 |
}, |
|
nicer AOA display
|
117 |
hook : func { |
118 |
if (contains(data,'approach-aoa')) |
|
119 |
me.device.display.screenElements['AOA-approach'] |
|
120 |
.setRotation(-data['approach-aoa']/data['stall-aoa']*math.pi); |
|
121 |
}, |
|
adds AOA display
|
122 |
}, |
adds OAT, TAS, GSPD, WindDat...
|
123 |
WIND : { |
124 |
OPTN1 : func { |
|
125 |
me.device.display._winddata_optn = 1; |
|
126 |
me.device.display.screenElements['WindData'].show(); |
|
127 |
me.device.display.screenElements['WindData-OPTN1'].show(); |
|
128 |
me.device.display.screenElements['WindData-OPTN1-HDG'].show(); |
|
129 |
me.device.display.screenElements['WindData-OPTN2'].hide(); |
|
130 |
me.device.display.updateWindData(); |
|
uses the new coloration for ...
|
131 |
me.device.display.setSoftKeyColor(2, 1); |
132 |
me.colored['PFDAOA/WINDWINDOPTN1'] = 1; |
|
133 |
me.device.display.setSoftKeyColor(3, 0); |
|
134 |
delete(me.colored, 'PFDAOA/WINDWINDOPTN2'); |
|
adds OAT, TAS, GSPD, WindDat...
|
135 |
}, |
136 |
OPTN2 : func { |
|
137 |
me.device.display._winddata_optn = 2; |
|
138 |
me.device.display.screenElements['WindData'].show(); |
|
139 |
me.device.display.screenElements['WindData-OPTN1'].hide(); |
|
140 |
me.device.display.screenElements['WindData-OPTN2'].show(); |
|
141 |
me.device.display.screenElements['WindData-OPTN2-symbol'].show(); |
|
142 |
me.device.display.screenElements['WindData-OPTN2-headwind'].show(); |
|
143 |
me.device.display.screenElements['WindData-OPTN2-crosswind'].show(); |
|
144 |
me.device.display.updateWindData(); |
|
uses the new coloration for ...
|
145 |
me.device.display.setSoftKeyColor(2, 0); |
146 |
delete(me.colored, 'PFDAOA/WINDWINDOPTN1'); |
|
147 |
me.device.display.setSoftKeyColor(3, 1); |
|
148 |
me.colored['PFDAOA/WINDWINDOPTN2'] = 1; |
|
adds OAT, TAS, GSPD, WindDat...
|
149 |
}, |
150 |
OFF : func { |
|
151 |
me.device.display._winddata_optn = 0; |
|
152 |
me.device.display.screenElements['WindData'].hide(); |
|
153 |
me.device.display.screenElements['WindData-OPTN1'].hide(); |
|
154 |
me.device.display.screenElements['WindData-OPTN2'].hide(); |
|
uses the new coloration for ...
|
155 |
me.device.display.setSoftKeyColor(2, 0); |
156 |
delete(me.colored, 'PFDAOA/WINDWINDOPTN1'); |
|
157 |
me.device.display.setSoftKeyColor(3, 0); |
|
158 |
delete(me.colored, 'PFDAOA/WINDWINDOPTN2'); |
|
adds OAT, TAS, GSPD, WindDat...
|
159 |
}, |
160 |
}, |
|
161 |
}, |
|
adds BRG1/2 animation
|
162 |
BRG1 : func (brg = 1){ |
163 |
var source = 'brg' ~ brg ~ '-source'; |
|
164 |
var list = ['NAV' ~ brg, 'GPS', 'ADF', 'OFF']; |
|
165 |
var index = std.Vector |
|
166 |
.new(list) |
|
167 |
.index(radios.getNode(source).getValue()); |
|
168 |
var next = (index == size(list) -1) ? 0 : index + 1; |
|
169 |
radios.getNode(source).setValue(list[next]); |
|
uses the new coloration for ...
|
170 |
if (list[next] != 'OFF') { |
171 |
me.device.display.setSoftKeyColor(brg == 1 ? 4 : 6, 1); |
|
172 |
me.colored['PFDBRG' ~ brg] = 1; |
|
173 |
} |
|
174 |
else { |
|
175 |
me.device.display.setSoftKeyColor(brg == 1 ? 4 : 6, 0); |
|
176 |
delete(me.colored, 'PFDBRG' ~ brg); |
|
177 |
} |
|
adds BRG1/2 animation
|
178 |
}, |
179 |
BRG2 : func { |
|
180 |
call(me.bindings.PFD.PFD.BRG1, [ 2 ], me); |
|
181 |
}, |
|
adds BARO settings
|
182 |
'STD BARO' : func { |
183 |
setprop('/instrumentation/altimeter/setting-inhg', 29.92); |
|
184 |
me.device.display.updateBARO(); |
|
185 |
pop(me.path); |
|
186 |
me.device.display.updateSoftKeys(); |
|
187 |
}, |
|
188 |
IN : func { |
|
189 |
me.device.display._baro_unit = 'inhg'; |
|
190 |
me.device.display.updateBARO(); |
|
191 |
}, |
|
192 |
HPA : func { |
|
193 |
me.device.display._baro_unit = 'hpa'; |
|
194 |
me.device.display.updateBARO(); |
|
195 |
}, |
|
softkeys are available now
|
196 |
}, |
197 |
XPDR: { |
|
adds transponder
|
198 |
STBY : func { |
199 |
setprop('/instrumentation/transponder/ident', 0); |
|
200 |
setprop('/instrumentation/transponder/knob-mode', 1); |
|
201 |
setprop('/instrumentation/zkv1000/radio/xpdr-mode', 'STBY'); |
|
202 |
me.device.display.updateXPDR(); |
|
203 |
}, |
|
204 |
ON : func { |
|
205 |
setprop('/instrumentation/transponder/ident', 1); |
|
206 |
setprop('/instrumentation/transponder/knob-mode', 4); |
|
207 |
setprop('/instrumentation/zkv1000/radio/xpdr-mode', 'ON'); |
|
208 |
me.device.display.updateXPDR(); |
|
209 |
}, |
|
210 |
ALT : func { |
|
211 |
setprop('/instrumentation/transponder/ident', 1); |
|
212 |
setprop('/instrumentation/transponder/knob-mode', 5); |
|
213 |
setprop('/instrumentation/zkv1000/radio/xpdr-mode', 'ALT'); |
|
214 |
me.device.display.updateXPDR(); |
|
215 |
}, |
|
216 |
VFR : func { |
|
217 |
setprop('/instrumentation/transponder/id-code', '1200'); |
|
218 |
me.device.display.updateXPDR(); |
|
219 |
}, |
|
220 |
IDENT : func { |
|
221 |
call(me.bindings.PFD.IDENT, [], me); |
|
222 |
}, |
|
223 |
CODE : { |
|
224 |
'0' : func (n = 0) { |
|
XPDR settings via knob or so...
|
225 |
if (getprop('/instrumentation/zkv1000/radios/xpdr-tuning-fms-method')) |
226 |
return; |
|
227 |
me.device.display.timers2.softkeys_inactivity.stop(); |
|
Softkeys revert to the previ...
|
228 |
me.bindings.PFD.XPDR.CODE.inactivity.restart(me.device.display.softkeys_inactivity_delay); |
XPDR settings via knob or so...
|
229 |
# disable FMS knob entering method |
230 |
me.device.knobs.FmsInner = void; |
|
231 |
# When entering the code, the next softkey in sequence |
|
232 |
# must be pressed within 10 seconds, or the entry is cancelled |
|
233 |
# and restored to the previous code |
|
234 |
if (!contains(me.bindings.PFD.XPDR.CODE, 'on_change_inactivity')) { |
|
235 |
me.bindings.PFD.XPDR.CODE.on_change_inactivity = maketimer(10, |
|
236 |
func { |
|
237 |
setprop('/instrumentation/zkv1000/radios/xpdr-tuning-digit', 3); |
|
238 |
me.device.knobs.FmsInner = me.device.knobs.XPDRCodeSetDigits; |
|
239 |
me.device.knobs.FmsOuter = me.device.knobs.XPDRCodeNextDigits; |
|
240 |
call(me.bindings.PFD.XPDR.CODE.restore, [], me); |
|
241 |
}); |
|
242 |
me.bindings.PFD.XPDR.CODE.on_change_inactivity.singleShot = 1; |
|
243 |
me.bindings.PFD.XPDR.CODE.on_change_inactivity.start(); |
|
244 |
} |
|
245 |
else |
|
246 |
me.bindings.PFD.XPDR.CODE.on_change_inactivity.restart(10); |
|
adds transponder
|
247 |
var tuning = radios.getNode('xpdr-tuning-digit'); |
248 |
var d = tuning.getValue(); |
|
249 |
setprop('/instrumentation/transponder/inputs/digit[' ~ d ~ ']', n); |
|
XPDR settings via knob or so...
|
250 |
if (d == 1) { |
251 |
if (!contains(me.bindings.PFD.XPDR.CODE, 'on_change_auto_validation')) |
|
252 |
me.bindings.PFD.XPDR.CODE.on_change_auto_validation = maketimer(5, |
|
253 |
func call(me.bindings.PFD.IDENT, [], me)); |
|
254 |
me.bindings.PFD.XPDR.CODE.on_change_auto_validation.singleShot = 1; |
|
255 |
me.bindings.PFD.XPDR.CODE.on_change_auto_validation.start(); |
|
256 |
} |
|
257 |
else { |
|
258 |
d -= 1; |
|
259 |
tuning.setValue(d); |
|
260 |
} |
|
adds transponder
|
261 |
me.device.display.updateXPDR(); |
262 |
}, |
|
263 |
'1' : func { |
|
264 |
call(me.bindings.PFD.XPDR.CODE['0'], [ 1 ], me); |
|
265 |
}, |
|
266 |
'2' : func { |
|
267 |
call(me.bindings.PFD.XPDR.CODE['0'], [ 2 ], me); |
|
268 |
}, |
|
269 |
'3' : func { |
|
270 |
call(me.bindings.PFD.XPDR.CODE['0'], [ 3 ], me); |
|
271 |
}, |
|
272 |
'4' : func { |
|
273 |
call(me.bindings.PFD.XPDR.CODE['0'], [ 4 ], me); |
|
274 |
}, |
|
275 |
'5' : func { |
|
276 |
call(me.bindings.PFD.XPDR.CODE['0'], [ 5 ], me); |
|
277 |
}, |
|
278 |
'6' : func { |
|
279 |
call(me.bindings.PFD.XPDR.CODE['0'], [ 6 ], me); |
|
280 |
}, |
|
281 |
'7' : func { |
|
282 |
call(me.bindings.PFD.XPDR.CODE['0'], [ 7 ], me); |
|
283 |
}, |
|
softkeys are available now
|
284 |
IDENT: func { |
Softkeys revert to the previ...
|
285 |
me.bindings.PFD.XPDR.CODE.inactivity.restart(me.device.display.softkeys_inactivity_delay); |
286 |
me.device.display.timers2.softkeys_inactivity.restart(me.device.display.softkeys_inactivity_delay); |
|
adds transponder
|
287 |
call(me.bindings.PFD.IDENT, [], me); |
288 |
}, |
|
289 |
BKSP: func { |
|
XPDR settings via knob or so...
|
290 |
if (getprop('/instrumentation/zkv1000/radios/xpdr-tuning-fms-method')) |
291 |
return; |
|
292 |
if (contains(me.bindings.PFD.XPDR.CODE, 'on_change_inactivity')) |
|
293 |
me.bindings.PFD.XPDR.CODE.on_change_inactivity.restart(10); |
|
294 |
if (contains(me.bindings.PFD.XPDR.CODE, 'on_change_auto_validation')) |
|
295 |
me.bindings.PFD.XPDR.CODE.on_change_auto_validation.stop(); |
|
adds transponder
|
296 |
var tuning = radios.getNode('xpdr-tuning-digit'); |
297 |
var d = tuning.getValue(); |
|
XPDR settings via knob or so...
|
298 |
if (d < 3) { |
299 |
d += 1; |
|
300 |
tuning.setValue(d); |
|
301 |
} |
|
adds transponder
|
302 |
me.device.display.updateXPDR(); |
softkeys are available now
|
303 |
}, |
adds transponder
|
304 |
BACK : func (inactive = 0) { |
XPDR settings via knob or so...
|
305 |
call(me.bindings.PFD.XPDR.CODE.restore, [], me); |
adds transponder
|
306 |
pop(me.path); |
XPDR settings via knob or so...
|
307 |
call(me.bindings.PFD.XPDR.CODE.exit, [me.path], me); |
308 |
}, |
|
309 |
restore : func { |
|
310 |
setprop('/instrumentation/transponder/id-code', |
|
311 |
sprintf('%s', getprop('/instrumentation/zkv1000/radios/xpdr-backup-code'))); |
|
312 |
me.device.display.updateXPDR(); |
|
adds transponder
|
313 |
}, |
314 |
exit : func (p) { |
|
Softkeys revert to the previ...
|
315 |
if (contains(me.bindings.PFD.XPDR.CODE, 'inactivity')) # does not exists if IDENT pressed from top-level |
316 |
me.bindings.PFD.XPDR.CODE.inactivity.stop(); |
|
adds transponder
|
317 |
radios.removeChild('xpdr-tuning-digit', 0); |
318 |
radios.removeChild('xpdr-backup-code', 0); |
|
XPDR settings via knob or so...
|
319 |
radios.removeChild('xpdr-tuning-fms-method', 0); |
adds transponder
|
320 |
me.path = p; |
321 |
me.device.display.updateXPDR(); |
|
softkeys are available now
|
322 |
me.device.display.updateSoftKeys(); |
XPDR settings via knob or so...
|
323 |
me.device.knobs.FmsInner = void; |
324 |
me.device.knobs.FmsOuter = void; |
|
325 |
me.device.display.timers2.softkeys_inactivity.restart(me.device.display.softkeys_inactivity_delay); |
|
softkeys are available now
|
326 |
}, |
adds transponder
|
327 |
hook : func { |
XPDR settings via knob or so...
|
328 |
# this level has its own timer as we may need to revert changes, and got different timers |
329 |
me.device.display.timers2.softkeys_inactivity.stop(); |
|
Softkeys revert to the previ...
|
330 |
me.bindings.PFD.XPDR.CODE.inactivity = maketimer( |
331 |
me.device.display.softkeys_inactivity_delay, |
|
XPDR settings via knob or so...
|
332 |
func call(me.bindings.PFD.XPDR.CODE.BACK, [], me)); |
Softkeys revert to the previ...
|
333 |
me.bindings.PFD.XPDR.CODE.inactivity.singleShot = 1; |
334 |
me.bindings.PFD.XPDR.CODE.inactivity.start(); |
|
adds transponder
|
335 |
var tuning = getprop('/instrument/zkv1000/radios/xpdr-tuning-digit'); |
336 |
if (tuning == nil) { |
|
337 |
radios.getNode('xpdr-tuning-digit', 1).setValue(3); |
|
338 |
radios.getNode('xpdr-backup-code', 1).setValue(getprop('/instrumentation/transponder/id-code')); |
|
XPDR settings via knob or so...
|
339 |
radios.getNode('xpdr-tuning-fms-method', 1).setValue(0); |
adds transponder
|
340 |
me.device.display.updateXPDR(); |
341 |
} |
|
XPDR settings via knob or so...
|
342 |
me.device.knobs.FmsInner = me.device.knobs.XPDRCodeSetDigits; |
343 |
me.device.knobs.FmsOuter = me.device.knobs.XPDRCodeNextDigits; |
|
adds transponder
|
344 |
}, |
softkeys are available now
|
345 |
}, |
adds transponder
|
346 |
}, |
347 |
IDENT : func { |
|
348 |
if (getprop('/instrumentation/zkv1000/radio/xpdr-mode') == 'STBY') |
|
349 |
return; |
|
350 |
setprop('/instrumentation/transponder/ident', 1); |
|
351 |
me.bindings.PFD.XPDR.ident = maketimer(18, |
|
352 |
func { |
|
353 |
setprop('/instrumentation/transponder/ident', 0); |
|
354 |
me.device.display.updateXPDR(); |
|
355 |
}); |
|
356 |
me.bindings.PFD.XPDR.ident.singleShot = 1; |
|
357 |
me.bindings.PFD.XPDR.ident.start(); |
|
XPDR settings via knob or so...
|
358 |
call(me.bindings.PFD.XPDR.CODE.exit, [], me); |
softkeys are available now
|
359 |
}, |
adds CDI
|
360 |
CDI : func { |
361 |
var list = ['OFF']; |
|
362 |
if (getprop('/instrumentation/gps/route-distance-nm') != nil) |
|
363 |
append(list, 'GPS'); |
|
364 |
if (getprop('/instrumentation/nav/in-range') != nil) |
|
365 |
append(list, 'NAV1'); |
|
366 |
if (getprop('/instrumentation/nav[1]/in-range') != nil) |
|
367 |
append(list, 'NAV2'); |
|
368 |
var index = std.Vector |
|
369 |
.new(list) |
|
370 |
.index(cdi.getNode('source').getValue()); |
|
371 |
var next = (index == size(list) -1) ? 0 : index + 1; |
|
372 |
cdi.getNode('source').setValue(list[next]); |
|
373 |
CDIfromSOURCE(list[next]); |
|
374 |
me.device.display.updateCDI(); |
|
375 |
}, |
|
TMR/REF window
|
376 |
'TMR/REF' : func { |
377 |
if (!contains(me.device.windows.state, 'TMR/REF')) { |
|
TMR/REF available
|
378 |
var Vspeed_visiblity = func (id, selected, Vspeed) |
379 |
me.device.data[Vspeed ~ '-visible'] = |
|
380 |
me.device.windows.state[id].objects[selected].text |
|
381 |
== |
|
382 |
me.device.windows.state[id].objects[selected].choices[0]; |
|
383 |
var GenericTimer = func (id, selected) { |
|
384 |
var action = me.device.windows.state[id].objects[selected].text; |
|
385 |
if (action == 'START?') { |
|
386 |
me.device.data.TMRrevert = 0; |
|
387 |
me.device.data.TMRlast = getprop('/sim/time/elapsed-sec') - 1; |
|
388 |
me.device.data.TMRreset = me.device.windows.state[id].objects[selected - 2].text; |
|
389 |
me.device.data.TMRtimer = maketimer(1, func { |
|
390 |
var (hh, mm, ss) = split(':', |
|
391 |
me.device.windows.state[id].objects[selected - 2].text); |
|
392 |
var direction = -1; |
|
393 |
if ((me.device.windows.state[id].objects[selected - 1].text |
|
394 |
== |
|
395 |
me.device.windows.state[id].objects[selected - 1].choices[0]) |
|
396 |
or me.device.data.TMRrevert) |
|
397 |
direction = 1; |
|
398 |
var now = getprop('/sim/time/elapsed-sec'); |
|
399 |
var dt = int(now - me.device.data.TMRlast) * direction; |
|
400 |
me.device.data.TMRlast = now; |
|
401 |
var val = HMS(hh, mm, ss, dt); |
|
402 |
me.device.windows.state[id].objects[selected - 2].text = val; |
|
403 |
me.device.windows.window[id ~ '-' ~ (selected -2)] |
|
404 |
.setText(val); |
|
405 |
if (val == '00:00:00' and direction == -1) |
|
406 |
me.device.data.TMRrevert = 1; |
|
407 |
}, me); |
|
408 |
me.device.data.TMRtimer.start(); |
|
409 |
action = 'STOP?'; |
|
410 |
} |
|
411 |
elsif (action == 'STOP?') { |
|
412 |
me.device.data.TMRtimer.stop(); |
|
413 |
action = 'RESET?'; |
|
414 |
} |
|
415 |
elsif (action == 'RESET?') { |
|
416 |
action = 'START?'; |
|
417 |
if ((me.device.windows.state[id].objects[selected - 1].text |
|
418 |
== |
|
419 |
me.device.windows.state[id].objects[selected - 1].choices[1]) |
|
420 |
and !me.device.data.TMRrevert) |
|
421 |
var val = me.device.data.TMRreset; |
|
422 |
else |
|
423 |
var val = '00:00:00'; |
|
424 |
me.device.windows.state[id].objects[selected - 2].text = val; |
|
425 |
me.device.windows.window[id ~ '-' ~ (selected -2)] |
|
426 |
.setText(val); |
|
427 |
} |
|
428 |
me.device.windows.window[me.device.windows.selected] |
|
429 |
.setText(action); |
|
430 |
me.device.windows.state[id].objects[selected].text = action; |
|
431 |
}; |
|
TMR/REF window
|
432 |
me.device.windows.draw( |
433 |
'TMR/REF', |
|
434 |
{x: 720, y: 535, w: 300, l: 5, sep: 3}, |
|
TMR/REF window adaptation
|
435 |
[ # objects infos |
TMR/REF window
|
436 |
{text: 'REFERENCES', type: 'title'}, |
437 |
{type: 'separator'}, |
|
438 |
{text: 'TIMER', type: 'normal'}, |
|
439 |
{text: '00:00:00', type: 'selected|time', }, |
|
TMR/REF available
|
440 |
{text: ' UP >', type: 'editable', choices: [' UP >', '<DOWN ']}, |
441 |
{text: 'START?', type: 'editable|end-of-line', callback: func (id, selected) GenericTimer(id, selected)}, |
|
TMR/REF window
|
442 |
{type: 'separator'}, |
TMR/REF available
|
443 |
{text: sprintf('Vx %3iKT', alerts.getNode('Vx').getValue()), type: 'normal', scrollgroup:0}, |
444 |
{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')}, |
|
445 |
{text: sprintf('Vy %3iKT', alerts.getNode('Vy').getValue()), type: 'normal', scrollgroup:1}, |
|
446 |
{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')}, |
|
447 |
{text: sprintf('Vr %3iKT', alerts.getNode('Vr').getValue()), type: 'normal', scrollgroup:2}, |
|
448 |
{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')}, |
|
449 |
{text: sprintf('Vglide %3iKT', alerts.getNode('Vglide').getValue()), type: 'normal', scrollgroup:3}, |
|
450 |
{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
|
451 |
{type: 'separator'}, |
452 |
{text: 'MINIMUMS', type: 'normal'}, |
|
TMR/REF available
|
453 |
{text: ' OFF >', type: 'editable', choices: [' OFF >', '< BARO >','<TEMP COMP'], callback: func}, |
TMR/REF window adaptation
|
454 |
{text: ' 1000FT', type: 'editable', format: '% 5iFT', factor: 100, callback: func}, |
455 |
], |
|
456 |
{ # scrolling info, see menu.nas |
|
457 |
lines : 3, |
|
458 |
columns : 2, |
|
459 |
} |
|
TMR/REF window
|
460 |
); |
461 |
me.device.knobs.FmsInner = me.device.knobs.MenuSettings; |
|
462 |
me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu; |
|
TMR/REF available
|
463 |
me.device.buttons.ENT = me.device.buttons.ValidateTMRREF; |
464 |
me.device.buttons.FMS = me.device.buttons.ValidateTMRREF; |
|
465 |
me.device.buttons.CLR = me.device.buttons.ClearTMRREF; |
|
TMR/REF window
|
466 |
} |
467 |
else { |
|
TMR/REF available
|
468 |
me.device.buttons.ClearTMRREF(); |
TMR/REF window
|
469 |
} |
470 |
}, |
|
softkeys are available now
|
471 |
}, |
472 |
MFD : { |
|
473 |
ENGINE: { |
|
474 |
FUEL: { |
|
475 |
UNDO: func { |
|
476 |
pop(me.path); |
|
477 |
me.device.display.updateSoftKeys(); |
|
478 |
}, |
|
479 |
ENTER: func { |
|
480 |
pop(me.path); |
|
481 |
me.device.display.updateSoftKeys(); |
|
482 |
}, |
|
483 |
}, |
|
484 |
ENGINE: func { |
|
485 |
me.path = []; |
|
486 |
me.device.display.updateSoftKeys(); |
|
487 |
}, |
|
488 |
}, |
|
add missing exit to MFD/CHKL...
|
489 |
CHKLIST : { |
490 |
EXIT: func { |
|
491 |
me.path = []; |
|
492 |
me.device.display.updateSoftKeys(); |
|
493 |
}, |
|
494 |
}, |
|
softkeys are available now
|
495 |
}, |
commit initial
|
496 |
}, |
497 |
}; |
|
massive code reorganisation ...
|
498 | |
499 |
var keyMap = { |
|
500 |
# softkeys map for PFD and MFD {{{ |
|
501 |
PFD : { |
|
502 |
first : 1, |
|
503 |
texts : ['INSET', 'SENSOR', 'PFD', 'OBS', 'CDI', 'DME', 'XPDR', 'IDENT', 'TMR/REF', 'NRST' ], |
|
504 |
INSET : { |
|
505 |
texts : ['OFF', 'DCLTR', 'WXLGND', 'TRAFFIC', 'TOPO', 'TERRAIN', 'STRMSCP', 'NEXRAD-C', 'XM LTNG', 'METAR'], |
|
506 |
}, |
|
507 |
SENSOR : { |
|
508 |
first : 2, |
|
509 |
texts : [ 'ADC1', 'ADC2', '', 'AHRS1', 'AHRS2'], |
|
510 |
}, |
|
511 |
PFD : { |
|
512 |
texts : [ 'SYN VIS', 'DFLTS', 'AOA/WIND', 'DME', 'BRG1', 'HSI FMT', 'BRG2', '', 'ALT UNIT', 'STD BARO' ], |
|
513 |
'SYN VIS' : { |
|
514 |
texts : [ 'PATHWAY', 'SYN TERR', 'HR2NHDG', 'APTSIGNS', 'FPM'], |
|
515 |
}, |
|
516 |
'AOA/WIND' : { |
|
517 |
first : 4, |
|
518 |
texts : ['AOA', 'WIND'], |
|
519 |
AOA : { |
|
520 |
first : 5, |
|
521 |
texts : ['AOA ON', 'AOA AUTO'], |
|
522 |
}, |
|
523 |
WIND : { |
|
524 |
first : 2, |
|
525 |
texts : ['OPTN1', 'OPTN2', '', 'OFF'], |
|
526 |
}, |
|
527 |
}, |
|
528 |
'HSI FMT' : { |
|
529 |
first : 6, |
|
530 |
texts : ['360 HSI', 'ARC HSI'], |
|
531 |
}, |
|
532 |
'ALT UNIT' : { |
|
533 |
first : 5, |
|
534 |
texts : ['METERS', '', 'IN', 'HPA'], |
|
535 |
}, |
|
536 |
}, |
|
537 |
XPDR : { |
|
538 |
first : 2, |
|
539 |
texts : ['STBY', 'ON', 'ALT', '', 'VFR', 'CODE', 'IDENT'], |
|
540 |
CODE : { |
|
541 |
texts : ['0', '1', '2', '3', '4', '5', '6', '7', 'IDENT', 'BKSP'], |
|
542 |
}, |
|
543 |
}, |
|
544 |
}, |
|
545 |
MFD : { |
|
546 |
texts : ['ENGINE', '', 'MAP', '', '', '', '', '', '', 'DCLTR', 'SHW CHRT', 'CHKLIST'], |
|
547 |
MAP : { |
|
548 |
texts: ['TRAFFIC', 'PROFILE', 'TOPO', 'TERRAIN', 'AIRWAYS', 'STRMSCP','NEXRAD-C', 'XM LTNG', 'METAR', 'LEGEND', 'BACK'], |
|
549 |
}, |
|
550 |
CHKLIST : { |
|
551 |
texts : ['ENGINE', '', '', '', '', 'DONE', '', '', '', '', 'EXIT', 'EMERGCY'], |
|
552 |
}, |
|
553 |
ENGINE : { |
|
554 |
texts : ['ENGINE', 'ANTI-ICE', '', 'DCLTR', '', 'ASSIST', '', '', '', '', 'FUEL'], |
|
555 |
'ANTI-ICE' : { |
|
556 |
texts : ['LEFT', 'AUTO', 'RIGHT', '', '', '', '', '', '', '', '', 'BACK'], |
|
557 |
}, |
|
558 |
FUEL : { |
|
559 |
first : 1, |
|
560 |
texts : ['FULL', 'TABS', '', '', '', '', '', '', '', 'UNDO', 'ENTER'], |
|
561 |
}, |
|
562 |
}, |
|
563 |
}, |
|
564 |
}; |
|
565 |
if (data['stall-aoa'] == 9999) |
|
566 |
keyMap.PFD.PFD['AOA/WIND'].texts = ['', 'WIND']; |
|
567 |
#}}} |