HTML5 Device Motion Event

This event provides direct access to motion data from an accelerometer and gyroscope. The three pieces of data provided are the acceleration, acceleration including gravity and rotation rate.
At this moment the data supported is from Accelerometer only.

Supported Platform(s)

- BlackBerry PlayBook
- Ripple Emulator

View Supported Platform Table

APIOS 5.0OS 6.0OS 7.0PlayBookRipple
initDeviceMotionEvent       Y 
accelerationIncludingGravity       YY
interval       Y 

Configuration Document Settings

To use all of the API described for this object, you must ensure the following settings are in your configuration document:

This API does not require a <feature> element to be declared in the configuration document of your BlackBerry WebWorks Application.

Permission Elements (PlayBook Only)
This API does not require a <permission> element to be declared in the configuration document of your BlackBerry WebWorks Application.

initDeviceMotionEvent


void initDeviceMotionEvent()

Supported Platform(s)

 - BlackBerry PlayBook

Description

Initializes the event listener and it's parameters


Properties:


Property Type Description Supported Platform(s)
accelerationIncludingGravity Acceleration
readonly
Implementations that are unable to provide acceleration data without the effect of gravity (due, for example, to the lack of a gyroscope) may instead supply the acceleration including the effect of gravity. This is less useful in many applications but is provided as a means of providing best-effort support. In this case, the values reported are equal to the acceleration of the device, plus an acceleration equal and opposite to the acceleration due to gravity.
 - BlackBerry PlayBook
 - Ripple Emulator
interval Number
readonly
The regular interval at which the event must fire at, given in milliseconds
 - BlackBerry PlayBook

Code Example(s)


<script type="text/javascript">

window.addEventListener("devicemotion", function(event) {

		var ax = "Acceleration X value- " + event.accelerationIncludingGravity.x;
		var ay = "Acceleration Y value- " + event.accelerationIncludingGravity.y;
		var az = "Acceleration Z value- " + event.accelerationIncludingGravity.z;

		alert(ax+"\n"+ay+"\n"+az);

}, true);

</script>

Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 30 2012 13:31:17 GMT-0500 (EST)