From cf7215aa2aab70fea30403400554b3aecdc0e7a1 Mon Sep 17 00:00:00 2001 From: Dione Batista Date: Sun, 5 Jun 2022 15:38:06 -0400 Subject: [PATCH] add config Page --- apps/cassioWatch/app.js | 8 +++++++- apps/cassioWatch/cassioWatch.settings.js | 24 ++++++++++++++++++++++++ apps/cassioWatch/metadata.json | 1 + 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 apps/cassioWatch/cassioWatch.settings.js diff --git a/apps/cassioWatch/app.js b/apps/cassioWatch/app.js index 2c4f2234a..d789003cc 100644 --- a/apps/cassioWatch/app.js +++ b/apps/cassioWatch/app.js @@ -74,6 +74,10 @@ let Rocket = { }; let rocket_sequence = 1; +let settings = require('Storage').readJSON("cassioWatch.settings.json", true) || {}; +let rocketSpeed = settings.rocketSpeed || 700; +delete settings; + g.clear(); function DrawClock() { @@ -128,7 +132,7 @@ function DrawScene() { g.drawString(Bangle.getStepCount(), 143, 104); ClockInterval = setInterval(DrawClock, 30000); DrawClock(); - RocketInterval = setInterval(DrawRocket, 700); + RocketInterval = setInterval(DrawRocket, rocketSpeed); DrawRocket(); BatteryInterval = setInterval(DrawBattery, 5 * 60000); DrawBattery(); @@ -158,3 +162,5 @@ DrawScene(); if (Bangle.isLocked()) { ClearIntervals(true); } + +//eval(require("Storage").read("cassioWatch.settings.js"))(()=>load()); \ No newline at end of file diff --git a/apps/cassioWatch/cassioWatch.settings.js b/apps/cassioWatch/cassioWatch.settings.js new file mode 100644 index 000000000..b07c6c58f --- /dev/null +++ b/apps/cassioWatch/cassioWatch.settings.js @@ -0,0 +1,24 @@ +(function(back) { + var FILE = "cassioWatch.settings.json"; + var settings = Object.assign({ + rocketSpeed: 700, + }, require('Storage').readJSON(FILE, true) || {}); + + function writeSettings() { + require('Storage').writeJSON(FILE, settings); + } + + + E.showMenu({ + "" : { "title" : "Cassio Watch" }, + "< Back" : () => back(), + 'Rocket Speed': { + value: 0|settings.rocketSpeed, + min: 100, max: 60000, + onchange: v => { + settings.rocketSpeed = v; + writeSettings(); + } + }, + }); + }) \ No newline at end of file diff --git a/apps/cassioWatch/metadata.json b/apps/cassioWatch/metadata.json index c6b177066..e7fe0c058 100644 --- a/apps/cassioWatch/metadata.json +++ b/apps/cassioWatch/metadata.json @@ -12,6 +12,7 @@ "readme": "README.md", "storage": [ { "name": "cassioWatch.app.js", "url": "app.js" }, + {"name":"cassioWatch.settings.js","url":"settings.js"}, { "name": "cassioWatch.img", "url": "icon.js", "evaluate": true } ] }