• 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

    require("health").readAllRecordsSince()
    

    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:

      const activeSPM = 100;
      const intenseSPM = 130;
      const threshold = 0.7;
      let activity = { active: 0, intense: 0 };
    
      const currentDate = new Date();
      const durationDays = 7;
      const timeAgo = new Date(currentDate.getTime() - durationDays * 24 * 60 * 60 * 1000);
    
      require("health").readAllRecordsSince(tiĀ­meAgo, h => {
        if (h.steps >= (intenseSPM * 10 * threshold)) {
          print("intense:", h);
          activity.intense += (h.steps / intenseSPM) * (1 / threshold) * (7 / durationDays);
        } else if (h.steps >= (activeSPM * 10 * threshold)) {
          //print("active:", h);
          activity.active += (h.steps / activeSPM) * (1 / threshold) * (7 / durationDays);
        }
      });
    

    How can I get the exact step count of the last minute only, to avoid averaging/guessing the step count like above?

About

Avatar for Ishidres @Ishidres started