commit initial
|
1 |
var buttonsClass = { |
improves role/name variables...
|
2 |
new : func (device) { |
commit initial
|
3 |
var m = { parents: [ buttonsClass ] }; |
improves role/name variables...
|
4 |
m.device = device; |
commit initial
|
5 |
return m; |
6 |
}, |
|
7 | ||
8 |
PAN : func (xdir = 0, ydir = 0) { |
|
9 |
}, |
|
10 | ||
11 |
AsSwitchNAV : func { |
|
remove hardcoded properties ...
|
12 |
var n = radios.getValue('nav-tune'); |
commit initial
|
13 |
var tmp = getprop('/instrumentation/nav[' ~ n ~ ']/frequencies/selected-mhz'); |
14 |
setprop('/instrumentation/nav[' ~ n ~ ']/frequencies/selected-mhz', getprop('/instrumentation/nav[' ~ n ~ ']/frequencies/standby-mhz')); |
|
15 |
setprop('/instrumentation/nav[' ~ n ~ ']/frequencies/standby-mhz', tmp); |
|
creates flightdeck hash to p...
|
16 |
foreach (var c; keys(flightdeck)) |
17 |
if (contains(flightdeck[c], 'display')) |
|
18 |
flightdeck[c].display.updateNAV({refresh: n+1}); |
|
commit initial
|
19 |
}, |
20 | ||
ajout de l'animation des bou...
|
21 |
AsSwitchCOM : func (x) { |
commit initial
|
22 |
if (x) { |
ajout de l'animation des bou...
|
23 |
me.AsSwitchCOM_pushed = getprop('/sim/time/elapsed-sec'); |
commit initial
|
24 |
} |
ajout de l'animation des bou...
|
25 |
else { |
26 |
var pressed = getprop('/sim/time/elapsed-sec') - me.AsSwitchCOM_pushed; |
|
27 |
if (pressed > 2) { |
|
28 |
setprop('/instrumentation/comm/frequencies/selected-mhz', 121.500); |
|
remove hardcoded properties ...
|
29 |
radios.setValue('comm1-selected', 1); |
30 |
radios.setValue('comm2-selected', 0); |
|
fix COMM display standby fre...
|
31 |
foreach (var d; keys(flightdeck)) |
32 |
if (contains(flightdeck[d], 'display')) { |
|
33 |
flightdeck[d].display.updateCOMM({refresh: 1}); |
|
34 |
flightdeck[d].display.updateCOMM({refresh: 2}); |
|
35 |
} |
|
ajout de l'animation des bou...
|
36 |
} |
37 |
else { |
|
remove hardcoded properties ...
|
38 |
var c = radios.getValue('comm-tune'); |
ajout de l'animation des bou...
|
39 |
var tmp = getprop('/instrumentation/comm[' ~ c ~ ']/frequencies/selected-mhz'); |
40 |
setprop('/instrumentation/comm[' ~ c ~ ']/frequencies/selected-mhz', getprop('/instrumentation/comm[' ~ c ~ ']/frequencies/standby-mhz')); |
|
41 |
setprop('/instrumentation/comm[' ~ c ~ ']/frequencies/standby-mhz', tmp); |
|
fix COMM display standby fre...
|
42 |
foreach (var d; keys(flightdeck)) |
43 |
if (contains(flightdeck[d], 'display')) |
|
44 |
flightdeck[d].display.updateCOMM({refresh: c+1}); |
|
ajout de l'animation des bou...
|
45 |
} |
commit initial
|
46 |
} |
47 |
}, |
|
48 | ||
ajout de l'animation des bou...
|
49 |
ALT : func () { |
50 |
var alt = getprop('instrumentation/altimeter/indicated-altitude-ft'); |
|
remove hardcoded properties ...
|
51 |
afcs.setIntValue('selected-alt-ft', math.round(alt, 10)); |
commit initial
|
52 |
}, |
53 | ||
TMR/REF available
|
54 |
ValidateTMRREF : func (a = 0) { |
55 |
if (a) |
|
56 |
return; |
|
57 |
var (id, selected) = split('-', me.device.windows.selected); |
|
58 |
var state = me.device.windows.state[id]; |
|
59 |
selected += state.scroll.offset; |
|
60 |
if (contains(state.objects[selected], 'callback')) |
|
61 |
call(state.objects[selected].callback, [id, selected], me); |
|
62 |
}, |
|
63 | ||
64 |
ClearTMRREF : func (a = 0) { |
|
65 |
if (a) |
|
66 |
return; |
|
67 |
me.device.windows.del(); |
|
68 |
me.device.data.TMRtimer = nil; |
|
69 |
me.device.knobs.FmsInner = func; |
|
70 |
me.device.knobs.FmsOuter = func; |
|
71 |
me.device.buttons.ENT = func; |
|
72 |
me.device.buttons.FMS = func; |
|
73 |
me.device.buttons.CLR = func; |
|
74 |
}, |
|
75 | ||
fix MFD page selection syste...
|
76 |
MFD_page_wrapper : func (id, selected) { |
77 |
var s = me.device.data[id][me.device.display['page selected']]; |
|
78 |
var group = s.name; |
|
79 |
var subpage = s.objects[selected].text; |
|
80 | ||
81 |
foreach (var k; keys(me.device.windows.window)) |
|
allows only implemented MFD ...
|
82 |
if (find(id, k) == 0) { |
83 |
me.device.windows.del(id); |
|
84 |
break; |
|
85 |
} |
|
86 |
call(me.device.display.MFD[group][subpage], [], me); |
|
fix MFD page selection syste...
|
87 |
}, |
88 | ||
massive code reorganisation ...
|
89 |
MapMenu : func (a = 0) { |
90 |
if (a == 1) |
|
91 |
return; |
|
92 |
var menu_label = 'MAP MENU'; |
|
93 |
if (!contains(me.device.windows.window, menu_label ~ '-bg')) { |
|
94 |
var level_min = 13; |
|
95 |
var level_max = 7; |
|
96 |
var levels = [ sprintf(' % 2u >', level_max) ]; |
|
97 |
for (var i = level_max + 1; i <= level_min; i += 1) |
|
98 |
append(levels, sprintf(i < level_min ? '< % 2u >' : '< % 2u ', i)); |
|
99 |
var orientation = [ ' NORTH UP >', '< TRK UP >' ]; |
|
100 |
if (getprop('/instrumentation/gps/route-distance-nm') != nil) |
|
101 |
append(orientation, '< DTK UP >'); |
|
102 |
append(orientation, '< HDG UP '); |
|
103 |
me.device.windows.draw( |
|
104 |
menu_label, |
|
105 |
{x: 720, y: 100, w: 300, l:3, sep: 1}, |
|
106 |
[ |
|
107 |
{text: menu_label, type: 'title'}, |
|
108 |
{type: 'separator'}, |
|
109 |
{text: 'ZOOM LEVEL', type: 'normal'}, |
|
110 |
{text: sprintf('%s % 2u %s', |
|
111 |
me.device.data.zoom > level_max ? '<' : ' ', |
|
112 |
me.device.data.zoom, |
|
113 |
me.device.data.zoom < level_min ? '>' : ' '), |
|
114 |
type: 'selected|end-of-line', |
|
115 |
choices: levels, |
|
116 |
callback: func (id, selected) { |
|
117 |
var z = me.device.windows.state[id].objects[selected].text; |
|
118 |
foreach (var c; [' ', '<', '>']) |
|
119 |
z = string.replace(z, c, ''); |
|
120 |
me.device.data.zoom = z; |
|
121 |
me.device.map.changeZoom(); |
|
122 |
me.device.map.update(); |
|
123 |
} |
|
124 |
}, |
|
125 |
{text: 'ORIENTATION', type: 'normal'}, |
|
126 |
{text: (func foreach (var o; orientation) if (find(me.device.data.orientation.text, o) > -1) return o;)(), |
|
127 |
type: 'editable|end-of-line', |
|
128 |
choices: orientation, |
|
129 |
callback: func (id, selected) { |
|
130 |
var o = me.device.windows.state[id].objects[selected].text; |
|
131 |
o = substr(o, 2); |
|
132 |
o = substr(o, 0, size(o) - 2); |
|
133 |
o = string.trim(o); |
|
134 |
me.device.data.orientation.text = o; |
|
135 |
me.device.map.update(); |
|
136 |
} |
|
137 |
}, |
|
138 |
] |
|
139 |
); |
|
140 |
me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu; |
|
141 |
me.device.knobs.FmsInner = me.device.knobs.MenuSettings; |
|
142 |
me.device.buttons.CLR = me.device.buttons.MapMenu; |
|
143 |
me.device.buttons.ENT = me.device.buttons.ValidateTMRREF; |
|
144 |
} |
|
145 |
else { |
|
146 |
me.device.buttons.ENT = func; |
|
147 |
me.device.buttons.CLR = func; |
|
148 |
me.device.knobs.FmsInner = func; |
|
149 |
me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group; |
|
150 |
me.device.windows.del(menu_label); |
|
151 |
} |
|
152 |
}, |
|
153 | ||
add brightness and lights co...
|
154 |
GlobalParams: func (a) { |
155 |
if (a == 1) |
|
156 |
return; |
|
157 |
var windowId = 'GLOBAL SETTINGS'; |
|
158 |
var obj_infos = [ |
|
159 |
{text: 'DISPLAY', type: 'title'}, |
|
160 |
{type: 'separator'}, |
|
161 |
{text: 'Brightness: ', type: 'normal'}, |
|
creates settings management
|
162 |
{text: sprintf( '% 3u %%', zkv.getValue('display-brightness-norm') * 100 / 0.7), |
add brightness and lights co...
|
163 |
type: 'selected immediate end-of-line', |
creates settings management
|
164 |
format: ' % 3u %% ', |
add brightness and lights co...
|
165 |
range: {max: 100, min: 0}, |
166 |
callback: func (id, selected) { |
|
167 |
var b = num(string.trim(me.device.windows.state[id].objects[selected].text, 0, func (c) c == `%` or c == ` `)); |
|
168 |
zkv.setDoubleValue('display-brightness-norm', b * 0.7 / 100); |
|
169 |
}, |
|
170 |
}, |
|
creates settings management
|
171 |
{text: 'Light : ', type: 'normal'}, |
add brightness and lights co...
|
172 |
{text: ' 0 >', |
173 |
type: 'editable|immediate|end-of-line', |
|
creates settings management
|
174 |
choices: [' 0 >', '< 1 >', '< 2 >', '< 3 '], |
add brightness and lights co...
|
175 |
callback: func (id, selected) { |
creates settings management
|
176 |
var l = num(string.trim(me.device.windows.state[id].objects[selected].text, 0, func (c) c == ` ` or c == `<` or c == `>`)); |
177 |
zkv.setDoubleValue('lightmap', l * 3); |
|
add brightness and lights co...
|
178 |
} |
creates settings management
|
179 |
}, |
180 |
{text: 'UNITS', type: 'title'}, |
|
181 |
{type: 'separator'}, |
|
182 |
{text: 'Pressure :', type: 'normal'}, |
|
settings now have effect
|
183 |
{text: data.settings.units.pressure == 'inhg' ? ' inHg >' : '< hPa ', |
creates settings management
|
184 |
type: 'editable|end-of-line', |
185 |
choices: [ ' inHg >', '< hPa '], |
|
186 |
callback: func (id, selected) { |
|
187 |
var u = string.trim(me.device.windows.state[id].objects[selected].text, 0, func (c) c == ` ` or c == `<` or c == `>`); |
|
188 |
if (u == 'inHg') |
|
189 |
data.settings.units.pressure = 'inhg'; |
|
190 |
else |
|
191 |
data.settings.units.pressure = 'hpa'; |
|
settings now have effect
|
192 |
me.device.display.updateBARO(); |
creates settings management
|
193 |
} |
194 |
}, |
|
195 |
{text: 'Altitude :', type: 'normal'}, |
|
settings now have effect
|
196 |
{text: units.altitude.from_ft == 1 ? ' feet >' : '< meters ', |
creates settings management
|
197 |
type: 'editable|end-of-line', |
198 |
choices: [ ' feet >', '< meters ' ], |
|
199 |
callback: func (id, selected) { |
|
200 |
var u = string.trim(me.device.windows.state[id].objects[selected].text, 0, func (c) c == ` ` or c == `<` or c == `>`); |
|
settings now have effect
|
201 |
if (u == 'feet') { |
creates settings management
|
202 |
data.settings.units.altitude = 'ft'; |
settings now have effect
|
203 |
units.altitude.from_ft = 1; |
204 |
units.altitude.from_m = M2FT; |
|
205 |
} |
|
206 |
else { |
|
creates settings management
|
207 |
data.settings.units.altitude = 'm'; |
settings now have effect
|
208 |
units.altitude.from_ft = FT2M; |
209 |
units.altitude.from_m = 1; |
|
210 |
} |
|
211 |
} |
|
212 |
}, |
|
213 |
{text: 'Distance :', type: 'normal'}, |
|
214 |
{text: units.distance.from_nm == 1 ? ' NM >' : '< km ', |
|
215 |
type: 'editable|end-of-line', |
|
216 |
choices: [' NM >', '< km '], |
|
217 |
callback: func (id, selected) { |
|
218 |
var u = string.trim(me.device.windows.state[id].objects[selected].text, 0, func (c) c == ` ` or c == `<` or c == `>`); |
|
219 |
if (u == 'NM') { |
|
220 |
data.settings.units.distance = 'nm'; |
|
221 |
units.distance.from_nm = 1; |
|
222 |
units.distance.from_m = M2NM * 1000; |
|
223 |
} |
|
224 |
else { |
|
225 |
data.settings.units.distance = 'km'; |
|
226 |
units.distance.from_nm = NM2M / 1000; |
|
227 |
units.distance.from_m = 0.001; |
|
228 |
} |
|
creates settings management
|
229 |
} |
230 |
}, |
|
231 |
{text: 'Speed :', type: 'normal'}, |
|
settings now have effect
|
232 |
{text: units.speed.from_kt == 1 ? ' knots >' : '< km/h ', |
creates settings management
|
233 |
type: 'editable|end-of-line', |
234 |
choices: [ ' knots >', '< km/h ' ], |
|
235 |
callback: func (id, selected) { |
|
236 |
var u = string.trim(me.device.windows.state[id].objects[selected].text, 0, func (c) c == ` ` or c == `<` or c == `>`); |
|
settings now have effect
|
237 |
if (u == 'knots') { |
creates settings management
|
238 |
data.settings.units.altitude = 'kt'; |
settings now have effect
|
239 |
units.speed.from_kt = 1; |
240 |
units.speed.from_kmh = MPS2KT / 3.6; |
|
241 |
} |
|
242 |
else { |
|
creates settings management
|
243 |
data.settings.units.altitude = 'kmh'; |
settings now have effect
|
244 |
units.speed.from_kt = KT2MPS * 3.6; |
245 |
units.speed.from_kmh = 1; |
|
246 |
} |
|
247 |
foreach (var v; ['Vx', 'Vy', 'Vr', 'Vglide', 'Vne']) { |
|
248 |
var speed = alerts.getValue(v) * units.speed.from_kt; |
|
249 |
data[v] = speed != nil ? speed : 9999; |
|
250 |
} |
|
creates settings management
|
251 |
} |
252 |
}, |
|
253 |
{text: 'Vert. Spd :', type: 'normal'}, |
|
settings now have effect
|
254 |
{text: units.vspeed.from_fpm == 1 ? ' ft/min >' : '< m/min ', |
creates settings management
|
255 |
type: 'editable|end-of-line', |
256 |
choices: [ ' ft/min >', '< m/min ' ], |
|
257 |
callback: func (id, selected) { |
|
258 |
var u = string.trim(me.device.windows.state[id].objects[selected].text, 0, func (c) c == ` ` or c == `<` or c == `>`); |
|
settings now have effect
|
259 |
if (u == 'ft/min') { |
creates settings management
|
260 |
data.settings.units.altitude = 'fpm'; |
settings now have effect
|
261 |
units.vspeed.from_fpm = 1; |
262 |
units.vspeed.from_mpm = M2FT; |
|
263 |
} |
|
264 |
else { |
|
creates settings management
|
265 |
data.settings.units.altitude = 'mpm'; |
settings now have effect
|
266 |
units.vspeed.from_fpm = FT2M; |
267 |
units.vspeed.from_mpm = 1; |
|
268 |
} |
|
creates settings management
|
269 |
} |
270 |
}, |
|
adds time display setting
|
271 |
{type: 'separator'}, |
272 |
{text: 'TIME REF: ', type: 'normal'}, |
|
273 |
{text: data.settings.time.actual, |
|
274 |
type: 'editable|end-of-line', |
|
275 |
choices: [ ' GMT >', '< LCL >', '< UTC >', '< RL ' ], |
|
276 |
callback: func (id, selected) { |
|
277 |
data.settings.time.actual = me.device.windows.state[id].objects[selected].text; |
|
278 |
data.settings.time.label = string.trim(me.device.windows.state[id].objects[selected].text, 0, func (c) c == ` ` or c == `<` or c == `>`); |
|
279 |
} |
|
280 |
}, |
|
add brightness and lights co...
|
281 |
]; |
creates settings management
|
282 |
me.device.windows.draw( windowId, {autogeom: 1}, obj_infos); |
add brightness and lights co...
|
283 |
me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu; |
284 |
me.device.knobs.FmsInner = me.device.knobs.MenuSettings; |
|
creates settings management
|
285 |
me.device.buttons.ENT = me.device.buttons.ValidateTMRREF; |
add brightness and lights co...
|
286 |
me.device.buttons.CLR = func { |
287 |
me.device.windows.del(windowId); |
|
288 |
me.device.knobs.FmsOuter = func; |
|
289 |
me.device.knobs.FmsInner = func; |
|
290 |
foreach (var b; ['ENT', 'CLR']) |
|
291 |
me.device.buttons[b] = func; |
|
292 |
me.device.buttons.MENU = me.device.buttons.GlobalParams; |
|
293 |
} |
|
294 |
me.device.buttons.MENU = me.device.buttons.CLR; |
|
295 |
}, |
|
296 | ||
handle DTO button
|
297 |
DirectTo : func (a) { |
298 |
if (a) return; |
|
299 |
if (me.device.windows.selected == nil) return; |
|
300 |
var (id, selected) = split('-', me.device.windows.selected); |
|
301 |
var state = me.device.windows.state[id]; |
|
302 |
selected += state.scroll.offset; |
|
303 |
var scratch = props.globals.getNode('/instrumentation/gps/scratch'); |
|
304 |
if (contains(state.objects[selected], 'dto')) { |
|
305 |
scratch.setValue('longitude-deg', state.objects[selected].dto.lon); |
|
306 |
scratch.setValue('latitude-deg', state.objects[selected].dto.lat); |
|
307 |
scratch.setValue('ident', state.objects[selected].dto.id); |
|
308 |
scratch.setValue('altitude-ft', data.alt); |
|
309 |
setprop('/instrumentation/gps/command', 'direct'); |
|
310 |
} |
|
311 |
}, |
|
312 | ||
adds FPL button
|
313 |
FPL : func (a) { |
314 |
if (a or data.fpSize == 0 or me.device.windows.selected != '') |
|
315 |
return; |
|
316 |
var windowId = 'FLIGHTPLAN LIST'; |
|
317 |
var flightplan = props.globals.getNode('/autopilot/route-manager'); |
|
318 |
var route = flightplan.getNode('route'); |
|
319 |
var obj_infos = []; |
|
320 |
var firstEntry = 1; |
|
321 |
var current = flightplan.getValue('current-wp'); |
|
322 |
for (var i = current; i <= data.fpSize; i += 1) { |
|
323 |
var wp = route.getChild('wp', i); |
|
324 |
append(obj_infos, { |
|
325 |
type: (firstEntry ? 'selected' : 'editable'), |
|
326 |
text: sprintf('#%2d %-10s', data.fpSize - i, wp.getValue('id')), |
|
327 |
scrollgroup: i - current, |
|
328 |
dto: { |
|
329 |
lon: wp.getValue('lon'), |
|
330 |
lat: wp.getValue('lat'), |
|
331 |
id: wp.getValue('id') |
|
332 |
}, |
|
333 |
}); |
|
334 |
append(obj_infos, { |
|
335 |
type: 'normal|end-of-line', |
|
336 |
scrollgroup: i - current, |
|
337 |
text: sprintf(' %3dNM %3d°', |
|
338 |
math.round(wp.getValue('leg-distance-nm')), |
|
339 |
math.round(wp.getValue('leg-bearing-true-deg'))) |
|
340 |
}); |
|
341 |
firstEntry = 0; |
|
342 |
} |
|
343 |
me.device.windows.draw(windowId, obj_infos, {lines: 6, columns: 2}); |
|
344 |
me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu; |
|
345 |
me.device.knobs.FmsInner = me.device.knobs.NavigateMenu; |
|
346 |
me.device.buttons.ENT = func; |
|
347 |
me.device.buttons.MENU = func; |
|
348 |
me.device.buttons.CLR = func { |
|
349 |
me.device.windows.del(windowId); |
|
350 |
if (me.device.role == 'PFD') { |
|
351 |
me.device.knobs.FmsOuter = func; |
|
352 |
me.device.knobs.FmsInner = func; |
|
353 |
me.device.buttons.MENU = me.device.buttons.GlobalParams; |
|
354 |
} |
|
355 |
else { |
|
356 |
me.device.knobs.FmsInner = func; |
|
357 |
me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group; |
|
358 |
me.device.buttons.MENU = me.device.buttons.MapMenu; |
|
359 |
} |
|
360 |
foreach (var b; ['ENT', 'CLR']) |
|
361 |
me.device.buttons[b] = func; |
|
362 |
} |
|
363 |
me.device.buttons.MENU = me.device.buttons.CLR; |
|
364 |
}, |
|
365 | ||
commit initial
|
366 |
MENU : void, |
367 |
PROC : void, |
|
368 |
CLR : void, |
|
369 |
ENT : void, |
|
370 |
FMS : void, |
|
371 |
}; |