ADXL345_I2C
- class wpilib.ADXL345_I2C(port: wpilib._wpilib.I2C.Port, range: SupportsInt | SupportsIndex = 2, deviceAddress: SupportsInt | SupportsIndex = 29)
Bases:
NTSendableADXL345 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).
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; valid values are 2, 4, 8, or 16 Gs. The default is 2 Gs.
deviceAddress – The I2C address of the accelerometer (0x1D or 0x53)
- class AllAxes
Bases:
pybind11_objectContainer type for accelerations from all axes.
- class Axis(value: SupportsInt | SupportsIndex)
Bases:
pybind11_objectAccelerometer axes.
Members:
X : X axis.
Y : Y axis.
Z : Z axis.
- X = <Axis.X: 0>
- Y = <Axis.Y: 2>
- Z = <Axis.Z: 4>
- ADXL345_I2C.Axis.name -> str
- property value
- DEFAULT_ADDRESS = 29
- getAcceleration(axis: wpilib._wpilib.ADXL345_I2C.Axis) 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
- setRange(range: SupportsInt | SupportsIndex) None
Set the measuring range of the accelerometer.
- Parameters:
range – The maximum acceleration, positive or negative, that the accelerometer will measure. Valid values are 2, 4, 8, or 16 Gs.