Create settings.js

pull/651/head
nujw 2021-01-22 13:48:35 +13:00 committed by GitHub
parent 53c31c74b0
commit c1eda83f28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 36 additions and 0 deletions

36
apps/speedalt/settings.js Normal file
View File

@ -0,0 +1,36 @@
(function(back) {
let settings = require('Storage').readJSON('speedalt.json',1)||{};
/*
function save(key, value) {
settings[key] = value;
require('Storage').write('settings.json',settings);
}
*/
function setUnits(m,u) {
settings['spd'] = m;
settings['spd_unit'] = u;
require('Storage').write('settings.json',settings);
}
function setUnitsAlt(m,u) {
settings['alt'] = m;
settings['alt_unit'] = u;
require('Storage').write('settings.json',settings);
}
const appMenu = {
'': {'title': 'Units'},
'< Back': back,
'default (spd)' : function() { setUnits(0,''); },
"Kph (spd)" : function() { setUnits(1,'kph'); },
"Knots (spd)" : function() { setUnits(1.852,'knots'); },
"Mph (spd)" : function() { setUnits(1.60934,'mph'); },
"m/s (spd)" : function() { setUnits(3.6,'m/s'); },
"Meters (alt)" : function() { setUnitsAlt(1,'m'); },
"Feet (alt)" : function() { setUnitsAlt(0.3048,'feet'); }
};
E.showMenu(appMenu)
})