Package edu.wpi.first.wpilibj
Class ADXL345_I2C
java.lang.Object
edu.wpi.first.wpilibj.ADXL345_I2C
- All Implemented Interfaces:
NTSendable
,Sendable
,AutoCloseable
ADXL345 I2C Accelerometer.
The Onboard I2C port is subject to system lockups. See WPILib Known Issues page for details.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Container type for accelerations from all axes.static enum
Accelerometer axes.static enum
Accelerometer range. -
Field Summary
-
Constructor Summary
ConstructorDescriptionADXL345_I2C
(I2C.Port port, ADXL345_I2C.Range range) Constructs the ADXL345 Accelerometer with I2C address 0x1D.ADXL345_I2C
(I2C.Port port, ADXL345_I2C.Range range, int deviceAddress) Constructs the ADXL345 Accelerometer over I2C. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
double
Get the acceleration of one axis in Gs.Get the acceleration of all axes in Gs.int
Returns the I2C device address.int
getPort()
Returns the I2C port.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.void
initSendable
(NTSendableBuilder builder) Initializes thisSendable
object.final void
setRange
(ADXL345_I2C.Range range) Set the measuring range of the accelerometer.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface edu.wpi.first.networktables.NTSendable
initSendable
-
Field Details
-
kAddress
Default I2C device address.- See Also:
-
-
Constructor Details
-
ADXL345_I2C
Constructs the ADXL345 Accelerometer with I2C address 0x1D.- Parameters:
port
- The I2C port the accelerometer is attached torange
- The range (+ or -) that the accelerometer will measure.
-
ADXL345_I2C
Constructs the ADXL345 Accelerometer over I2C.- Parameters:
port
- The I2C port the accelerometer is attached torange
- The range (+ or -) that the accelerometer will measure.deviceAddress
- I2C address of the accelerometer (0x1D or 0x53)
-
-
Method Details
-
getPort
Returns the I2C port.- Returns:
- The I2C port.
-
getDeviceAddress
Returns the I2C device address.- Returns:
- The I2C device address.
-
close
- Specified by:
close
in interfaceAutoCloseable
-
setRange
Set the measuring range of the accelerometer.- Parameters:
range
- The maximum acceleration, positive or negative, that the accelerometer will measure.
-
getX
Returns the acceleration along the X axis in g-forces.- Returns:
- The acceleration along the X axis in g-forces.
-
getY
Returns the acceleration along the Y axis in g-forces.- Returns:
- The acceleration along the Y axis in g-forces.
-
getZ
Returns the acceleration along the Z axis in g-forces.- Returns:
- The acceleration along the Z axis in g-forces.
-
getAcceleration
Get the acceleration of one axis in Gs.- Parameters:
axis
- The axis to read from.- Returns:
- Acceleration of the ADXL345 in Gs.
-
getAccelerations
Get the acceleration of all axes in Gs.- Returns:
- An object containing the acceleration measured on each axis of the ADXL345 in Gs.
-
initSendable
Description copied from interface:NTSendable
Initializes thisSendable
object.- Specified by:
initSendable
in interfaceNTSendable
- Parameters:
builder
- sendable builder
-