forked from FOSS/BangleApps
Initial commit of `lapcounter` app
parent
33c76db781
commit
5a3fd1d9e3
17
apps.json
17
apps.json
|
@ -4986,5 +4986,22 @@
|
|||
{"name":"showimg.app.js","url":"app.js"},
|
||||
{"name":"showimg.img","url":"app-icon.js","evaluate":true}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "lapcounter",
|
||||
"name": "Lap Counter",
|
||||
"version": "0.01",
|
||||
"description": "Click button to count laps. Shows count and total time snapshot (like a stopwatch, but laid back).",
|
||||
"icon": "app.png",
|
||||
"screenshots": [{"url":"screenshot.png"}],
|
||||
"type": "app",
|
||||
"tags": "tool,outdoors",
|
||||
"readme":"README.md",
|
||||
"supports": ["BANGLEJS", "BANGLEJS2"],
|
||||
"allow_emulator": true,
|
||||
"storage": [
|
||||
{"name":"lapcounter.app.js","url":"app.js"},
|
||||
{"name":"lapcounter.img","url":"app-icon.js","evaluate":true}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
0.01: first release
|
|
@ -0,0 +1,19 @@
|
|||
# Lap Counter
|
||||
|
||||
Click button to count laps (e.g. in a swimming pool).
|
||||
Also shows total duration snapshot (like a stopwatch, but laid back).
|
||||
|
||||

|
||||
|
||||
## Usage
|
||||
|
||||
* Click BTN1 to start counting. Counter becomes `0`, duration becomes `00:00.0`
|
||||
* Each time you click BTN1, counter is incremented, and you see duration between first and last clicks.
|
||||
|
||||
## Features
|
||||
|
||||
Disables LCD timeout (so that you can be _sure_ what BTN1 would do).
|
||||
|
||||
## Creator
|
||||
|
||||
[Nimrod Kerrett](https://zzzen.com)
|
|
@ -0,0 +1 @@
|
|||
require("heatshrink").decompress(atob("mEwwkBiIA/AH4A/AAkQgEBAREAC6oABdZQXkI6wuKC5iPUFxoXIOpoX/C6QFCC6IsCC6ZEDC/4XcPooXOFgoXQIgwX/C7IUFC5wsIC5ouCC6hcJC5h1DF9YwBChCPOAH4A/AH4Ap"));
|
|
@ -0,0 +1,53 @@
|
|||
const w = g.getWidth();
|
||||
const h = g.getHeight();
|
||||
const wid_h = 24;
|
||||
let tStart;
|
||||
let tNow;
|
||||
let counter=-1;
|
||||
|
||||
const icon = require("heatshrink").decompress(atob("mEwwkBiIA/AH4A/AAkQgEBAREAC6oABdZQXkI6wuKC5iPUFxoXIOpoX/C6QFCC6IsCC6ZEDC/4XcPooXOFgoXQIgwX/C7IUFC5wsIC5ouCC6hcJC5h1DF9YwBChCPOAH4A/AH4Ap"));
|
||||
|
||||
function timeToText(t) { // Courtesy of stopwatch app
|
||||
let hrs = Math.floor(t/3600000);
|
||||
let mins = Math.floor(t/60000)%60;
|
||||
let secs = Math.floor(t/1000)%60;
|
||||
let tnth = Math.floor(t/100)%10;
|
||||
let text;
|
||||
|
||||
if (hrs === 0)
|
||||
text = ("0"+mins).substr(-2) + ":" + ("0"+secs).substr(-2) + "." + tnth;
|
||||
else
|
||||
text = ("0"+hrs) + ":" + ("0"+mins).substr(-2) + ":" + ("0"+secs).substr(-2);
|
||||
//log_debug(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
function doCounter() {
|
||||
if (counter<0) {
|
||||
tStart = Date.now();
|
||||
tNow = tStart;
|
||||
} else {
|
||||
tNow = Date.now();
|
||||
}
|
||||
counter++;
|
||||
let dT = tNow-tStart;
|
||||
|
||||
g.clearRect(0,wid_h,w,h-wid_h);
|
||||
g.setFontAlign(0,0);
|
||||
g.setFont("Vector",72);
|
||||
g.drawString(counter,w/2,h/2);
|
||||
g.setFont("Vector",24);
|
||||
g.drawString(timeToText(dT),w/2,h/2+50);
|
||||
}
|
||||
|
||||
setWatch(doCounter, BTN1, true);
|
||||
|
||||
g.clear(true);
|
||||
Bangle.loadWidgets();
|
||||
Bangle.drawWidgets();
|
||||
Bangle.setLCDTimeout(0);
|
||||
g.drawImage(icon,w/2-24,h/2-24);
|
||||
g.setFontAlign(0,0);
|
||||
require("Font8x12").add(Graphics);
|
||||
g.setFont("8x12");
|
||||
g.drawString("Click button to count.", w/2, h/2+22);
|
Binary file not shown.
After Width: | Height: | Size: 749 B |
Binary file not shown.
After Width: | Height: | Size: 6.4 KiB |
Loading…
Reference in New Issue