just moves some code in more...
|
1 |
# vim: set foldmethod=marker foldmarker={{{,}}} : |
fix MFD page selection syste...
|
2 |
displayClass.MFD = { |
adds MFD menu for Aux/System...
|
3 |
AUX: { |
add flight planning menu
|
4 |
'TRIP PLANNING' : func { |
5 |
me.device.buttons.CLR = func { |
|
6 |
me.device.buttons.CLR = func; |
|
7 |
fgcommand('dialog-close', { 'dialog-name' : 'route-manager' }); |
|
8 |
fgcommand('dialog-close', { 'dialog-name' : 'map' }); |
|
9 |
}; |
|
10 |
fgcommand('dialog-show', { 'dialog-name' : 'map' }); |
|
11 |
fgcommand('dialog-show', { 'dialog-name' : 'route-manager' }); |
|
12 |
}, |
|
adds MFD menu for Aux/System...
|
13 |
'SYSTEM SETUP' : func { |
14 |
var obj_infos = [ |
|
15 |
{text: 'NAV BOX DATA FIELDS', type: 'title'}, |
|
16 |
{type: 'separator'}, |
|
17 |
{text: 'DATA FIELD NUMBER', type: 'normal'}, |
|
18 |
{text: ' 1 >', type: 'selected|end-of-line', choices: [' 1 >', '< 2 >', '< 3 >', '< 4 ']}, |
|
19 |
]; |
|
navigation box content
|
20 |
foreach (var item; keys(me.device.display.navbox)) { |
21 |
if (item == 'LEG') # LEG only displayed on PFD navigation box |
|
22 |
continue; |
|
adds MFD menu for Aux/System...
|
23 |
append(obj_infos, { |
navigation box content
|
24 |
text: sprintf('%-3s ', item), |
25 |
type: 'editable', |
|
adds MFD menu for Aux/System...
|
26 |
callback: func (id, selected) { |
improve MFD system settings ...
|
27 |
var field = string.trim(me.device.windows.state[id].objects[3].text, |
28 |
0, |
|
29 |
func (c) c == `<` or c == `>` or c == ` `); |
|
adds MFD menu for Aux/System...
|
30 |
me.device.display.screenElements['DATA-FIELD' ~ field ~ '-ID-text'] |
improve MFD system settings ...
|
31 |
.setText(string.trim(me.device.windows.state[id].objects[selected].text, 1)); |
adds MFD menu for Aux/System...
|
32 |
} |
33 |
}); |
|
navigation box content
|
34 |
append(obj_infos, { |
35 |
text: sprintf('(%s)', me.device.display.navbox[item][1]), |
|
36 |
type: 'normal|end-of-line', |
|
37 |
}); |
|
adds MFD menu for Aux/System...
|
38 |
} |
39 |
var windowId = 'SYSTEM SETUP'; |
|
make use of new window drawi...
|
40 |
me.device.windows.draw( windowId, obj_infos ); |
adds MFD menu for Aux/System...
|
41 |
me.device.buttons.CLR = func { |
42 |
me.device.windows.del(windowId); |
|
43 |
me.device.buttons.ENT = func; |
|
44 |
me.device.buttons.CLR = func; |
|
45 |
me.device.knobs.FmsInner = func; |
|
46 |
me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group; |
|
47 |
} |
|
48 |
me.device.knobs.FmsInner = me.device.knobs.MenuSettings; |
|
49 |
me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu; |
|
50 |
me.device.buttons.ENT = me.device.buttons.ValidateTMRREF; |
|
fix MFD page selection syste...
|
51 |
}, |
52 |
}, |
|
add flightplan display
|
53 |
FPL : { |
54 |
'ACTIVE FLIGHT PLAN' : func { |
|
55 |
me.device.windows.del(id); |
|
56 |
var flightplan = props.globals.getNode('/autopilot/route-manager'); |
|
57 |
var route = flightplan.getNode('route'); |
|
58 |
var obj_infos = [ |
|
59 |
{text: 'ACTIVE FLIGTHPLAN', type: 'title'}, |
|
60 |
{type: 'separator'}, |
|
61 |
]; |
|
62 |
if (route.getValue('num')) { |
|
63 |
append(obj_infos, {text: sprintf('DEP: %s', flightplan.getNode('departure').getValue('airport')), type: 'normal|end-of-line'}); |
|
64 |
append(obj_infos, {text: sprintf('ARR: %s', flightplan.getNode('destination').getValue('airport')), type: 'normal|end-of-line'}); |
|
65 |
append(obj_infos, {text: sprintf('DIS: %dnm', flightplan.getValue('total-distance')), type: 'normal|end-of-line'}); |
|
66 |
append(obj_infos, {type: 'separator'}); |
|
67 |
var current_wp = flightplan.getValue('current-wp'); |
|
68 |
var firstEntry = 1; |
|
69 |
for (var n = 1; n < route.getValue('num'); n += 1) { |
|
70 |
var wp = route.getChild('wp', n); |
|
71 |
append(obj_infos, {text: sprintf('%1s %-7s %3d° %3dnm %s', |
|
72 |
n == current_wp ? utf8.chstr(9658) : ' ', |
|
73 |
wp.getValue('id'), |
|
74 |
math.round(wp.getValue('leg-bearing-true-deg')), |
|
75 |
math.round(wp.getValue('leg-distance-nm')), |
|
76 |
wp.getValue('altitude-ft') > -100 ? ' ' ~ wp.getValue('altitude-ft') ~ 'ft': '' |
|
77 |
), |
|
78 |
type: (firstEntry ? 'selected' : 'editable') ~ '|end-of-line', |
|
79 |
scrollgroup: n |
|
80 |
}); |
|
81 |
firstEntry = 0; |
|
82 |
} |
|
83 |
append(obj_infos, {type: 'separator'}); |
|
84 |
} |
|
85 |
else { |
|
86 |
append(obj_infos, {text: 'NO FP LOADED', type: 'normal|end-of-line'}); |
|
87 |
} |
|
88 |
var windowId = 'ACTIVE FLIGTH PLAN'; |
|
89 |
me.device.windows.draw( windowId, obj_infos, {lines: 6, columns: 1} ); |
|
90 |
me.device.buttons.CLR = func { |
|
91 |
me.device.windows.del(windowId); |
|
92 |
me.device.buttons.ENT = func; |
|
93 |
me.device.buttons.CLR = func; |
|
94 |
me.device.knobs.FmsInner = func; |
|
95 |
me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group; |
|
96 |
} |
|
97 |
me.device.knobs.FmsInner = me.device.knobs.NavigateMenu; |
|
98 |
me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu; |
|
99 |
}, |
|
100 |
}, |
|
add MFD pages for nearest ai...
|
101 |
NRST : { |
102 |
'NEAREST AIRPORTS': func { |
|
103 |
var airports = findAirportsWithinRange(99.99); |
|
104 |
var obj_infos = [ |
|
105 |
{text: size(airports) ~ ' NEAREST AIRPORTS', type: 'title'}, |
|
106 |
{type: 'separator'}, |
|
107 |
]; |
|
108 |
var name_max_length = 0; |
|
109 |
forindex (var idx; airports) { |
|
110 |
var info = airportinfo(airports[idx].id); |
|
111 |
var (course, distance) = courseAndDistance(info); |
|
112 |
var name = sprintf('%s (%s)', airports[idx].id, airports[idx].name); |
|
113 |
if (size(name) > name_max_length) |
|
114 |
name_max_length = size(name); |
|
115 | ||
116 |
append(obj_infos, { |
|
117 |
text: name, |
|
118 |
type: (idx ? 'editable' : 'selected') ~ '|immediate|end-of-line', |
|
119 |
scrollgroup: idx, |
|
120 |
} |
|
121 |
); |
|
122 |
append(obj_infos, { |
|
fix bad distance display for...
|
123 |
text: sprintf(' %s DST %2dNM CRS %03d', utf8.chstr(9658), distance, course), |
add MFD pages for nearest ai...
|
124 |
type: 'normal|end-of-line', |
125 |
scrollgroup: idx |
|
126 |
} |
|
127 |
); |
|
128 |
} |
|
129 |
append(obj_infos, {type: 'separator'}); |
|
130 |
var windowId = 'NEAREST AIRPORTS'; |
|
make use of new window drawi...
|
131 |
me.device.windows.draw( windowId, obj_infos, {lines: 4, columns: 1} ); |
add MFD pages for nearest ai...
|
132 |
me.device.buttons.CLR = func { |
133 |
me.device.windows.del(windowId); |
|
134 |
me.device.buttons.ENT = func; |
|
135 |
me.device.buttons.CLR = func; |
|
136 |
me.device.knobs.FmsInner = func; |
|
137 |
me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group; |
|
138 |
} |
|
139 |
me.device.knobs.FmsInner = me.device.knobs.NavigateMenu; |
|
140 |
me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu; |
|
141 |
me.device.buttons.ENT = func (a = 0) { |
|
142 |
if (a) return; |
|
143 |
me.device.windows.del(windowId); |
|
144 |
var (_, selected) = split('-', me.device.windows.selected); |
|
145 |
var (airport_id, _) = split(" ", obj_infos[selected].text); |
|
146 |
call(me.device.display.MFD._ShowAirportInfo, [airport_id], me); |
|
147 |
}; |
|
148 |
}, |
|
149 |
'NEAREST INTERSECTIONS': func { |
|
150 |
call(me.device.display.MFD._NearestNavaids, ['fix'], me); |
|
151 |
}, |
|
152 |
'NEAREST NDB': func { |
|
153 |
call(me.device.display.MFD._NearestNavaids, ['ndb'], me); |
|
154 |
}, |
|
155 |
'NEAREST VOR': func { |
|
156 |
call(me.device.display.MFD._NearestNavaids, ['vor'], me); |
|
157 |
}, |
|
158 |
}, |
|
159 |
_NearestNavaids: func (navaid_type) { |
|
160 |
var navaids = findNavaidsWithinRange(99.99, navaid_type); |
|
161 |
var obj_infos = [ |
|
162 |
{text: size(navaids) ~ ' NEAREST ' ~ string.uc(navaid_type), type: 'title'}, |
|
163 |
{type: 'separator'}, |
|
164 |
]; |
|
165 |
var idx = 0; |
|
166 |
foreach (var navaid; navaids) { |
|
167 |
var (course, distance) = courseAndDistance(navaid); |
|
168 |
var name = navaid.id ~ ' (' ~ navaid.name ~ ')'; |
|
169 | ||
170 |
append(obj_infos, { |
|
171 |
text: navaid.id ~ ' (' ~ navaid.name ~ ')', |
|
172 |
type: (idx ? 'editable' : 'selected') ~ '|immediate|end-of-line', |
|
173 |
scrollgroup: idx, |
|
174 |
} |
|
175 |
); |
|
176 |
append(obj_infos, { |
|
177 |
text: sprintf(' %s DST %2dNM CRS %03d', utf8.chstr(9658), distance, course), |
|
178 |
type: 'normal|end-of-line', |
|
179 |
scrollgroup: idx |
|
180 |
} |
|
181 |
); |
|
182 |
idx += 1; |
|
183 |
} |
|
184 |
append(obj_infos, {type: 'separator'}); |
|
185 |
var windowId = obj_infos[0].text; |
|
make use of new window drawi...
|
186 |
me.device.windows.draw( windowId, obj_infos, {lines: 4, columns: 1} ); |
add MFD pages for nearest ai...
|
187 |
me.device.buttons.CLR = func { |
188 |
me.device.windows.del(windowId); |
|
189 |
me.device.buttons.ENT = func; |
|
190 |
me.device.buttons.CLR = func; |
|
191 |
me.device.knobs.FmsInner = func; |
|
192 |
me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group; |
|
193 |
} |
|
194 |
me.device.knobs.FmsInner = me.device.knobs.NavigateMenu; |
|
195 |
me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu; |
|
196 |
me.device.buttons.ENT = func (a = 0) { |
|
197 |
if (a) return; |
|
198 |
me.device.windows.del(windowId); |
|
199 |
var (_, selected) = split('-', me.device.windows.selected); |
|
200 |
var (navaid_id, _) = split(" ", obj_infos[selected].text); |
|
201 |
if (navaid_type == 'airport') |
|
202 |
call(me.device.display.MFD._ShowAirportInfo, [navaid_id], me); |
|
203 |
else |
|
204 |
call(me.device.display.MFD._ShowNavaidInfo, [navaid_id, navaid_type], me); |
|
205 |
}; |
|
206 |
}, |
|
207 |
_ShowNavaidInfo: func (navaid_id, navaid_type) { |
|
208 |
var info = findNavaidsByID(navaid_id, navaid_type); |
|
209 |
if (size(info) == 0) return; |
|
210 |
me.device.knobs.FmsInner = func; |
|
211 |
me.device.knobs.FmsOuter = func; |
|
212 |
me.device.buttons.ENT = func; |
|
213 |
print(typeof(info[0])); |
|
214 |
var obj_infos = [ |
|
215 |
{text: info[0].id ~ ' INFORMATION', type: 'title'}, |
|
216 |
{type: 'separator'}, |
|
217 |
{text: 'ID ' ~ info[0].id, type: 'normal|end-of-line'}, |
|
218 |
{text: 'NAME ' ~ info[0].name, type: 'normal|end-of-line'}, |
|
219 |
{text: 'TYPE ' ~ info[0].type, type: 'normal|end-of-line'}, |
|
220 |
{text: sprintf('LON %.3f %s', abs(info[0].lon), info[0].lon > 0 ? 'E' : 'W'), type: 'normal|end-of-line'}, |
|
221 |
{text: sprintf('LAT %.3f %s', abs(info[0].lat), info[0].lat > 0 ? 'N' : 'S'), type: 'normal|end-of-line'}, |
|
222 |
]; |
|
223 |
call(func {return info[0].range }, [], nil, nil, var errors = []); |
|
224 |
if (!size(errors)) |
|
225 |
append(obj_infos, {text: sprintf('RANGE %i NM', info[0].range * 1.852), type: 'normal|end-of-line'}); |
|
226 |
call(func {return info[0].frequency }, [], nil, nil, var errors = []); |
|
227 |
if (!size(errors)) |
|
228 |
append(obj_infos, {text: sprintf('FREQ %.2f kHz', info[0].frequency / 100), type: 'normal|end-of-line'}); |
|
229 |
var lines = size(obj_infos); |
|
230 |
var windowId = 'NAVAID INFORMATIONS'; |
|
make use of new window drawi...
|
231 |
me.device.windows.draw( windowId, obj_infos ); |
add MFD pages for nearest ai...
|
232 |
me.device.buttons.CLR = func { |
233 |
me.device.windows.del(windowId); |
|
234 |
me.device.buttons.ENT = func; |
|
235 |
me.device.buttons.CLR = func; |
|
236 |
me.device.knobs.FmsInner = func; |
|
237 |
me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group; |
|
238 |
} |
|
239 |
}, |
|
240 |
_ShowAirportInfo: func (airport_id) { |
|
241 |
me.device.knobs.FmsInner = func; |
|
242 |
me.device.knobs.FmsOuter = func; |
|
243 |
me.device.buttons.ENT = func; |
|
244 |
var info = airportinfo(airport_id); |
|
245 |
var obj_infos = [ |
|
246 |
{text: airport_id ~ ' INFORMATION', type: 'title'}, |
|
247 |
{type: 'separator'}, |
|
248 |
{text: sprintf('ELEVATION %.0d FT', info.elevation * 3.28), type: 'normal|end-of-line'}, |
|
249 |
{text: sprintf('LON: %.3f %s', abs(info.lon), info.lon > 0 ? 'E' : 'W'), type: 'normal|end-of-line'}, |
|
250 |
{text: sprintf('LAT: %.3f %s', abs(info.lat), info.lat > 0 ? 'N' : 'S'), type: 'normal|end-of-line'}, |
|
251 |
{type: 'separator'}, |
|
252 |
{text: 'RUNWAYS', type: 'title'}, |
|
253 |
]; |
|
254 |
foreach (var rwy; sort(keys(info.runways), string.icmp)) { |
|
255 |
var rwyInfo = sprintf("%-3s %4.0dm %3.0d°", |
|
256 |
rwy, |
|
257 |
info.runways[rwy].length, |
|
258 |
info.runways[rwy].heading); |
|
259 |
if (info.runways[rwy].ils != nil) { |
|
260 |
rwyInfo = sprintf("%s %3.3f Mhz", rwyInfo, info.runways[rwy].ils.frequency / 100); |
|
261 |
} |
|
262 |
append(obj_infos, {text: rwyInfo, type: 'normal|end-of-line'}); |
|
263 |
} |
|
264 |
var sep = 2; # to count separators, already two printed |
|
265 |
if (size(info.comms()) > 0) { |
|
266 |
# TODO: find nearby freqs if none found for airport |
|
267 |
append(obj_infos, {type: 'separator'}); sep += 1; |
|
make use of new window drawi...
|
268 |
append(obj_infos, {text: 'COMMS FREQUENCIES', type: 'title'}); |
add MFD pages for nearest ai...
|
269 |
var freqs = {}; |
270 |
var comms = info.comms(); |
|
271 |
foreach (var c; comms) |
|
272 |
freqs[c.ident] = sprintf("%.3f", c.frequency); |
|
273 | ||
274 |
foreach (var f; sort(keys(freqs), string.icmp)) |
|
275 |
append(obj_infos, {text: sprintf('%-15s %.3f', f, freqs[f]), type: 'normal|end-of-line'}); |
|
276 |
} |
|
277 |
var lines = size(obj_infos) - sep; # minus the separators |
|
278 |
var windowId = 'AIRPORT INFORMATIONS'; |
|
make use of new window drawi...
|
279 |
me.device.windows.draw( windowId, obj_infos ); |
add MFD pages for nearest ai...
|
280 |
me.device.buttons.CLR = func { |
281 |
me.device.windows.del(windowId); |
|
282 |
me.device.buttons.ENT = func; |
|
283 |
me.device.buttons.CLR = func; |
|
284 |
me.device.knobs.FmsInner = func; |
|
285 |
me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group; |
|
286 |
} |
|
287 |
}, |
|
fix MFD page selection syste...
|
288 |
}; |
289 | ||
290 |
displayClass.setMFDPages = func { |
|
just moves some code in more...
|
291 |
me.device.data['page selection'] = [ |
292 |
# list of pages, by group {{{ |
|
293 |
{ |
|
294 |
name: 'MAP', |
|
295 |
objects: [ |
|
296 |
{text: 'NAVIGATION MAP'}, |
|
297 |
{text: 'TRAFFIC MAP'}, |
|
298 |
{text: 'STORMSCOPE'}, |
|
299 |
{text: 'WEATHER DATA LINK'}, |
|
300 |
{text: 'TAWS-B'}, |
|
301 |
], |
|
302 |
}, |
|
303 |
{ |
|
304 |
name: 'WPT', |
|
305 |
objects: [ |
|
306 |
{text: 'AIRPORT INFORMATION'}, |
|
307 |
{text: 'AIRPORT DIRECTORY'}, |
|
308 |
{text: 'DEPARTURE INFORMATION'}, |
|
309 |
{text: 'ARRIVAL INFORMATION'}, |
|
310 |
{text: 'APPROACH INFORMATION'}, |
|
311 |
{text: 'WEATHER INFORMATION'}, |
|
312 |
{text: 'INTERSECTION INFORMATION'}, |
|
313 |
{text: 'NDB INFORMATION'}, |
|
314 |
{text: 'VOR INFORMATION'}, |
|
315 |
{text: 'USER WAYPOINT INFORMATION'}, |
|
316 |
], |
|
317 |
}, |
|
318 |
{ |
|
319 |
name: 'AUX', |
|
320 |
objects: [ |
|
321 |
{text: 'TRIP PLANNING'}, |
|
322 |
{text: 'UTILITY'}, |
|
323 |
{text: 'GPS STATUS'}, |
|
324 |
{text: 'SYSTEM SETUP'}, |
|
325 |
], |
|
326 |
}, |
|
327 |
{ |
|
328 |
name: 'FPL', |
|
329 |
objects: [ |
|
330 |
{text: 'ACTIVE FLIGHT PLAN'}, |
|
331 |
{text: 'WIDE VIEW, NARROW VIEW'}, |
|
332 |
{text: 'FLIGHT PLAN CATALOG'}, |
|
333 |
], |
|
334 |
}, |
|
335 |
{ |
|
336 |
name: 'PROC', |
|
337 |
objects: [ |
|
338 |
{text: 'DEPARTURE LOADING'}, |
|
339 |
{text: 'ARRIVAL LOADING'}, |
|
340 |
{text: 'APPROACH LOADING'}, |
|
341 |
], |
|
342 |
}, |
|
343 |
{ |
|
344 |
name: 'NRST', |
|
345 |
objects: [ |
|
346 |
{text: 'NEAREST AIRPORTS'}, |
|
347 |
{text: 'NEAREST INTERSECTIONS'}, |
|
348 |
{text: 'NEAREST NDB'}, |
|
349 |
{text: 'NEAREST VOR'}, |
|
350 |
{text: 'NEAREST USER WAYPOINTS'}, |
|
351 |
{text: 'NEAREST FREQUENCIES'}, |
|
352 |
{text: 'NEAREST AIRSPACES'}, |
|
353 |
], |
|
354 |
}, |
|
355 |
# }}} |
|
356 |
]; |
|
357 | ||
fix MFD page selection syste...
|
358 |
foreach (var g; me.device.data['page selection']) { |
359 |
var obj_s = size(g.objects); |
|
360 |
# build specific geometry per page, depending of number of sub-pages |
|
361 |
g.geometry = {x: 720, y: 758 - ((obj_s + 3) * 24), w: 300, l: obj_s + 1, sep: 1}; |
|
362 |
# complete the hash with reccurrent elements type and callback |
|
allows only implemented MFD ...
|
363 |
var firstEntry = 1; |
fix MFD page selection syste...
|
364 |
foreach (var o; g.objects) { |
allows only implemented MFD ...
|
365 |
if (contains(me.MFD, g.name) and contains(me.MFD[g.name], o.text)) { |
366 |
o.type = firstEntry ? 'selected' : 'editable'; |
|
367 |
o.type ~= '|end-of-line'; |
|
368 |
o.callback = me.device.buttons.MFD_page_wrapper; |
|
make first menu item selecte...
|
369 |
firstEntry = 0; |
allows only implemented MFD ...
|
370 |
} |
371 |
else |
|
372 |
o.type = 'normal|end-of-line'; |
|
fix MFD page selection syste...
|
373 |
} |
374 |
} |
|
375 |
# build the available groups line, at the bottom |
|
376 |
forindex (var g; me.device.data['page selection']) { |
|
377 |
append(me.device.data['page selection'][g].objects, {type: 'separator'}); |
|
378 |
for (var i = 0; i < g; i+=1) |
|
379 |
append(me.device.data['page selection'][g].objects, |
|
380 |
{text: me.device.data['page selection'][i].name, type: 'normal'}); |
|
381 |
append(me.device.data['page selection'][g].objects, |
|
382 |
{text: me.device.data['page selection'][i].name, type: 'highlighted'}); |
|
383 |
for (var i = g+1; i < size(me.device.data['page selection']); i+=1) |
|
384 |
append(me.device.data['page selection'][g].objects, |
|
385 |
{text: me.device.data['page selection'][i].name, type: 'normal'}); |
|
386 |
} |
|
387 |
me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group; |
|
388 |
}; |