Class ADXL345_SPI

java.lang.Object
edu.wpi.first.wpilibj.ADXL345_SPI
All Implemented Interfaces:
NTSendable, Sendable, AutoCloseable

public class ADXL345_SPI
extends Object
implements NTSendable, AutoCloseable
ADXL345 SPI Accelerometer.
  • Constructor Details

  • Method Details

    • getPort

      public int getPort()
      Returns the SPI port.
      Returns:
      The SPI port.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • setRange

      public void setRange​(ADXL345_SPI.Range range)
      Set the measuring range of the accelerometer.
      Parameters:
      range - The maximum acceleration, positive or negative, that the accelerometer will measure.
    • getX

      public double getX()
      Returns the acceleration along the X axis in g-forces.
      Returns:
      The acceleration along the X axis in g-forces.
    • getY

      public double getY()
      Returns the acceleration along the Y axis in g-forces.
      Returns:
      The acceleration along the Y axis in g-forces.
    • getZ

      public double getZ()
      Returns the acceleration along the Z axis in g-forces.
      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

      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​(NTSendableBuilder builder)
      Description copied from interface: NTSendable
      Initializes this Sendable object.
      Specified by:
      initSendable in interface NTSendable
      Parameters:
      builder - sendable builder