mirror of https://github.com/espruino/BangleApps
stopwatch - Added widgets
parent
f66aab5823
commit
fbce9aaa7c
|
@ -392,7 +392,7 @@
|
||||||
{ "id": "swatch",
|
{ "id": "swatch",
|
||||||
"name": "Stopwatch",
|
"name": "Stopwatch",
|
||||||
"icon": "stopwatch.png",
|
"icon": "stopwatch.png",
|
||||||
"version":"0.04",
|
"version":"0.05",
|
||||||
"interface": "interface.html",
|
"interface": "interface.html",
|
||||||
"description": "Simple stopwatch with Lap Time logging to a JSON file",
|
"description": "Simple stopwatch with Lap Time logging to a JSON file",
|
||||||
"tags": "health",
|
"tags": "health",
|
||||||
|
|
|
@ -4,3 +4,4 @@
|
||||||
0.03: Added ability to save Lap log as a date named JSON file into memory
|
0.03: Added ability to save Lap log as a date named JSON file into memory
|
||||||
Fixed bug from 0.01 where BN1 (reset) could clear the lap log when timer is running
|
Fixed bug from 0.01 where BN1 (reset) could clear the lap log when timer is running
|
||||||
0.04: Changed save file filename, add interface.html to allow laps to be loaded
|
0.04: Changed save file filename, add interface.html to allow laps to be loaded
|
||||||
|
0.05: Added widgets
|
||||||
|
|
|
@ -13,24 +13,26 @@ function timeToText(t) {
|
||||||
return mins+":"+("0"+secs).substr(-2)+"."+("0"+hs).substr(-2);
|
return mins+":"+("0"+secs).substr(-2)+"."+("0"+hs).substr(-2);
|
||||||
}
|
}
|
||||||
function updateLabels() {
|
function updateLabels() {
|
||||||
g.clear();
|
g.reset(1);
|
||||||
|
g.clearRect(0,23,g.getWidth()-1,g.getHeight()-24);
|
||||||
g.setFont("6x8",2);
|
g.setFont("6x8",2);
|
||||||
g.setFontAlign(0,0,3);
|
g.setFontAlign(0,0,3);
|
||||||
g.drawString(started?"STOP":"GO",230,120);
|
g.drawString(started?"STOP":"GO",230,120);
|
||||||
if (!started) g.drawString("RESET",230,190);
|
if (!started) g.drawString("RESET",230,180);
|
||||||
g.drawString(started?"LAP":"SAVE",230,50);
|
g.drawString(started?"LAP":"SAVE",230,50);
|
||||||
g.setFont("6x8",1);
|
g.setFont("6x8",1);
|
||||||
g.setFontAlign(-1,-1);
|
g.setFontAlign(-1,-1);
|
||||||
for (var i in lapTimes) {
|
for (var i in lapTimes) {
|
||||||
if (i<18)
|
if (i<16)
|
||||||
{g.drawString(lapTimes.length-i+": "+timeToText(lapTimes[i]),35,timeY + 30 + i*8);}
|
{g.drawString(lapTimes.length-i+": "+timeToText(lapTimes[i]),35,timeY + 30 + i*8);}
|
||||||
else
|
else if (i<32)
|
||||||
{g.drawString(lapTimes.length-i+": "+timeToText(lapTimes[i]),125,timeY + 30 + (i-18)*8);}
|
{g.drawString(lapTimes.length-i+": "+timeToText(lapTimes[i]),125,timeY + 30 + (i-16)*8);}
|
||||||
}
|
}
|
||||||
drawsecs();
|
drawsecs();
|
||||||
}
|
}
|
||||||
function drawsecs() {
|
function drawsecs() {
|
||||||
var t = tCurrent-tStart;
|
var t = tCurrent-tStart;
|
||||||
|
g.reset(1);
|
||||||
g.setFont("Vector",48);
|
g.setFont("Vector",48);
|
||||||
g.setFontAlign(0,0);
|
g.setFontAlign(0,0);
|
||||||
var secs = Math.floor(t/1000)%60;
|
var secs = Math.floor(t/1000)%60;
|
||||||
|
@ -103,3 +105,5 @@ setWatch(function() { // Reset
|
||||||
}, BTN3, {repeat:true});
|
}, BTN3, {repeat:true});
|
||||||
|
|
||||||
updateLabels();
|
updateLabels();
|
||||||
|
Bangle.loadWidgets();
|
||||||
|
Bangle.drawWidgets();
|
||||||
|
|
Loading…
Reference in New Issue