Watching for change in position
You can get the acceleration data (X, Y, and Z) at regular intervals by watching for the change in device position.
- returns – watchID - String
- callback – Function that will be called whenever there is a change in location
- Options object (Optional)
The returned watch ID references the accelerometer's watch interval, and can be used with accelerometer.clearWatch to stop watching the accelerometer.
<cffunction access="public" name="callbackfunc" returntype="void" >
The callback function passed to the watch function will be invoked based on the frequency provided in the options object. The callback function will receive an argument 'acceleration' with the following properties:
- x - Amount of acceleration on the x-axis
- y - Amount of acceleration on the x-axis
- z - Amount of acceleration on the z-axis
- timestamp - The creation timestamp in milliseconds
The 'acceleration' object has the accelerometer data captured at a specific time.
The Options object
The Options object contains the following parameter:
- frequency – The time delay for invoking the callback function to obtain the Accelerometer data (in milliseconds)