Module: Toybox::SensorHistory

Overview

The SensorHistory module contains the interface for SensorHistory.

SensorHistory provides access to historical information recorded by the on-board sensors of device hardware. The amount of information that is available is device dependent. This means that one device may provide more information than another. This class provides an ORDER_* enum which is used to select the data order of the sample iterator.

Since:

  • 2.1.0

Supported Devices:

  • Approach S60

  • fenix 3 HR

  • fenix 5/S/X

  • fenix Chronos

  • Forerunner 735XT

  • Forerunner 935

  • vivoactive HR

  • vivoactive 3

Requires Permission:

  • SensorHistory

Defined Under Namespace

Classes: SensorHistoryIterator, SensorSample

Constant Summary

ORDER_NEWEST_FIRST = 0

Request iterator with newest data first

Since:

  • 2.1.0

ORDER_OLDEST_FIRST = 1

Request iterator with oldest data first

Since:

  • 2.1.0

Instance Method Summary collapse

Instance Method Details

getElevationHistory(options) ⇒ Toybox::SensorHistory::SensorHistoryIterator

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

This function always returns the most recent pressure samples. The time between each SensorSample in the iterator may be device dependent.

Examples:

Gets a SensoryHistoryIterator and prints out the elevation value from the most recent SensorSample

using Toybox.SensorHistory;
using Toybox.Lang;
using Toybox.System;

// Create a method to get the SensorHistoryIterator object
function getIterator() {
    // Check device for SensorHistory compatibility
    if ((Toybox has :SensorHistory) && (Toybox.SensorHistory has :getElevationHistory)) {
        return Toybox.SensorHistory.getElevationHistory({});
    }
    return null;
}

// Store the iterator info in a variable. The options are 'null' in
// this case so the entire available history is returned with the
// newest samples returned first.
var sensorIter = getIterator();

// Print out the next entry in the iterator
if (sensorIter != null) {
    System.println(sensorIter.next().data);
}

Parameters:

Options Hash (options):

Returns:

See Also:

Since:

  • 2.1.0

Supported Devices:

  • fenix 5/S/X

  • fenix Chronos

  • Forerunner 935

  • vivoactive HR

  • vivoactive 3


9237
9238
# File 'Monkeybrains.rb', line 9237

def getElevationHistory(options)
end

getHeartRateHistory(options) ⇒ Toybox::SensorHistory::SensorHistoryIterator

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 SensorSample in the iterator may be device dependent.

Examples:

Gets a SensoryHistoryIterator and prints out the heart rate value from the most recent SensorSample

using Toybox.SensorHistory;
using Toybox.Lang;
using Toybox.System;

// Create a method to get the SensorHistoryIterator object
function getIterator() {
    // Check device for SensorHistory compatibility
    if ((Toybox has :SensorHistory) && (Toybox.SensorHistory has :getHeartRateHistory)) {
        return Toybox.SensorHistory.getHeartRateHistory({});
    }
    return null;
}

// Store the iterator info in a variable. The options are 'null' in
// this case so the entire available history is returned with the
// newest samples returned first.
var sensorIter = getIterator();

// Print out the next entry in the iterator
if (sensorIter != null) {
    System.println(sensorIter.next().data);
}

Parameters:

Options Hash (options):

Returns:

See Also:

Since:

  • 2.1.0

Supported Devices:

  • fenix 5/S/X

  • fenix Chronos

  • Forerunner 735XT

  • Forerunner 935

  • vivoactive HR

  • vivoactive 3


9072
9073
# File 'Monkeybrains.rb', line 9072

def getHeartRateHistory(options)
end

getPressureHistory(options) ⇒ Toybox::SensorHistory::SensorHistoryIterator

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

This function always returns the most recent pressure samples. The time between each SensorSample in the iterator may be device dependent.

Examples:

Gets a SensoryHistoryIterator and prints out the pressure value from the most recent SensorSample

using Toybox.SensorHistory;
using Toybox.Lang;
using Toybox.System;

// Create a method to get the SensorHistoryIterator object
function getIterator() {
    // Check device for SensorHistory compatibility
    if ((Toybox has :SensorHistory) && (Toybox.SensorHistory has :getPressureHistory)) {
        return Toybox.SensorHistory.getPressureHistory({});
    }
    return null;
}

// Store the iterator info in a variable. The options are 'null' in
// this case so the entire available history is returned with the
// newest samples returned first.
var sensorIter = getIterator();

// Print out the next entry in the iterator
if (sensorIter != null) {
    System.println(sensorIter.next().data);
}

Parameters:

Options Hash (options):

Returns:

See Also:

Since:

  • 2.1.0

Supported Devices:

  • fenix 5/S/X

  • fenix Chronos

  • Forerunner 935

  • vivoactive HR


9182
9183
# File 'Monkeybrains.rb', line 9182

def getPressureHistory(options)
end

getTemperatureHistory(options) ⇒ Toybox::SensorHistory::SensorHistoryIterator

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

This function always returns the most recent temperature samples. The time between each SensorSample in the iterator may be device dependent.

Examples:

Gets a SensoryHistoryIterator and prints out the temperature value from the most recent SensorSample

using Toybox.SensorHistory;
using Toybox.Lang;
using Toybox.System;

// Create a method to get the SensorHistoryIterator object
function getIterator() {
    // Check device for SensorHistory compatibility
    if ((Toybox has :SensorHistory) && (Toybox.SensorHistory has :getTemperatureHistory)) {
        // Set up the method with parameters
        return Toybox.SensorHistory.getTemperatureHistory({});
    }
    return null;
}

// Store the iterator info in a variable. The options are 'null' in
// this case so the entire available history is returned with the
// newest samples returned first.
var sensorIter = getIterator();

// Print out the next entry in the iterator
if (sensorIter != null) {
    System.println(sensorIter.next().data);
}

Parameters:

Options Hash (options):

Returns:

See Also:

Since:

  • 2.1.0

Supported Devices:

  • fenix 5/S/X

  • fenix Chronos

  • Forerunner 935

  • vivoactive HR

  • vivoactive 3


9128
9129
# File 'Monkeybrains.rb', line 9128

def getTemperatureHistory(options)
end