Showing 2 changed files with 68 additions and 17 deletions
+59 -17
Nasal/buttons.nas
... ...
@@ -159,36 +159,79 @@ var buttonsClass = {
159 159
             {text: 'DISPLAY', type: 'title'},
160 160
             {type: 'separator'},
161 161
             {text: 'Brightness: ', type: 'normal'},
162
-            {text: sprintf('% 3u %%', zkv.getValue('display-brightness-norm') * 100 / 0.7),
162
+            {text: sprintf( '% 3u %%', zkv.getValue('display-brightness-norm') * 100 / 0.7),
163 163
                 type: 'selected immediate end-of-line',
164
-                format: '% 3u %%',
164
+                format: ' % 3u %% ',
165 165
                 range: {max: 100, min: 0},
166 166
                 callback: func (id, selected) {
167 167
                     var b = num(string.trim(me.device.windows.state[id].objects[selected].text, 0, func (c) c == `%` or c == ` `));
168 168
                     zkv.setDoubleValue('display-brightness-norm', b * 0.7 / 100);
169 169
                 },
170 170
             },
171
-            {text: 'Light: ', type: 'normal'},
171
+            {text: 'Light    : ', type: 'normal'},
172 172
             {text: '  0 >',
173 173
                 type: 'editable|immediate|end-of-line',
174
-                choices: ['  0 >', '<  1 >', '< 2 >', '< 3  '],
174
+                choices: ['  0 >', '< 1 >', '< 2 >', '< 3  '],
175 175
                 callback: func (id, selected) {
176
-                    var l = me.device.windows.state[id].objects[selected].text;
177
-                    foreach (var c; [' ', '<', '>'])
178
-                        l = string.replace(l, c, '');
179
-                    zkv.setDoubleValue('lightmap', num(l) * 3);
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);
180 178
                 }
181
-            }
179
+            },
180
+            {text: 'UNITS', type: 'title'},
181
+            {type: 'separator'},
182
+            {text: 'Pressure  :', type: 'normal'},
183
+            {text: data.settings.units.pressure == 'hpa' ? '  inHg >' : '<  hPa  ',
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';
192
+                }
193
+            },
194
+            {text: 'Altitude  :', type: 'normal'},
195
+            {text: data.settings.units.altitude == 'ft' ? '   feet  >' : '< meters  ',
196
+                type: 'editable|end-of-line',
197
+                choices: [ '   feet  >', '< meters  ' ],
198
+                callback: func (id, selected) {
199
+                    var u = string.trim(me.device.windows.state[id].objects[selected].text, 0, func (c) c == ` ` or c == `<` or c == `>`);
200
+                    if (u == 'feet')
201
+                        data.settings.units.altitude = 'ft';
202
+                    else
203
+                        data.settings.units.altitude = 'm';
204
+                }
205
+            },
206
+            {text: 'Speed     :', type: 'normal'},
207
+            {text: data.settings.units.speed == 'kt' ? '  knots  >' : '<  km/h   ',
208
+                type: 'editable|end-of-line',
209
+                choices: [ '  knots  >', '<  km/h   ' ],
210
+                callback: func (id, selected) {
211
+                    var u = string.trim(me.device.windows.state[id].objects[selected].text, 0, func (c) c == ` ` or c == `<` or c == `>`);
212
+                    if (u == 'knots')
213
+                        data.settings.units.altitude = 'kt';
214
+                    else
215
+                        data.settings.units.altitude = 'kmh';
216
+                }
217
+            },
218
+            {text: 'Vert. Spd :', type: 'normal'},
219
+            {text: data.settings.units.altitude == 'fpm' ? '  ft/min >' : '<  m/min  ',
220
+                type: 'editable|end-of-line',
221
+                choices: [ '  ft/min >', '<  m/min  ' ],
222
+                callback: func (id, selected) {
223
+                    var u = string.trim(me.device.windows.state[id].objects[selected].text, 0, func (c) c == ` ` or c == `<` or c == `>`);
224
+                    if (u == 'ft/min')
225
+                        data.settings.units.altitude = 'fpm';
226
+                    else
227
+                        data.settings.units.altitude = 'mpm';
228
+                }
229
+            },
182 230
         ];
183
-        var lines = size(obj_infos);
184
-        var name_max_length = 20;
185
-        me.device.windows.draw(
186
-            windowId,
187
-            {x: 1014 - (name_max_length * 10), y: 758 - ((lines + 3) * 24), w: name_max_length * 10, l: lines, sep: 1},
188
-            obj_infos
189
-        );
231
+        me.device.windows.draw( windowId, {autogeom: 1}, obj_infos);
190 232
         me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu;
191 233
         me.device.knobs.FmsInner = me.device.knobs.MenuSettings;
234
+        me.device.buttons.ENT = me.device.buttons.ValidateTMRREF;
192 235
         me.device.buttons.CLR = func {
193 236
             me.device.windows.del(windowId);
194 237
             me.device.knobs.FmsOuter = func;
... ...
@@ -197,7 +240,6 @@ var buttonsClass = {
197 240
                 me.device.buttons[b] = func;
198 241
             me.device.buttons.MENU = me.device.buttons.GlobalParams;
199 242
         }
200
-        me.device.buttons.ENT  = me.device.buttons.CLR;
201 243
         me.device.buttons.MENU = me.device.buttons.CLR;
202 244
     },
203 245
 
+9
zkv1000.nas
... ...
@@ -38,6 +38,15 @@ var data = { # set of data common to all devices
38 38
     lon : 0,
39 39
     aoa : 0,
40 40
     tcas: [],
41
+    settings: {
42
+        units: {
43
+            pressure: 'inhg',
44
+            altitude: 'ft',
45
+            speed: 'knots',
46
+            distance: 'nm',
47
+            vertical: 'fpm',
48
+        },
49
+    },
41 50
     timers : {
42 51
         '20Hz': maketimer (
43 52
             0.05,