code/WPILib/ADXL345_I2C.cpp
/**
 * Get the acceleration of all axes in Gs.
 * 
 * @return Acceleration measured on all axes of the ADXL345 in Gs.
 */
Get the acceleration of all axes in Gs.

@return Acceleration measured on all axes of the ADXL345 in Gs.
Get the acceleration of all axes in Gs . @return Acceleration measured on all axes of the ADXL345 in Gs .
ADXL345_I2C::AllAxes ADXL345_I2C::GetAccelerations()
{
	AllAxes data = {0.0};
	INT16 rawData[3];
	if (m_i2c)
	{
		m_i2c->Read(kDataRegister, sizeof(rawData), (UINT8*)rawData);
		for (INT32 i=0; i<3; i++)
		{
			rawData[i] = ((rawData[i] >> 8) & 0xFF) | (rawData[i] << 8);
		}
		data.XAxis = rawData[0] * kGsPerLSB;
		data.YAxis = rawData[1] * kGsPerLSB;
		data.ZAxis = rawData[2] * kGsPerLSB;
	}
	return data;
}
ADXL345_I2C :: AllAxes ADXL345_I2C :: GetAccelerations ( ) { AllAxes data = { 0.0 } ; INT16 rawData [ 3 ] ; if ( m_i2c ) { m_i2c -> Read ( kDataRegister , sizeof ( rawData ) , ( UINT8 * ) rawData ) ; for ( INT32 i = 0 ; i < 3 ; i ++ ) { rawData [ i ] = ( ( rawData [ i ] >> 8 ) & 0xFF ) | ( rawData [ i ] << 8 ) ; } data . XAxis = rawData [ 0 ] * kGsPerLSB ; data . YAxis = rawData [ 1 ] * kGsPerLSB ; data . ZAxis = rawData [ 2 ] * kGsPerLSB ; } return data ; }
Get the acceleration of all axes in Gs.
Get the acceleration of all axes in Gs .
// Sensor is little endian... swap bytes