|
WPILib 2012
WPILibRoboticsLibraryforFRC
|
#include <ADXL345_I2C.h>
Classes | |
| struct | AllAxes |
Public Types | |
| enum | DataFormat_Range { kRange_2G = 0x00, kRange_4G = 0x01, kRange_8G = 0x02, kRange_16G = 0x03 } |
| enum | Axes { kAxis_X = 0x00, kAxis_Y = 0x02, kAxis_Z = 0x04 } |
Public Member Functions | |
| ADXL345_I2C (UINT8 moduleNumber, DataFormat_Range range=kRange_2G) | |
| virtual | ~ADXL345_I2C () |
| virtual double | GetAcceleration (Axes axis) |
| virtual AllAxes | GetAccelerations () |
Protected Types | |
| enum | PowerCtlFields { kPowerCtl_Link = 0x20, kPowerCtl_AutoSleep = 0x10, kPowerCtl_Measure = 0x08, kPowerCtl_Sleep = 0x04 } |
| enum | DataFormatFields { kDataFormat_SelfTest = 0x80, kDataFormat_SPI = 0x40, kDataFormat_IntInvert = 0x20, kDataFormat_FullRes = 0x08, kDataFormat_Justify = 0x04 } |
Protected Attributes | |
| I2C * | m_i2c |
Static Protected Attributes | |
| static const UINT8 | kAddress = 0x3A |
| static const UINT8 | kPowerCtlRegister = 0x2D |
| static const UINT8 | kDataFormatRegister = 0x31 |
| static const UINT8 | kDataRegister = 0x32 |
| static const double | kGsPerLSB = 0.00390625 |
ADXL345 Accelerometer on I2C.
This class alows access to a Analog Devices ADXL345 3-axis accelerometer on an I2C bus. This class assumes the default (not alternate) sensor address of 0x3A (8-bit address).
| ADXL345_I2C::ADXL345_I2C | ( | UINT8 | moduleNumber, |
| ADXL345_I2C::DataFormat_Range | range = kRange_2G |
||
| ) | [explicit] |
Constructor.
| moduleNumber | The digital module that the sensor is plugged into (1 or 2). |
| range | The range (+ or -) that the accelerometer will measure. |
| ADXL345_I2C::~ADXL345_I2C | ( | ) | [virtual] |
Destructor.
| double ADXL345_I2C::GetAcceleration | ( | ADXL345_I2C::Axes | axis | ) | [virtual] |
Get the acceleration of one axis in Gs.
| axis | The axis to read from. |
| ADXL345_I2C::AllAxes ADXL345_I2C::GetAccelerations | ( | ) | [virtual] |
Get the acceleration of all axes in Gs.
1.7.4