Merge pull request #2138 from splch/work_hours

Twenties - vibrates during work hours
pull/2143/head^2
Gordon Williams 2022-09-23 08:44:36 +01:00 committed by GitHub
commit 75066fae86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 6 deletions

View File

@ -1,2 +1,3 @@
0.01: New Widget!
0.02: Fix calling null on draw
0.02: Fix calling null on draw
0.03: Only vibrate during work

View File

@ -2,7 +2,7 @@
"id": "widtwenties",
"name": "Twenties",
"shortName": "twenties",
"version": "0.02",
"version": "0.03",
"description": "Buzzes every 20m to stand / sit and look 20ft away for 20s.",
"icon": "widget.png",
"type": "widget",

View File

@ -7,9 +7,15 @@ they don't interfere with currently-running apps */
const look = 20 * 1000; // 20 seconds
buzz = _ => {
Bangle.buzz().then(_ => {
setTimeout(Bangle.buzz, look);
});
const date = new Date();
const day = date.getDay();
const hour = date.getHours();
// buzz at work
if (day <= 5 && hour >= 8 && hour <= 17) {
Bangle.buzz().then(_ => {
setTimeout(Bangle.buzz, look);
});
}
};
// add widget
@ -21,4 +27,4 @@ they don't interfere with currently-running apps */
setInterval(WIDGETS.twenties.buzz, move); // buzz to stand / sit
})();
// Bangle.drawWidgets(); // <-- for development only
// Bangle.drawWidgets(); // <-- for development only