10 #include <hal/SimDevice.h>
12 #include "frc/ErrorBase.h"
14 #include "frc/interfaces/Accelerometer.h"
15 #include "frc/smartdashboard/Sendable.h"
16 #include "frc/smartdashboard/SendableHelper.h"
20 class SendableBuilder;
34 enum Axes { kAxis_X = 0x00, kAxis_Y = 0x02, kAxis_Z = 0x04 };
49 explicit ADXL345_I2C(I2C::Port port, Range range = kRange_2G,
50 int deviceAddress = kAddress);
58 double GetX()
override;
59 double GetY()
override;
60 double GetZ()
override;
83 hal::SimDevice m_simDevice;
84 hal::SimEnum m_simRange;
85 hal::SimDouble m_simX;
86 hal::SimDouble m_simY;
87 hal::SimDouble m_simZ;
89 static constexpr
int kAddress = 0x1D;
90 static constexpr
int kPowerCtlRegister = 0x2D;
91 static constexpr
int kDataFormatRegister = 0x31;
92 static constexpr
int kDataRegister = 0x32;
93 static constexpr
double kGsPerLSB = 0.00390625;
96 kPowerCtl_Link = 0x20,
97 kPowerCtl_AutoSleep = 0x10,
98 kPowerCtl_Measure = 0x08,
99 kPowerCtl_Sleep = 0x04
102 enum DataFormatFields {
103 kDataFormat_SelfTest = 0x80,
104 kDataFormat_SPI = 0x40,
105 kDataFormat_IntInvert = 0x20,
106 kDataFormat_FullRes = 0x08,
107 kDataFormat_Justify = 0x04
Definition: ADXL345_I2C.h:36
double GetX() override
Common interface for getting the x axis acceleration.
ADXL345_I2C(I2C::Port port, Range range=kRange_2G, int deviceAddress=kAddress)
Constructs the ADXL345 Accelerometer over I2C.
virtual double GetAcceleration(Axes axis)
Get the acceleration of one axis in Gs.
double GetY() override
Common interface for getting the y axis acceleration.
Interface for 3-axis accelerometers.
Definition: Accelerometer.h:15
virtual AllAxes GetAccelerations()
Get the acceleration of all axes in Gs.
Base class for most objects.
Definition: ErrorBase.h:104
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
ADXL345 Accelerometer on I2C.
Definition: ADXL345_I2C.h:29
Interface for Sendable objects.
Definition: Sendable.h:17
A class that enforces constraints on the differential drive kinematics.
Definition: SPIAccelerometerSim.h:16
double GetZ() override
Common interface for getting the z axis acceleration.
I2C bus interface class.
Definition: I2C.h:24
void SetRange(Range range) override
Common interface for setting the measuring range of an accelerometer.
A helper class for use with objects that add themselves to SendableRegistry.
Definition: SendableHelper.h:28
Definition: SendableBuilder.h:23