133 static constexpr int kPowerCtlRegister = 0x2D;
134 static constexpr int kDataFormatRegister = 0x31;
135 static constexpr int kDataRegister = 0x32;
136 static constexpr double kGsPerLSB = 0.00390625;
138 enum SPIAddressFields { kAddress_Read = 0x80, kAddress_MultiByte = 0x40 };
140 enum PowerCtlFields {
141 kPowerCtl_Link = 0x20,
142 kPowerCtl_AutoSleep = 0x10,
143 kPowerCtl_Measure = 0x08,
144 kPowerCtl_Sleep = 0x04
147 enum DataFormatFields {
148 kDataFormat_SelfTest = 0x80,
149 kDataFormat_SPI = 0x40,
150 kDataFormat_IntInvert = 0x20,
151 kDataFormat_FullRes = 0x08,
152 kDataFormat_Justify = 0x04
ADXL345 Accelerometer on SPI.
Definition: ADXL345_SPI.h:22
double GetX()
Returns the acceleration along the X axis in g-forces.
double GetZ()
Returns the acceleration along the Z axis in g-forces.
~ADXL345_SPI() override=default
virtual double GetAcceleration(Axes axis)
Get the acceleration of one axis in Gs.
SPI::Port GetSpiPort() const
virtual AllAxes GetAccelerations()
Get the acceleration of all axes in Gs.
double GetY()
Returns the acceleration along the Y axis in g-forces.
void SetRange(Range range)
Set the measuring range of the accelerometer.
Axes
Accelerometer axes.
Definition: ADXL345_SPI.h:41
@ kAxis_Y
Y axis.
Definition: ADXL345_SPI.h:45
@ kAxis_Z
Z axis.
Definition: ADXL345_SPI.h:47
@ kAxis_X
X axis.
Definition: ADXL345_SPI.h:43
void InitSendable(nt::NTSendableBuilder &builder) override
Initializes this Sendable object.
ADXL345_SPI & operator=(ADXL345_SPI &&)=default
ADXL345_SPI(ADXL345_SPI &&)=default
ADXL345_SPI(SPI::Port port, Range range=kRange_2G)
Constructor.
Range
Accelerometer range.
Definition: ADXL345_SPI.h:27
@ kRange_16G
16 Gs max.
Definition: ADXL345_SPI.h:35
@ kRange_4G
4 Gs max.
Definition: ADXL345_SPI.h:31
@ kRange_2G
2 Gs max.
Definition: ADXL345_SPI.h:29
@ kRange_8G
8 Gs max.
Definition: ADXL345_SPI.h:33
SPI bus interface class.
Definition: SPI.h:26
Port
SPI port.
Definition: SPI.h:31
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_SPI.h:53
double YAxis
Acceleration along the Y axis in g-forces.
Definition: ADXL345_SPI.h:57
double ZAxis
Acceleration along the Z axis in g-forces.
Definition: ADXL345_SPI.h:59
double XAxis
Acceleration along the X axis in g-forces.
Definition: ADXL345_SPI.h:55