10 #include "frc/ErrorBase.h"
12 #include "frc/interfaces/Accelerometer.h"
13 #include "frc/smartdashboard/SendableBase.h"
27 enum Axes { kAxis_X = 0x00, kAxis_Y = 0x02, kAxis_Z = 0x04 };
41 explicit ADXL345_SPI(SPI::Port port, Range range = kRange_2G);
50 double GetX()
override;
51 double GetY()
override;
52 double GetZ()
override;
75 static constexpr
int kPowerCtlRegister = 0x2D;
76 static constexpr
int kDataFormatRegister = 0x31;
77 static constexpr
int kDataRegister = 0x32;
78 static constexpr
double kGsPerLSB = 0.00390625;
80 enum SPIAddressFields { kAddress_Read = 0x80, kAddress_MultiByte = 0x40 };
83 kPowerCtl_Link = 0x20,
84 kPowerCtl_AutoSleep = 0x10,
85 kPowerCtl_Measure = 0x08,
86 kPowerCtl_Sleep = 0x04
89 enum DataFormatFields {
90 kDataFormat_SelfTest = 0x80,
91 kDataFormat_SPI = 0x40,
92 kDataFormat_IntInvert = 0x20,
93 kDataFormat_FullRes = 0x08,
94 kDataFormat_Justify = 0x04
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
double GetZ() override
Common interface for getting the z axis acceleration.
void SetRange(Range range) override
Common interface for setting the measuring range of an accelerometer.
SPI bus interface class.
Definition: SPI.h:31
double GetY() override
Common interface for getting the y axis acceleration.
double GetX() override
Common interface for getting the x axis acceleration.
Definition: ADXL345_SPI.h:29
Base class for most objects.
Definition: ErrorBase.h:74
Definition: SendableBase.h:19
ADXL345 Accelerometer on SPI.
Definition: ADXL345_SPI.h:23
virtual AllAxes GetAccelerations()
Get the acceleration of all axes in Gs.
Definition: SendableBuilder.h:23
ADXL345_SPI(SPI::Port port, Range range=kRange_2G)
Constructor.
Interface for 3-axis accelerometers.
Definition: Accelerometer.h:15
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
virtual double GetAcceleration(Axes axis)
Get the acceleration of one axis in Gs.