... | ... |
@@ -178,5 +178,10 @@ var powerOn = func { |
178 | 178 |
# thread.newthread(func { |
179 | 179 |
flightdeck[name] = deviceClass.new(name); |
180 | 180 |
# }); |
181 |
- settimer(setListeners, 5); |
|
181 |
+ |
|
182 |
+ if (! contains(data.timers, 'listeners')) { |
|
183 |
+ data.timers.listeners = maketimer(5, setListeners); |
|
184 |
+ data.timers.listeners.singleShot = 1; |
|
185 |
+ data.timers.listeners.start(); |
|
186 |
+ } |
|
182 | 187 |
} |
... | ... |
@@ -22,6 +22,7 @@ var displayClass = { |
22 | 22 |
.createGroup() |
23 | 23 |
.show(); |
24 | 24 |
|
25 |
+ m.timers = {}; |
|
25 | 26 |
m.timers2 = {}; # tho old timer implementation use already a named timer hash |
26 | 27 |
# Softkeys revert to the previous level after 45 seconds of inactivity. |
27 | 28 |
m.softkeys_inactivity_delay = 45; |
... | ... |
@@ -213,18 +214,27 @@ var displayClass = { |
213 | 214 |
}, |
214 | 215 |
#}}} |
215 | 216 |
|
216 |
-# timers stuff {{{ |
|
217 |
- timers : {}, |
|
217 |
+ off: func { |
|
218 |
+ foreach(var timer; keys(me.timers2)) { |
|
219 |
+ me.timers2[timer].stop(); |
|
220 |
+ delete(me.timers2, timer); |
|
221 |
+ } |
|
222 |
+ me.screen.del(); |
|
223 |
+ me.display.del(); |
|
224 |
+ }, |
|
225 |
+ |
|
226 |
+# temporary Widget Display for HDG and CRS modification {{{ |
|
227 |
+ |
|
228 |
+ temporaryWidgetDisplay : {}, |
|
218 | 229 |
|
219 | 230 |
timerTrigger : func { |
220 | 231 |
var now = systime(); |
221 |
- foreach (var id; keys(me.timers)) { |
|
222 |
- if (me.timers[id] < now) { |
|
232 |
+ foreach (var id; keys(me.temporaryWidgetDisplay)) { |
|
233 |
+ if (me.temporaryWidgetDisplay[id] < now) { |
|
223 | 234 |
me.screenElements[id].hide(); |
224 |
- delete(me.timers, id); |
|
235 |
+ delete(me.temporaryWidgetDisplay, id); |
|
225 | 236 |
} |
226 | 237 |
} |
227 |
- settimer(func me.timerTrigger(), 1); |
|
228 | 238 |
}, |
229 | 239 |
|
230 | 240 |
addTimer : func (duration, element) { |
... | ... |
@@ -232,26 +242,27 @@ var displayClass = { |
232 | 242 |
element = [ element ]; |
233 | 243 |
var end = systime() + duration; |
234 | 244 |
foreach (var e; element) |
235 |
- me.timers[e] = end; |
|
245 |
+ me.temporaryWidgetDisplay[e] = end; |
|
236 | 246 |
}, |
237 | 247 |
#}}} |
238 | 248 |
|
239 | 249 |
showInitProgress : func { |
240 | 250 |
#{{{ |
241 | 251 |
if (me.device.role == 'PFD') { |
242 |
- me.updateAI(); |
|
243 |
- me.updateVSI(); |
|
244 |
- me.updateIAS(); |
|
245 |
- me.updateALT(); |
|
246 |
- me.updateHSI(); |
|
247 |
- me.updateTIME(); |
|
248 |
- me.updateOAT(); |
|
249 |
- me.updateTAS(); |
|
250 |
- me.updateBRG(); |
|
251 |
- me.updateXPDR(); |
|
252 |
- me.updateBARO(); |
|
253 |
- me.updateOMI(); |
|
254 |
- me.timerTrigger(); |
|
252 |
+ me.timers.updateAI = maketimer(0.1, me, me.updateAI ); |
|
253 |
+ me.timers.updateVSI = maketimer(0.1, me, me.updateVSI ); |
|
254 |
+ me.timers.updateIAS = maketimer(0.1, me, me.updateIAS ); |
|
255 |
+ me.timers.updateALT = maketimer(0.2, me, me.updateALT ); |
|
256 |
+ me.timers.updateHSI = maketimer(0.2, me, me.updateHSI ); |
|
257 |
+ me.timers.updateTIME = maketimer(1.0, me, me.updateTIME ); |
|
258 |
+ me.timers.updateOAT = maketimer(3.0, me, me.updateOAT ); |
|
259 |
+ me.timers.updateTAS = maketimer(0.5, me, me.updateTAS ); |
|
260 |
+ me.timers.updateBRG = maketimer(0.5, me, me.updateBRG ); |
|
261 |
+ me.timers.updateXPDR = maketimer(0, me, me.updateXPDR ); me.timers.updateXPDR.singleShot=1; |
|
262 |
+ me.timers.updateBARO = maketimer(0, me, me.updateBARO ); me.timers.updateBARO.singleShot=1; |
|
263 |
+ me.timers.updateOMI = maketimer(1.0, me, me.updateOMI ); |
|
264 |
+ me.timers.timerTrigger = maketimer(1.0, me, me.timerTrigger ); |
|
265 |
+ |
|
255 | 266 |
me.screen.show(); |
256 | 267 |
me.device.buttons.MENU = me.device.buttons.GlobalParams; |
257 | 268 |
} |
... | ... |
@@ -267,7 +278,10 @@ var displayClass = { |
267 | 278 |
me.updateCOMM({auto:'comm', tune: radios.getNode('comm-tune').getValue()}); |
268 | 279 |
me.softkeys_inactivity(); |
269 | 280 |
me.updateSoftKeys(); |
270 |
- me.updateNavigationBox(); |
|
281 |
+ me.timers.updateNavigationBox = maketimer(me.device.role == 'MFD' ? 0.6 : 0.3, me, me.updateNavigationBox); |
|
282 |
+ |
|
283 |
+ foreach (var timer; keys(me.timers)) |
|
284 |
+ me.timers[timer].start(); |
|
271 | 285 |
}, |
272 | 286 |
#}}} |
273 | 287 |
|
... | ... |
@@ -432,6 +446,7 @@ var displayClass = { |
432 | 446 |
|
433 | 447 |
updateNavigationBox : func (getDataFields = 0) { |
434 | 448 |
# update Navigation Box on MFD and PFD header {{{ |
449 |
+ var enroute = getprop('/autopilot/route-manager/current-wp') > -1; |
|
435 | 450 |
var route = me.device.map.layers.route; |
436 | 451 |
var fpSize = size(route.flightPlan); |
437 | 452 |
var navbox = { |
... | ... |
@@ -477,23 +492,19 @@ var displayClass = { |
477 | 492 |
if (getDataFields) |
478 | 493 |
return keys(navbox); |
479 | 494 |
if (me.device.role == 'MFD') { |
480 |
- var enroute = getprop('/autopilot/route-manager/current-wp') > -1; |
|
481 | 495 |
for (var i=1; i<=4; i+=1) |
482 | 496 |
me.screenElements['DATA-FIELD' ~ i ~ '-VAL-text'] |
483 | 497 |
.setVisible(enroute) |
484 | 498 |
.setText( |
485 | 499 |
navbox[me.screenElements['DATA-FIELD' ~ i ~ '-ID-text'].setVisible(enroute).get('text')]() |
486 | 500 |
); |
487 |
- settimer(func me.updateNavigationBox(), 0.6); |
|
488 | 501 |
} |
489 | 502 |
else { # PFD |
490 |
- var enroute = getprop('/autopilot/route-manager/current-wp') > -1; |
|
491 | 503 |
me.screenElements['ETE'].setVisible(enroute); |
492 | 504 |
me.screenElements['DIS'].setVisible(enroute); |
493 | 505 |
me.screenElements['ETE-text'].setVisible(enroute).setText(navbox.ETE()); |
494 | 506 |
me.screenElements['DIS-text'].setVisible(enroute).setText(navbox.DIS()); |
495 | 507 |
me.screenElements['LEG-text'].setVisible(enroute).setText(navbox.LEG()); |
496 |
- settimer(func me.updateNavigationBox(), 0.3); |
|
497 | 508 |
} |
498 | 509 |
}, |
499 | 510 |
#}}} |
... | ... |
@@ -576,7 +587,6 @@ var displayClass = { |
576 | 587 |
.setTranslation(getprop("/instrumentation/slip-skid-ball/indicated-slip-skid") * 10, 0); |
577 | 588 |
me.screenElements['Traffic'] |
578 | 589 |
.setVisible(size(data.tcas)); |
579 |
- settimer(func me.updateAI(), 0.1); |
|
580 | 590 |
}, |
581 | 591 |
#}}} |
582 | 592 |
|
... | ... |
@@ -591,7 +601,6 @@ var displayClass = { |
591 | 601 |
vsi = -4500; |
592 | 602 |
me.screenElements.VSI |
593 | 603 |
.setTranslation(0, vsi * -0.03465); |
594 |
- settimer(func me.updateVSI(), 0.1); |
|
595 | 604 |
}, |
596 | 605 |
#}}} |
597 | 606 |
|
... | ... |
@@ -644,7 +653,6 @@ var displayClass = { |
644 | 653 |
.setTranslation(0, -284.5 * (Sy - 1)); |
645 | 654 |
me._last_ias_kt = ias; |
646 | 655 |
me._last_ias_s = now; |
647 |
- settimer(func me.updateIAS(), 0.1); |
|
648 | 656 |
}, |
649 | 657 |
_last_ias_kt : 0, |
650 | 658 |
_last_ias_s : systime(), |
... | ... |
@@ -658,7 +666,6 @@ var displayClass = { |
658 | 666 |
.setText(sprintf('%iKT', getprop('/instrumentation/airspeed-indicator/true-speed-kt'))); |
659 | 667 |
me.screenElements['GSPD-text'] |
660 | 668 |
.setText(sprintf('%iKT', getprop('/velocities/groundspeed-kt'))); |
661 |
- settimer(func me.updateTAS(), 0.5); |
|
662 | 669 |
}, |
663 | 670 |
#}}} |
664 | 671 |
|
... | ... |
@@ -818,7 +825,6 @@ var displayClass = { |
818 | 825 |
.setTranslation(0, -284.5 * (Sy - 1)); |
819 | 826 |
me._last_alt_ft = alt; |
820 | 827 |
me._last_alt_s = now; |
821 |
- settimer(func me.updateALT(), 0.2); |
|
822 | 828 |
}, |
823 | 829 |
_last_alt_ft : 0, |
824 | 830 |
_last_alt_Sy : [0,0,0,0,0,0,0,0,0,0], |
... | ... |
@@ -844,7 +850,6 @@ var displayClass = { |
844 | 850 |
.setRotation(-hdg * D2R); |
845 | 851 |
me.screenElements['HDG-text'] |
846 | 852 |
.setText(sprintf("%03u°", hdg)); |
847 |
- settimer(func me.updateHSI(), 0.1); |
|
848 | 853 |
}, |
849 | 854 |
#}}} |
850 | 855 |
|
... | ... |
@@ -1079,7 +1084,6 @@ var displayClass = { |
1079 | 1084 |
# updates the displayed time botoom left {{{ |
1080 | 1085 |
me.screenElements['TIME-text'] |
1081 | 1086 |
.setText(getprop('/sim/time/gmt-string')); |
1082 |
- settimer(func me.updateTIME(), 1); |
|
1083 | 1087 |
}, |
1084 | 1088 |
#}}} |
1085 | 1089 |
|
... | ... |
@@ -1125,7 +1129,6 @@ var displayClass = { |
1125 | 1129 |
var tmp = getprop('/environment/temperature-deg' ~ me._oat_unit); |
1126 | 1130 |
me.screenElements['OAT-text'] |
1127 | 1131 |
.setText(sprintf((abs(tmp) < 10) ? "%.1f %s" : "%i %s", tmp, (me._oat_unit == 'c') ? '°C' : 'F')); |
1128 |
- settimer(func me.updateOAT(), 3); |
|
1129 | 1132 |
}, |
1130 | 1133 |
_oat_unit : 'c', |
1131 | 1134 |
#}}} |
... | ... |
@@ -1278,7 +1281,6 @@ var displayClass = { |
1278 | 1281 |
.hide(); |
1279 | 1282 |
} |
1280 | 1283 |
} |
1281 |
- settimer(func me.updateBRG(), 0.5); |
|
1282 | 1284 |
}, |
1283 | 1285 |
#}}} |
1284 | 1286 |
|
... | ... |
@@ -1303,7 +1305,6 @@ var displayClass = { |
1303 | 1305 |
else |
1304 | 1306 |
me.screenElements['OMI'] |
1305 | 1307 |
.hide(); |
1306 |
- settimer(func me.updateOMI(), 1); |
|
1307 | 1308 |
}, |
1308 | 1309 |
_omi_data : { |
1309 | 1310 |
'outer': {t: 'O', bg: [0,1,1]}, |
... | ... |
@@ -86,6 +86,7 @@ Please report bug at <zkv1000@seb.lautre.net>. |
86 | 86 |
* angle of attack display (not sure about calculation): specific for each airplane (see Installation instructions below) |
87 | 87 |
* Bearing needs some checks to be sure it shows the correct information |
88 | 88 |
* XPDR: emergency code depending of the country (eg.: 1200 for US, 7700 for Europe), should be set in settings |
89 |
+ * use of [maketimer()](http://wiki.flightgear.org/Nasal_library#maketimer.28.29) instead of [settimer()](http://wiki.flightgear.org/Nasal_library#settimer.28.29) when possible |
|
89 | 90 |
* ![][80%] |
90 | 91 |
* route displayed on map: legs ![][done], current and next leg ![][done], TOC/TOD ![][ongoing], OBS ![][ongoing] |
91 | 92 |
* ![][70%] |
... | ... |
@@ -96,7 +97,6 @@ Please report bug at <zkv1000@seb.lautre.net>. |
96 | 97 |
* ![][50%] |
97 | 98 |
* EIS: animations for temperature for YaSim and JSBSim |
98 | 99 |
* ![][40%] |
99 |
- * use of [maketimer()](http://wiki.flightgear.org/Nasal_library#maketimer.28.29) instead of [settimer()](http://wiki.flightgear.org/Nasal_library#settimer.28.29) when possible |
|
100 | 100 |
* ![][30%] |
101 | 101 |
* ![][20%] |
102 | 102 |
* ![][10%] |