Skip to content

Commit

Permalink
Fix bugs for Heart Rate and First Run
Browse files Browse the repository at this point in the history
  • Loading branch information
aidanblack committed Jul 13, 2021
1 parent 63cfc6c commit f588c2b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,37 +53,38 @@ var clockController = new Clock(
console.log("initialize body and heart rate");

const heartRate = document.getElementById("heartRate");
const body = null;
const hrm;

function processHeartRate() {
if (!settings.hideHeartRate && display.on) {
heartRate.animate("enable");
}
}

function processBodyPresence() {
if (!settings.hideHeartRate && display.on && body.present) {
hrm.start();
} else {
hrm.stop();
}
}

const body = null;
if (BodyPresenceSensor) {
body = new BodyPresenceSensor();
body.start();
body.addEventListener("reading", () => {
processHeartRate();
});
}

const hrm;
if (HeartRateSensor) {
hrm = new HeartRateSensor({ frequency: 1 });
hrm.start();
hrm.addEventListener("reading", () => {
processHeartRate();
});
}

if (BodyPresenceSensor) {
body = new BodyPresenceSensor();
body.start();
body.addEventListener("reading", () => {
processBodyPresence();
});
}

// ***** Display *****
console.log("set up display");

Expand All @@ -97,16 +98,17 @@ if (display.aodAvailable && me.permissions.granted("access_aod")) {
display.addEventListener("change", () => {
// Is the display on?
if (!display.aodActive && display.on) {
body.start();
hrm.start();
body.start();
clock.granularity = "seconds";
clockController.weather.updateWeather();
}
else {
body.stop();
hrm.stop();
body.stop();
clock.granularity = "minutes";
}
processHeartRate();
face.updateDisplay();
});
}
Expand All @@ -115,16 +117,17 @@ else {
display.addEventListener("change", () => {
// Is the display on?
if (display.on) {
body.start();
hrm.start();
body.start();
clock.granularity = "seconds";
clockController.weather.updateWeather();
}
else {
body.stop();
hrm.stop();
body.stop();
clock.granularity = "minutes";
}
processHeartRate();
face.updateDisplay();
});
}
Expand All @@ -135,7 +138,13 @@ clockController.updateDisplay = () => { face.updateDisplay() };
console.log("set up weather");

var weather = new Weather(document.getElementById("temperature"), document.getElementById("weatherIcon"));
weather.tempUnit = settings.tempUnit.selected;
try {
weather.tempUnit = settings.tempUnit.selected || "Celsius";
}
catch (err) {
console.log(err);
weather.tempUnit = "Celsius";
}
clockController.weather = weather;

// ***** Goals *****
Expand Down
Binary file modified build/app.fba
Binary file not shown.

0 comments on commit f588c2b

Please sign in to comment.