![]() |
WPILibC++ 2025.3.2
|
ADXL345 Accelerometer on I2C. More...
#include <frc/ADXL345_I2C.h>
Classes | |
| struct | AllAxes |
| Container type for accelerations from all axes. More... | |
Public Types | |
| enum | Range { kRange_2G = 0 , kRange_4G = 1 , kRange_8G = 2 , kRange_16G = 3 } |
| Accelerometer range. More... | |
| enum | Axes { kAxis_X = 0x00 , kAxis_Y = 0x02 , kAxis_Z = 0x04 } |
| Accelerometer axes. More... | |
Public Member Functions | |
| ADXL345_I2C (I2C::Port port, Range range=kRange_2G, int deviceAddress=kAddress) | |
| Constructs the ADXL345 Accelerometer over I2C. | |
| ~ADXL345_I2C () override=default | |
| ADXL345_I2C (ADXL345_I2C &&)=default | |
| ADXL345_I2C & | operator= (ADXL345_I2C &&)=default |
| I2C::Port | GetI2CPort () const |
| int | GetI2CDeviceAddress () const |
| void | SetRange (Range range) |
| Set the measuring range of the accelerometer. | |
| double | GetX () |
| Returns the acceleration along the X axis in g-forces. | |
| double | GetY () |
| Returns the acceleration along the Y axis in g-forces. | |
| double | GetZ () |
| Returns the acceleration along the Z axis in g-forces. | |
| virtual double | GetAcceleration (Axes axis) |
| Get the acceleration of one axis in Gs. | |
| virtual AllAxes | GetAccelerations () |
| Get the acceleration of all axes in Gs. | |
| void | InitSendable (nt::NTSendableBuilder &builder) override |
| Initializes this Sendable object. | |
Public Member Functions inherited from nt::NTSendable | |
| void | InitSendable (wpi::SendableBuilder &builder) override |
| Initializes this Sendable object. | |
Public Member Functions inherited from wpi::Sendable | |
| virtual constexpr | ~Sendable ()=default |
Public Member Functions inherited from wpi::SendableHelper< ADXL345_I2C > | |
| constexpr | SendableHelper (const SendableHelper &rhs)=default |
| constexpr | SendableHelper (SendableHelper &&rhs) |
| constexpr SendableHelper & | operator= (const SendableHelper &rhs)=default |
| constexpr SendableHelper & | operator= (SendableHelper &&rhs) |
Static Public Attributes | |
| static constexpr int | kAddress = 0x1D |
| Default I2C device address. | |
Additional Inherited Members | |
Protected Member Functions inherited from wpi::SendableHelper< ADXL345_I2C > | |
| constexpr | SendableHelper ()=default |
| constexpr | ~SendableHelper () |
ADXL345 Accelerometer on I2C.
This class allows access to a Analog Devices ADXL345 3-axis accelerometer on an I2C bus. This class assumes the default (not alternate) sensor address of 0x1D (7-bit address).
The Onboard I2C port is subject to system lockups. See WPILib Known Issues page for details.
|
overridedefault |
|
default |
|
virtual |
Get the acceleration of one axis in Gs.
| axis | The axis to read from. |
|
virtual |
Get the acceleration of all axes in Gs.
| int frc::ADXL345_I2C::GetI2CDeviceAddress | ( | ) | const |
| I2C::Port frc::ADXL345_I2C::GetI2CPort | ( | ) | const |
| double frc::ADXL345_I2C::GetX | ( | ) |
Returns the acceleration along the X axis in g-forces.
| double frc::ADXL345_I2C::GetY | ( | ) |
Returns the acceleration along the Y axis in g-forces.
| double frc::ADXL345_I2C::GetZ | ( | ) |
Returns the acceleration along the Z axis in g-forces.
|
overridevirtual |
|
default |
| void frc::ADXL345_I2C::SetRange | ( | Range | range | ) |
Set the measuring range of the accelerometer.
| range | The maximum acceleration, positive or negative, that the accelerometer will measure. |
|
staticconstexpr |
Default I2C device address.