mirror of https://github.com/espruino/BangleApps
commit
3ea91c66a2
|
@ -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**
|
||||
|
||||
Select the algorithm to Remove Motion artifacts:
|
||||
- None: (default) 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.
|
||||
- None: No Motion Artifact removal.
|
||||
- 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;
|
||||
};
|
||||
|
||||
const isInternal = (hrm) => {
|
||||
return !hrm.src || hrm.src === "int";
|
||||
};
|
||||
|
||||
Bangle.on('HRM', (hrm) => {
|
||||
if (bpm_corrected > 0) {
|
||||
if (isInternal(hrm) && bpm_corrected > 0) {
|
||||
// replace bpm data in event
|
||||
hrm.bpm_orig = hrm.bpm;
|
||||
hrm.confidence_orig = hrm.confidence;
|
||||
|
@ -17,16 +21,16 @@
|
|||
|
||||
let run = () => {
|
||||
const settings = Object.assign({
|
||||
mAremoval: 0
|
||||
mAremoval: 1
|
||||
}, require("Storage").readJSON("hrmmar.json", true) || {});
|
||||
|
||||
// select motion artifact removal algorithm
|
||||
switch(settings.mAremoval) {
|
||||
case 1:
|
||||
require("hrmfftelim").run(settings, updateHrm);
|
||||
require("hrmfftelim").run(settings, updateHrm, isInternal);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// override setHRMPower so we can run our code on HRM enable
|
||||
const oldSetHRMPower = Bangle.setHRMPower;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
exports.run = (settings, updateHrm) => {
|
||||
exports.run = (settings, updateHrm, isInternal) => {
|
||||
const SAMPLE_RATE = 12.5;
|
||||
const NUM_POINTS = 256; // fft size
|
||||
const ACC_PEAKS = 2; // remove this number of ACC peaks
|
||||
|
@ -147,7 +147,7 @@ exports.run = (settings, updateHrm) => {
|
|||
});
|
||||
|
||||
Bangle.on('accel', (acc) => {
|
||||
if (hrmdata !== undefined) {
|
||||
if (hrmdata !== undefined && isInternal(hrmdata)) {
|
||||
hrmvalues[idx] = hrmdata.filt;
|
||||
accvalues[idx] = acc.x*1000 + acc.y*1000 + acc.z*1000;
|
||||
idx++;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"name": "HRM Motion Artifacts removal",
|
||||
"shortName":"HRM MA removal",
|
||||
"icon": "app.png",
|
||||
"version":"0.01",
|
||||
"version":"0.02",
|
||||
"description": "Removes Motion Artifacts in Bangle.js's heart rate sensor data.",
|
||||
"type": "bootloader",
|
||||
"tags": "health",
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
var FILE = "hrmmar.json";
|
||||
// Load settings
|
||||
var settings = Object.assign({
|
||||
mAremoval: 0,
|
||||
mAremoval: 1,
|
||||
}, require('Storage').readJSON(FILE, true) || {});
|
||||
|
||||
function writeSettings() {
|
||||
|
|
Loading…
Reference in New Issue