1
0
Fork 0
BangleApps/apps/activityreminder/boot.js

44 lines
1.1 KiB
JavaScript
Raw Normal View History

2022-04-05 14:27:16 +00:00
global.activityreminder = Object.assign({
enabled: true,
startHour: 9,
endHour: 20,
maxInnactivityMin: 30,
dismissDelayMin: 15,
minSteps: 50,
}, require("Storage").readJSON("activityreminder.json", true) || {});
2022-04-07 16:16:51 +00:00
var stepsArray = [];
2022-04-05 14:27:16 +00:00
if (global.activityreminder) {
activityreminder =
Object.assign(activityreminder,
{
run: function(){
var now = new Date();
var h = now.getHours();
2022-04-07 16:16:51 +00:00
console.log(stepsArray);
2022-04-05 14:27:16 +00:00
if(h >= activityreminder.startHour && h < activityreminder.endHour)
{
var health = Bangle.getHealthStatus("day");
2022-04-07 16:16:51 +00:00
stepsArray.unshift(health.steps);
2022-04-07 16:21:43 +00:00
stepsArray = stepsArray.slice(0, activityreminder.maxInnactivityMin);
2022-04-05 14:27:16 +00:00
}
else{
2022-04-07 16:16:51 +00:00
stepsArray = [];
2022-04-05 14:27:16 +00:00
}
2022-04-07 16:16:51 +00:00
if(stepsArray.length == activityreminder.maxInnactivityMin){
if (stepsArray[0] - stepsArray[stepsArray.length-1] < activityreminder.minSteps)
2022-04-05 14:27:16 +00:00
{
2022-04-07 16:16:51 +00:00
load('authentiwatch.app.js');
2022-04-05 14:27:16 +00:00
}
}
2022-04-07 16:16:51 +00:00
}
2022-04-07 16:21:43 +00:00
});
2022-04-07 16:16:51 +00:00
setInterval(global.activityreminder.run, 2000);
2022-04-05 14:27:16 +00:00
}