edu.wpi.first.wpilibj

## Class AnalogAccelerometer

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

- All Implemented Interfaces:
    LiveWindowSendable, PIDSource, Sendable

      public class AnalogAccelerometer
      extends SensorBase
      implements PIDSource, LiveWindowSendable

  Handle operation of an analog accelerometer. The accelerometer reads acceleration directly through the sensor. Many sensors have multiple axis and can be treated as multiple devices. Each is calibrated by finding the center value over a period of time.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected PIDSourceType` | `m_pidSource`

    - ### 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
    `AnalogAccelerometer(AnalogInput channel)` Create a new instance of Accelerometer from an existing AnalogChannel.
    `AnalogAccelerometer(int channel)` Create a new instance of an accelerometer.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `free()` Delete the analog components used for the accelerometer.
    `double` | `getAcceleration()` Return the acceleration in Gs.
    `PIDSourceType` | `getPIDSourceType()` Get which parameter of the device you are using as a process control variable.
    `java.lang.String` | `getSmartDashboardType()` The string representation of the named data type that will be used by the smart dashboard for this `Sendable`.
    `void` | `initTable(NetworkTable subtable)` Initializes a table for this `Sendable` object.
    `double` | `pidGet()` Get the Acceleration for the PID Source parent.
    `void` | `setPIDSourceType(PIDSourceType pidSource)` Set which parameter of the device you are using as a process control variable.
    `void` | `setSensitivity(double sensitivity)` Set the accelerometer sensitivity.
    `void` | `setZero(double zero)` Set the voltage that corresponds to 0 G.
    `void` | `startLiveWindowMode()` Analog Channels don't have to do anything special when entering the LiveWindow.
    `void` | `stopLiveWindowMode()` Analog Channels don't have to do anything special when exiting the LiveWindow.
    `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_pidSource

          protected PIDSourceType m_pidSource

  - ### Constructor Detail

    - #### AnalogAccelerometer

          public AnalogAccelerometer(int channel)

      Create a new instance of an accelerometer.

      The constructor allocates desired analog channel.

      Parameters:
        `channel` - The channel number for the analog input the accelerometer is connected to

    - #### AnalogAccelerometer

          public AnalogAccelerometer(AnalogInput channel)

      Create a new instance of Accelerometer from an existing AnalogChannel. Make a new instance of accelerometer given an AnalogChannel. This is particularly useful if the port is going to be read as an analog channel as well as through the Accelerometer class.
      Parameters:
        `channel` - The existing AnalogInput object for the analog input the accelerometer is connected to

  - ### Method Detail

    - #### free

          public void free()

      Delete the analog components used for the accelerometer.
      Overrides:
        `free` in class `SensorBase`

    - #### getAcceleration

          public double getAcceleration()

      Return the acceleration in Gs.

      The acceleration is returned units of Gs.

      Returns:
        The current acceleration of the sensor in Gs.

    - #### setSensitivity

          public void setSensitivity(double sensitivity)

      Set the accelerometer sensitivity.

      This sets the sensitivity of the accelerometer used for calculating the acceleration. The sensitivity varies by accelerometer model. There are constants defined for various models.

      Parameters:
        `sensitivity` - The sensitivity of accelerometer in Volts per G.

    - #### setZero

          public void setZero(double zero)

      Set the voltage that corresponds to 0 G.

      The zero G voltage varies by accelerometer model. There are constants defined for various models.

      Parameters:
        `zero` - The zero G voltage.

    - #### setPIDSourceType

          public void setPIDSourceType(PIDSourceType pidSource)

      Description copied from interface: `PIDSource`
      Set which parameter of the device you are using as a process control variable.
      Specified by:
        `setPIDSourceType` in interface `PIDSource`
      Parameters:
        `pidSource` - An enum to select the parameter.

    - #### getPIDSourceType

          public PIDSourceType getPIDSourceType()

      Description copied from interface: `PIDSource`
      Get which parameter of the device you are using as a process control variable.
      Specified by:
        `getPIDSourceType` in interface `PIDSource`
      Returns:
        the currently selected PID source parameter

    - #### pidGet

          public double pidGet()

      Get the Acceleration for the PID Source parent.
      Specified by:
        `pidGet` in interface `PIDSource`
      Returns:
        The current acceleration 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()

      Analog Channels don't have to do anything special when entering the LiveWindow. 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()

      Analog Channels don't have to do anything special when exiting the LiveWindow. Stop having this sendable object automatically respond to value changes.
      Specified by:
        `stopLiveWindowMode` in interface `LiveWindowSendable`