Browse Source

fix the 'tude

meyn 0.1.3
Gisle Aune 11 months ago
parent
commit
d15fa26e79
  1. 2
      lib/client.mjs
  2. 49
      lib/tcx.mjs

2
lib/client.mjs

@ -53,4 +53,4 @@ export default class Trimlog {
this.token = data.access_token;
this.tokenExpiry = new Date(Date.now() + (data.expires_in * 1000 * 0.95));
}
}
}

49
lib/tcx.mjs

@ -28,7 +28,7 @@ export function generateTrimlogInput(filename, name = "Walk", type = "walk") {
latitude: parseFloat(tp.Position?.[0]?.LatitudeDegrees[0]),
altitude: parseFloat(tp.AltitudeMeters[0]),
distance: parseFloat(tp.DistanceMeters[0]),
heartrate: parseFloat(tp.HeartRateBpm?.[0].Value?.[0]),
pulse: parseFloat(tp.HeartRateBpm?.[0].Value?.[0]),
};
if (minAltitude == null || point.altitude < minAltitude) {
@ -52,7 +52,10 @@ export function generateTrimlogInput(filename, name = "Walk", type = "walk") {
measurements: Object.keys(map).sort().map(k => map[k]).map(p => ({
seconds: Math.round((new Date(p.time) - date) / 1000),
meters: p.distance,
pulse: p.heartrate,
pulse: p.pulse,
longitude: p.longitude,
latitude: p.latitude,
altitude: p.altitude,
}))
}}],
description: name,
@ -75,45 +78,3 @@ export function today() {
}
function pad(n) {return n > 9 ? n.toString() : `0${n}`}
/*
{
"date": "2023-12-31",
"contents": [
{
"rawActivity": {
"kind": "Walking",
"sets": [],
"measurements": [
{
"seconds": 1234,
"calories": 4321,
"meters": 432553
},
{
"seconds": 2468,
"calories": 42342,
"meters": 3424
},
{
"seconds": 3702,
"calories": 23423,
"meters": 2342
},
{
"seconds": 4936,
"calories": 23423,
"meters": 2342
}
],
"effortScale": 1,
"weight": 0
}
}
],
"description": "asdfasdfasdf",
"tags": []
}
*/
Loading…
Cancel
Save