Module: Toybox::ActivityMonitor

Overview

The ActivityMonitor module contains the interface for Activity Monitoring data.

Examples:

Shows the use of HeartRateIterator, HeartRateSample, and Info

using Toybox.ActivityMonitor;
using Toybox.System;

// get a HeartRateIterator object; oldest sample first
var hrIterator = ActivityMonitor.getHeartRateHistory(null, false);
var previous = hrIterator.next();                                   // get the previous HR
var lastSampleTime = null;                                          // get the last

while (true) {
    var sample = hrIterator.next();
    if (null != sample) {                                           // null check
        if (sample.hearRate != ActivityMonitor.INVALID_HR_SAMPLE    // check for invalid samples
            && previous.heartRate
            != ActivityMonitor.INVALID_HR_SAMPLE) {
                lastSampleTime = sample.when;
                System.println("Previous: " + previous.heartRate);  // print the previous sample
                System.println("Sample: " + sample.heartRate);      // print the current sample
        }
    }
}

// get ActivityMonitor info
var info = ActivityMonitor.getInfo();

var steps = info.steps;
var calories = info.calories;

System.println("You have taken: " + steps +
               " steps and burned: " + calories + " calories!");

Since:

  • 1.0.0

Defined Under Namespace

Classes: ActiveMinutes, HeartRateIterator, HeartRateSample, History, Info

Constant Summary

MOVE_BAR_LEVEL_MAX = 5

The maximum level of the move bar

Since:

  • 1.0.0

MOVE_BAR_LEVEL_MIN = 0

The minimum level of the move bar

Since:

  • 1.0.0

INVALID_HR_SAMPLE = 255

Indicates that the given heart rate sample is invalid.

Since:

  • 1.2.2

Supported Devices:

  • D2 Bravo Titanium

  • fenix 3 HR

  • fenix 5/S/X

  • fenix Chronos

  • Forerunner 235

  • Forerunner 735XT

  • Forerunner 935

  • vivoactive HR

Instance Method Summary collapse

Instance Method Details

getHeartRateHistory(period, newestFirst) ⇒ ActivityMonitor.HeartRateIterator

Get the heart rate history for the given period, up to the last power cycle.

This function always returns the most recent heart rate samples. The time between each HeartRateSample in the iterator may be device dependent.

Parameters:

  • period (Toybox::Time::Duration, Toybox::Lang::Number)

    The period of time from which to retrieve heart rate samples

    • If period is null, the entire available history is retrieved

    • If period is a Duration, then the history for the given Duration is retrieved

    • If period is a Number, then the last Number entries are retrieved

  • newestFirst (Toybox::Lang::Boolean)

    The order in which to retrieve heart rate samples

    • true to get the samples newest first

    • false to get the samples oldest first

Returns:

Since:

  • 1.2.1

Supported Devices:

  • D2 Bravo Titanium

  • fenix 3 HR

  • fenix 5/S/X

  • fenix Chronos

  • Forerunner 235

  • Forerunner 735XT

  • Forerunner 935

  • vivoactive HR



828
829
# File 'Monkeybrains.rb', line 828

def getHeartRateHistory(period, newestFirst)
end

getHistoryToybox::Lang::Array

Get an Array of ActivityMonitor.History objects

Returns:

Since:

  • 1.0.0



844
845
# File 'Monkeybrains.rb', line 844

def getHistory()
end

getInfoToybox::ActivityMonitor::Info

Get the current ActivityMonitor.Info

Returns:

Since:

  • 1.0.0



835
836
# File 'Monkeybrains.rb', line 835

def getInfo()
end