Improve energy efficiency of the buzzing and update the source for sitting / standing
parent
2656f25e69
commit
dd354eaf11
|
|
@ -2,3 +2,4 @@
|
||||||
0.02: Fix calling null on draw
|
0.02: Fix calling null on draw
|
||||||
0.03: Only vibrate during work
|
0.03: Only vibrate during work
|
||||||
0.04: Convert to boot code
|
0.04: Convert to boot code
|
||||||
|
0.05: Improve energy efficiency
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# Twenties
|
# Twenties
|
||||||
|
|
||||||
Follow the [20-20-20 rule](https://www.aoa.org/AOA/Images/Patients/Eye%20Conditions/20-20-20-rule.pdf) with discrete reminders. Your Bangle will buzz every 20 minutes for you to look away from your screen, and then buzz 20 seconds later to look back. Additionally, alternate between standing and sitting every 20 minutes to be standing for [more than 30 minutes](https://uwaterloo.ca/kinesiology-health-sciences/how-long-should-you-stand-rather-sit-your-work-station) per hour.
|
Follow the [20-20-20 rule](https://www.aoa.org/AOA/Images/Patients/Eye%20Conditions/20-20-20-rule.pdf) with discrete reminders. Your Bangle will buzz every 20 minutes for you to look away from your screen, and then buzz 20 seconds later to look back. Additionally, alternate between standing and sitting every 20 minutes to be standing for [more than 30 minutes](https://uwaterloo.ca/news/how-long-should-you-stand-rather-sit-your-work-station) per hour.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,22 @@
|
||||||
(() => {
|
(() => {
|
||||||
const move = 20 * 60 * 1000; // 20 minutes
|
const LOOP_INTERVAL = 1.2e6; // 20 minutes
|
||||||
const look = 20 * 1000; // 20 seconds
|
const BUZZ_INTERVAL = 2e4; // 20 seconds
|
||||||
|
|
||||||
const buzz = _ => {
|
const isWorkTime = (d) =>
|
||||||
const date = new Date();
|
d.getDay() % 6 && d.getHours() >= 8 && d.getHours() < 18;
|
||||||
const day = date.getDay();
|
|
||||||
const hour = date.getHours();
|
const scheduleNext = () => {
|
||||||
// buzz at work
|
const now = new Date();
|
||||||
if (day >= 1 && day <= 5 &&
|
if (isWorkTime(now)) {
|
||||||
hour >= 8 && hour <= 17) {
|
Bangle.buzz().then(() => setTimeout(Bangle.buzz, BUZZ_INTERVAL));
|
||||||
Bangle.buzz().then(_ => {
|
setTimeout(scheduleNext, LOOP_INTERVAL);
|
||||||
setTimeout(Bangle.buzz, look);
|
} else {
|
||||||
});
|
const next = new Date(now);
|
||||||
|
next.setHours(8, 0, 0, 0);
|
||||||
|
while (!isWorkTime(next)) next.setDate(next.getDate() + 1);
|
||||||
|
setTimeout(scheduleNext, next - now);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
setInterval(buzz, move); // buzz to stand / sit
|
scheduleNext();
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,14 @@
|
||||||
{
|
{
|
||||||
"id": "twenties",
|
"id": "twenties",
|
||||||
"name": "Twenties",
|
"name": "Twenties",
|
||||||
"shortName": "twenties",
|
"shortName": "Twenties",
|
||||||
"version": "0.04",
|
"version": "0.0.5",
|
||||||
"description": "Buzzes every 20m to stand / sit and look 20ft away for 20s.",
|
"description": "Buzzes every 20m to stand / sit and look 20ft away for 20s.",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"type": "bootloader",
|
"type": "bootloader",
|
||||||
"tags": "alarm,tool,health",
|
"tags": "alarm,tool,health",
|
||||||
"supports": ["BANGLEJS", "BANGLEJS2"],
|
"supports": ["BANGLEJS", "BANGLEJS2"],
|
||||||
|
"allow_emulator": true,
|
||||||
"readme": "README.md",
|
"readme": "README.md",
|
||||||
"storage": [{ "name": "twenties.boot.js", "url": "boot.js" }]
|
"storage": [{ "name": "twenties.boot.js", "url": "boot.js" }]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue