Merge pull request #3280 from Ishidres/feat/sleep-detection-improvements
sleeplog: Add wear detection based on measured temperaturemaster
commit
c6b84a0dc9
|
|
@ -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_
|
||||
|
|
|
|||
|
|
@ -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: 19.5, // temperature threshold to count as worn
|
||||
}, require("Storage").readJSON("sleeplog.json", true) || {})
|
||||
};
|
||||
|
||||
|
|
@ -158,13 +159,13 @@ 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) => {
|
||||
// correct status
|
||||
if (!isWearing) data.status = 1;
|
||||
|
|
@ -177,8 +178,12 @@ if (sleeplog.conf.enabled) {
|
|||
}
|
||||
},
|
||||
|
||||
// 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.wearTemp !== 19.5) {
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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: 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
|
||||
|
|
@ -345,6 +346,19 @@
|
|||
writeSetting();
|
||||
}
|
||||
},
|
||||
/*LANG*/"Wear Temperature": {
|
||||
value: settings.wearTemp,
|
||||
step: 0.5,
|
||||
min: 19.5,
|
||||
max: 40,
|
||||
wrap: true,
|
||||
noList: true,
|
||||
format: v => v === 19.5 ? "Disabled" : v + "°C",
|
||||
onchange: v => {
|
||||
settings.wearTemp = v;
|
||||
writeSetting();
|
||||
}
|
||||
},
|
||||
/*LANG*/"Reset to Default": () => {
|
||||
settings.maxAwake = defaults.maxAwake;
|
||||
settings.minConsec = defaults.minConsec;
|
||||
|
|
|
|||
Loading…
Reference in New Issue