WPILib 2012
WPILibRoboticsLibraryforFRC
Classes | Public Types | Public Member Functions | Protected Types | Protected Attributes | Static Protected Attributes
ADXL345_I2C Class Reference

#include <ADXL345_I2C.h>

Inheritance diagram for ADXL345_I2C:
SensorBase ErrorBase

List of all members.

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

I2Cm_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

Detailed Description

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).


Constructor & Destructor Documentation

ADXL345_I2C::ADXL345_I2C ( UINT8  moduleNumber,
ADXL345_I2C::DataFormat_Range  range = kRange_2G 
) [explicit]

Constructor.

Parameters:
moduleNumberThe digital module that the sensor is plugged into (1 or 2).
rangeThe range (+ or -) that the accelerometer will measure.
ADXL345_I2C::~ADXL345_I2C ( ) [virtual]

Destructor.


Member Function Documentation

double ADXL345_I2C::GetAcceleration ( ADXL345_I2C::Axes  axis) [virtual]

Get the acceleration of one axis in Gs.

Parameters:
axisThe axis to read from.
Returns:
Acceleration of the ADXL345 in Gs.
ADXL345_I2C::AllAxes ADXL345_I2C::GetAccelerations ( ) [virtual]

Get the acceleration of all axes in Gs.

Returns:
Acceleration measured on all axes of the ADXL345 in Gs.

The documentation for this class was generated from the following files:
 All Classes Functions Variables