Showing 3 changed files with 23 additions and 3 deletions
+17
Nasal/buttons.nas
... ...
@@ -274,6 +274,23 @@ var buttonsClass = {
274 274
                     }
275 275
                 }
276 276
             },
277
+            {text: 'Temperat. :', type: 'normal', scrollgroup: 5},
278
+            {text: units.temperature.from_C(0) ? '  F >' : '< °C  ',
279
+                type: 'editable|end-of-line',
280
+                choices: [ '  F >', '< °C  ' ],
281
+                scrollgroup: 5,
282
+                callback: func (id, selected) {
283
+                    var u = string.trim(me.device.windows.state[id].objects[selected].text, 0, func (c) c == ` ` or c == `<` or c == `>`);
284
+                    if (u == '°C') {
285
+                        units.temperature.from_C = func (c) return c;
286
+                        units.temperature.from_F = func (f) return (f - 32) / 1.8;
287
+                    }
288
+                    else {
289
+                        units.temperature.from_C = func (c) return c * 1.8 + 32;
290
+                        units.temperature.from_F = func (f) return f;
291
+                    }
292
+                }
293
+            },
277 294
             {type: 'separator'},
278 295
             {text: 'TIME REF: ', type: 'normal'},
279 296
             {text: data.settings.time.actual,
+2 -3
Nasal/display.nas
... ...
@@ -1289,11 +1289,10 @@ var displayClass = {
1289 1289
 
1290 1290
     updateOAT : func {
1291 1291
 # update OAT display on normal and reversionnary modes (every 3s) {{{
1292
-        var tmp = getprop('/environment/temperature-deg' ~ me._oat_unit);
1292
+        var tmp = units.temperature.from_C(getprop('/environment/temperature-degc'));
1293 1293
         me.screenElements['OAT-text']
1294
-            .setText(sprintf((abs(tmp) < 10) ? "%.1f %s" : "%i %s", tmp, (me._oat_unit == 'c') ? '°C' : 'F'));
1294
+            .setText(sprintf((abs(tmp) < 10) ? "%.1f %s" : "%i %s", tmp, units.temperature.from_C(0) ? 'F' : '°C'));
1295 1295
     },
1296
-    _oat_unit : 'c',
1297 1296
 #}}}
1298 1297
 
1299 1298
     updateWindData : func {
+4
zkv1000.nas
... ...
@@ -44,6 +44,10 @@ var units = {
44 44
         from_m : M2NM / 1000,
45 45
         from_nm : 1,
46 46
     },
47
+    temperature : {
48
+        from_C : func (c) return c,
49
+        from_F : func (f) return (f -32) / 1.8,
50
+    },
47 51
 };
48 52
 
49 53
 var data = { # set of data common to all devices