ADXL345_I2C
- class wpilib.ADXL345_I2C(port: wpilib._wpilib.I2C.Port, range: wpilib._wpilib.ADXL345_I2C.Range = <Range.kRange_2G: 0>, deviceAddress: int = 29)
Bases:
NTSendable
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 <a href=”https://docs.wpilib.org/en/stable/docs/yearly-overview/known-issues.html#onboard-i2c-causing-system-lockups”> WPILib Known Issues</a> page for details.
Constructs the ADXL345 Accelerometer over I2C.
- Parameters:
port – The I2C port the accelerometer is attached to
range – The range (+ or -) that the accelerometer will measure
deviceAddress – The I2C address of the accelerometer (0x1D or 0x53)
- class AllAxes
Bases:
pybind11_object
Container type for accelerations from all axes.
- property XAxis float
Acceleration along the X axis in g-forces.
- property YAxis float
Acceleration along the Y axis in g-forces.
- property ZAxis float
Acceleration along the Z axis in g-forces.
- class Axes(value: int)
Bases:
pybind11_object
Accelerometer axes.
Members:
kAxis_X : X axis.
kAxis_Y : Y axis.
kAxis_Z : Z axis.
- kAxis_X = <Axes.kAxis_X: 0>
- kAxis_Y = <Axes.kAxis_Y: 2>
- kAxis_Z = <Axes.kAxis_Z: 4>
- property name
- property value
- class Range(value: int)
Bases:
pybind11_object
Accelerometer range.
Members:
kRange_2G : 2 Gs max.
kRange_4G : 4 Gs max.
kRange_8G : 8 Gs max.
kRange_16G : 16 Gs max.
- kRange_16G = <Range.kRange_16G: 3>
- kRange_2G = <Range.kRange_2G: 0>
- kRange_4G = <Range.kRange_4G: 1>
- kRange_8G = <Range.kRange_8G: 2>
- property name
- property value
- getAcceleration(axis: wpilib._wpilib.ADXL345_I2C.Axes) float
Get the acceleration of one axis in Gs.
- Parameters:
axis – The axis to read from.
- Returns:
Acceleration of the ADXL345 in Gs.
- getAccelerations() wpilib._wpilib.ADXL345_I2C.AllAxes
Get the acceleration of all axes in Gs.
- Returns:
An object containing the acceleration measured on each axis of the ADXL345 in Gs.
- getI2CDeviceAddress() int
- getI2CPort() wpilib._wpilib.I2C.Port
- getX() float
Returns the acceleration along the X axis in g-forces.
- Returns:
The acceleration along the X axis in g-forces.
- getY() float
Returns the acceleration along the Y axis in g-forces.
- Returns:
The acceleration along the Y axis in g-forces.
- getZ() float
Returns the acceleration along the Z axis in g-forces.
- Returns:
The acceleration along the Z axis in g-forces.
- initSendable(builder: ntcore._ntcore.NTSendableBuilder) None
- kAddress = 29
- setRange(range: wpilib._wpilib.ADXL345_I2C.Range) None
Set the measuring range of the accelerometer.
- Parameters:
range – The maximum acceleration, positive or negative, that the accelerometer will measure.