From 853d8eeef337169be211da221ce81e7149fb59c9 Mon Sep 17 00:00:00 2001 From: Ishidres <17363426+Ishidres@users.noreply.github.com> Date: Fri, 8 Mar 2024 00:08:48 +0100 Subject: [PATCH 01/22] Add comments about sleep status, fix typo --- apps/sleeplog/boot.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/sleeplog/boot.js b/apps/sleeplog/boot.js index 53873ab29..e956c5ed1 100644 --- a/apps/sleeplog/boot.js +++ b/apps/sleeplog/boot.js @@ -158,11 +158,12 @@ if (sleeplog.conf.enabled) { data.timestamp = data.timestamp || ((Date.now() / 6E5 | 0) - 1) * 6E5; // add preliminary status depending on charging and movement thresholds + // 1 = not worn, 2 = awake, 3 = light sleep, 4 = deep sleep data.status = Bangle.isCharging() ? 1 : data.movement <= sleeplog.conf.deepTh ? 4 : data.movement <= sleeplog.conf.lightTh ? 3 : 2; - // check if changing to deep sleep from non sleepling + // check if changing to deep sleep from non sleeping if (data.status === 4 && sleeplog.status <= 2) { // check wearing status sleeplog.checkIsWearing((isWearing, data) => { From c4a25b6be1921959926197b13adad05e9a13a3a1 Mon Sep 17 00:00:00 2001 From: Ishidres <17363426+Ishidres@users.noreply.github.com> Date: Mon, 11 Mar 2024 18:10:13 +0100 Subject: [PATCH 02/22] Determine if worn based on temperature threshold --- apps/sleeplog/boot.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/apps/sleeplog/boot.js b/apps/sleeplog/boot.js index e956c5ed1..ac7e63b1e 100644 --- a/apps/sleeplog/boot.js +++ b/apps/sleeplog/boot.js @@ -13,6 +13,7 @@ global.sleeplog = { minConsec: 18E5, // [ms] minimal time to count for consecutive sleep deepTh: 100, // threshold for deep sleep lightTh: 200, // threshold for light sleep + wearTemp: 27, // temperature threshold to count as worn }, require("Storage").readJSON("sleeplog.json", true) || {}) }; @@ -166,12 +167,18 @@ if (sleeplog.conf.enabled) { // check if changing to deep sleep from non sleeping if (data.status === 4 && sleeplog.status <= 2) { // check wearing status + if (sleeplog.isNotWorn()) { + data.status = 1; + } + + /* sleeplog.checkIsWearing((isWearing, data) => { // correct status if (!isWearing) data.status = 1; // set status sleeplog.setStatus(data); }, data); + */ } else { // set status sleeplog.setStatus(data); @@ -209,6 +216,12 @@ if (sleeplog.conf.enabled) { }, 2500, returnFn, data); }, + // Determine if Bangle.JS is worn based on temperature (same strategy as in activityreminder) + // https://github.com/espruino/BangleApps/blob/master/apps/activityreminder/boot.js#L37 + isNotWorn: function() { + return (Bangle.isCharging() || this.conf.wearTemp >= E.getTemperature()); + }, + // define function to set the status setStatus: function(data) { // update lastCheck From ff92b515b6c3ecfec08a509057e97ce9deee5fe8 Mon Sep 17 00:00:00 2001 From: Ishidres <17363426+Ishidres@users.noreply.github.com> Date: Mon, 11 Mar 2024 18:14:08 +0100 Subject: [PATCH 03/22] Fix comparison operator in isNotWorn function --- apps/sleeplog/boot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/sleeplog/boot.js b/apps/sleeplog/boot.js index ac7e63b1e..a35e5e64f 100644 --- a/apps/sleeplog/boot.js +++ b/apps/sleeplog/boot.js @@ -219,7 +219,7 @@ if (sleeplog.conf.enabled) { // Determine if Bangle.JS is worn based on temperature (same strategy as in activityreminder) // https://github.com/espruino/BangleApps/blob/master/apps/activityreminder/boot.js#L37 isNotWorn: function() { - return (Bangle.isCharging() || this.conf.wearTemp >= E.getTemperature()); + return (Bangle.isCharging() || this.conf.wearTemp > E.getTemperature()); }, // define function to set the status From c046fcd1827c5ea0783975150f9302aedffe6d40 Mon Sep 17 00:00:00 2001 From: Ishidres <17363426+Ishidres@users.noreply.github.com> Date: Mon, 11 Mar 2024 18:15:02 +0100 Subject: [PATCH 04/22] Add wear temperature setting --- apps/sleeplog/settings.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/apps/sleeplog/settings.js b/apps/sleeplog/settings.js index 9bf37ed69..c11dbf291 100644 --- a/apps/sleeplog/settings.js +++ b/apps/sleeplog/settings.js @@ -13,6 +13,7 @@ minConsec: 18E5, // [ms] minimal time to count for consecutive sleep deepTh: 100, // threshold for deep sleep lightTh: 200, // threshold for light sleep + wearTemp: 27, // temperature threshold to count as worn // app settings breakToD: 12, // [h] time of day when to start/end graphs appTimeout: 0 // lock and backlight timeouts for the app @@ -345,6 +346,19 @@ writeSetting(); } }, + /*LANG*/"Wear Temperature": { + value: settings.w, + step: 0.5, + min: 20, + max: 40, + wrap: true, + noList: true, + format: v => v + "°C", + onchange: v => { + settings.wearTemp = v; + writeSetting(); + } + }, /*LANG*/"Reset to Default": () => { settings.maxAwake = defaults.maxAwake; settings.minConsec = defaults.minConsec; From 7325cc4d3a9084c0d1be0d23286a6d32138a69ab Mon Sep 17 00:00:00 2001 From: Ishidres <17363426+Ishidres@users.noreply.github.com> Date: Mon, 11 Mar 2024 18:17:00 +0100 Subject: [PATCH 05/22] Add check for wearing status and set status accordingly --- apps/sleeplog/boot.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/sleeplog/boot.js b/apps/sleeplog/boot.js index a35e5e64f..c66db772f 100644 --- a/apps/sleeplog/boot.js +++ b/apps/sleeplog/boot.js @@ -167,9 +167,12 @@ if (sleeplog.conf.enabled) { // check if changing to deep sleep from non sleeping if (data.status === 4 && sleeplog.status <= 2) { // check wearing status + // if not worn set status to not worn if (sleeplog.isNotWorn()) { data.status = 1; } + + sleeplog.setStatus(data); /* sleeplog.checkIsWearing((isWearing, data) => { From 9220c720a46912960b896694688273a72cb9ece8 Mon Sep 17 00:00:00 2001 From: Ishidres <17363426+Ishidres@users.noreply.github.com> Date: Mon, 11 Mar 2024 18:24:56 +0100 Subject: [PATCH 06/22] Fix typo --- apps/sleeplog/settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/sleeplog/settings.js b/apps/sleeplog/settings.js index c11dbf291..5d925caa5 100644 --- a/apps/sleeplog/settings.js +++ b/apps/sleeplog/settings.js @@ -347,7 +347,7 @@ } }, /*LANG*/"Wear Temperature": { - value: settings.w, + value: settings.wearTemp, step: 0.5, min: 20, max: 40, From 4491b6541538c78610d27bfe2063f68567d2b030 Mon Sep 17 00:00:00 2001 From: Ishidres <17363426+Ishidres@users.noreply.github.com> Date: Tue, 12 Mar 2024 23:52:44 +0100 Subject: [PATCH 07/22] Aktualisieren von settings.js --- apps/sleeplog/settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/sleeplog/settings.js b/apps/sleeplog/settings.js index 5d925caa5..4fd29f3b6 100644 --- a/apps/sleeplog/settings.js +++ b/apps/sleeplog/settings.js @@ -13,7 +13,7 @@ minConsec: 18E5, // [ms] minimal time to count for consecutive sleep deepTh: 100, // threshold for deep sleep lightTh: 200, // threshold for light sleep - wearTemp: 27, // temperature threshold to count as worn + wearTemp: 28, // temperature threshold to count as worn // app settings breakToD: 12, // [h] time of day when to start/end graphs appTimeout: 0 // lock and backlight timeouts for the app From c293b8cfc3d164594cf305669c05546406e3832c Mon Sep 17 00:00:00 2001 From: Ishidres <17363426+Ishidres@users.noreply.github.com> Date: Fri, 15 Mar 2024 10:47:43 +0100 Subject: [PATCH 08/22] Update boot.js --- apps/sleeplog/boot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/sleeplog/boot.js b/apps/sleeplog/boot.js index c66db772f..8dbee6812 100644 --- a/apps/sleeplog/boot.js +++ b/apps/sleeplog/boot.js @@ -13,7 +13,7 @@ global.sleeplog = { minConsec: 18E5, // [ms] minimal time to count for consecutive sleep deepTh: 100, // threshold for deep sleep lightTh: 200, // threshold for light sleep - wearTemp: 27, // temperature threshold to count as worn + wearTemp: 28, // temperature threshold to count as worn }, require("Storage").readJSON("sleeplog.json", true) || {}) }; From 6b76475768500fc18818c8821fe444b401930456 Mon Sep 17 00:00:00 2001 From: Ishidres <17363426+Ishidres@users.noreply.github.com> Date: Fri, 15 Mar 2024 10:58:52 +0100 Subject: [PATCH 09/22] Update boot.js --- apps/sleeplog/boot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/sleeplog/boot.js b/apps/sleeplog/boot.js index c66db772f..8dbee6812 100644 --- a/apps/sleeplog/boot.js +++ b/apps/sleeplog/boot.js @@ -13,7 +13,7 @@ global.sleeplog = { minConsec: 18E5, // [ms] minimal time to count for consecutive sleep deepTh: 100, // threshold for deep sleep lightTh: 200, // threshold for light sleep - wearTemp: 27, // temperature threshold to count as worn + wearTemp: 28, // temperature threshold to count as worn }, require("Storage").readJSON("sleeplog.json", true) || {}) }; From b02d730a6fb9750e9de108a1aa0e28f8f13d6997 Mon Sep 17 00:00:00 2001 From: Ishidres <17363426+Ishidres@users.noreply.github.com> Date: Wed, 20 Mar 2024 14:16:59 +0100 Subject: [PATCH 10/22] =?UTF-8?q?set=20default=20wear=20temperature=20to?= =?UTF-8?q?=2029=C2=B0C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/sleeplog/boot.js | 2 +- apps/sleeplog/settings.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/sleeplog/boot.js b/apps/sleeplog/boot.js index 8dbee6812..9a90ef3e6 100644 --- a/apps/sleeplog/boot.js +++ b/apps/sleeplog/boot.js @@ -13,7 +13,7 @@ global.sleeplog = { minConsec: 18E5, // [ms] minimal time to count for consecutive sleep deepTh: 100, // threshold for deep sleep lightTh: 200, // threshold for light sleep - wearTemp: 28, // temperature threshold to count as worn + wearTemp: 29, // temperature threshold to count as worn }, require("Storage").readJSON("sleeplog.json", true) || {}) }; diff --git a/apps/sleeplog/settings.js b/apps/sleeplog/settings.js index 4fd29f3b6..a2c428c29 100644 --- a/apps/sleeplog/settings.js +++ b/apps/sleeplog/settings.js @@ -13,7 +13,7 @@ minConsec: 18E5, // [ms] minimal time to count for consecutive sleep deepTh: 100, // threshold for deep sleep lightTh: 200, // threshold for light sleep - wearTemp: 28, // temperature threshold to count as worn + wearTemp: 29, // temperature threshold to count as worn // app settings breakToD: 12, // [h] time of day when to start/end graphs appTimeout: 0 // lock and backlight timeouts for the app From 245b78e292c1d2e22bcc5a83fdca6f90da426f34 Mon Sep 17 00:00:00 2001 From: Ishidres <17363426+Ishidres@users.noreply.github.com> Date: Wed, 20 Mar 2024 14:52:25 +0100 Subject: [PATCH 11/22] Refactor --- apps/sleeplog/boot.js | 36 +++++++++++++++++++----------------- apps/sleeplog/settings.js | 7 +++++++ 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/apps/sleeplog/boot.js b/apps/sleeplog/boot.js index 9a90ef3e6..44b7c08c9 100644 --- a/apps/sleeplog/boot.js +++ b/apps/sleeplog/boot.js @@ -13,6 +13,7 @@ global.sleeplog = { minConsec: 18E5, // [ms] minimal time to count for consecutive sleep deepTh: 100, // threshold for deep sleep lightTh: 200, // threshold for light sleep + tempWearCheck: false, // use temperature to detect if worn wearTemp: 29, // temperature threshold to count as worn }, require("Storage").readJSON("sleeplog.json", true) || {}) }; @@ -166,22 +167,23 @@ if (sleeplog.conf.enabled) { // check if changing to deep sleep from non sleeping if (data.status === 4 && sleeplog.status <= 2) { - // check wearing status - // if not worn set status to not worn - if (sleeplog.isNotWorn()) { - data.status = 1; - } - - sleeplog.setStatus(data); - - /* - sleeplog.checkIsWearing((isWearing, data) => { - // correct status - if (!isWearing) data.status = 1; - // set status + // check wearing status either based on HRM or temperature as set in settings + if (this.conf.tempWearCheck) { + // if not worn set status to not worn + if (!sleeplog.isWornByTemp()) { + data.status = 1; + } + sleeplog.setStatus(data); - }, data); - */ + } else { + // if not worn set status to not worn + sleeplog.checkIsWearing((isWearing, data) => { + // correct status + if (!isWearing) data.status = 1; + // set status + sleeplog.setStatus(data); + }, data); + } } else { // set status sleeplog.setStatus(data); @@ -221,8 +223,8 @@ if (sleeplog.conf.enabled) { // Determine if Bangle.JS is worn based on temperature (same strategy as in activityreminder) // https://github.com/espruino/BangleApps/blob/master/apps/activityreminder/boot.js#L37 - isNotWorn: function() { - return (Bangle.isCharging() || this.conf.wearTemp > E.getTemperature()); + isWornByTemp: function() { + return (!Bangle.isCharging() && E.getTemperature() >= this.conf.wearTemp); }, // define function to set the status diff --git a/apps/sleeplog/settings.js b/apps/sleeplog/settings.js index a2c428c29..d23a6369a 100644 --- a/apps/sleeplog/settings.js +++ b/apps/sleeplog/settings.js @@ -13,6 +13,7 @@ minConsec: 18E5, // [ms] minimal time to count for consecutive sleep deepTh: 100, // threshold for deep sleep lightTh: 200, // threshold for light sleep + tempWearCheck: false, // use temperature to detect if worn wearTemp: 29, // temperature threshold to count as worn // app settings breakToD: 12, // [h] time of day when to start/end graphs @@ -435,6 +436,12 @@ require("sleeplog").setEnabled(v); } }, + /*LANG*/"Wear detection using temperature": { + value: settings.tempWearCheck, + onchange: v => { + settings.tempWearCheck = v; + } + }, /*LANG*/"Debugging": { value: debugImg, onchange: () => setTimeout(showDebug, 10) From 58af5410409733f1598342841c671fd4a98e92ae Mon Sep 17 00:00:00 2001 From: Ishidres <17363426+Ishidres@users.noreply.github.com> Date: Wed, 20 Mar 2024 14:53:15 +0100 Subject: [PATCH 12/22] Refactor --- apps/sleeplog/boot.js | 36 +++++++++++++++++++----------------- apps/sleeplog/settings.js | 7 +++++++ 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/apps/sleeplog/boot.js b/apps/sleeplog/boot.js index 9a90ef3e6..44b7c08c9 100644 --- a/apps/sleeplog/boot.js +++ b/apps/sleeplog/boot.js @@ -13,6 +13,7 @@ global.sleeplog = { minConsec: 18E5, // [ms] minimal time to count for consecutive sleep deepTh: 100, // threshold for deep sleep lightTh: 200, // threshold for light sleep + tempWearCheck: false, // use temperature to detect if worn wearTemp: 29, // temperature threshold to count as worn }, require("Storage").readJSON("sleeplog.json", true) || {}) }; @@ -166,22 +167,23 @@ if (sleeplog.conf.enabled) { // check if changing to deep sleep from non sleeping if (data.status === 4 && sleeplog.status <= 2) { - // check wearing status - // if not worn set status to not worn - if (sleeplog.isNotWorn()) { - data.status = 1; - } - - sleeplog.setStatus(data); - - /* - sleeplog.checkIsWearing((isWearing, data) => { - // correct status - if (!isWearing) data.status = 1; - // set status + // check wearing status either based on HRM or temperature as set in settings + if (this.conf.tempWearCheck) { + // if not worn set status to not worn + if (!sleeplog.isWornByTemp()) { + data.status = 1; + } + sleeplog.setStatus(data); - }, data); - */ + } else { + // if not worn set status to not worn + sleeplog.checkIsWearing((isWearing, data) => { + // correct status + if (!isWearing) data.status = 1; + // set status + sleeplog.setStatus(data); + }, data); + } } else { // set status sleeplog.setStatus(data); @@ -221,8 +223,8 @@ if (sleeplog.conf.enabled) { // Determine if Bangle.JS is worn based on temperature (same strategy as in activityreminder) // https://github.com/espruino/BangleApps/blob/master/apps/activityreminder/boot.js#L37 - isNotWorn: function() { - return (Bangle.isCharging() || this.conf.wearTemp > E.getTemperature()); + isWornByTemp: function() { + return (!Bangle.isCharging() && E.getTemperature() >= this.conf.wearTemp); }, // define function to set the status diff --git a/apps/sleeplog/settings.js b/apps/sleeplog/settings.js index a2c428c29..d23a6369a 100644 --- a/apps/sleeplog/settings.js +++ b/apps/sleeplog/settings.js @@ -13,6 +13,7 @@ minConsec: 18E5, // [ms] minimal time to count for consecutive sleep deepTh: 100, // threshold for deep sleep lightTh: 200, // threshold for light sleep + tempWearCheck: false, // use temperature to detect if worn wearTemp: 29, // temperature threshold to count as worn // app settings breakToD: 12, // [h] time of day when to start/end graphs @@ -435,6 +436,12 @@ require("sleeplog").setEnabled(v); } }, + /*LANG*/"Wear detection using temperature": { + value: settings.tempWearCheck, + onchange: v => { + settings.tempWearCheck = v; + } + }, /*LANG*/"Debugging": { value: debugImg, onchange: () => setTimeout(showDebug, 10) From 177ad56392154a9daba21c107c088ebd7a176c30 Mon Sep 17 00:00:00 2001 From: Ishidres <17363426+Ishidres@users.noreply.github.com> Date: Thu, 21 Mar 2024 20:58:08 +0100 Subject: [PATCH 13/22] Refactor to combine checkIsWearing() and isWornByTemp() --- apps/sleeplog/boot.js | 44 ++++++++++++++----------------------------- 1 file changed, 14 insertions(+), 30 deletions(-) diff --git a/apps/sleeplog/boot.js b/apps/sleeplog/boot.js index 44b7c08c9..c6cd12b6f 100644 --- a/apps/sleeplog/boot.js +++ b/apps/sleeplog/boot.js @@ -167,37 +167,27 @@ if (sleeplog.conf.enabled) { // check if changing to deep sleep from non sleeping if (data.status === 4 && sleeplog.status <= 2) { - // check wearing status either based on HRM or temperature as set in settings - if (this.conf.tempWearCheck) { - // if not worn set status to not worn - if (!sleeplog.isWornByTemp()) { - data.status = 1; - } - + sleeplog.checkIsWearing((isWearing, data) => { + // correct status + if (!isWearing) data.status = 1; + // set status sleeplog.setStatus(data); - } else { - // if not worn set status to not worn - sleeplog.checkIsWearing((isWearing, data) => { - // correct status - if (!isWearing) data.status = 1; - // set status - sleeplog.setStatus(data); - }, data); - } - } else { - // set status - sleeplog.setStatus(data); + }, data); } }, - // define function to check if the bangle is worn by using the hrm + // check wearing status either based on HRM or temperature as set in settings checkIsWearing: function(returnFn, data) { + if (this.conf.tempWearCheck) { + return returnFn(!Bangle.isCharging() && E.getTemperature() >= this.conf.wearTemp, data); + } + // create a temporary object to store data and functions global.tmpWearingCheck = { - // define temporary hrm listener function to read the wearing status - hrmListener: hrm => tmpWearingCheck.isWearing = hrm.isWearing, - // set default wearing status - isWearing: false, + // define temporary hrm listener function to read the wearing status + hrmListener: hrm => tmpWearingCheck.isWearing = hrm.isWearing, + // set default wearing status + isWearing: false, }; // enable HRM @@ -221,12 +211,6 @@ if (sleeplog.conf.enabled) { }, 2500, returnFn, data); }, - // Determine if Bangle.JS is worn based on temperature (same strategy as in activityreminder) - // https://github.com/espruino/BangleApps/blob/master/apps/activityreminder/boot.js#L37 - isWornByTemp: function() { - return (!Bangle.isCharging() && E.getTemperature() >= this.conf.wearTemp); - }, - // define function to set the status setStatus: function(data) { // update lastCheck From 7cc67ceb278786834212b12e1f9fd34656e91634 Mon Sep 17 00:00:00 2001 From: Ishidres <17363426+Ishidres@users.noreply.github.com> Date: Fri, 22 Mar 2024 13:02:25 +0100 Subject: [PATCH 14/22] Add missing else part --- apps/sleeplog/boot.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/sleeplog/boot.js b/apps/sleeplog/boot.js index c6cd12b6f..19981623c 100644 --- a/apps/sleeplog/boot.js +++ b/apps/sleeplog/boot.js @@ -173,6 +173,9 @@ if (sleeplog.conf.enabled) { // set status sleeplog.setStatus(data); }, data); + } else { + // set status + sleeplog.setStatus(data); } }, From efae29ce358ab5aef8ad4e55aab4f251db01cc38 Mon Sep 17 00:00:00 2001 From: Ishidres <17363426+Ishidres@users.noreply.github.com> Date: Fri, 22 Mar 2024 13:22:31 +0100 Subject: [PATCH 15/22] Undo accidental indent --- apps/sleeplog/boot.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/sleeplog/boot.js b/apps/sleeplog/boot.js index 19981623c..6e0c02419 100644 --- a/apps/sleeplog/boot.js +++ b/apps/sleeplog/boot.js @@ -187,10 +187,10 @@ if (sleeplog.conf.enabled) { // create a temporary object to store data and functions global.tmpWearingCheck = { - // define temporary hrm listener function to read the wearing status - hrmListener: hrm => tmpWearingCheck.isWearing = hrm.isWearing, - // set default wearing status - isWearing: false, + // define temporary hrm listener function to read the wearing status + hrmListener: hrm => tmpWearingCheck.isWearing = hrm.isWearing, + // set default wearing status + isWearing: false, }; // enable HRM From 565fb152556770fdd373859891bde855dcc9a1d6 Mon Sep 17 00:00:00 2001 From: Ishidres <17363426+Ishidres@users.noreply.github.com> Date: Fri, 22 Mar 2024 16:21:52 +0100 Subject: [PATCH 16/22] Remove temperature wear check and update wear temperature setting --- apps/sleeplog/boot.js | 3 +-- apps/sleeplog/settings.js | 12 +++--------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/apps/sleeplog/boot.js b/apps/sleeplog/boot.js index 6e0c02419..2660fcad6 100644 --- a/apps/sleeplog/boot.js +++ b/apps/sleeplog/boot.js @@ -13,7 +13,6 @@ global.sleeplog = { minConsec: 18E5, // [ms] minimal time to count for consecutive sleep deepTh: 100, // threshold for deep sleep lightTh: 200, // threshold for light sleep - tempWearCheck: false, // use temperature to detect if worn wearTemp: 29, // temperature threshold to count as worn }, require("Storage").readJSON("sleeplog.json", true) || {}) }; @@ -181,7 +180,7 @@ if (sleeplog.conf.enabled) { // check wearing status either based on HRM or temperature as set in settings checkIsWearing: function(returnFn, data) { - if (this.conf.tempWearCheck) { + if (!!this.conf.wearTemp) { return returnFn(!Bangle.isCharging() && E.getTemperature() >= this.conf.wearTemp, data); } diff --git a/apps/sleeplog/settings.js b/apps/sleeplog/settings.js index d23a6369a..6ec52e2dc 100644 --- a/apps/sleeplog/settings.js +++ b/apps/sleeplog/settings.js @@ -13,7 +13,6 @@ minConsec: 18E5, // [ms] minimal time to count for consecutive sleep deepTh: 100, // threshold for deep sleep lightTh: 200, // threshold for light sleep - tempWearCheck: false, // use temperature to detect if worn wearTemp: 29, // temperature threshold to count as worn // app settings breakToD: 12, // [h] time of day when to start/end graphs @@ -350,13 +349,14 @@ /*LANG*/"Wear Temperature": { value: settings.wearTemp, step: 0.5, - min: 20, + min: 19.5, max: 40, wrap: true, noList: true, format: v => v + "°C", + format: v => v === 19.5 ? "Disabled" : v + "°C", onchange: v => { - settings.wearTemp = v; + settings.wearTemp = v === 19.5 ? null : v; writeSetting(); } }, @@ -436,12 +436,6 @@ require("sleeplog").setEnabled(v); } }, - /*LANG*/"Wear detection using temperature": { - value: settings.tempWearCheck, - onchange: v => { - settings.tempWearCheck = v; - } - }, /*LANG*/"Debugging": { value: debugImg, onchange: () => setTimeout(showDebug, 10) From d9aee1a121c2364addbc33913b5e35281b497481 Mon Sep 17 00:00:00 2001 From: Ishidres <17363426+Ishidres@users.noreply.github.com> Date: Fri, 22 Mar 2024 16:32:49 +0100 Subject: [PATCH 17/22] Update README.md --- apps/sleeplog/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/sleeplog/README.md b/apps/sleeplog/README.md index 10468200e..824f6902f 100644 --- a/apps/sleeplog/README.md +++ b/apps/sleeplog/README.md @@ -65,6 +65,8 @@ Logfiles are not removed on un-/reinstall to prevent data loss. _30_ / _31_ / ... / __100__ / ... / _200_ - __Light Sleep__ | light sleep threshold _100_ / _110_ / ... / __200__ / ... / _400_ + - __Wear Temperature__ | Set the minimum measured temperature of the wearable to consider it being worn. Can be disabled to use the HRM instead to detect if it's being worn. + __Disabled__ / _20.0°C_ / _20.5°C_ / ... / _40.0°C_ - __Reset to Default__ | reset to bold values above - __BreakToD__ | time of day to break view _0:00_ / _1:00_ / ... / __12:00__ / ... / _23:00_ From e5a76b0825377afb2dc3fe7ab3575349439e91aa Mon Sep 17 00:00:00 2001 From: Ishidres <17363426+Ishidres@users.noreply.github.com> Date: Fri, 22 Mar 2024 16:37:04 +0100 Subject: [PATCH 18/22] Remove duplicate format key --- apps/sleeplog/settings.js | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/sleeplog/settings.js b/apps/sleeplog/settings.js index 6ec52e2dc..f6f492c35 100644 --- a/apps/sleeplog/settings.js +++ b/apps/sleeplog/settings.js @@ -353,7 +353,6 @@ max: 40, wrap: true, noList: true, - format: v => v + "°C", format: v => v === 19.5 ? "Disabled" : v + "°C", onchange: v => { settings.wearTemp = v === 19.5 ? null : v; From 50afb26b8d7a64f91cfcabeec49013a794386c66 Mon Sep 17 00:00:00 2001 From: Ishidres <17363426+Ishidres@users.noreply.github.com> Date: Fri, 22 Mar 2024 16:39:35 +0100 Subject: [PATCH 19/22] Change condition check to !== null --- apps/sleeplog/boot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/sleeplog/boot.js b/apps/sleeplog/boot.js index 2660fcad6..70de13f5b 100644 --- a/apps/sleeplog/boot.js +++ b/apps/sleeplog/boot.js @@ -180,7 +180,7 @@ if (sleeplog.conf.enabled) { // check wearing status either based on HRM or temperature as set in settings checkIsWearing: function(returnFn, data) { - if (!!this.conf.wearTemp) { + if (this.conf.wearTemp !== null) { return returnFn(!Bangle.isCharging() && E.getTemperature() >= this.conf.wearTemp, data); } From fed3ef93140019cac0146e8036f441931e6c6669 Mon Sep 17 00:00:00 2001 From: Ishidres <17363426+Ishidres@users.noreply.github.com> Date: Fri, 22 Mar 2024 16:53:15 +0100 Subject: [PATCH 20/22] Disable temperature wear detection by default --- apps/sleeplog/boot.js | 2 +- apps/sleeplog/settings.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/sleeplog/boot.js b/apps/sleeplog/boot.js index 70de13f5b..67a852132 100644 --- a/apps/sleeplog/boot.js +++ b/apps/sleeplog/boot.js @@ -13,7 +13,7 @@ global.sleeplog = { minConsec: 18E5, // [ms] minimal time to count for consecutive sleep deepTh: 100, // threshold for deep sleep lightTh: 200, // threshold for light sleep - wearTemp: 29, // temperature threshold to count as worn + wearTemp: null, // temperature threshold to count as worn }, require("Storage").readJSON("sleeplog.json", true) || {}) }; diff --git a/apps/sleeplog/settings.js b/apps/sleeplog/settings.js index f6f492c35..e3811624a 100644 --- a/apps/sleeplog/settings.js +++ b/apps/sleeplog/settings.js @@ -13,7 +13,7 @@ minConsec: 18E5, // [ms] minimal time to count for consecutive sleep deepTh: 100, // threshold for deep sleep lightTh: 200, // threshold for light sleep - wearTemp: 29, // temperature threshold to count as worn + wearTemp: null, // temperature threshold to count as worn // app settings breakToD: 12, // [h] time of day when to start/end graphs appTimeout: 0 // lock and backlight timeouts for the app From cc259783cd68d4732482432a88515a0f736e9164 Mon Sep 17 00:00:00 2001 From: Ishidres <17363426+Ishidres@users.noreply.github.com> Date: Fri, 22 Mar 2024 17:59:09 +0100 Subject: [PATCH 21/22] wearTemp is 19.5 by default --- apps/sleeplog/boot.js | 4 ++-- apps/sleeplog/settings.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/sleeplog/boot.js b/apps/sleeplog/boot.js index 67a852132..dc0cd5ae1 100644 --- a/apps/sleeplog/boot.js +++ b/apps/sleeplog/boot.js @@ -13,7 +13,7 @@ global.sleeplog = { minConsec: 18E5, // [ms] minimal time to count for consecutive sleep deepTh: 100, // threshold for deep sleep lightTh: 200, // threshold for light sleep - wearTemp: null, // temperature threshold to count as worn + wearTemp: 19.5, // temperature threshold to count as worn }, require("Storage").readJSON("sleeplog.json", true) || {}) }; @@ -180,7 +180,7 @@ if (sleeplog.conf.enabled) { // check wearing status either based on HRM or temperature as set in settings checkIsWearing: function(returnFn, data) { - if (this.conf.wearTemp !== null) { + if (this.conf.wearTemp !== 19.5) { return returnFn(!Bangle.isCharging() && E.getTemperature() >= this.conf.wearTemp, data); } diff --git a/apps/sleeplog/settings.js b/apps/sleeplog/settings.js index e3811624a..736fead05 100644 --- a/apps/sleeplog/settings.js +++ b/apps/sleeplog/settings.js @@ -13,7 +13,7 @@ minConsec: 18E5, // [ms] minimal time to count for consecutive sleep deepTh: 100, // threshold for deep sleep lightTh: 200, // threshold for light sleep - wearTemp: null, // temperature threshold to count as worn + wearTemp: 19.5, // temperature threshold to count as worn // app settings breakToD: 12, // [h] time of day when to start/end graphs appTimeout: 0 // lock and backlight timeouts for the app From b2a84970f53e28f4cef23ecf2595844e1068eb38 Mon Sep 17 00:00:00 2001 From: Ishidres <17363426+Ishidres@users.noreply.github.com> Date: Fri, 22 Mar 2024 18:05:42 +0100 Subject: [PATCH 22/22] Don't replace 19.5 with null --- apps/sleeplog/settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/sleeplog/settings.js b/apps/sleeplog/settings.js index 736fead05..2c967cd2e 100644 --- a/apps/sleeplog/settings.js +++ b/apps/sleeplog/settings.js @@ -355,7 +355,7 @@ noList: true, format: v => v === 19.5 ? "Disabled" : v + "°C", onchange: v => { - settings.wearTemp = v === 19.5 ? null : v; + settings.wearTemp = v; writeSetting(); } },