code/WPILib/ADXL345_I2C.cpp
/**
 * Get the acceleration of one axis in Gs.
 * 
 * @param axis The axis to read from.
 * @return Acceleration of the ADXL345 in Gs.
 */
Get the acceleration of one axis in Gs.

@param axis The axis to read from.
@return Acceleration of the ADXL345 in Gs.
Get the acceleration of one axis in Gs . @param axis The axis to read from . @return Acceleration of the ADXL345 in Gs .
double ADXL345_I2C::GetAcceleration(ADXL345_I2C::Axes axis)
{
	INT16 rawAccel = 0;
	if(m_i2c)
	{
		m_i2c->Read(kDataRegister + (UINT8)axis, sizeof(rawAccel), (UINT8 *)&rawAccel);
		rawAccel = ((rawAccel >> 8) & 0xFF) | (rawAccel << 8);
	}
	return rawAccel * kGsPerLSB;
}
double ADXL345_I2C :: GetAcceleration ( ADXL345_I2C :: Axes axis ) { INT16 rawAccel = 0 ; if ( m_i2c ) { m_i2c -> Read ( kDataRegister + ( UINT8 ) axis , sizeof ( rawAccel ) , ( UINT8 * ) & rawAccel ) ; rawAccel = ( ( rawAccel >> 8 ) & 0xFF ) | ( rawAccel << 8 ) ; } return rawAccel * kGsPerLSB ; }
Get the acceleration of one axis in Gs.
Get the acceleration of one axis in Gs .
// Sensor is little endian... swap bytes