fixes #57 where diagram would show spikes

This commit is contained in:
Lars Berning 2022-01-31 19:47:18 +01:00
parent b1aebef900
commit 6792ca77c1
No known key found for this signature in database
GPG Key ID: 028E73C9E1D8A0B3
1 changed files with 5 additions and 2 deletions

View File

@ -68,8 +68,11 @@ export default class RowerDataCharacteristic extends bleno.Characteristic {
// Total Distance in meters
bufferBuilder.writeUInt24LE(Math.round(data.distanceTotal))
// Instantaneous Pace in seconds/500m
// if split is infinite (i.e. while pausing), use the highest possible number
bufferBuilder.writeUInt16LE(data.split !== Infinity ? Math.round(data.split) : 0xFFFF)
// if split is infinite (i.e. while pausing), should use the highest possible number (0xFFFF)
// todo: eventhough mathematically correct, setting 0xFFFF (65535s) causes some ugly spikes
// in some applications which could shift the axis (i.e. workout diagrams in MyHomeFit)
// so instead for now we use 0 here
bufferBuilder.writeUInt16LE(data.split !== Infinity ? Math.round(data.split) : 0)
// Instantaneous Power in watts
bufferBuilder.writeUInt16LE(Math.round(data.power))
// Energy in kcal