Class: Toybox::Sensor::SensorData

Inherits:
Lang::Object show all

Overview

A class to encapsulate all high-frequency sensor data that can be retrieved.

Examples:

Setting up an accel data callback

using Toybox.Sensor;

// Initialize accel data variables
var mX = [0]
var mY = [0]
var mZ = [0]

// Callback to receive accel data
function accel_callback(sensorData) {
    mX = sensorData.accelerometerData.x;
    mY = sensorData.accelerometerData.y;
    mZ = sensorData.accelerometerData.z;
    onAccelData();
}
// This method can now be used with registerSensorDataListener()

Since:

  • 2.3.0

Instance Attribute Summary collapse

Method Summary

Methods inherited from Lang::Object

equals, hashCode, method, toString, weak

Instance Attribute Details

accelerometerDataObject

An AccelerometerData object.

Can be null if accelerometer data was not requested.

Since:

  • 2.3.0


8655
8656
8657
# File 'Monkeybrains.rb', line 8655

def accelerometerData
  @accelerometerData
end

heartRateDataObject

A HeartRateData object.

Can be null if heart rate interval data is not available.

Examples:

using Toybox.Sensor;

var heartBeatIntervals = [];

function heartBeatIntervalsCallback(sensorData) {
    if (sensorData has :heartRateData && sensorData.heartRateData != null) {
         heartBeatIntervals = sensorData.heartRateData.heartBeatIntervals;
    }
}

See Also:

Since:

  • 3.0.0


8672
8673
8674
# File 'Monkeybrains.rb', line 8672

def heartRateData
  @heartRateData
end