From 42069a6e4e57c2b0a106f078f3d8a2c6d506b43f Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Tue, 1 Nov 2022 06:56:09 +0100 Subject: [PATCH] sleepphasealarm Fix: Do not wake when falling asleep --- apps/gpsautotime/settings.js | 2 +- apps/gpsautotime/widget.js | 2 +- apps/sleepphasealarm/ChangeLog | 2 +- apps/sleepphasealarm/README.md | 4 +++- apps/sleepphasealarm/app.js | 2 +- apps/sleepphasealarm/interface.html | 2 +- apps/sleepphasealarm/metadata.json | 2 +- 7 files changed, 9 insertions(+), 7 deletions(-) diff --git a/apps/gpsautotime/settings.js b/apps/gpsautotime/settings.js index be6e3bbec..34a6364fe 100644 --- a/apps/gpsautotime/settings.js +++ b/apps/gpsautotime/settings.js @@ -13,7 +13,7 @@ E.showMenu({ "" : { "title" : "GPS auto time" }, "< Back" : () => back(), - 'Show Widgets': { + 'Show Widget': { value: !!settings.show, onchange: v => { settings.show = v; diff --git a/apps/gpsautotime/widget.js b/apps/gpsautotime/widget.js index a21c14619..14d6fe140 100644 --- a/apps/gpsautotime/widget.js +++ b/apps/gpsautotime/widget.js @@ -9,7 +9,7 @@ delete settings; Bangle.on('GPS',function(fix) { - if (fix.fix) { + if (fix.fix && fix.time) { var curTime = fix.time.getTime()/1000; setTime(curTime); lastTimeSet = curTime; diff --git a/apps/sleepphasealarm/ChangeLog b/apps/sleepphasealarm/ChangeLog index 6bf296342..9f2b07d49 100644 --- a/apps/sleepphasealarm/ChangeLog +++ b/apps/sleepphasealarm/ChangeLog @@ -10,4 +10,4 @@ 0.09: Vibrate with configured pattern Add setting to defer start of algorithm Add setting to disable scheduler alarm - +0.10: Fix: Do not wake when falling asleep diff --git a/apps/sleepphasealarm/README.md b/apps/sleepphasealarm/README.md index ecb3feb06..574e84e1e 100644 --- a/apps/sleepphasealarm/README.md +++ b/apps/sleepphasealarm/README.md @@ -9,6 +9,8 @@ The display shows: - Time difference between current time and alarm time (ETA). - Current state of the ESS algorithm, "Sleep" or "Awake", useful for debugging. State can also be "Deferred", see the "Run before alarm"-option. +Replacing the watch strap with a more comfortable one (e.g. made of nylon) is recommended. + ## Settings * **Keep alarm enabled** @@ -16,7 +18,7 @@ The display shows: - No: No action at configured alarm time from scheduler. * **Run before alarm** - disabled: (default) The ESS algorithm starts immediately when the application starts. - - 1..23: The ESS algorithm starts the configured time before the alarm. E.g. when set to 1h for an alarm at 7:00 the ESS algorithm will start at 6:00. This improves battery life. + - 1..23: The ESS algorithm starts the configured time before the alarm. E.g. when set to 1h for an alarm at 7:00 the ESS algorithm will start at 6:00. This increases battery life. ## Logging diff --git a/apps/sleepphasealarm/app.js b/apps/sleepphasealarm/app.js index b19799c4b..b3aacc80d 100644 --- a/apps/sleepphasealarm/app.js +++ b/apps/sleepphasealarm/app.js @@ -168,7 +168,7 @@ if (nextAlarmDate !== undefined) { // The alarm widget should handle this one addLog(now, "alarm"); setTimeout(load, 1000); - } else if (measure && now >= minAlarm && swest_last === false) { + } else if (measure && now >= minAlarm && swest === false) { addLog(now, "alarm"); buzz(); measure = false; diff --git a/apps/sleepphasealarm/interface.html b/apps/sleepphasealarm/interface.html index f45c183e1..8c8cea990 100644 --- a/apps/sleepphasealarm/interface.html +++ b/apps/sleepphasealarm/interface.html @@ -30,7 +30,7 @@ function getData() { // remove window Util.hideModal(); - logs = logs.filter(log => log != null); + logs = logs.filter(log => log != null && log.filter(entry => entry.type === "alarm").length > 0); logs.sort(function(a, b) {return new Date(b?.filter(entry => entry.type === "alarm")[0]?.time) - new Date(a?.filter(entry => entry.type === "alarm")[0]?.time)}); // sort by alarm date desc logs.forEach((log, i) => { const timeStr = log.filter(entry => entry.type === "alarm")[0]?.time; diff --git a/apps/sleepphasealarm/metadata.json b/apps/sleepphasealarm/metadata.json index 6ec5f4180..35eea7466 100644 --- a/apps/sleepphasealarm/metadata.json +++ b/apps/sleepphasealarm/metadata.json @@ -2,7 +2,7 @@ "id": "sleepphasealarm", "name": "SleepPhaseAlarm", "shortName": "SleepPhaseAlarm", - "version": "0.09", + "version": "0.10", "description": "Uses the accelerometer to estimate sleep and wake states with the principle of Estimation of Stationary Sleep-segments (ESS, see https://ubicomp.eti.uni-siegen.de/home/datasets/ichi14/index.html.en). This app will read the next alarm from the alarm application and will wake you up to 30 minutes early at the best guessed time when you are almost already awake.", "icon": "app.png", "tags": "alarm",