mirror of https://github.com/espruino/BangleApps
New clkinfo: stopw
parent
55d7a893b1
commit
ae74346bb1
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
|
@ -0,0 +1,44 @@
|
||||||
|
(() => {
|
||||||
|
let durationOnPause = "---";
|
||||||
|
let redrawInterval;
|
||||||
|
let startTime;
|
||||||
|
|
||||||
|
const unqueueRedraw = () => {
|
||||||
|
if (redrawInterval) clearInterval(redrawInterval);
|
||||||
|
redrawInterval = undefined;
|
||||||
|
};
|
||||||
|
|
||||||
|
const queueRedraw = function() {
|
||||||
|
unqueueRedraw();
|
||||||
|
redrawInterval = setInterval(() => this.emit('redraw'), 100);
|
||||||
|
};
|
||||||
|
|
||||||
|
const duration = () => ((Date.now() - startTime) / 1000).toFixed(1);
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: "timer",
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
name: "stopw",
|
||||||
|
get: () => ({
|
||||||
|
text: startTime
|
||||||
|
? duration()
|
||||||
|
: durationOnPause,
|
||||||
|
img: atob("GBiBAAAAAAB+AAB+AAAAAAB+AAH/sAOB8AcA4A4YcAwYMBgYGBgYGBg8GBg8GBgYGBgAGAwAMA4AcAcA4AOBwAH/gAB+AAAAAAAAAA==")
|
||||||
|
}),
|
||||||
|
show: queueRedraw,
|
||||||
|
hide: unqueueRedraw,
|
||||||
|
run: function() { // tapped
|
||||||
|
if (startTime) {
|
||||||
|
durationOnPause = duration();
|
||||||
|
startTime = undefined;
|
||||||
|
unqueueRedraw();
|
||||||
|
} else {
|
||||||
|
queueRedraw.call(this);
|
||||||
|
startTime = Date.now();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
})
|
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"id": "clkinfostopw",
|
||||||
|
"name": "Stop Watch Clockinfo",
|
||||||
|
"version":"0.01",
|
||||||
|
"description": "A simple stopwatch, shown via clockinfo",
|
||||||
|
"icon": "app.png",
|
||||||
|
"type": "clkinfo",
|
||||||
|
"tags": "clkinfo,timer",
|
||||||
|
"supports" : ["BANGLEJS2"],
|
||||||
|
"storage": [
|
||||||
|
{"name":"stopw.clkinfo.js","url":"clkinfo.js"}
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in New Issue