Show elapsed time, and tweak stopwatch so lap times don't overlap the bottom widget area

master
Gordon Williams 2020-04-16 10:25:13 +01:00
parent 083e4f752f
commit bb42044aa9
2 changed files with 13 additions and 12 deletions

View File

@ -17,11 +17,12 @@ function getLapTimes() {
<div class="columns">\n`;
lapData.forEach((lap,lapIndex) => {
lap.date = lap.n.substr(7,16).replace("_"," ");
lap.elapsed = lap.d.shift(); // remove first item
html += `
<div class="column col-12">
<div class="card-header">
<div class="card-title h5">${lap.date}</div>
<div class="card-subtitle text-gray">${lap.d.length} Laps</div>
<div class="card-subtitle text-gray">${lap.d.length} Laps, total time ${lap.elapsed}</div>
</div>
<div class="card-body">
<table class="table table-striped table-hover">

View File

@ -27,10 +27,10 @@ function updateLabels() {
g.setFont("6x8",1);
g.setFontAlign(-1,-1);
for (var i in lapTimes) {
if (i<16)
if (i<15)
{g.drawString(lapTimes.length-i+": "+timeToText(lapTimes[i]),35,timeY + 40 + i*8);}
else if (i<32)
{g.drawString(lapTimes.length-i+": "+timeToText(lapTimes[i]),125,timeY + 40 + (i-16)*8);}
else if (i<30)
{g.drawString(lapTimes.length-i+": "+timeToText(lapTimes[i]),125,timeY + 40 + (i-15)*8);}
}
drawsecs();
}
@ -92,12 +92,12 @@ setWatch(function() { // Start/stop
updateLabels();
if (started)
displayInterval = setInterval(function() {
var last = tCurrent;
if (started) tCurrent = Date.now();
if (Math.floor(last/1000)!=Math.floor(tCurrent/1000))
drawsecs();
else
drawms();
var last = tCurrent;
if (started) tCurrent = Date.now();
if (Math.floor(last/1000)!=Math.floor(tCurrent/1000))
drawsecs();
else
drawms();
}, 20);
}, BTN2, {repeat:true});
@ -108,10 +108,10 @@ setWatch(function() { // Lap
lapTimes.unshift(tCurrent-tStart);
}
if (!started) { // save
var timenow= Date();
var filename = "swatch-"+(new Date()).toISOString().substr(0,16).replace("T","_")+".json";
if (tCurrent!=tStart)
lapTimes.unshift(tCurrent-tStart);
// this maxes out the 28 char maximum
lapTimes.unshift(tCurrent-tStart);
require("Storage").writeJSON(filename, getLapTimesArray());
tStart = tCurrent = tTotal = Date.now();
lapTimes = [];