Skip to content

Commit

Permalink
Update AdditionalStrokeData.js
Browse files Browse the repository at this point in the history
  • Loading branch information
JaapvanEkris authored Sep 3, 2024
1 parent 8e089d0 commit a31d959
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions app/peripherals/ble/pm5/characteristic/AdditionalStrokeData.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'
/*
Open Rowing Monitor, https://github.com/laberning/openrowingmonitor
Open Rowing Monitor, https://github.com/JaapvanEkris/openrowingmonitor
Implementation of the AdditionalStrokeData as defined in:
https://www.concept2.co.uk/files/pdf/us/monitors/PM5_BluetoothSmartInterfaceDefinition.pdf
Expand Down Expand Up @@ -40,20 +40,20 @@ export default class AdditionalStrokeData extends bleno.Characteristic {
// elapsedTime: UInt24LE in 0.01 sec
bufferBuilder.writeUInt24LE(Math.round(data.totalMovingTime * 100))
// strokePower: UInt16LE in watts
bufferBuilder.writeUInt16LE(Math.round(data.cyclePower))
bufferBuilder.writeUInt16LE(data.cyclePower > 0 ? Math.round(data.cyclePower) : 0)
// strokeCalories: UInt16LE in cal
bufferBuilder.writeUInt16LE(Math.round(data.strokeCalories * 1000))
bufferBuilder.writeUInt16LE(data.strokeCalories > 0 ? Math.round(data.strokeCalories * 1000) : 0)
// strokeCount: UInt16LE
bufferBuilder.writeUInt16LE(Math.round(data.totalNumberOfStrokes))
bufferBuilder.writeUInt16LE(data.totalNumberOfStrokes > 0 ? Math.round(data.totalNumberOfStrokes) : 0)
// projectedWorkTime: UInt24LE in 1 sec
bufferBuilder.writeUInt24LE(Math.round(data.cycleProjectedEndTime))
bufferBuilder.writeUInt24LE(data.cycleProjectedEndTime > 0 ? Math.round(data.cycleProjectedEndTime) : 0)
// projectedWorkDistance: UInt24LE in 1 m
bufferBuilder.writeUInt24LE(Math.round(data.cycleProjectedEndLinearDistance))
bufferBuilder.writeUInt24LE(data.cycleProjectedEndLinearDistance > 0 ? Math.round(data.cycleProjectedEndLinearDistance) : 0)
if (!this._updateValueCallback) {
// the multiplexer uses a slightly different format for the AdditionalStrokeData
// it adds workPerStroke at the end
// workPerStroke: UInt16LE in 0.1 Joules
bufferBuilder.writeUInt16LE(Math.round(data.strokeWork * 10))
bufferBuilder.writeUInt16LE(data.strokeWork > 0 ? Math.round(data.strokeWork * 10) : 0)
}

if (this._updateValueCallback) {
Expand Down

0 comments on commit a31d959

Please sign in to comment.