Show elapsed time, and tweak stopwatch so lap times don't overlap the bottom widget area
parent
083e4f752f
commit
bb42044aa9
|
|
@ -17,11 +17,12 @@ function getLapTimes() {
|
||||||
<div class="columns">\n`;
|
<div class="columns">\n`;
|
||||||
lapData.forEach((lap,lapIndex) => {
|
lapData.forEach((lap,lapIndex) => {
|
||||||
lap.date = lap.n.substr(7,16).replace("_"," ");
|
lap.date = lap.n.substr(7,16).replace("_"," ");
|
||||||
|
lap.elapsed = lap.d.shift(); // remove first item
|
||||||
html += `
|
html += `
|
||||||
<div class="column col-12">
|
<div class="column col-12">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<div class="card-title h5">${lap.date}</div>
|
<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>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<table class="table table-striped table-hover">
|
<table class="table table-striped table-hover">
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,10 @@ function updateLabels() {
|
||||||
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<16)
|
if (i<15)
|
||||||
{g.drawString(lapTimes.length-i+": "+timeToText(lapTimes[i]),35,timeY + 40 + i*8);}
|
{g.drawString(lapTimes.length-i+": "+timeToText(lapTimes[i]),35,timeY + 40 + i*8);}
|
||||||
else if (i<32)
|
else if (i<30)
|
||||||
{g.drawString(lapTimes.length-i+": "+timeToText(lapTimes[i]),125,timeY + 40 + (i-16)*8);}
|
{g.drawString(lapTimes.length-i+": "+timeToText(lapTimes[i]),125,timeY + 40 + (i-15)*8);}
|
||||||
}
|
}
|
||||||
drawsecs();
|
drawsecs();
|
||||||
}
|
}
|
||||||
|
|
@ -92,12 +92,12 @@ setWatch(function() { // Start/stop
|
||||||
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
|
||||||
drawms();
|
drawms();
|
||||||
}, 20);
|
}, 20);
|
||||||
}, BTN2, {repeat:true});
|
}, BTN2, {repeat:true});
|
||||||
|
|
||||||
|
|
@ -108,10 +108,10 @@ setWatch(function() { // Lap
|
||||||
lapTimes.unshift(tCurrent-tStart);
|
lapTimes.unshift(tCurrent-tStart);
|
||||||
}
|
}
|
||||||
if (!started) { // save
|
if (!started) { // save
|
||||||
var timenow= Date();
|
|
||||||
var filename = "swatch-"+(new Date()).toISOString().substr(0,16).replace("T","_")+".json";
|
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
|
// this maxes out the 28 char maximum
|
||||||
lapTimes.unshift(tCurrent-tStart);
|
|
||||||
require("Storage").writeJSON(filename, getLapTimesArray());
|
require("Storage").writeJSON(filename, getLapTimesArray());
|
||||||
tStart = tCurrent = tTotal = Date.now();
|
tStart = tCurrent = tTotal = Date.now();
|
||||||
lapTimes = [];
|
lapTimes = [];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue