Package edu.wpi.first.wpilibj
Class ADXL345_SPI
- java.lang.Object
-
- edu.wpi.first.wpilibj.SendableBase
-
- edu.wpi.first.wpilibj.ADXL345_SPI
-
- All Implemented Interfaces:
Accelerometer
,Sendable
,AutoCloseable
public class ADXL345_SPI extends SendableBase implements Accelerometer
ADXL345 SPI Accelerometer.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ADXL345_SPI.AllAxes
static class
ADXL345_SPI.Axes
-
Nested classes/interfaces inherited from interface edu.wpi.first.wpilibj.interfaces.Accelerometer
Accelerometer.Range
-
-
Constructor Summary
Constructors Constructor Description ADXL345_SPI(SPI.Port port, Accelerometer.Range range)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
double
getAcceleration(ADXL345_SPI.Axes axis)
Get the acceleration of one axis in Gs.ADXL345_SPI.AllAxes
getAccelerations()
Get the acceleration of all axes in Gs.double
getX()
Common interface for getting the x axis acceleration.double
getY()
Common interface for getting the y axis acceleration.double
getZ()
Common interface for getting the z axis acceleration.void
initSendable(SendableBuilder builder)
Initializes thisSendable
object.void
setRange(Accelerometer.Range range)
Common interface for setting the measuring range of an accelerometer.-
Methods inherited from class edu.wpi.first.wpilibj.SendableBase
addChild, free, getName, getSubsystem, setName, setName, setName, setSubsystem
-
-
-
-
Field Detail
-
m_spi
protected SPI m_spi
-
-
Constructor Detail
-
ADXL345_SPI
public ADXL345_SPI(SPI.Port port, Accelerometer.Range range)
Constructor.- Parameters:
port
- The SPI port that the accelerometer is connected torange
- The range (+ or -) that the accelerometer will measure.
-
-
Method Detail
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Overrides:
close
in classSendableBase
-
setRange
public void setRange(Accelerometer.Range range)
Description copied from interface:Accelerometer
Common interface for setting the measuring range of an accelerometer.- Specified by:
setRange
in interfaceAccelerometer
- Parameters:
range
- The maximum acceleration, positive or negative, that the accelerometer will measure. Not all accelerometers support all ranges.
-
getX
public double getX()
Description copied from interface:Accelerometer
Common interface for getting the x axis acceleration.- Specified by:
getX
in interfaceAccelerometer
- Returns:
- The acceleration along the x axis in g-forces
-
getY
public double getY()
Description copied from interface:Accelerometer
Common interface for getting the y axis acceleration.- Specified by:
getY
in interfaceAccelerometer
- Returns:
- The acceleration along the y axis in g-forces
-
getZ
public double getZ()
Description copied from interface:Accelerometer
Common interface for getting the z axis acceleration.- Specified by:
getZ
in interfaceAccelerometer
- Returns:
- The acceleration along the z axis in g-forces
-
getAcceleration
public double getAcceleration(ADXL345_SPI.Axes axis)
Get the acceleration of one axis in Gs.- Parameters:
axis
- The axis to read from.- Returns:
- Acceleration of the ADXL345 in Gs.
-
getAccelerations
public ADXL345_SPI.AllAxes 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
public void initSendable(SendableBuilder builder)
Description copied from interface:Sendable
Initializes thisSendable
object.- Specified by:
initSendable
in interfaceSendable
- Parameters:
builder
- sendable builder
-
-