Get step count of the last minute (not 10 minutes) to record weekly moderate and vigorous intensity aerobic physical activity? #6585
Replies: 1 comment
-
Posted at 2024-02-01 by @thyttan I guess one way is you could use It might be better to refactor something in the health app or some other place, I don't know... Edit: fix link Posted at 2024-02-01 by Ishidres I checked the health boot.js code but if I understand correctly it also only listens for the "health" event and then saves the data to the database. And if I understand this commit correctly, "health" gets fired in Posted at 2024-02-01 by @gfwilliams As you noted we only store health data every 10 minutes to help with battery/storage usage. Yes, you'd be better off just checking Your app could have its own 'boot code' file ( Posted at 2024-02-01 by Ishidres Okay thanks but what I don't understand: Doesn't the code in yourapp.boot.js also need to save data to storage every minute? Because if I understand it correctly when I switch apps or activities any running app gets terminated and thus any saved variables (to cache the step count at the end of the last minute) get cleared (like widgets) and the boot code needs to run again? Posted at 2024-02-01 by @gfwilliams There's an But if you only save for every minute where you have activity, that may only be 150 writes/week which is file. The only gotcha is preserving step count for the current minute when swapping apps, which you would have to save state for Posted at 2024-02-01 by @thyttan Edit: Gordon beat me to it. To keep information between resetting/loading of apps you can act on the E.kill event. I guess one could also make the assumption that at times with lots of app switching you probably are not doing a lot of moving around. So it probably wouldn't impact the statistics too much doing without retaining info across resets/loads. Posted at 2024-02-01 by Ishidres Thanks everyone!
Yes, that's probably true, so to save CPU and battery usage, I'll probably ignore App switches and not save data to storage, and assume that no significant activity was done during that time. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2024-01-31 by Ishidres
The WHO recommends to "perform at least 150 minutes of moderate intensity aerobic physical activity throughout the week or do at least 75 minutes of vigorous intensity aerobic physical activity throughout the week".
I would like to implement this into an app that records a minute as "moderate intensity" if more than 100 steps were performed or records it as a "vigorous intensity" if more than 130 steps were performed.
So far, I simply used
to get all health records of the last week to filter out the records with an appropriate step count (see code snippet below). However, BangleJS only saves step counts per 10 minutes (probably to save storage). This is understandable but gives more inaccurate results here:
How can I get the exact step count of the last minute only, to avoid averaging/guessing the step count like above?
Beta Was this translation helpful? Give feedback.
All reactions