143 static constexpr int kPowerCtlRegister = 0x2D;
144 static constexpr int kDataFormatRegister = 0x31;
145 static constexpr int kDataRegister = 0x32;
146 static constexpr double kGsPerLSB = 0.00390625;
148 enum PowerCtlFields {
149 kPowerCtl_Link = 0x20,
150 kPowerCtl_AutoSleep = 0x10,
151 kPowerCtl_Measure = 0x08,
152 kPowerCtl_Sleep = 0x04
155 enum DataFormatFields {
156 kDataFormat_SelfTest = 0x80,
157 kDataFormat_SPI = 0x40,
158 kDataFormat_IntInvert = 0x20,
159 kDataFormat_FullRes = 0x08,
160 kDataFormat_Justify = 0x04
ADXL345 Accelerometer on I2C.
Definition: ADXL345_I2C.h:27
static constexpr int kAddress
Default I2C device address.
Definition: ADXL345_I2C.h:68
virtual double GetAcceleration(Axes axis)
Get the acceleration of one axis in Gs.
double GetZ()
Returns the acceleration along the Z axis in g-forces.
double GetY()
Returns the acceleration along the Y axis in g-forces.
~ADXL345_I2C() override=default
int GetI2CDeviceAddress() const
Range
Accelerometer range.
Definition: ADXL345_I2C.h:32
@ kRange_16G
16 Gs max.
Definition: ADXL345_I2C.h:40
@ kRange_2G
2 Gs max.
Definition: ADXL345_I2C.h:34
@ kRange_4G
4 Gs max.
Definition: ADXL345_I2C.h:36
@ kRange_8G
8 Gs max.
Definition: ADXL345_I2C.h:38
ADXL345_I2C & operator=(ADXL345_I2C &&)=default
virtual AllAxes GetAccelerations()
Get the acceleration of all axes in Gs.
Axes
Accelerometer axes.
Definition: ADXL345_I2C.h:46
@ kAxis_X
X axis.
Definition: ADXL345_I2C.h:48
@ kAxis_Y
Y axis.
Definition: ADXL345_I2C.h:50
@ kAxis_Z
Z axis.
Definition: ADXL345_I2C.h:52
double GetX()
Returns the acceleration along the X axis in g-forces.
ADXL345_I2C(I2C::Port port, Range range=kRange_2G, int deviceAddress=kAddress)
Constructs the ADXL345 Accelerometer over I2C.
void InitSendable(nt::NTSendableBuilder &builder) override
Initializes this Sendable object.
void SetRange(Range range)
Set the measuring range of the accelerometer.
ADXL345_I2C(ADXL345_I2C &&)=default
I2C::Port GetI2CPort() const
I2C bus interface class.
Definition: I2C.h:23
Port
I2C connection ports.
Definition: I2C.h:28
A move-only C++ wrapper around a HAL simulator device handle.
Definition: SimDevice.h:642
C++ wrapper around a HAL simulator double value handle.
Definition: SimDevice.h:533
C++ wrapper around a HAL simulator enum value handle.
Definition: SimDevice.h:574
Helper class for building Sendable dashboard representations for NetworkTables.
Definition: NTSendableBuilder.h:22
Interface for NetworkTable Sendable objects.
Definition: NTSendable.h:16
A helper class for use with objects that add themselves to SendableRegistry.
Definition: SendableHelper.h:19
Definition: AprilTagPoseEstimator.h:15
Container type for accelerations from all axes.
Definition: ADXL345_I2C.h:58
double XAxis
Acceleration along the X axis in g-forces.
Definition: ADXL345_I2C.h:60
double YAxis
Acceleration along the Y axis in g-forces.
Definition: ADXL345_I2C.h:62
double ZAxis
Acceleration along the Z axis in g-forces.
Definition: ADXL345_I2C.h:64