Create a Bangle.isWorn() method #6091
Replies: 1 comment
-
Posted at 2022-09-06 by @thyttan This thread has some tips regarding this. The 20-20-20 app is a great idea btw! Gonna' check it out. Right now I use 'Activity Reminder' for nudging me to move around. Posted at 2022-09-06 by @gfwilliams It's a nice idea only running widgets if the watch is worn, but the issue is we can't 'unload' widgets so I'm not sure it'd work that well. For 'isWorn' there are a few options - maybe someone could make a simple library when they come up with a solution that works nicely and then everyone could use it? Posted at 2022-09-06 by splch Thanks a bunch for the link! I like the temperature solution since it could be low-power. Potentially checking if E.getTemperature() is above some value, if Bangle.getAccel() is above a low magnitude, not Bangle.isCharging(). Posted at 2022-09-06 by splch Would it be easier to suspend watch features (like buzzing) for opt-in widgets when not worn? I was thinking about adding a check right before I buzz the watch about whether it’s being worn. And I’ll make a PR for the library and share it on the other thread so everyone can improve it :) Posted at 2022-09-07 by @gfwilliams That sounds great! Temperature may be an idea but it will take a long time to respond - motion is probably enough, and potentially won't use too much extra power since the accelerometer is always running anyway. In terms of buzzing - one option is just to overwrite There is also a 'quiet mode' and you could just enable that when the Bangle is not worn. That may be more sensible. However some people may still wish for buzzing if the Bangle is on a desk (eg alarms) so I guess it should be an option. Posted at 2022-09-07 by splch I collected some data yesterday (I attached the CSV) that recorded the temperature and acceleration... I'll try to fit a decision tree to it today for a basic if-else predictor :) Hopefully acceleration is enough! I like the quiet mode the most, but would that also quiet alarms like you mentioned? In that case the more widget-by-widget solution would be overriding. Attachments: Posted at 2022-09-07 by splch I put together a quick decision tree and here's the output: Here is the proposed JS that achieved an accuracy of 99% on the dataset: function isWorn() {
if (Bangle.isCharging())
return false;
if (E.getTemperature() > 24.625)
return true;
if (Bangle.getAccel().mag > 1.045)
return true;
return false;
} Attachments: Posted at 2022-09-08 by @thyttan The temperature one will probably vary a lot with ambient temperature. At least during the hot summer days I needed to have the threshold at ca. 31 degrees. Edit: Maybe an approximation of ambient temperature could be put in a variable that is updated by a function when the watch is not worn and not charging. This variable could then be used instead of the fixed value 24.625. Posted at 2022-09-08 by user140377 Can't you just query the PPG sensor? Posted at 2022-09-08 by rigrig Temperature feels really tricky, I can easily imagine it getting higher from e.g. leaving the watch in the sun than wearing it. Quiet mode has 3 levels: Instead of a
That way other apps can check Posted at 2022-09-08 by @gfwilliams Comments on the PR at espruino/Espruino#2264 but I just added the code mentioned above as a library: espruino/BangleApps@ff9a5c4 I made it so it returns a promise, because I think there's a good chance that the code will need changing and may need to do some things (like waiting for an HRM reading) that don't return immediately. I think there is a potential for the library to emit a 'worn' event as well (which probably makes a lot of sense) but I imagine @splch is thinking that in cases like alarms they might want to just check instantaneously at the point they were thinking of making a noise. In terms of the checks, I think a few things would need improving:
Posted at 2022-09-08 by splch @thyttan I like the idea of recording temperature relative to the mean… But if a person is always wearing their watch, the man will always be high. Gordon might be right about acceleration being the best way to go. @user140377 We definitely can, and I think that it’d be great to check if the sensors have power before using them. But I’d like a low-power solution that works if the user isn’t powering their HRM or GPS. @rigrig I agree, temperature alone isn’t enough. I can’t think of a use of temperature that isn’t able to be fooled 😂 I like the worn event! It’d make sense to me to have certain widgets start on the worn event. I was only thinking about either a global variable or function… @gfwilliams I’ll update the function to check if certain sensors are powered on (like HRM) before using that data. I also need to collect some more data with the healthStatus movement! That function might be enough to detect if you’re wearing the watch :) Posted at 2022-09-08 by rigrig Another idea: just look at the accelerometer with a timeout?
But I guess constantly running code for Posted at 2022-09-08 by @thyttan In the case when the user mostly keeps the bangle on them, maybe it could be assumed the ambient temperature is a couple degrees lower than the 'wearing temperature'? So maybe there would be three temperature measurements:
When the last 'ambient temperature' reading became too old then 'assumed ambient temperature' would take it's place. But I also suspect that Gordon might be right :p. Posted at 2022-09-09 by splch I just gave it a shot yesterday with the Without temperature, the model has a 99.2% accuracy :) The decision tree function is:
Attachments: Posted at 2022-09-09 by @thyttan Cool 😎 Posted at 2022-12-29 by !evil Hi, I was using https://banglejs.com/apps/?id=health for a day until I realized that it doesn't stop HRM when I stop wearing it at night. see edit below Anyways, Bangle.js already detects movement for powerSave option and for me this would be sufficient. The following proof-of-concept works well enough for me:
I didn't find a way to get the current power state/poll interval/"hasn't moved". Is there? edit: I was wrong, acceleration diffs are unsigned, sry Posted at 2023-01-06 by @gfwilliams I see it's you, but just a note that this just went in: espruino/Espruino@05791f3 So Bangle.js 2v17 will have the ability to query if the device has been moving or not Posted at 2023-06-17 by d3nd3-o0 https://pastebin.com/BahN25YL |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2022-09-06 by splch
I recently made a widget that buzzes following the 20-20-20 rule… But it should only run when the user is actually wearing the watch. Is there already some detection for if someone is wearing the watch? Or do all widgets run constantly in the background?
If all widgets are always running, my proposal is an optional boolean in the manifest that can have a widget only run while the watch is being worn. I could see other widgets using this, but mine definitely could and it’d increase the battery life as well!
I’m thinking a call like this:
Call type:
Return
Description
Beta Was this translation helpful? Give feedback.
All reactions