-
• #2
For charging there is Bangle.isCharging.
"Not on a wrist" is tricky, but I guess you could use the accelerometer and check if there is no movement for a certain period. Maybe even check forx
andy
being zero if you always place it face up/down. -
• #3
Checking heart rate could work?
-
• #4
Thanks. I like the "face down" tip. That looks like it may be what I'm looking for.
-
• #6
Ta. That could work for removal, but I was also hoping to pause heartrate monitoring when removed as well as silencing. Perhaps a hybrid approach might work, with movement/orientation switching is back to "being worn" mode. All good food for thought...
-
• #7
Great - I'll take a look. I also saw an app that scheduled silent times, so I was going to look at the code for that as well to see what I could "borrow".
-
• #8
You could use
movement
from http://www.espruino.com/Reference#l_Bangle_getHealthStatus to detect if the Bangle is moving around at all, and also theHRM-raw
event that comes from the HRM on Bangle.js 2 has a field for whether it thinks the Bangle is being worn (eg if something is close to the HRM) - but if the Bangle is on a table then it could still be fooled. -
• #9
Ta - I'll look into the HRM event as well. Lots of options to research!
-
• #10
Maybe I have something that suits your needs:
I wrote a little helper function to get only the isWearing value fromHRM-raw
.Here a little example:
checkIsWearing( (isWearingStatus, messages) => { print(messages[isWearingStatus ? 1 : 0]); }, [ "You are not wearing the watch.", "Yor watch is on your wrist or on a surface that appears similar." ] );
The return function is called with the isWearing-status as first and the passed data as second argument:
returnFn(isWearing, data);
Here the code of this function:
// define function to check if the bangle is worn by using the hrm function checkIsWearing(returnFn, data) { // create a temporary object to store data and functions global.tmpWearingCheck = { // define temporary hrm listener function to read the wearing status hrmListener: hrm => tmpWearingCheck.isWearing = hrm.isWearing, // set default wearing status isWearing: false, }; // enable HRM Bangle.setHRMPower(true, "wearingCheck"); // wait until HRM is initialised setTimeout((returnFn, data) => { // add HRM listener Bangle.on('HRM-raw', tmpWearingCheck.hrmListener); // wait for two cycles (HRM working on 60Hz) setTimeout((returnFn, data) => { // remove listener and disable HRM Bangle.removeListener('HRM-raw', tmpWearingCheck.hrmListener); Bangle.setHRMPower(false, "wearingCheck"); // cache wearing status var isWearing = tmpWearingCheck.isWearing; // clear temporary object delete global.tmpWearingCheck; // call return function with status returnFn(isWearing, data); }, 34, returnFn, data); }, 2500, returnFn, data); }
I am using this in the 0.10+ version of sleeplog:
https://github.com/storm64/BangleApps/blob/sleeplog_beta/apps/sleeplog/boot.js -
• #11
If you want another example of the thermometer-solution, it's implemented in the app 'Activity Reminder'.
Is it possible to detect whether a bangle.js2 is either on charge or (preferably) not on a wrist? If so I want to look in to possibly creating an app to silence the vibration/notification in those circumstances. I've tried a search using the obvious terms and cannot find anything that already exists.