Summary
Used to access the accelerometer on the device. The device accelerometer is represented in javascript by using the require statement.
Example
accelerometer = require( "accelerometer" );
accelerometer.onEvent = function(event){
console.log( "Got the event");
console.log( " timestamp: " + event.timestamp);
console.log( " x: " + event.x);
console.log( " y: " + event.y);
console.log( " z: " + event.z);
}
accelerometer.startEvents( .5 );
document.wait();
onEvent
Install a function on this property that will be called at the interval specified in the startEvents method. The function should have the following prototype:
void onEventCallback(event)
Parameters
event - An event object with a timestamp, x, y, and z properties. These properties are all double values.
Return Value
none
startEvents
Establishes the interval that the onEvent callback will be called.
void startEvents(interval)
Parameters
interval - A double value, in seconds
Return Value
none
stopEvents
Stops sending events to the onEvents callback
void stopEvents()
Parameters
None
Return Value
none