Created
November 11, 2019 16:37
-
-
Save jh3y/b1631ec2446d3db3f4e4cae1477fa6f1 to your computer and use it in GitHub Desktop.
Foundation for activity monitor w/ Bangle.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let buzzing = false | |
/** | |
* Hard-coded interval for now is not ideal | |
*/ | |
const minutes = 10 | |
const interval = minutes * (1000 * 60) | |
/** | |
* Can you detect if the Bangle is Buzzing or in Buzz in progress? | |
*/ | |
const buzz = () => { | |
try { | |
Bangle.buzz().then( | |
() => buzzing ? buzz() : void() | |
) | |
} catch (err) { | |
return err | |
} | |
} | |
/** | |
* Buzz uncontrollably until you intervene by pressing the middle button | |
*/ | |
const buzzUncontrollably = () => { | |
setWatch(() => { | |
buzzing = false | |
g.clear() | |
E.showMessage("Resume."); | |
setTimeout(() => { | |
g.clear() | |
}, 2000) | |
}, BTN2); | |
if (buzzing) { | |
buzz() | |
} | |
} | |
const health = setInterval(() => { | |
if (!buzzing) { | |
buzzing = true | |
E.showMessage('Move!!!') | |
buzzUncontrollably() | |
} | |
}, interval) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment