Showing 3 changed files with 37 additions and 18 deletions
+22
Nasal/display.nas
... ...
@@ -19,6 +19,10 @@ var displayClass = {
19 19
         m.device = device;
20 20
         m.screenElements = {};
21 21
 
22
+        m.timers2 = {}; # tho old timer implementation use already a named timer hash
23
+        # Softkeys revert to the previous level after 45 seconds of inactivity.
24
+        m.softkeys_inactivity_delay = 45;
25
+
22 26
         if (role == 'MFD') {
23 27
             m.MFDMapTiles = MapTiles.new(m.display);
24 28
             m.MFDMapNavDisplay = MapNavDisplay.new(m.display);
... ...
@@ -206,6 +210,7 @@ var displayClass = {
206 210
             }
207 211
             me._updateRadio({auto:'nav'});
208 212
             me._updateRadio({auto:'comm'});
213
+            me.softkeys_inactivity();
209 214
             me.updateSoftKeys();
210 215
             me.progress.removeAllChildren();
211 216
             me.progress = nil;
... ...
@@ -363,6 +368,18 @@ var displayClass = {
363 368
     },
364 369
 #}}}
365 370
 
371
+    softkeys_inactivity : func {
372
+# automagically back to previous level after some delay {{{
373
+        me.timers2.softkeys_inactivity = maketimer (
374
+            me.softkeys_inactivity_delay,
375
+            func {
376
+                pop(me.device.softkeys.path);
377
+                me.updateSoftKeys();
378
+            }, me);
379
+        me.timers2.softkeys_inactivity.singleShot = 1;
380
+    },
381
+#}}}
382
+
366 383
     updateSoftKeys : func {
367 384
 # update SoftKeys boxes {{{
368 385
         # grey background code = #353939
... ...
@@ -399,6 +416,11 @@ var displayClass = {
399 416
                 me.screenElements[sprintf("SoftKey%02i-text", k)]
400 417
                     .setText('');
401 418
         }
419
+
420
+        if (size(me.device.softkeys.path))
421
+            me.timers2.softkeys_inactivity.restart(me.softkeys_inactivity_delay);
422
+        else
423
+            me.timers2.softkeys_inactivity.stop();
402 424
     },
403 425
 #}}}
404 426
 
+14 -17
Nasal/softkeys.nas
... ...
@@ -120,38 +120,34 @@ var softkeysClass = {
120 120
             },
121 121
             XPDR: {
122 122
                 STBY : func {
123
-                    me.bindings.PFD.XPDR.inactivity.restart(45);
124 123
                     setprop('/instrumentation/transponder/ident', 0);
125 124
                     setprop('/instrumentation/transponder/knob-mode', 1);
126 125
                     setprop('/instrumentation/zkv1000/radio/xpdr-mode', 'STBY');
127 126
                     me.device.display.updateXPDR();
128 127
                 },
129 128
                 ON : func {
130
-                    me.bindings.PFD.XPDR.inactivity.restart(45);
131 129
                     setprop('/instrumentation/transponder/ident', 1);
132 130
                     setprop('/instrumentation/transponder/knob-mode', 4);
133 131
                     setprop('/instrumentation/zkv1000/radio/xpdr-mode', 'ON');
134 132
                     me.device.display.updateXPDR();
135 133
                 },
136 134
                 ALT : func {
137
-                    me.bindings.PFD.XPDR.inactivity.restart(45);
138 135
                     setprop('/instrumentation/transponder/ident', 1);
139 136
                     setprop('/instrumentation/transponder/knob-mode', 5);
140 137
                     setprop('/instrumentation/zkv1000/radio/xpdr-mode', 'ALT');
141 138
                     me.device.display.updateXPDR();
142 139
                 },
143 140
                 VFR : func {
144
-                    me.bindings.PFD.XPDR.inactivity.restart(45);
145 141
                     setprop('/instrumentation/transponder/id-code', '1200');
146 142
                     me.device.display.updateXPDR();
147 143
                 },
148 144
                 IDENT : func {
149
-                    me.bindings.PFD.XPDR.inactivity.restart(45);
150 145
                     call(me.bindings.PFD.IDENT, [], me);
151 146
                 },
152 147
                 CODE : {
153 148
                     '0' : func (n = 0) {
154
-                        me.bindings.PFD.XPDR.inactivity.restart(45);
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);
155 151
                         var tuning = radios.getNode('xpdr-tuning-digit');
156 152
                         var d = tuning.getValue();
157 153
                         setprop('/instrumentation/transponder/inputs/digit[' ~ d ~ ']', n);
... ...
@@ -181,11 +177,13 @@ var softkeysClass = {
181 177
                         call(me.bindings.PFD.XPDR.CODE['0'], [ 7 ], me);
182 178
                     },
183 179
                     IDENT: func {
184
-                        me.bindings.PFD.XPDR.inactivity.restart(45);
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);
185 182
                         call(me.bindings.PFD.IDENT, [], me);
186 183
                     },
187 184
                     BKSP: func {
188
-                        me.bindings.PFD.XPDR.inactivity.restart(45);
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);
189 187
                         var tuning = radios.getNode('xpdr-tuning-digit');
190 188
                         var d = tuning.getValue();
191 189
                         d += (d < 3) ? 1 : -3;
... ...
@@ -201,8 +199,8 @@ var softkeysClass = {
201 199
                         call(me.bindings.PFD.XPDR.CODE.exit, inactive ? [[]] : [me.path], me);
202 200
                     },
203 201
                     exit : func (p) {
204
-                        if (contains(me.bindings.PFD.XPDR, 'inactivity')) # does not exists if IDENT pressed from top-level
205
-                            me.bindings.PFD.XPDR.inactivity.stop();
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();
206 204
                         radios.removeChild('xpdr-tuning-digit', 0);
207 205
                         radios.removeChild('xpdr-backup-code', 0);
208 206
                         me.path = p;
... ...
@@ -210,7 +208,12 @@ var softkeysClass = {
210 208
                         me.device.display.updateSoftKeys();
211 209
                     },
212 210
                     hook : func {
213
-                        me.bindings.PFD.XPDR.inactivity.restart(45);
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();
214 217
                         var tuning = getprop('/instrument/zkv1000/radios/xpdr-tuning-digit');
215 218
                         if (tuning == nil) {
216 219
                             radios.getNode('xpdr-tuning-digit', 1).setValue(3);
... ...
@@ -219,12 +222,6 @@ var softkeysClass = {
219 222
                         }
220 223
                     },
221 224
                 },
222
-                hook : func {
223
-                    me.bindings.PFD.XPDR.inactivity = maketimer(45,
224
-                        func call(me.bindings.PFD.XPDR.CODE.BACK, [1], me));
225
-                    me.bindings.PFD.XPDR.inactivity.singleShot = 1;
226
-                    me.bindings.PFD.XPDR.inactivity.start();
227
-                },
228 225
             },
229 226
             IDENT : func {
230 227
                 if (getprop('/instrumentation/zkv1000/radio/xpdr-mode') == 'STBY')
+1 -1
README.md
... ...
@@ -63,8 +63,8 @@ Please report bug at <seb.marque@free.fr>.
63 63
   * XPDR from SoftKeys
64 64
   * Selected altitude bug (widget off if IA within 100ft)
65 65
   * baro settings
66
+  * SoftKeys menus navigation for PFD and MFD, not yet implemented function are logged in console
66 67
 * ![][90%]
67
-  * SoftKeys menus navigation for PFD and MFD, not yet implemented function are logged in console (not yet 100% because it lackss the 45sec timer of inactivity on every level, actually done only for XPDR menu, that can easily be extended ![][ongoing])
68 68
   * Radio stack, including ID for NAV (bug: NAV1 ID isn't displayed ![][pause])
69 69
   * Bearing needs some checks to be sure it shows the correct information
70 70
   * CDI ![][ongoing], lacks information about the scale