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) || {});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (global.activityreminder) {
|
|
|
|
|
|
|
|
activityreminder =
|
|
|
|
Object.assign(activityreminder,
|
|
|
|
{
|
|
|
|
stepsArray: [],
|
|
|
|
|
|
|
|
run: function(){
|
|
|
|
var now = new Date();
|
|
|
|
var h = now.getHours();
|
|
|
|
if(h >= activityreminder.startHour && h < activityreminder.endHour)
|
|
|
|
{
|
|
|
|
var health = Bangle.getHealthStatus("day");
|
|
|
|
activityreminder.stepsArray.unshift(health.steps);
|
|
|
|
activityreminder.stepsArray = activityreminder.stepsArray.slice(0, activityreminder.maxInnactivityMin);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
activityreminder.stepsArray = [];
|
|
|
|
}
|
|
|
|
if(activityreminder.stepsArray.length == activityreminder.maxInnactivityMin){
|
|
|
|
if (activityreminder.stepsArray[0] - activityreminder.stepsArray[activityreminder.stepsArray.length-1] < activityreminder.minSteps)
|
|
|
|
{
|
|
|
|
activityreminder.showAlert();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
showAlert: function(){
|
2022-04-07 15:30:55 +00:00
|
|
|
g.clear();
|
|
|
|
Bangle.loadWidgets();
|
|
|
|
Bangle.drawWidgets();
|
2022-04-05 14:27:16 +00:00
|
|
|
E.showPrompt("Innactivity detected",{
|
|
|
|
title:"Activity reminder",
|
|
|
|
buttons : {"Ok": true,"Dismiss": false}
|
|
|
|
}).then(function(v) {
|
|
|
|
if(v == true){
|
|
|
|
activityreminder.stepsArray = activityreminder.stepsArray.slice(0, activityreminder.maxInnactivityMin - 3);
|
|
|
|
}
|
|
|
|
if(v == false){
|
|
|
|
activityreminder.stepsArray = activityreminder.stepsArray.slice(0, activityreminder.maxInnactivityMin - activityreminder.dismissDelayMin);
|
|
|
|
}
|
|
|
|
load();
|
|
|
|
});
|
|
|
|
Bangle.buzz();
|
2022-04-07 15:30:55 +00:00
|
|
|
setTimeout(load, 10000);
|
2022-04-05 14:27:16 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2022-04-07 15:30:55 +00:00
|
|
|
setInterval(global.activityreminder.run, 2000);
|
2022-04-05 14:27:16 +00:00
|
|
|
}
|
|
|
|
|