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