SensorCollector2

abstract class SensorCollector2<M : SensorMeasurement<M>, C : SensorCollector2<M, C>>(val context: Context, val sensorDelay: SensorDelay, val startOffsetEnabled: Boolean, var accuracyChangedListener: SensorCollector2.OnAccuracyChangedListener<M, C>?, var measurementListener: SensorCollector2.OnMeasurementListener<M, C>?)

Base class for sensor collectors. This collector does not have an internal buffer.

Parameters

M

type of measurement.

C

type of collector.

Inheritors

Constructors

Link copied to clipboard
constructor(context: Context, sensorDelay: SensorDelay, startOffsetEnabled: Boolean, accuracyChangedListener: SensorCollector2.OnAccuracyChangedListener<M, C>?, measurementListener: SensorCollector2.OnMeasurementListener<M, C>?)

Types

Link copied to clipboard

Interface to notify when sensor accuracy changes.

Link copied to clipboard

Interface to notify when a new measurement is available. Notice that notified measurements from multiple collectors of different sensors, might be out of order. Notice that notified measurement is reused for memory efficiency.

Properties

Link copied to clipboard

listener to notify changes in accuracy.

Link copied to clipboard

Android context.

Link copied to clipboard

listener to notify new measurements. It must be noticed that measurements notification might be delayed.

Link copied to clipboard

Gets most recent timestamp of all measurements processed so far. Timestamp is expressed in nanoseconds by a monotonic clock based on SystemClock.elapsedRealtimeNanos.

Link copied to clipboard

Gets number of processed measurements since this collector started.

Link copied to clipboard

Indicates whether collector is running and collecting measurements.

Link copied to clipboard
abstract val sensor: Sensor?

Sensor being used to obtain measurements or null if not available. This can be used to obtain additional information about the sensor.

Link copied to clipboard

Indicates whether requested sensor is available or not.

Link copied to clipboard

Delay of sensor between samples.

Link copied to clipboard

Initial offset expressed in nano seconds between first received measurement timestamp and start time expressed in the monotonically increasing system clock obtained by SystemClock.elapsedRealtimeNanos.

Link copied to clipboard

indicates whether startOffset will be computed when first measurement is received or not. True indicates that offset is computed, false assumes that offset is null.

Link copied to clipboard

Timestamp when collector started expressed as a monotonically increasing timestamp in nanoseconds as indicated by SystemClock.elapsedRealtimeNanos.

Functions

Link copied to clipboard
fun start(startTimestamp: Long = SystemClock.elapsedRealtimeNanos()): Boolean

Starts collecting sensor measurements.

Link copied to clipboard
fun stop()

Stops collecting sensor measurements.