mirror of https://github.com/espruino/BangleApps
Refactor
parent
b02d730a6f
commit
58af541040
|
@ -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
|
||||||
|
tempWearCheck: false, // use temperature to detect if worn
|
||||||
wearTemp: 29, // temperature threshold to count as worn
|
wearTemp: 29, // temperature threshold to count as worn
|
||||||
}, require("Storage").readJSON("sleeplog.json", true) || {})
|
}, require("Storage").readJSON("sleeplog.json", true) || {})
|
||||||
};
|
};
|
||||||
|
@ -166,22 +167,23 @@ 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 either based on HRM or temperature as set in settings
|
||||||
|
if (this.conf.tempWearCheck) {
|
||||||
// if not worn set status to not worn
|
// if not worn set status to not worn
|
||||||
if (sleeplog.isNotWorn()) {
|
if (!sleeplog.isWornByTemp()) {
|
||||||
data.status = 1;
|
data.status = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sleeplog.setStatus(data);
|
sleeplog.setStatus(data);
|
||||||
|
} else {
|
||||||
/*
|
// if not worn set status to not worn
|
||||||
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);
|
||||||
|
@ -221,8 +223,8 @@ if (sleeplog.conf.enabled) {
|
||||||
|
|
||||||
// Determine if Bangle.JS is worn based on temperature (same strategy as in activityreminder)
|
// 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
|
// https://github.com/espruino/BangleApps/blob/master/apps/activityreminder/boot.js#L37
|
||||||
isNotWorn: function() {
|
isWornByTemp: function() {
|
||||||
return (Bangle.isCharging() || this.conf.wearTemp > E.getTemperature());
|
return (!Bangle.isCharging() && E.getTemperature() >= this.conf.wearTemp);
|
||||||
},
|
},
|
||||||
|
|
||||||
// define function to set the status
|
// define function to set the status
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
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
|
||||||
|
tempWearCheck: false, // use temperature to detect if worn
|
||||||
wearTemp: 29, // temperature threshold to count as worn
|
wearTemp: 29, // temperature threshold to count as worn
|
||||||
// app settings
|
// app settings
|
||||||
breakToD: 12, // [h] time of day when to start/end graphs
|
breakToD: 12, // [h] time of day when to start/end graphs
|
||||||
|
@ -435,6 +436,12 @@
|
||||||
require("sleeplog").setEnabled(v);
|
require("sleeplog").setEnabled(v);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
/*LANG*/"Wear detection using temperature": {
|
||||||
|
value: settings.tempWearCheck,
|
||||||
|
onchange: v => {
|
||||||
|
settings.tempWearCheck = v;
|
||||||
|
}
|
||||||
|
},
|
||||||
/*LANG*/"Debugging": {
|
/*LANG*/"Debugging": {
|
||||||
value: debugImg,
|
value: debugImg,
|
||||||
onchange: () => setTimeout(showDebug, 10)
|
onchange: () => setTimeout(showDebug, 10)
|
||||||
|
|
Loading…
Reference in New Issue