commit initial
|
1 |
var softkeysClass = { |
softkeys are available now
|
2 |
new : func (device, node, role) { |
commit initial
|
3 |
var m = { parents: [ softkeysClass ] }; |
4 |
m.node = node; |
|
softkeys are available now
|
5 |
m.device = device; |
commit initial
|
6 |
m.role = role; |
softkeys are available now
|
7 |
m.path = []; |
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 | ||
20 |
var path = keyMap[me.role]; |
|
21 |
foreach(var p; me.path) { |
|
22 |
if (contains(path, p)) |
|
23 |
path = path[p]; |
|
24 |
else |
|
25 |
break; |
|
commit initial
|
26 |
} |
27 | ||
softkeys are available now
|
28 |
var bindings = me.bindings[me.role]; |
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 { |
|
61 |
pop(me.path); |
|
62 |
me.device.display.updateSoftKeys(); |
|
63 |
}, |
|
64 |
}, |
|
65 |
PFD: { |
|
adds OAT, TAS, GSPD, WindDat...
|
66 |
'AOA/WIND' : { |
67 |
WIND : { |
|
68 |
OPTN1 : func { |
|
69 |
me.device.display._winddata_optn = 1; |
|
70 |
me.device.display.screenElements['WindData'].show(); |
|
71 |
me.device.display.screenElements['WindData-OPTN1'].show(); |
|
72 |
me.device.display.screenElements['WindData-OPTN1-HDG'].show(); |
|
73 |
me.device.display.screenElements['WindData-OPTN2'].hide(); |
|
74 |
me.device.display.updateWindData(); |
|
75 |
}, |
|
76 |
OPTN2 : func { |
|
77 |
me.device.display._winddata_optn = 2; |
|
78 |
me.device.display.screenElements['WindData'].show(); |
|
79 |
me.device.display.screenElements['WindData-OPTN1'].hide(); |
|
80 |
me.device.display.screenElements['WindData-OPTN2'].show(); |
|
81 |
me.device.display.screenElements['WindData-OPTN2-symbol'].show(); |
|
82 |
me.device.display.screenElements['WindData-OPTN2-headwind'].show(); |
|
83 |
me.device.display.screenElements['WindData-OPTN2-crosswind'].show(); |
|
84 |
me.device.display.updateWindData(); |
|
85 |
}, |
|
86 |
OFF : func { |
|
87 |
me.device.display._winddata_optn = 0; |
|
88 |
me.device.display.screenElements['WindData'].hide(); |
|
89 |
me.device.display.screenElements['WindData-OPTN1'].hide(); |
|
90 |
me.device.display.screenElements['WindData-OPTN2'].hide(); |
|
91 |
}, |
|
92 |
}, |
|
93 |
}, |
|
adds BRG1/2 animation
|
94 |
BRG1 : func (brg = 1){ |
95 |
var source = 'brg' ~ brg ~ '-source'; |
|
96 |
var list = ['NAV' ~ brg, 'GPS', 'ADF', 'OFF']; |
|
97 |
var index = std.Vector |
|
98 |
.new(list) |
|
99 |
.index(radios.getNode(source).getValue()); |
|
100 |
var next = (index == size(list) -1) ? 0 : index + 1; |
|
101 |
radios.getNode(source).setValue(list[next]); |
|
102 |
}, |
|
103 |
BRG2 : func { |
|
104 |
call(me.bindings.PFD.PFD.BRG1, [ 2 ], me); |
|
105 |
}, |
|
adds BARO settings
|
106 |
'STD BARO' : func { |
107 |
setprop('/instrumentation/altimeter/setting-inhg', 29.92); |
|
108 |
me.device.display.updateBARO(); |
|
109 |
pop(me.path); |
|
110 |
me.device.display.updateSoftKeys(); |
|
111 |
}, |
|
112 |
IN : func { |
|
113 |
me.device.display._baro_unit = 'inhg'; |
|
114 |
me.device.display.updateBARO(); |
|
115 |
}, |
|
116 |
HPA : func { |
|
117 |
me.device.display._baro_unit = 'hpa'; |
|
118 |
me.device.display.updateBARO(); |
|
119 |
}, |
|
softkeys are available now
|
120 |
}, |
121 |
XPDR: { |
|
adds transponder
|
122 |
STBY : func { |
123 |
setprop('/instrumentation/transponder/ident', 0); |
|
124 |
setprop('/instrumentation/transponder/knob-mode', 1); |
|
125 |
setprop('/instrumentation/zkv1000/radio/xpdr-mode', 'STBY'); |
|
126 |
me.device.display.updateXPDR(); |
|
127 |
}, |
|
128 |
ON : func { |
|
129 |
setprop('/instrumentation/transponder/ident', 1); |
|
130 |
setprop('/instrumentation/transponder/knob-mode', 4); |
|
131 |
setprop('/instrumentation/zkv1000/radio/xpdr-mode', 'ON'); |
|
132 |
me.device.display.updateXPDR(); |
|
133 |
}, |
|
134 |
ALT : func { |
|
135 |
setprop('/instrumentation/transponder/ident', 1); |
|
136 |
setprop('/instrumentation/transponder/knob-mode', 5); |
|
137 |
setprop('/instrumentation/zkv1000/radio/xpdr-mode', 'ALT'); |
|
138 |
me.device.display.updateXPDR(); |
|
139 |
}, |
|
140 |
VFR : func { |
|
141 |
setprop('/instrumentation/transponder/id-code', '1200'); |
|
142 |
me.device.display.updateXPDR(); |
|
143 |
}, |
|
144 |
IDENT : func { |
|
145 |
call(me.bindings.PFD.IDENT, [], me); |
|
146 |
}, |
|
147 |
CODE : { |
|
148 |
'0' : func (n = 0) { |
|
Softkeys revert to the previ...
|
149 |
me.bindings.PFD.XPDR.CODE.inactivity.restart(me.device.display.softkeys_inactivity_delay); |
150 |
me.device.display.timers2.softkeys_inactivity.restart(me.device.display.softkeys_inactivity_delay); |
|
adds transponder
|
151 |
var tuning = radios.getNode('xpdr-tuning-digit'); |
152 |
var d = tuning.getValue(); |
|
153 |
setprop('/instrumentation/transponder/inputs/digit[' ~ d ~ ']', n); |
|
154 |
d += (d > 0) ? -1 : 3; |
|
155 |
tuning.setValue(d); |
|
156 |
me.device.display.updateXPDR(); |
|
157 |
}, |
|
158 |
'1' : func { |
|
159 |
call(me.bindings.PFD.XPDR.CODE['0'], [ 1 ], me); |
|
160 |
}, |
|
161 |
'2' : func { |
|
162 |
call(me.bindings.PFD.XPDR.CODE['0'], [ 2 ], me); |
|
163 |
}, |
|
164 |
'3' : func { |
|
165 |
call(me.bindings.PFD.XPDR.CODE['0'], [ 3 ], me); |
|
166 |
}, |
|
167 |
'4' : func { |
|
168 |
call(me.bindings.PFD.XPDR.CODE['0'], [ 4 ], me); |
|
169 |
}, |
|
170 |
'5' : func { |
|
171 |
call(me.bindings.PFD.XPDR.CODE['0'], [ 5 ], me); |
|
172 |
}, |
|
173 |
'6' : func { |
|
174 |
call(me.bindings.PFD.XPDR.CODE['0'], [ 6 ], me); |
|
175 |
}, |
|
176 |
'7' : func { |
|
177 |
call(me.bindings.PFD.XPDR.CODE['0'], [ 7 ], me); |
|
178 |
}, |
|
softkeys are available now
|
179 |
IDENT: func { |
Softkeys revert to the previ...
|
180 |
me.bindings.PFD.XPDR.CODE.inactivity.restart(me.device.display.softkeys_inactivity_delay); |
181 |
me.device.display.timers2.softkeys_inactivity.restart(me.device.display.softkeys_inactivity_delay); |
|
adds transponder
|
182 |
call(me.bindings.PFD.IDENT, [], me); |
183 |
}, |
|
184 |
BKSP: func { |
|
Softkeys revert to the previ...
|
185 |
me.bindings.PFD.XPDR.CODE.inactivity.restart(me.device.display.softkeys_inactivity_delay); |
186 |
me.device.display.timers2.softkeys_inactivity.restart(me.device.display.softkeys_inactivity_delay); |
|
adds transponder
|
187 |
var tuning = radios.getNode('xpdr-tuning-digit'); |
188 |
var d = tuning.getValue(); |
|
189 |
d += (d < 3) ? 1 : -3; |
|
190 |
tuning.setValue(d); |
|
191 |
me.device.display.updateXPDR(); |
|
softkeys are available now
|
192 |
}, |
adds transponder
|
193 |
BACK : func (inactive = 0) { |
194 |
var code = sprintf('%i', getprop('/instrumentation/zkv1000/radios/xpdr-backup-code')); |
|
195 |
for (var i = 0; i < 4; i += 1) |
|
196 |
setprop('/instrumentation/transponder/inputs/digit[' ~ (3 - i) ~ ']', |
|
197 |
substr(code, i, 1)); |
|
198 |
pop(me.path); |
|
199 |
call(me.bindings.PFD.XPDR.CODE.exit, inactive ? [[]] : [me.path], me); |
|
200 |
}, |
|
201 |
exit : func (p) { |
|
Softkeys revert to the previ...
|
202 |
if (contains(me.bindings.PFD.XPDR.CODE, 'inactivity')) # does not exists if IDENT pressed from top-level |
203 |
me.bindings.PFD.XPDR.CODE.inactivity.stop(); |
|
adds transponder
|
204 |
radios.removeChild('xpdr-tuning-digit', 0); |
205 |
radios.removeChild('xpdr-backup-code', 0); |
|
206 |
me.path = p; |
|
207 |
me.device.display.updateXPDR(); |
|
softkeys are available now
|
208 |
me.device.display.updateSoftKeys(); |
209 |
}, |
|
adds transponder
|
210 |
hook : func { |
Softkeys revert to the previ...
|
211 |
# this level has its own timer as we may need to revert changes |
212 |
me.bindings.PFD.XPDR.CODE.inactivity = maketimer( |
|
213 |
me.device.display.softkeys_inactivity_delay, |
|
214 |
func call(me.bindings.PFD.XPDR.CODE.BACK, [1], me)); |
|
215 |
me.bindings.PFD.XPDR.CODE.inactivity.singleShot = 1; |
|
216 |
me.bindings.PFD.XPDR.CODE.inactivity.start(); |
|
adds transponder
|
217 |
var tuning = getprop('/instrument/zkv1000/radios/xpdr-tuning-digit'); |
218 |
if (tuning == nil) { |
|
219 |
radios.getNode('xpdr-tuning-digit', 1).setValue(3); |
|
220 |
radios.getNode('xpdr-backup-code', 1).setValue(getprop('/instrumentation/transponder/id-code')); |
|
221 |
me.device.display.updateXPDR(); |
|
222 |
} |
|
223 |
}, |
|
softkeys are available now
|
224 |
}, |
adds transponder
|
225 |
}, |
226 |
IDENT : func { |
|
227 |
if (getprop('/instrumentation/zkv1000/radio/xpdr-mode') == 'STBY') |
|
228 |
return; |
|
229 |
setprop('/instrumentation/transponder/ident', 1); |
|
230 |
me.bindings.PFD.XPDR.ident = maketimer(18, |
|
231 |
func { |
|
232 |
setprop('/instrumentation/transponder/ident', 0); |
|
233 |
me.device.display.updateXPDR(); |
|
234 |
}); |
|
235 |
me.bindings.PFD.XPDR.ident.singleShot = 1; |
|
236 |
me.bindings.PFD.XPDR.ident.start(); |
|
237 |
call(me.bindings.PFD.XPDR.CODE.exit, [[]], me); |
|
softkeys are available now
|
238 |
}, |
adds CDI
|
239 |
CDI : func { |
240 |
var list = ['OFF']; |
|
241 |
if (getprop('/instrumentation/gps/route-distance-nm') != nil) |
|
242 |
append(list, 'GPS'); |
|
243 |
if (getprop('/instrumentation/nav/in-range') != nil) |
|
244 |
append(list, 'NAV1'); |
|
245 |
if (getprop('/instrumentation/nav[1]/in-range') != nil) |
|
246 |
append(list, 'NAV2'); |
|
247 |
var index = std.Vector |
|
248 |
.new(list) |
|
249 |
.index(cdi.getNode('source').getValue()); |
|
250 |
var next = (index == size(list) -1) ? 0 : index + 1; |
|
251 |
cdi.getNode('source').setValue(list[next]); |
|
252 |
CDIfromSOURCE(list[next]); |
|
253 |
me.device.display.updateCDI(); |
|
254 |
}, |
|
softkeys are available now
|
255 |
}, |
256 |
MFD : { |
|
257 |
ENGINE: { |
|
258 |
FUEL: { |
|
259 |
UNDO: func { |
|
260 |
pop(me.path); |
|
261 |
me.device.display.updateSoftKeys(); |
|
262 |
}, |
|
263 |
ENTER: func { |
|
264 |
pop(me.path); |
|
265 |
me.device.display.updateSoftKeys(); |
|
266 |
}, |
|
267 |
}, |
|
268 |
ENGINE: func { |
|
269 |
me.path = []; |
|
270 |
me.device.display.updateSoftKeys(); |
|
271 |
}, |
|
272 |
}, |
|
add missing exit to MFD/CHKL...
|
273 |
CHKLIST : { |
274 |
EXIT: func { |
|
275 |
me.path = []; |
|
276 |
me.device.display.updateSoftKeys(); |
|
277 |
}, |
|
278 |
}, |
|
softkeys are available now
|
279 |
}, |
commit initial
|
280 |
}, |
281 |
}; |