ADXL345 Accelerometer on SPI.
More...
#include <ADXL345_SPI.h>
|
enum | Axes { kAxis_X = 0x00,
kAxis_Y = 0x02,
kAxis_Z = 0x04
} |
|
enum | Range { kRange_2G = 0,
kRange_4G = 1,
kRange_8G = 2,
kRange_16G = 3
} |
|
|
enum | SPIAddressFields { kAddress_Read = 0x80,
kAddress_MultiByte = 0x40
} |
|
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
} |
|
|
static const int | kPowerCtlRegister = 0x2D |
|
static const int | kDataFormatRegister = 0x31 |
|
static const int | kDataRegister = 0x32 |
|
static constexpr double | kGsPerLSB = 0.00390625 |
|
ADXL345 Accelerometer on SPI.
This class allows access to an Analog Devices ADXL345 3-axis accelerometer via SPI. This class assumes the sensor is wired in 4-wire SPI mode.
ADXL345_SPI::ADXL345_SPI |
( |
SPI::Port |
port, |
|
|
ADXL345_SPI::Range |
range = kRange_2G |
|
) |
| |
|
explicit |
Constructor.
- Parameters
-
port | The SPI port the accelerometer is attached to |
range | The range (+ or -) that the accelerometer will measure |
double ADXL345_SPI::GetAcceleration |
( |
ADXL345_SPI::Axes |
axis | ) |
|
|
virtual |
Get the acceleration of one axis in Gs.
- Parameters
-
axis | The axis to read from. |
- Returns
- Acceleration of the ADXL345 in Gs.
Get the acceleration of all axes in Gs.
- Returns
- An object containing the acceleration measured on each axis of the ADXL345 in Gs.
std::string ADXL345_SPI::GetSmartDashboardType |
( |
| ) |
const |
|
overridevirtual |
- Returns
- the string representation of the named data type that will be used by the smart dashboard for this sendable
Implements frc::Sendable.
double ADXL345_SPI::GetX |
( |
| ) |
|
|
overridevirtual |
Common interface for getting the x axis acceleration.
- Returns
- The acceleration along the x axis in g-forces
Implements frc::Accelerometer.
double ADXL345_SPI::GetY |
( |
| ) |
|
|
overridevirtual |
Common interface for getting the y axis acceleration.
- Returns
- The acceleration along the y axis in g-forces
Implements frc::Accelerometer.
double ADXL345_SPI::GetZ |
( |
| ) |
|
|
overridevirtual |
Common interface for getting the z axis acceleration.
- Returns
- The acceleration along the z axis in g-forces
Implements frc::Accelerometer.
Initializes a table for this sendable object.
- Parameters
-
subtable | The table to put the values in. |
Implements frc::Sendable.
void ADXL345_SPI::SetRange |
( |
Range |
range | ) |
|
|
overridevirtual |
Common interface for setting the measuring range of an accelerometer.
- Parameters
-
range | The maximum acceleration, positive or negative, that the accelerometer will measure. Not all accelerometers support all ranges. |
Implements frc::Accelerometer.
The documentation for this class was generated from the following files:
- build/cppSource/wpilibc/headers/ADXL345_SPI.h
- build/cppSource/wpilibc/sources/ADXL345_SPI.cpp