138 static constexpr int kPowerCtlRegister = 0x2D;
139 static constexpr int kDataFormatRegister = 0x31;
140 static constexpr int kDataRegister = 0x32;
141 static constexpr double kGsPerLSB = 0.00390625;
143 enum PowerCtlFields {
144 kPowerCtl_Link = 0x20,
145 kPowerCtl_AutoSleep = 0x10,
146 kPowerCtl_Measure = 0x08,
147 kPowerCtl_Sleep = 0x04
150 enum DataFormatFields {
151 kDataFormat_SelfTest = 0x80,
152 kDataFormat_SPI = 0x40,
153 kDataFormat_IntInvert = 0x20,
154 kDataFormat_FullRes = 0x08,
155 kDataFormat_Justify = 0x04
virtual AllAxes GetAccelerations()
Get the acceleration of all axes in Gs.
void SetRange(Range range)
Set the measuring range of the accelerometer.
virtual double GetAcceleration(Axes axis)
Get the acceleration of one axis in Gs.
int GetI2CDeviceAddress() const
double GetY()
Returns the acceleration along the Y axis in g-forces.
ADXL345_I2C & operator=(ADXL345_I2C &&)=default
Axes
Accelerometer axes.
Definition ADXL345_I2C.hpp:41
@ kAxis_X
X axis.
Definition ADXL345_I2C.hpp:43
@ kAxis_Z
Z axis.
Definition ADXL345_I2C.hpp:47
@ kAxis_Y
Y axis.
Definition ADXL345_I2C.hpp:45
I2C::Port GetI2CPort() const
ADXL345_I2C(I2C::Port port, Range range=kRange_2G, int deviceAddress=kAddress)
Constructs the ADXL345 Accelerometer over I2C.
Range
Accelerometer range.
Definition ADXL345_I2C.hpp:27
@ kRange_8G
8 Gs max.
Definition ADXL345_I2C.hpp:33
@ kRange_4G
4 Gs max.
Definition ADXL345_I2C.hpp:31
@ kRange_2G
2 Gs max.
Definition ADXL345_I2C.hpp:29
@ kRange_16G
16 Gs max.
Definition ADXL345_I2C.hpp:35
void InitSendable(wpi::nt::NTSendableBuilder &builder) override
Initializes this Sendable object.
static constexpr int kAddress
Default I2C device address.
Definition ADXL345_I2C.hpp:63
~ADXL345_I2C() override=default
ADXL345_I2C(ADXL345_I2C &&)=default
double GetZ()
Returns the acceleration along the Z axis in g-forces.
double GetX()
Returns the acceleration along the X axis in g-forces.
I2C bus interface class.
Definition I2C.hpp:21
Port
I2C connection ports.
Definition I2C.hpp:26
A move-only C++ wrapper around a HAL simulator device handle.
Definition SimDevice.hpp:278
C++ wrapper around a HAL simulator double value handle.
Definition SimDevice.hpp:169
C++ wrapper around a HAL simulator enum value handle.
Definition SimDevice.hpp:210
Helper class for building Sendable dashboard representations for NetworkTables.
Definition NTSendableBuilder.hpp:21
Interface for NetworkTable Sendable objects.
Definition NTSendable.hpp:16
A helper class for use with objects that add themselves to SendableRegistry.
Definition SendableHelper.hpp:21
Definition CvSource.hpp:15
Container type for accelerations from all axes.
Definition ADXL345_I2C.hpp:53
double ZAxis
Acceleration along the Z axis in g-forces.
Definition ADXL345_I2C.hpp:59
double YAxis
Acceleration along the Y axis in g-forces.
Definition ADXL345_I2C.hpp:57
double XAxis
Acceleration along the X axis in g-forces.
Definition ADXL345_I2C.hpp:55