You are here: Accelerometer APIs
Using the Accelerometer API, you can register various gesture events (such as shake), and then detect the change in orientation of a device along three orthogonal axes x, y, and z.
The following diagram shows the standard coordinate system that the Volt MX Accelerometer API uses
This coordinate system is independent of any particular type of device. The following table describes the coordinate system to be used for the accelerometer API:
|Floating point value indicating the magnitude of the acceleration force along the X-Axis
|Towards the right when the device is facing you
|Towards the left when the device is facing you
|Floating point value indicating the magnitude of the acceleration force along the Y-Axis
|Towards the top of the top of the device
|Towards the bottom of the device
|Floating point value indicating the magnitude of the acceleration force along the Z-Axis
|The axis coming out from the device screen (towards you) when the device is facing you
|The axis coming out from the device back (away from you) when the device is facing you
The Accelerometer API uses
voltmx.accelerometer Namespace and helps you manage and retrieve data from the device's accelerometer. It comprises of the following API elements.
|Registers event handlers for acceleration events, such as 'shake'.
|Sets callback functions for retrieving the current device acceleration.
|Starts monitoring the device's acceleration on a continuous basis.
|Stops the device monitoring activity if it is active.
|Unregisters event handlers for the specified acceleration event types.
When you use the Acceleometer API, any changes in gestures are registered by invoking the voltmx.accelerometer.registerAccelerationEvents function. After the change is registered, the current acceleration of the device is determined by using the voltmx.accelerometer.retrieveCurrentAcceleration function. Moniter the acceleration of the device by using the voltmx.accelerometer.startMonitoringAcceleration function. To stop monitoring the device, use the voltmx.accelerometer.stopMonitoringAcceleration function. To unregister event handlers for the specified acceleration event types, you can use the voltmx.accelerometer.unregisterAccelerationEvents function.
Note: The accelerometer APIs are applicable only when
To view the functionality of the Accelerometer API in action, download the sample application from the link below. Once the application is downloaded, build and preview the application using the Volt MX App.