Store accelerometer readings in a buffer
- Import the following classes:
- net.rim.device.api.system.AccelerometerChannelConfig;
- net.rim.device.api.system.AccelerometerSensor.Channel;
- Create a configuration for a channel to the accelerometer.
AccelerometerChannelConfig channelConfig = new AccelerometerChannelConfig( AccelerometerChannelConfig.TYPE_RAW );
- Invoke AccelerometerChannelConfig.setSamplesCount(), to specify the number of acceleration readings to store in the buffer. Each element in the buffer contains acceleration readings for the x, y, and z axes and data on when the reading took place.
channelConfig.setSamplesCount( 500 );
- Invoke AccelerometerSensor.openChannel() to open a channel to the accelerometer.
Channel bufferedChannel = AccelerometerSensor.openChannel( Application.getApplication(), channelConfig );
Was this information helpful? Send us your comments.