edu.wpi.first.wpilibj

## Class ADXL345_SPI

- java.lang.Object
- - edu.wpi.first.wpilibj.SensorBase
  - - edu.wpi.first.wpilibj.ADXL345_SPI

- All Implemented Interfaces:
    Accelerometer, LiveWindowSendable, Sendable

      public class ADXL345_SPI
      extends SensorBase
      implements Accelerometer, LiveWindowSendable

  ADXL345 SPI Accelerometer.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and 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`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected SPI` | `m_spi`

    - ### Fields inherited from class edu.wpi.first.wpilibj.SensorBase

      `kAnalogInputChannels, kAnalogOutputChannels, kDigitalChannels, kPCMModules, kPDPChannels, kPDPModules, kPwmChannels, kRelayChannels, kSolenoidChannels, kSystemClockTicksPerMicrosecond`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ADXL345_SPI(SPI.Port port, Accelerometer.Range range)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `free()` Free the resources used by this object.
    `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.
    `java.lang.String` | `getSmartDashboardType()` The string representation of the named data type that will be used by the smart dashboard for this `Sendable`.
    `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` | `initTable(NetworkTable subtable)` Initializes a table for this `Sendable` object.
    `void` | `setRange(Accelerometer.Range range)` Common interface for setting the measuring range of an accelerometer.
    `void` | `startLiveWindowMode()` Start having this sendable object automatically respond to value changes reflect the value on the table.
    `void` | `stopLiveWindowMode()` Stop having this sendable object automatically respond to value changes.
    `void` | `updateTable()` Update the table for this sendable object with the latest values.

    - ### Methods inherited from class edu.wpi.first.wpilibj.SensorBase

      `checkAnalogInputChannel, checkAnalogOutputChannel, checkDigitalChannel, checkPDPChannel, checkPDPModule, checkPWMChannel, checkRelayChannel, checkSolenoidChannel, checkSolenoidModule, getDefaultSolenoidModule, setDefaultSolenoidModule`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 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 to
        `range` - The range (+ or -) that the accelerometer will measure.

  - ### Method Detail

    - #### free

          public void free()

      Description copied from class: `SensorBase`
      Free the resources used by this object.
      Overrides:
        `free` in class `SensorBase`

    - #### 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 interface `Accelerometer`
      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 interface `Accelerometer`
      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 interface `Accelerometer`
      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 interface `Accelerometer`
      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.

    - #### getSmartDashboardType

          public java.lang.String getSmartDashboardType()

      Description copied from interface: `Sendable`
      The string representation of the named data type that will be used by the smart dashboard for this `Sendable`.
      Specified by:
        `getSmartDashboardType` in interface `Sendable`
      Returns:
        The type of this `Sendable`.

    - #### initTable

          public void initTable(NetworkTable subtable)

      Description copied from interface: `Sendable`
      Initializes a table for this `Sendable` object.
      Specified by:
        `initTable` in interface `Sendable`
      Parameters:
        `subtable` - The table to put the values in.

    - #### updateTable

          public void updateTable()

      Description copied from interface: `LiveWindowSendable`
      Update the table for this sendable object with the latest values.
      Specified by:
        `updateTable` in interface `LiveWindowSendable`

    - #### startLiveWindowMode

          public void startLiveWindowMode()

      Description copied from interface: `LiveWindowSendable`
      Start having this sendable object automatically respond to value changes reflect the value on the table.
      Specified by:
        `startLiveWindowMode` in interface `LiveWindowSendable`

    - #### stopLiveWindowMode

          public void stopLiveWindowMode()

      Description copied from interface: `LiveWindowSendable`
      Stop having this sendable object automatically respond to value changes.
      Specified by:
        `stopLiveWindowMode` in interface `LiveWindowSendable`