Retrieve accelerometer readings from a buffer
- Import the following classes:
- net.rim.device.api.system.AccelerometerData;
- net.rim.device.api.system.AccelerometerSensor.Channel;
- Query the buffer for accelerometer data.
AccelerometerData accData = bufferedChannel.getAccelerometerData();
- Invoke AccelerometerData.getNewBatchLength(), to get the number of readings retrieved since the last query.
int newBatchSize = accData.getNewBatchLength();
- Invoke AccelerometerData.getXAccHistory(),
AccelerometerData.getYAccHistory(), and AccelerometerData.getZAccHistory()
to retrieve accelerometer data from the buffer for each axis.
short[] xAccel = accData.getXAccHistory();
short[] yAccel = accData.getYAccHistory();
short[] zAccel = accData.getZAccHistory();
Was this information helpful? Send us your comments.