0 out of 1 rated this helpful - Rate this topic

Accelerometer Class

Windows Phone

March 22, 2012

Provides Windows Phone applications access to the device’s accelerometer sensor.

System.Object
  Microsoft.Devices.Sensors.SensorBase<AccelerometerReading>
    Microsoft.Devices.Sensors.Accelerometer

Namespace:  Microsoft.Devices.Sensors
Assembly:  Microsoft.Devices.Sensors (in Microsoft.Devices.Sensors.dll)
XMLNS for XAML: Not mapped to an xmlns.
public sealed class Accelerometer : SensorBase<AccelerometerReading>
<Accelerometer .../>

The Accelerometer type exposes the following members.

  Name Description
Public method Accelerometer Creates a new instance of the Accelerometer object.
Top
  Name Description
Public property CurrentValue Gets an object that implements ISensorReading that contains the current value of the sensor. This object will be one of the following types, depending on which sensor is being referenced: AccelerometerReading, CompassReading, GyroscopeReading, MotionReading. (Inherited from SensorBase<TSensorReading>.)
Public property IsDataValid Gets the validity of the sensor’s data. (Inherited from SensorBase<TSensorReading>.)
Public property Static member IsSupported Gets or sets whether the device on which the application is running supports the accelerometer sensor.
Public property State Gets the current state of the accelerometer. The value is a member of the SensorState enumeration.
Public property TimeBetweenUpdates Gets or sets the preferred time between CurrentValueChanged events. (Inherited from SensorBase<TSensorReading>.)
Top
  Name Description
Public method Dispose Releases the managed and unmanaged resources used by the Accelerometer.
Public method Equals (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from SensorBase<TSensorReading>.)
Public method GetHashCode (Inherited from Object.)
Public method GetType (Inherited from Object.)
Protected method MemberwiseClone (Inherited from Object.)
Public method Start Starts data acquisition from the accelerometer.
Public method Stop Stops data acquisition from the accelerometer.
Public method ToString (Inherited from Object.)
Top
  Name Description
Public event CurrentValueChanged Occurs when new data arrives from the sensor. (Inherited from SensorBase<TSensorReading>.)
Public event ReadingChanged Obsolete. Occurs when new data arrives from the accelerometer. This method is deprecated in the current release. Applications should use the CurrentValueChanged event of the SensorBase<TSensorReading> class instead.
Top

The acceleration value is expressed as a 3-dimensional vector representing the acceleration components in the X, Y, and Z axes in gravitational units. The orientation of the acceleration is relative to the device such that -1g is applied in the Z-axis when the device is face up on a level table and -1g is applied to the Y-axis when the device is placed perpendicular to the table top.

The accelerometer sensor will detect the force of gravity along with any forces resulting from the movement of the phone. The MotionReading class uses multiple device sensors to separate the gravity vector from the device acceleration and allows you to easily determine the current attitude (yaw, pitch, and roll) of the device.

Windows Phone OS

Supported in: 7.1, 7.0

Windows Phone

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Did you find this helpful?
(1500 characters remaining)