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