Skip to content

Commit d9161bc

Browse files
committed
Bangle.js2: Adjust accelerometer axes for HRM algorithm to more closely match the datasheet
1 parent ebc8738 commit d9161bc

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
nRF52: Add 'slaveLatency' option to BluetoothRemoteGATTServer.connect, default changed from 2 to 4
44
nRF52: Add 'phy' and 'mtu' events to NRF/BluetoothDevice when these change on a connection
55
MDBT42Q: Remove SHA512 from the build (needs 2.5k flash, rarely used)
6+
Bangle.js2: Adjust accelerometer axes for HRM algorithm to more closely match the datasheet
67

78
2v27 : nRF5x: Ensure Bluetooth notifications work correctly when two separate connections use the same handle for their characteristics
89
nRF5x: Remove handlers from our handlers array when a device is disconnected

libs/misc/heartrate_vc31_binary.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,14 @@ bool hrm_new(int ppgValue, Vector3 *acc) {
6262
hrmInfo.raw = ppgValue;
6363
// Feed data into algorithm
6464
AlgoInputData_t inputData;
65-
inputData.axes.x = acc->y >> 5; // perpendicular to the direction of the arm
66-
inputData.axes.y = acc->x >> 5; // along the direction of the arm
67-
inputData.axes.z = acc->z >> 5;
65+
// Acceleration data should have 1G=256 (acc is 1G=8192, so shift by 5 bits)
66+
inputData.axes.x = -acc->y >> 5; // perpendicular to the direction of the arm (if left-hand, in direction of thumb)
67+
inputData.axes.y = -acc->x >> 5; // along the direction of the arm (if left-hand, in direction of middle finger)
68+
inputData.axes.z = acc->z >> 5; // if left-hand, running into palm
6869
inputData.ppgSample = vcInfo.ppgValue | (vcInfo.wasAdjusted ? 0x1000 : 0);
6970
inputData.envSample = vcInfo.envValue;
7071
hrmInfo.msSinceLastHRM += timeDiff;
72+
// TODO: The VC31 example code uses a static value here (eg hrmPollInterval) - maybe we should do this
7173
Algo_Input(&inputData, timeDiff, hrmInfo.sportMode, 0/*surfaceRecogMode*/,0/*opticalAidMode*/);
7274
AlgoOutputData_t outputData;
7375
Algo_Output(&outputData);
@@ -93,4 +95,4 @@ void hrm_get_hrm_info(JsVar *o) {
9395

9496
// Append extra information to an existing HRM-raw event object
9597
void hrm_get_hrm_raw_info(JsVar *o) {
96-
}
98+
}

0 commit comments

Comments
 (0)