Determine if worn based on temperature threshold
parent
1aa6474974
commit
c4a25b6be1
|
|
@ -13,6 +13,7 @@ global.sleeplog = {
|
||||||
minConsec: 18E5, // [ms] minimal time to count for consecutive sleep
|
minConsec: 18E5, // [ms] minimal time to count for consecutive sleep
|
||||||
deepTh: 100, // threshold for deep sleep
|
deepTh: 100, // threshold for deep sleep
|
||||||
lightTh: 200, // threshold for light sleep
|
lightTh: 200, // threshold for light sleep
|
||||||
|
wearTemp: 27, // temperature threshold to count as worn
|
||||||
}, require("Storage").readJSON("sleeplog.json", true) || {})
|
}, require("Storage").readJSON("sleeplog.json", true) || {})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -166,12 +167,18 @@ if (sleeplog.conf.enabled) {
|
||||||
// check if changing to deep sleep from non sleeping
|
// check if changing to deep sleep from non sleeping
|
||||||
if (data.status === 4 && sleeplog.status <= 2) {
|
if (data.status === 4 && sleeplog.status <= 2) {
|
||||||
// check wearing status
|
// check wearing status
|
||||||
|
if (sleeplog.isNotWorn()) {
|
||||||
|
data.status = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
sleeplog.checkIsWearing((isWearing, data) => {
|
sleeplog.checkIsWearing((isWearing, data) => {
|
||||||
// correct status
|
// correct status
|
||||||
if (!isWearing) data.status = 1;
|
if (!isWearing) data.status = 1;
|
||||||
// set status
|
// set status
|
||||||
sleeplog.setStatus(data);
|
sleeplog.setStatus(data);
|
||||||
}, data);
|
}, data);
|
||||||
|
*/
|
||||||
} else {
|
} else {
|
||||||
// set status
|
// set status
|
||||||
sleeplog.setStatus(data);
|
sleeplog.setStatus(data);
|
||||||
|
|
@ -209,6 +216,12 @@ if (sleeplog.conf.enabled) {
|
||||||
}, 2500, returnFn, data);
|
}, 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
|
// define function to set the status
|
||||||
setStatus: function(data) {
|
setStatus: function(data) {
|
||||||
// update lastCheck
|
// update lastCheck
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue