WPILibC++ 2024.1.1-beta-4
|
ADXL345 Accelerometer on SPI. More...
#include <frc/ADXL345_SPI.h>
Classes | |
struct | AllAxes |
Public Types | |
enum | Range { kRange_2G = 0 , kRange_4G = 1 , kRange_8G = 2 , kRange_16G = 3 } |
enum | Axes { kAxis_X = 0x00 , kAxis_Y = 0x02 , kAxis_Z = 0x04 } |
Public Member Functions | |
ADXL345_SPI (SPI::Port port, Range range=kRange_2G) | |
Constructor. More... | |
~ADXL345_SPI () override=default | |
ADXL345_SPI (ADXL345_SPI &&)=default | |
ADXL345_SPI & | operator= (ADXL345_SPI &&)=default |
SPI::Port | GetSpiPort () const |
void | SetRange (Range range) |
Set the measuring range of the accelerometer. More... | |
double | GetX () |
Returns the acceleration along the X axis in g-forces. More... | |
double | GetY () |
Returns the acceleration along the Y axis in g-forces. More... | |
double | GetZ () |
Returns the acceleration along the Z axis in g-forces. More... | |
virtual double | GetAcceleration (Axes axis) |
Get the acceleration of one axis in Gs. More... | |
virtual AllAxes | GetAccelerations () |
Get the acceleration of all axes in Gs. More... | |
void | InitSendable (nt::NTSendableBuilder &builder) override |
Initializes this Sendable object. More... | |
Public Member Functions inherited from nt::NTSendable | |
virtual void | InitSendable (NTSendableBuilder &builder)=0 |
Initializes this Sendable object. More... | |
void | InitSendable (wpi::SendableBuilder &builder) override |
Initializes this Sendable object. More... | |
Public Member Functions inherited from wpi::Sendable | |
virtual | ~Sendable ()=default |
virtual void | InitSendable (SendableBuilder &builder)=0 |
Initializes this Sendable object. More... | |
Public Member Functions inherited from wpi::SendableHelper< ADXL345_SPI > | |
SendableHelper (const SendableHelper &rhs)=default | |
SendableHelper (SendableHelper &&rhs) | |
SendableHelper & | operator= (const SendableHelper &rhs)=default |
SendableHelper & | operator= (SendableHelper &&rhs) |
Protected Types | |
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 } |
Protected Attributes | |
SPI | m_spi |
hal::SimDevice | m_simDevice |
hal::SimEnum | m_simRange |
hal::SimDouble | m_simX |
hal::SimDouble | m_simY |
hal::SimDouble | m_simZ |
Static Protected Attributes | |
static constexpr int | kPowerCtlRegister = 0x2D |
static constexpr int | kDataFormatRegister = 0x31 |
static constexpr int | kDataRegister = 0x32 |
static constexpr double | kGsPerLSB = 0.00390625 |
Additional Inherited Members | |
Protected Member Functions inherited from wpi::SendableHelper< ADXL345_SPI > | |
SendableHelper ()=default | |
~SendableHelper () | |
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.
|
protected |
|
protected |
|
protected |
Constructor.
port | The SPI port the accelerometer is attached to |
range | The range (+ or -) that the accelerometer will measure |
|
overridedefault |
|
default |
|
virtual |
Get the acceleration of one axis in Gs.
axis | The axis to read from. |
|
virtual |
Get the acceleration of all axes in Gs.
SPI::Port frc::ADXL345_SPI::GetSpiPort | ( | ) | const |
double frc::ADXL345_SPI::GetX | ( | ) |
Returns the acceleration along the X axis in g-forces.
double frc::ADXL345_SPI::GetY | ( | ) |
Returns the acceleration along the Y axis in g-forces.
double frc::ADXL345_SPI::GetZ | ( | ) |
Returns the acceleration along the Z axis in g-forces.
|
overridevirtual |
|
default |
void frc::ADXL345_SPI::SetRange | ( | Range | range | ) |
Set the measuring range of the accelerometer.
range | The maximum acceleration, positive or negative, that the accelerometer will measure. |
|
staticconstexprprotected |
|
staticconstexprprotected |
|
staticconstexprprotected |
|
staticconstexprprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |