Merge pull request #4 from jasnell/stopwatch-update
Stopwatch: beep on button press, reset laptimesmaster
commit
8076430514
|
|
@ -50,18 +50,19 @@ function drawms() {
|
||||||
|
|
||||||
setWatch(function() { // Start/stop
|
setWatch(function() { // Start/stop
|
||||||
started = !started;
|
started = !started;
|
||||||
if (started)
|
Bangle.beep();
|
||||||
|
if (started)
|
||||||
tStart = Date.now()+tStart-tCurrent;
|
tStart = Date.now()+tStart-tCurrent;
|
||||||
tCurrent = Date.now();
|
tCurrent = Date.now();
|
||||||
if (displayInterval) {
|
if (displayInterval) {
|
||||||
clearInterval(displayInterval);
|
clearInterval(displayInterval);
|
||||||
displayInterval = undefined;
|
displayInterval = undefined;
|
||||||
}
|
}
|
||||||
updateLabels();
|
updateLabels();
|
||||||
if (started)
|
if (started)
|
||||||
displayInterval = setInterval(function() {
|
displayInterval = setInterval(function() {
|
||||||
var last = tCurrent;
|
var last = tCurrent;
|
||||||
if (started) tCurrent = Date.now();
|
if (started) tCurrent = Date.now();
|
||||||
if (Math.floor(last/1000)!=Math.floor(tCurrent/1000))
|
if (Math.floor(last/1000)!=Math.floor(tCurrent/1000))
|
||||||
drawsecs();
|
drawsecs();
|
||||||
else
|
else
|
||||||
|
|
@ -69,12 +70,15 @@ setWatch(function() { // Start/stop
|
||||||
}, 20);
|
}, 20);
|
||||||
}, BTN2, {repeat:true});
|
}, BTN2, {repeat:true});
|
||||||
setWatch(function() { // Reset
|
setWatch(function() { // Reset
|
||||||
|
Bangle.beep();
|
||||||
if (!started) {
|
if (!started) {
|
||||||
tStart = tCurrent = Date.now();
|
tStart = tCurrent = Date.now();
|
||||||
}
|
}
|
||||||
|
lapTimes = [];
|
||||||
updateLabels();
|
updateLabels();
|
||||||
}, BTN1, {repeat:true});
|
}, BTN1, {repeat:true});
|
||||||
setWatch(function() { // Lap
|
setWatch(function() { // Lap
|
||||||
|
Bangle.beep();
|
||||||
if (started) tCurrent = Date.now();
|
if (started) tCurrent = Date.now();
|
||||||
lapTimes.unshift(tCurrent-tStart);
|
lapTimes.unshift(tCurrent-tStart);
|
||||||
tStart = tCurrent;
|
tStart = tCurrent;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue