mirror of https://github.com/espruino/BangleApps
settings 0.54: If setting.json is corrupt, ensure it gets re-written
parent
e03c8c842f
commit
1b1f1d776b
|
@ -58,3 +58,4 @@
|
||||||
0.51: Add setting for configuring a launcher
|
0.51: Add setting for configuring a launcher
|
||||||
0.52: Add option for left-handed users
|
0.52: Add option for left-handed users
|
||||||
0.53: Ensure that when clock is set, clockHasWidgets is set correctly too
|
0.53: Ensure that when clock is set, clockHasWidgets is set correctly too
|
||||||
|
0.54: If setting.json is corrupt, ensure it gets re-written
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"id": "setting",
|
"id": "setting",
|
||||||
"name": "Settings",
|
"name": "Settings",
|
||||||
"version": "0.53",
|
"version": "0.54",
|
||||||
"description": "A menu for setting up Bangle.js",
|
"description": "A menu for setting up Bangle.js",
|
||||||
"icon": "settings.png",
|
"icon": "settings.png",
|
||||||
"tags": "tool,system",
|
"tags": "tool,system",
|
||||||
|
|
|
@ -60,7 +60,9 @@ function resetSettings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
settings = storage.readJSON('setting.json', 1);
|
settings = storage.readJSON('setting.json', 1);
|
||||||
if (!settings) resetSettings();
|
if (("object" != typeof settings) ||
|
||||||
|
("object" != typeof settings.options))
|
||||||
|
resetSettings();
|
||||||
|
|
||||||
const boolFormat = v => v ? /*LANG*/"On" : /*LANG*/"Off";
|
const boolFormat = v => v ? /*LANG*/"On" : /*LANG*/"Off";
|
||||||
|
|
||||||
|
@ -237,9 +239,9 @@ function showThemeMenu() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
require("Storage").list(/^.*\.theme$/).forEach(
|
storage.list(/^.*\.theme$/).forEach(
|
||||||
n => {
|
n => {
|
||||||
let newTheme = require("Storage").readJSON(n);
|
let newTheme = storage.readJSON(n);
|
||||||
themesMenu[newTheme.name ? newTheme.name : n] = () => {
|
themesMenu[newTheme.name ? newTheme.name : n] = () => {
|
||||||
upd({
|
upd({
|
||||||
fg:cl(newTheme.fg), bg:cl(newTheme.bg),
|
fg:cl(newTheme.fg), bg:cl(newTheme.bg),
|
||||||
|
@ -567,11 +569,11 @@ function showUtilMenu() {
|
||||||
},
|
},
|
||||||
/*LANG*/'Compact Storage': () => {
|
/*LANG*/'Compact Storage': () => {
|
||||||
E.showMessage(/*LANG*/"Compacting...\nTakes approx\n1 minute",{title:/*LANG*/"Storage"});
|
E.showMessage(/*LANG*/"Compacting...\nTakes approx\n1 minute",{title:/*LANG*/"Storage"});
|
||||||
require("Storage").compact();
|
storage.compact();
|
||||||
showUtilMenu();
|
showUtilMenu();
|
||||||
},
|
},
|
||||||
/*LANG*/'Rewrite Settings': () => {
|
/*LANG*/'Rewrite Settings': () => {
|
||||||
require("Storage").write(".boot0","eval(require('Storage').read('bootupdate.js'));");
|
storage.write(".boot0","eval(require('Storage').read('bootupdate.js'));");
|
||||||
load("setting.app.js");
|
load("setting.app.js");
|
||||||
},
|
},
|
||||||
/*LANG*/'Flatten Battery': () => {
|
/*LANG*/'Flatten Battery': () => {
|
||||||
|
@ -592,9 +594,9 @@ function showUtilMenu() {
|
||||||
menu[/*LANG*/'Calibrate Battery'] = () => {
|
menu[/*LANG*/'Calibrate Battery'] = () => {
|
||||||
E.showPrompt(/*LANG*/"Is the battery fully charged?",{title:/*LANG*/"Calibrate"}).then(ok => {
|
E.showPrompt(/*LANG*/"Is the battery fully charged?",{title:/*LANG*/"Calibrate"}).then(ok => {
|
||||||
if (ok) {
|
if (ok) {
|
||||||
var s=require("Storage").readJSON("setting.json");
|
var s=storage.readJSON("setting.json");
|
||||||
s.batFullVoltage = (analogRead(D3)+analogRead(D3)+analogRead(D3)+analogRead(D3))/4;
|
s.batFullVoltage = (analogRead(D3)+analogRead(D3)+analogRead(D3)+analogRead(D3))/4;
|
||||||
require("Storage").writeJSON("setting.json",s);
|
storage.writeJSON("setting.json",s);
|
||||||
E.showAlert(/*LANG*/"Calibrated!").then(() => load("setting.app.js"));
|
E.showAlert(/*LANG*/"Calibrated!").then(() => load("setting.app.js"));
|
||||||
} else {
|
} else {
|
||||||
E.showAlert(/*LANG*/"Please charge Bangle.js for 3 hours and try again").then(() => load("settings.app.js"));
|
E.showAlert(/*LANG*/"Please charge Bangle.js for 3 hours and try again").then(() => load("settings.app.js"));
|
||||||
|
@ -659,7 +661,7 @@ function makeConnectable() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function showClockMenu() {
|
function showClockMenu() {
|
||||||
var clockApps = require("Storage").list(/\.info$/)
|
var clockApps = storage.list(/\.info$/)
|
||||||
.map(app => {var a=storage.readJSON(app, 1);return (a&&a.type == "clock")?a:undefined})
|
.map(app => {var a=storage.readJSON(app, 1);return (a&&a.type == "clock")?a:undefined})
|
||||||
.filter(app => app) // filter out any undefined apps
|
.filter(app => app) // filter out any undefined apps
|
||||||
.sort((a, b) => a.sortorder - b.sortorder);
|
.sort((a, b) => a.sortorder - b.sortorder);
|
||||||
|
@ -676,7 +678,7 @@ function showClockMenu() {
|
||||||
}
|
}
|
||||||
clockMenu[label] = () => {
|
clockMenu[label] = () => {
|
||||||
settings.clock = app.src;
|
settings.clock = app.src;
|
||||||
settings.clockHasWidgets = require("Storage").read(app.src).includes("Bangle.loadWidgets");
|
settings.clockHasWidgets = storage.read(app.src).includes("Bangle.loadWidgets");
|
||||||
updateSettings();
|
updateSettings();
|
||||||
showMainMenu();
|
showMainMenu();
|
||||||
};
|
};
|
||||||
|
@ -687,7 +689,7 @@ function showClockMenu() {
|
||||||
return E.showMenu(clockMenu);
|
return E.showMenu(clockMenu);
|
||||||
}
|
}
|
||||||
function showLauncherMenu() {
|
function showLauncherMenu() {
|
||||||
var launcherApps = require("Storage").list(/\.info$/)
|
var launcherApps = storage.list(/\.info$/)
|
||||||
.map(app => {var a=storage.readJSON(app, 1);return (a&&a.type == "launch")?a:undefined})
|
.map(app => {var a=storage.readJSON(app, 1);return (a&&a.type == "launch")?a:undefined})
|
||||||
.filter(app => app) // filter out any undefined apps
|
.filter(app => app) // filter out any undefined apps
|
||||||
.sort((a, b) => a.sortorder - b.sortorder);
|
.sort((a, b) => a.sortorder - b.sortorder);
|
||||||
|
@ -865,9 +867,9 @@ function showTouchscreenCalibration() {
|
||||||
Bangle.setOptions({
|
Bangle.setOptions({
|
||||||
touchX1: calib.x1, touchY1: calib.y1, touchX2: calib.x2, touchY2: calib.y2
|
touchX1: calib.x1, touchY1: calib.y1, touchX2: calib.x2, touchY2: calib.y2
|
||||||
});
|
});
|
||||||
var s = require("Storage").readJSON("setting.json",1)||{};
|
var s = storage.readJSON("setting.json",1)||{};
|
||||||
s.touch = calib;
|
s.touch = calib;
|
||||||
require("Storage").writeJSON("setting.json",s);
|
storage.writeJSON("setting.json",s);
|
||||||
g.setFont("6x8:2").setFontAlign(0,0).drawString("Calibrated!", g.getWidth()/2, g.getHeight()/2);
|
g.setFont("6x8:2").setFontAlign(0,0).drawString("Calibrated!", g.getWidth()/2, g.getHeight()/2);
|
||||||
// now load the main menu again
|
// now load the main menu again
|
||||||
setTimeout(showLCDMenu, 500);
|
setTimeout(showLCDMenu, 500);
|
||||||
|
|
Loading…
Reference in New Issue