Class ADXL362

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

public class ADXL362
extends Object
implements NTSendable, AutoCloseable
ADXL362 SPI Accelerometer.

This class allows access to an Analog Devices ADXL362 3-axis accelerometer.

  • Constructor Details

    • ADXL362

      public ADXL362​(ADXL362.Range range)
      Constructor. Uses the onboard CS1.
      Parameters:
      range - The range (+ or -) that the accelerometer will measure.
    • ADXL362

      public ADXL362​(SPI.Port port, ADXL362.Range range)
      Constructor.
      Parameters:
      port - The SPI port that the accelerometer is connected to
      range - The range (+ or -) that the accelerometer will measure.
  • 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 final void setRange​(ADXL362.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​(ADXL362.Axes axis)
      Get the acceleration of one axis in Gs.
      Parameters:
      axis - The axis to read from.
      Returns:
      Acceleration of the ADXL362 in Gs.
    • getAccelerations

      Get the acceleration of all axes in Gs.
      Returns:
      An object containing the acceleration measured on each axis of the ADXL362 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