Accelerometer Class

This type is an EasyAR Sense API in C#: Accelerometer . Some descriptions may not apply to Unity environment on this page.

This type is partially wrapped into Unity components: MegaTrackerFrameFilter . Members and instances of this type are not required to be used directly in most situations. Use this type by MegaTrackerFrameFilter.Accelerometer instead of creating new instances when a few unwrapped API is desired for use.

Description

Accelerometer calls the accelerometer provided by the operating system, and outputs AccelerometerResult .

When it is not needed anymore, call close function to close it. It shall not be used after calling close.

It is not recommended to open the accelerometer multiple times simultaneously, which may cause failure on open or cause precision downgrade.


Methods

isAvailable

C#

public virtual bool isAvailable()

Checks if the component is available. It returns true only on Android or iOS with supported hardware. On other operating systems, it is not supported.

output

C#

public virtual AccelerometerResultSource output()

Output port.

open

C#

public virtual bool open()

Opens the device. Sampling period is defined by implementation. If failed, it will return false.

openWithSamplingPeriod

C#

public virtual bool openWithSamplingPeriod(int samplingPeriodMilliseconds)

Opens the device with a specific sampling period. Sampling period is limited by hardware and may not reach the specified value. If failed, it will return false.

close

C#

public virtual void close()

Closes. It shall not be used after calling close.

getCurrentResult

C#

public virtual Optional< AccelerometerResult > getCurrentResult()

Gets the most recent result. If there is no result, it returns empty.