edu.wpi.first.wpilibj

## Class AnalogPotentiometer

- java.lang.Object
- - edu.wpi.first.wpilibj.AnalogPotentiometer

- All Implemented Interfaces:
    Potentiometer, LiveWindowSendable, PIDSource, Sendable

      public class AnalogPotentiometer
      extends java.lang.Object
      implements Potentiometer, LiveWindowSendable

  Class for reading analog potentiometers. Analog potentiometers read in an analog voltage that corresponds to a position. The position is in whichever units you choose, by way of the scaling and offset constants passed to the constructor.

- - ### Field Summary

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

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AnalogPotentiometer(AnalogInput input)` AnalogPotentiometer constructor.
    `AnalogPotentiometer(AnalogInput input, double scale)` AnalogPotentiometer constructor.
    `AnalogPotentiometer(AnalogInput input, double fullRange, double offset)` AnalogPotentiometer constructor.
    `AnalogPotentiometer(int channel)` AnalogPotentiometer constructor.
    `AnalogPotentiometer(int channel, double scale)` AnalogPotentiometer constructor.
    `AnalogPotentiometer(int channel, double fullRange, double offset)` AnalogPotentiometer constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `free()` Frees this resource.
    `double` | `get()` Get the current reading of the potentiometer.
    `PIDSourceType` | `getPIDSourceType()` Get which parameter of the device you are using as a process control variable.
    `java.lang.String` | `getSmartDashboardType()` Live Window code, only does anything if live window is activated.
    `void` | `initTable(NetworkTable subtable)` Initializes a table for this `Sendable` object.
    `double` | `pidGet()` Implement the PIDSource interface.
    `void` | `setPIDSourceType(PIDSourceType pidSource)` Set which parameter of the device you are using as a process control variable.
    `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 java.lang.Object

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

- - ### Field Detail

    - #### m_pidSource

          protected PIDSourceType m_pidSource

  - ### Constructor Detail

    - #### AnalogPotentiometer

          public AnalogPotentiometer(int channel,
                                     double fullRange,
                                     double offset)

      AnalogPotentiometer constructor.

      Use the fullRange and offset values so that the output produces meaningful values. I.E: you have a 270 degree potentiometer and you want the output to be degrees with the halfway point as 0 degrees. The fullRange value is 270.0(degrees) and the offset is -135.0 since the halfway point after scaling is 135 degrees. This will calculate the result from the fullRange times the fraction of the supply voltage, plus the offset.

      Parameters:
        `channel` - The analog channel this potentiometer is plugged into.
        `fullRange` - The scaling to multiply the fraction by to get a meaningful unit.
        `offset` - The offset to add to the scaled value for controlling the zero value

    - #### AnalogPotentiometer

          public AnalogPotentiometer(AnalogInput input,
                                     double fullRange,
                                     double offset)

      AnalogPotentiometer constructor.

      Use the fullRange and offset values so that the output produces meaningful values. I.E: you have a 270 degree potentiometer and you want the output to be degrees with the halfway point as 0 degrees. The fullRange value is 270.0(degrees) and the offset is -135.0 since the halfway point after scaling is 135 degrees. This will calculate the result from the fullRange times the fraction of the supply voltage, plus the offset.

      Parameters:
        `input` - The `AnalogInput` this potentiometer is plugged into.
        `fullRange` - The scaling to multiply the fraction by to get a meaningful unit.
        `offset` - The offset to add to the scaled value for controlling the zero value

    - #### AnalogPotentiometer

          public AnalogPotentiometer(int channel,
                                     double scale)

      AnalogPotentiometer constructor.

      Use the fullRange and offset values so that the output produces meaningful values. I.E: you have a 270 degree potentiometer and you want the output to be degrees with the halfway point as 0 degrees. The fullRange value is 270.0(degrees) and the offset is -135.0 since the halfway point after scaling is 135 degrees.

      Parameters:
        `channel` - The analog channel this potentiometer is plugged into.
        `scale` - The scaling to multiply the voltage by to get a meaningful unit.

    - #### AnalogPotentiometer

          public AnalogPotentiometer(AnalogInput input,
                                     double scale)

      AnalogPotentiometer constructor.

      Use the fullRange and offset values so that the output produces meaningful values. I.E: you have a 270 degree potentiometer and you want the output to be degrees with the halfway point as 0 degrees. The fullRange value is 270.0(degrees) and the offset is -135.0 since the halfway point after scaling is 135 degrees.

      Parameters:
        `input` - The `AnalogInput` this potentiometer is plugged into.
        `scale` - The scaling to multiply the voltage by to get a meaningful unit.

    - #### AnalogPotentiometer

          public AnalogPotentiometer(int channel)

      AnalogPotentiometer constructor.
      Parameters:
        `channel` - The analog channel this potentiometer is plugged into.

    - #### AnalogPotentiometer

          public AnalogPotentiometer(AnalogInput input)

      AnalogPotentiometer constructor.
      Parameters:
        `input` - The `AnalogInput` this potentiometer is plugged into.

  - ### Method Detail

    - #### get

          public double get()

      Get the current reading of the potentiometer.
      Specified by:
        `get` in interface `Potentiometer`
      Returns:
        The current position of the potentiometer.

    - #### 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()

      Implement the PIDSource interface.
      Specified by:
        `pidGet` in interface `PIDSource`
      Returns:
        The current reading.

    - #### getSmartDashboardType

          public java.lang.String getSmartDashboardType()

      Live Window code, only does anything if live window is activated.
      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`

    - #### free

          public void free()

      Frees this resource.

    - #### 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`