Skip to content

Commit

Permalink
Move body presence checking to main companion to enable tests, update…
Browse files Browse the repository at this point in the history
… Mocha
  • Loading branch information
sulkaharo committed Oct 6, 2024
1 parent 732ffb8 commit ea4cc70
Show file tree
Hide file tree
Showing 4 changed files with 1,894 additions and 2,735 deletions.
11 changes: 1 addition & 10 deletions app/alarms.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const ALARM_BG = 'BG';
const ALARM_PRED = 'PRED_BG';
const ALARM_STALE = 'STALE_DATA';
import { BodyPresenceSensor } from "body-presence";

export default class Alarms {

Expand All @@ -11,15 +10,7 @@ export default class Alarms {
this._snoozes = {};
ui.init(this);
this._ui = ui;
this._bodyPresence = false;

if (BodyPresenceSensor) {
console.log("This device has a BodyPresenceSensor!");
this._bodyPresence = new BodyPresenceSensor();
this._bodyPresence.start();
} else {
console.log("This device does NOT have a BodyPresenceSensor!");
}
this._bodyPresence = settings.bodyPrecense;
}

removeSnooze(type) {
Expand Down
16 changes: 15 additions & 1 deletion app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import AlarmUI from "./alert-ui.js";
//import Tracking from "./tracking.js";
import { memory } from "system";
import { me as device } from "device";
import { BodyPresenceSensor } from "body-presence";

if (!device.screen) device.screen = { width: 348, height: 250 };

Expand Down Expand Up @@ -64,11 +65,12 @@ UI_docGraph.width = device.screen.width;
let myGraph = new Graph(UI_docGraph);

let settings = {};

let latestHR = 0;

let month;

settings.bodyPrecense = _bodyPresence;

const alarmsUI = new AlarmUI();
const alarms = new Alarms(settings, alarmsUI);

Expand Down Expand Up @@ -121,6 +123,18 @@ function noiseCodeToDisplay (mgdl, noise) {
return display;
}

// Body Presence API

let _bodyPresence = false;

if (BodyPresenceSensor) {
console.log("This device has a BodyPresenceSensor!");
_bodyPresence = new BodyPresenceSensor();
_bodyPresence.start();
} else {
console.log("This device does NOT have a BodyPresenceSensor!");
}

//----------------------------------------------------------
//
// This section is for displaying the heart rate
Expand Down
2 changes: 1 addition & 1 deletion sdk5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"babel-eslint": "^10.0.3",
"eslint": "^6.6.0",
"jshint": "^2.10.3",
"mocha": "^6.2.2",
"mocha": "^10.7.3",
"should": "^13.2.3"
},
"fitbit": {
Expand Down
Loading

0 comments on commit ea4cc70

Please sign in to comment.