Skip to content

Instantly share code, notes, and snippets.

@jh3y
Created November 11, 2019 16:37
Show Gist options
  • Save jh3y/b1631ec2446d3db3f4e4cae1477fa6f1 to your computer and use it in GitHub Desktop.
Save jh3y/b1631ec2446d3db3f4e4cae1477fa6f1 to your computer and use it in GitHub Desktop.
Foundation for activity monitor w/ Bangle.js
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