Merge branch 'master' of github.com:espruino/BangleApps
commit
5c0de891f2
|
|
@ -1,3 +1,4 @@
|
|||
0.01: first release
|
||||
0.02: Adjust for touch events outside of screen g dimensions
|
||||
0.03: Do not register as watch, manually start clock on button
|
||||
0.04: Keep running in background by saving state
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "stopwatch",
|
||||
"name": "Stopwatch Touch",
|
||||
"version": "0.03",
|
||||
"version": "0.04",
|
||||
"description": "A touch based stop watch for Bangle JS 2",
|
||||
"icon": "stopwatch.png",
|
||||
"screenshots": [{"url":"screenshot1.png"},{"url":"screenshot2.png"},{"url":"screenshot3.png"}],
|
||||
|
|
|
|||
|
|
@ -1,9 +1,21 @@
|
|||
const CONFIGFILE = "stopwatch.json";
|
||||
|
||||
const now = Date.now();
|
||||
const config = Object.assign({
|
||||
state: {
|
||||
total: now,
|
||||
start: now,
|
||||
current: now,
|
||||
running: false,
|
||||
}
|
||||
}, require("Storage").readJSON(CONFIGFILE,1) || {});
|
||||
|
||||
let w = g.getWidth();
|
||||
let h = g.getHeight();
|
||||
let tTotal = Date.now();
|
||||
let tStart = tTotal;
|
||||
let tCurrent = tTotal;
|
||||
let running = false;
|
||||
let tTotal = config.state.total;
|
||||
let tStart = config.state.start;
|
||||
let tCurrent = config.state.current;
|
||||
let running = config.state.running;
|
||||
let timeY = 2*h/5;
|
||||
let displayInterval;
|
||||
let redrawButtons = true;
|
||||
|
|
@ -15,6 +27,14 @@ const pause_img = atob("GBiBAf////////////////wYP/wYP/wYP/wYP/wYP/wYP/wYP/wYP/wY
|
|||
const play_img = atob("GBjBAP//AAAAAAAAAAAIAAAOAAAPgAAP4AAP+AAP/AAP/wAP/8AP//AP//gP//gP//AP/8AP/wAP/AAP+AAP4AAPgAAOAAAIAAAAAAAAAAA=");
|
||||
const reset_img = atob("GBiBAf////////////AAD+AAB+f/5+f/5+f/5+cA5+cA5+cA5+cA5+cA5+cA5+cA5+cA5+f/5+f/5+f/5+AAB/AAD////////////w==");
|
||||
|
||||
function saveState() {
|
||||
config.state.total = tTotal;
|
||||
config.state.start = tStart;
|
||||
config.state.current = tCurrent;
|
||||
config.state.running = running;
|
||||
require("Storage").writeJSON(CONFIGFILE, config);
|
||||
}
|
||||
|
||||
function log_debug(o) {
|
||||
//console.log(o);
|
||||
}
|
||||
|
|
@ -106,6 +126,7 @@ function stopStart() {
|
|||
} else {
|
||||
draw();
|
||||
}
|
||||
saveState();
|
||||
}
|
||||
|
||||
function setButtonImages() {
|
||||
|
|
@ -130,6 +151,7 @@ function lapReset() {
|
|||
g.clearRect(0,24,w,h);
|
||||
draw();
|
||||
}
|
||||
saveState();
|
||||
}
|
||||
|
||||
// simple on screen button class
|
||||
|
|
@ -226,5 +248,10 @@ g.fillRect(0,0,w,h);
|
|||
|
||||
Bangle.loadWidgets();
|
||||
Bangle.drawWidgets();
|
||||
draw();
|
||||
setButtonImages();
|
||||
if (running) {
|
||||
startTimer();
|
||||
} else {
|
||||
draw();
|
||||
}
|
||||
setWatch(() => load(), BTN, { repeat: false, edge: "falling" });
|
||||
|
|
|
|||
2
core
2
core
|
|
@ -1 +1 @@
|
|||
Subproject commit 376824068d90986c245b46970fd80ccdca44e431
|
||||
Subproject commit 168dd4add3a281635c71d3a7cf683e87b847ffd7
|
||||
|
|
@ -278,9 +278,12 @@ exports.addInteractive = function(menu, options) {
|
|||
if (!options.focus) {
|
||||
options.focus=true; // if not focussed, set focus
|
||||
options.redraw();
|
||||
} else if (menu[options.menuA].items[options.menuB].run)
|
||||
} else if (menu[options.menuA].items[options.menuB].run) {
|
||||
Bangle.buzz(100, 0.7);
|
||||
menu[options.menuA].items[options.menuB].run(); // allow tap on an item to run it (eg home assistant)
|
||||
else options.focus=true;
|
||||
} else {
|
||||
options.focus=true;
|
||||
}
|
||||
};
|
||||
Bangle.on("touch",touchHandler);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue