BangleApps/apps/activityreminder/boot.js

46 lines
1.7 KiB
JavaScript
Raw Normal View History

function run() {
if (isNotWorn()) return;
let now = new Date();
let h = now.getHours();
let health = Bangle.getHealthStatus("day");
if (h >= activityreminder_settings.startHour && h < activityreminder_settings.endHour) {
2022-05-12 08:30:11 +00:00
if (health.steps - activityreminder_data.stepsOnDate >= activityreminder_settings.minSteps // more steps made than needed
|| health.steps < activityreminder_data.stepsOnDate) { // new day or reboot of the watch
activityreminder_data.stepsOnDate = health.steps;
activityreminder_data.stepsDate = now;
2022-05-12 08:30:11 +00:00
activityreminder.saveData(activityreminder_data);
/* todo in a futur release
add settimer to trigger like 10 secs after the stepsDate + minSteps
cancel all other timers of this app
*/
2022-05-12 08:30:11 +00:00
}
if(activityreminder.mustAlert(activityreminder_data, activityreminder_settings)){
load('activityreminder.app.js');
2022-04-05 14:27:16 +00:00
}
2022-04-18 14:28:34 +00:00
}
2022-04-18 14:28:34 +00:00
}
function isNotWorn() {
// todo in a futur release check temperature and mouvement in a futur release
return Bangle.isCharging();
}
2022-04-07 16:16:51 +00:00
const activityreminder = require("activityreminder");
const activityreminder_settings = activityreminder.loadSettings();
if (activityreminder_settings.enabled) {
const activityreminder_data = activityreminder.loadData();
2022-05-12 08:30:11 +00:00
if(activityreminder_data.firstLoad){
activityreminder_data.firstLoad =false;
activityreminder.saveData(activityreminder_data);
}
2022-04-18 15:30:57 +00:00
setInterval(run, 60000);
/* todo in a futur release
increase setInterval time to something that is still sensible (5 mins ?)
add settimer to trigger like 10 secs after the stepsDate + minSteps
cancel all other timers of this app
*/
2022-04-05 14:27:16 +00:00
}