Skip to content

Commit 43535a6

Browse files
committed
Bangle.js2: Add Bangle.setOptions({hrmStaticSampleTime})
1 parent c39547d commit 43535a6

File tree

4 files changed

+5
-1
lines changed

4 files changed

+5
-1
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
MDBT42Q: Remove SHA512 from the build (needs 2.5k flash, rarely used)
66
Bangle.js2: Adjust accelerometer axes for HRM algorithm to more closely match the datasheet
77
nRF52: Add NRF/BluetoothRemoteGATTServer.updateConnection for setting the phy
8+
Bangle.js2: Add Bangle.setOptions({hrmStaticSampleTime})
89

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

libs/banglejs/jswrap_bangle.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2721,6 +2721,7 @@ call `E.kickWatchdog()` from your code or the watch will reset after ~5 seconds.
27212721
* `hrmGreenAdjust` - (Bangle.js 2, 2v19+) if false (default is true) the green LED intensity won't be adjusted to get the HRM sensor 'exposure' correct. This is reset when the HRM is initialised with `Bangle.setHRMPower`.
27222722
* `hrmWearDetect` - (Bangle.js 2, 2v19+) if false (default is true) HRM readings won't be turned off if the watch isn't on your arm (based on HRM proximity sensor). This is reset when the HRM is initialised with `Bangle.setHRMPower`.
27232723
* `hrmPushEnv` - (Bangle.js 2, 2v19+) if true (default is false) HRM environment readings will be produced as `Bangle.on(`HRM-env`, ...)` events. This is reset when the HRM is initialised with `Bangle.setHRMPower`.
2724+
* `hrmStaticSampleTime` - (Bangle.js 2, 2v28+) if true (default is false) force the HRM to use hrmPollInterval as the sample time rather than the real poll interval
27242725
* `seaLevelPressure` (Bangle.js 2) Default 1013.25 millibars - this is used when calculating altitude from pressure sensor values from `Bangle.getPressure`/`pressure` events.
27252726
* `lcdBufferPtr` (Bangle.js 2 2v21+) Return a pointer to the first pixel of the 3 bit graphics buffer used by Bangle.js for the screen (stride = 178 bytes)
27262727
* `lcdDoubleRefresh` (Bangle.js 2 2v22+) If enabled, pulses EXTCOMIN twice per poll interval (avoids off-axis flicker)
@@ -2771,6 +2772,7 @@ JsVar * _jswrap_banglejs_setOptions(JsVar *options, bool createObject) {
27712772
{"hrmGreenAdjust", JSV_BOOLEAN, &vcInfo.allowGreenAdjust},
27722773
{"hrmWearDetect", JSV_BOOLEAN, &vcInfo.allowWearDetect},
27732774
{"hrmPushEnv", JSV_BOOLEAN, &vcInfo.pushEnvData},
2775+
{"hrmStaticSampleTime", JSV_BOOLEAN, &vcInfo.useStaticSampleTime},
27742776
#endif
27752777
#ifdef PRESSURE_DEVICE
27762778
{"seaLevelPressure", JSV_FLOAT, &barometerSeaLevelPressure},

libs/misc/heartrate_vc31_binary.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ bool hrm_new(int ppgValue, Vector3 *acc) {
7070
inputData.envSample = vcInfo.envValue;
7171
hrmInfo.msSinceLastHRM += timeDiff;
7272
// TODO: The VC31 example code uses a static value here (eg hrmPollInterval) - maybe we should do this
73-
Algo_Input(&inputData, timeDiff, hrmInfo.sportMode, 0/*surfaceRecogMode*/,0/*opticalAidMode*/);
73+
Algo_Input(&inputData, vcInfo.useStaticSampleTime ? hrmPollInterval : timeDiff, hrmInfo.sportMode, 0/*surfaceRecogMode*/,0/*opticalAidMode*/);
7474
AlgoOutputData_t outputData;
7575
Algo_Output(&outputData);
7676
//jsiConsolePrintf("HRM %d %d %d\n", outputData.hrData, outputData.reliability, hrmInfo.msSinceLastHRM);

libs/misc/hrm_vc31.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ typedef struct {
3636
bool allowGreenAdjust; // allow automatic adjustment of LED power
3737
bool allowWearDetect; // allow automatic check for whether HRM is worn
3838
bool pushEnvData; // call jsbangle_push_event to push data for every received ENV sample
39+
bool useStaticSampleTime; // use a static time period for samples, rather than the time between them
3940
} PACKED_FLAGS VC31Info;
4041

4142
extern VC31Info vcInfo;

0 commit comments

Comments
 (0)