Package edu.wpi.first.wpilibj
Class ADXL345_I2C
java.lang.Object
edu.wpi.first.wpilibj.ADXL345_I2C
- All Implemented Interfaces:
NTSendable,Sendable,Accelerometer,AutoCloseable
public class ADXL345_I2C extends Object implements Accelerometer, NTSendable, AutoCloseable
ADXL345 I2C Accelerometer.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classADXL345_I2C.AllAxesstatic classADXL345_I2C.AxesNested classes/interfaces inherited from interface edu.wpi.first.wpilibj.interfaces.Accelerometer
Accelerometer.Range -
Field Summary
-
Constructor Summary
Constructors Constructor Description ADXL345_I2C(I2C.Port port, Accelerometer.Range range)Constructs the ADXL345 Accelerometer with I2C address 0x1D.ADXL345_I2C(I2C.Port port, Accelerometer.Range range, int deviceAddress)Constructs the ADXL345 Accelerometer over I2C. -
Method Summary
Modifier and Type Method Description voidclose()doublegetAcceleration(ADXL345_I2C.Axes axis)Get the acceleration of one axis in Gs.ADXL345_I2C.AllAxesgetAccelerations()Get the acceleration of all axes in Gs.intgetDeviceAddress()intgetPort()doublegetX()Common interface for getting the x axis acceleration.doublegetY()Common interface for getting the y axis acceleration.doublegetZ()Common interface for getting the z axis acceleration.voidinitSendable(NTSendableBuilder builder)Initializes thisSendableobject.voidsetRange(Accelerometer.Range range)Common interface for setting the measuring range of an accelerometer.
-
Field Details
-
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
-
getDeviceAddress
-
close
- Specified by:
closein interfaceAutoCloseable
-
setRange
Description copied from interface:AccelerometerCommon interface for setting the measuring range of an accelerometer.- Specified by:
setRangein interfaceAccelerometer- Parameters:
range- The maximum acceleration, positive or negative, that the accelerometer will measure. Not all accelerometers support all ranges.
-
getX
Description copied from interface:AccelerometerCommon interface for getting the x axis acceleration.- Specified by:
getXin interfaceAccelerometer- Returns:
- The acceleration along the x axis in g-forces
-
getY
Description copied from interface:AccelerometerCommon interface for getting the y axis acceleration.- Specified by:
getYin interfaceAccelerometer- Returns:
- The acceleration along the y axis in g-forces
-
getZ
Description copied from interface:AccelerometerCommon interface for getting the z axis acceleration.- Specified by:
getZin interfaceAccelerometer- 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:NTSendableInitializes thisSendableobject.- Specified by:
initSendablein interfaceNTSendable- Parameters:
builder- sendable builder
-