Class: Toybox.Sensor.SensorData

Overview

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

Example:

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:

API Level 2.3.0

Supported Devices:

Instance Member Summary collapse

Instance Attribute Details

var accelerometerData as Sensor.AccelerometerData or Null

An AccelerometerData object.

Can be null if accelerometer data was not requested.

Since:

API Level 2.3.0

Supported Devices:

var gyroscopeData as Sensor.GyroscopeData or Null

An GyroscopeData object.

Can be null if gyroscope data was not requested.

Since:

API Level 3.3.0

Supported Devices:

Returns:

var heartRateData as Sensor.HeartRateData or Null

A HeartRateData object.

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

Example:

using Toybox.Sensor;

var heartBeatIntervals = [];

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

Since:

API Level 3.0.0

See Also:

Supported Devices:

var magnetometerData as Sensor.MagnetometerData or Null

An MagnetometerData object.

Can be null if MagnetometerData data was not requested.

Since:

API Level 3.3.0

Supported Devices:

Returns:


Generated Sep 23, 2024, 3:32:49 PM