mirror of https://github.com/espruino/BangleApps
hrmmar: bthrm compatibility
- Disable when bthrm is active - Enable fft elim as defaultpull/2657/head
parent
641fecf116
commit
a152ff546c
|
@ -0,0 +1,3 @@
|
||||||
|
0.01: New App
|
||||||
|
0.02: Disable when bthrm is active
|
||||||
|
Enable fft elim as default
|
|
@ -7,5 +7,5 @@ Measurements from the build in PPG-Sensor (Photoplethysmograph) is sensitive to
|
||||||
* **MA removal**
|
* **MA removal**
|
||||||
|
|
||||||
Select the algorithm to Remove Motion artifacts:
|
Select the algorithm to Remove Motion artifacts:
|
||||||
- None: (default) No Motion Artifact removal.
|
- None: No Motion Artifact removal.
|
||||||
- fft elim: (*experimental*) Remove Motion Artifacts by cutting out the frequencies from the HRM frequency spectrum that are noisy in acceleration spectrum. Under motion this can report a heart rate that is closer to the real one but will fail if motion frequency and heart rate overlap.
|
- fft elim: (default, *experimental*) Remove Motion Artifacts by cutting out the frequencies from the HRM frequency spectrum that are noisy in acceleration spectrum. Under motion this can report a heart rate that is closer to the real one but will fail if motion frequency and heart rate overlap.
|
||||||
|
|
|
@ -5,8 +5,12 @@
|
||||||
bpm_corrected = bpm;
|
bpm_corrected = bpm;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isInternal = (hrm) => {
|
||||||
|
return !hrm.src || hrm.src === "int";
|
||||||
|
};
|
||||||
|
|
||||||
Bangle.on('HRM', (hrm) => {
|
Bangle.on('HRM', (hrm) => {
|
||||||
if (bpm_corrected > 0) {
|
if (isInternal(hrm) && bpm_corrected > 0) {
|
||||||
// replace bpm data in event
|
// replace bpm data in event
|
||||||
hrm.bpm_orig = hrm.bpm;
|
hrm.bpm_orig = hrm.bpm;
|
||||||
hrm.confidence_orig = hrm.confidence;
|
hrm.confidence_orig = hrm.confidence;
|
||||||
|
@ -17,16 +21,16 @@
|
||||||
|
|
||||||
let run = () => {
|
let run = () => {
|
||||||
const settings = Object.assign({
|
const settings = Object.assign({
|
||||||
mAremoval: 0
|
mAremoval: 1
|
||||||
}, require("Storage").readJSON("hrmmar.json", true) || {});
|
}, require("Storage").readJSON("hrmmar.json", true) || {});
|
||||||
|
|
||||||
// select motion artifact removal algorithm
|
// select motion artifact removal algorithm
|
||||||
switch(settings.mAremoval) {
|
switch(settings.mAremoval) {
|
||||||
case 1:
|
case 1:
|
||||||
require("hrmfftelim").run(settings, updateHrm);
|
require("hrmfftelim").run(settings, updateHrm, isInternal);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
// override setHRMPower so we can run our code on HRM enable
|
// override setHRMPower so we can run our code on HRM enable
|
||||||
const oldSetHRMPower = Bangle.setHRMPower;
|
const oldSetHRMPower = Bangle.setHRMPower;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
exports.run = (settings, updateHrm) => {
|
exports.run = (settings, updateHrm, isInternal) => {
|
||||||
const SAMPLE_RATE = 12.5;
|
const SAMPLE_RATE = 12.5;
|
||||||
const NUM_POINTS = 256; // fft size
|
const NUM_POINTS = 256; // fft size
|
||||||
const ACC_PEAKS = 2; // remove this number of ACC peaks
|
const ACC_PEAKS = 2; // remove this number of ACC peaks
|
||||||
|
@ -147,7 +147,7 @@ exports.run = (settings, updateHrm) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
Bangle.on('accel', (acc) => {
|
Bangle.on('accel', (acc) => {
|
||||||
if (hrmdata !== undefined) {
|
if (hrmdata !== undefined && isInternal(hrmdata)) {
|
||||||
hrmvalues[idx] = hrmdata.filt;
|
hrmvalues[idx] = hrmdata.filt;
|
||||||
accvalues[idx] = acc.x*1000 + acc.y*1000 + acc.z*1000;
|
accvalues[idx] = acc.x*1000 + acc.y*1000 + acc.z*1000;
|
||||||
idx++;
|
idx++;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"name": "HRM Motion Artifacts removal",
|
"name": "HRM Motion Artifacts removal",
|
||||||
"shortName":"HRM MA removal",
|
"shortName":"HRM MA removal",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"version":"0.01",
|
"version":"0.02",
|
||||||
"description": "Removes Motion Artifacts in Bangle.js's heart rate sensor data.",
|
"description": "Removes Motion Artifacts in Bangle.js's heart rate sensor data.",
|
||||||
"type": "bootloader",
|
"type": "bootloader",
|
||||||
"tags": "health",
|
"tags": "health",
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
var FILE = "hrmmar.json";
|
var FILE = "hrmmar.json";
|
||||||
// Load settings
|
// Load settings
|
||||||
var settings = Object.assign({
|
var settings = Object.assign({
|
||||||
mAremoval: 0,
|
mAremoval: 1,
|
||||||
}, require('Storage').readJSON(FILE, true) || {});
|
}, require('Storage').readJSON(FILE, true) || {});
|
||||||
|
|
||||||
function writeSettings() {
|
function writeSettings() {
|
||||||
|
|
Loading…
Reference in New Issue