![]() |
WPILibC++ 2027.0.0-alpha-5
|
ADXL345 Accelerometer on I2C. More...
#include <wpi/hardware/accelerometer/ADXL345_I2C.hpp>
Classes | |
| struct | AllAxes |
| Container type for accelerations from all axes. More... | |
Public Types | |
| enum class | Axis { X = 0x00 , Y = 0x02 , Z = 0x04 } |
| Accelerometer axes. More... | |
Public Member Functions | |
| ADXL345_I2C (I2C::Port port, int range=2, int deviceAddress=DEFAULT_ADDRESS) | |
| 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 (int 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 (Axis axis) |
| Get the acceleration of one axis in Gs. | |
| virtual AllAxes | GetAccelerations () |
| Get the acceleration of all axes in Gs. | |
| void | InitSendable (wpi::nt::NTSendableBuilder &builder) override |
| Initializes this Sendable object. | |
| Public Member Functions inherited from wpi::nt::NTSendable | |
| void | InitSendable (wpi::util::SendableBuilder &builder) override |
| Initializes this Sendable object. | |
| Public Member Functions inherited from wpi::util::Sendable | |
| virtual constexpr | ~Sendable ()=default |
| Public Member Functions inherited from wpi::util::SendableHelper< ADXL345_I2C > | |
| constexpr | SendableHelper (const SendableHelper &rhs)=default |
| constexpr SendableHelper & | operator= (const SendableHelper &rhs)=default |
Static Public Attributes | |
| static constexpr int | DEFAULT_ADDRESS = 0x1D |
| Default I2C device address. | |
Additional Inherited Members | |
| Protected Member Functions inherited from wpi::util::SendableHelper< ADXL345_I2C > | |
| 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).
|
strong |
|
explicit |
|
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 wpi::ADXL345_I2C::GetI2CDeviceAddress | ( | ) | const |
| I2C::Port wpi::ADXL345_I2C::GetI2CPort | ( | ) | const |
| double wpi::ADXL345_I2C::GetX | ( | ) |
Returns the acceleration along the X axis in g-forces.
| double wpi::ADXL345_I2C::GetY | ( | ) |
Returns the acceleration along the Y axis in g-forces.
| double wpi::ADXL345_I2C::GetZ | ( | ) |
Returns the acceleration along the Z axis in g-forces.
|
overridevirtual |
Initializes this Sendable object.
| builder | sendable builder |
Implements wpi::nt::NTSendable.
|
default |
| void wpi::ADXL345_I2C::SetRange | ( | int | range | ) |
Set the measuring range of the accelerometer.
| range | The maximum acceleration, positive or negative, that the accelerometer will measure. Valid values are 2, 4, 8, or 16 Gs. |
|
staticconstexpr |
Default I2C device address.