Breath alarm

Posted on
  • I'm writing a "breath" app. I find out after writing it that there was already one in the apps repository, but my app fits better my needs so i'll finish it and publish it when ready.

    But i'm facing an issue that i don't know yet how to solve it:

    • I want the app to start ever hour (maybe configurable)
    • Ideally I would like to skip starting the app when i'm sleeping (is there a way to determine if the user is sleeping? i know the bangle can count steps without draining battery. is there a way to do the same but in order to determine if the user is awake or sleeping without draining battery?
    • I found the sched library provides an api to set alarms, and the alarm object can ship a js field that contains a js oneliner that can be used to execute an app.

    What would be the most optimal way to do this?

  • Would you be wearing the Bangle while sleeping?

    I'd say probably the best bet is to create a 'myapp.boot.js' file that does something like:

    Bangle.on('health', function(e) {
      if ((new Date()).getMinutes()!=0) return; // not every hour
      // could check e.steps here?
      if (e.movement > 1000) load("myapp.app.js");
    });
    

    The 'health' event is fired every 10 minutes with the last 10 mins data, and 'movement' is a value that shows how much the device was moved around during that 10 minutes. You could also check steps, and maybe even Bangle.isCharging() ?

    The other thing you could do is check if 'quiet mode' is on (but that's just based on time of day)

    There is a library for wear detection (https://github.com/espruino/BangleApps/blob/master/modules/wear_detect.js) but honestly it's got some issues. I guess you could do something similar for sleep detection and then at least over time users might contribute some changes that make it a bit more accurate.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Breath alarm

Posted by Avatar for pancake @pancake

Actions