Package frc.robot.subsystems.swervedrive.swerve.encoders

## Class PWMAnalogEncoder

- java.lang.Object
- - frc.robot.subsystems.swervedrive.swerve.SwerveEncoder<edu.wpi.first.wpilibj.AnalogEncoder>
  - - frc.robot.subsystems.swervedrive.swerve.encoders.PWMAnalogEncoder

    public class PWMAnalogEncoder
    extends SwerveEncoder<edu.wpi.first.wpilibj.AnalogEncoder>

### Field Summary

Fields
`private boolean` `m_inverted`
`private double` `m_lastAngle`
`private double` `m_lastTime`
`private edu.wpi.first.wpilibj.Timer` `m_timer`
`private double` `m_velocity`

### Fields inherited from class frc.robot.subsystems.swervedrive.swerve.SwerveEncoder

`m_encoder`

### Constructor Summary

Constructors
`PWMAnalogEncoder​(edu.wpi.first.wpilibj.AnalogEncoder encoder)` Constructor for analog encoder Swerve Encoder.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `configure()` Configure the absolute encoder if possible.
`void` `factoryDefault()` Reset encoder to factory default settings, if possible.
`double` `getAbsolutePosition()` Get the absolute position in degrees.
`com.ctre.phoenix.sensors.MagnetFieldStrength` `getMagnetFieldStrength()` Get the magnetic field strength, if available.
`double` `getVelocity()` Get the velocity of the absolute encoder in degrees per second.
`boolean` `reachable()` Is the encoder reachable?
`void` `setInverted​(boolean isInverted)` Configure the sensor direction
`void` `setOffset​(double offset)` Configure the magnetic offset for the AbsoluteEncoder.
`void` `updateVelocity()` Updates the velocity every second.

### Methods inherited from class frc.robot.subsystems.swervedrive.swerve.SwerveEncoder

`fromEncoder`

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

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

### Field Detail

#### m_timer

    private final edu.wpi.first.wpilibj.Timer m_timer

#### m_inverted

    private boolean m_inverted

#### m_lastAngle

    private double m_lastAngle

#### m_velocity

    private double m_velocity

#### m_lastTime

    private double m_lastTime

### Constructor Detail

#### PWMAnalogEncoder

    public PWMAnalogEncoder​(edu.wpi.first.wpilibj.AnalogEncoder encoder)

Constructor for analog encoder Swerve Encoder.

Parameters:
  `encoder` - AnalogEncoder.

### Method Detail

#### updateVelocity

    public void updateVelocity()

Updates the velocity every second.

#### configure

    public void configure()

Configure the absolute encoder if possible.

Specified by:
  `configure` in class `SwerveEncoder<edu.wpi.first.wpilibj.AnalogEncoder>`

#### factoryDefault

    public void factoryDefault()

Reset encoder to factory default settings, if possible.

Specified by:
  `factoryDefault` in class `SwerveEncoder<edu.wpi.first.wpilibj.AnalogEncoder>`

#### getMagnetFieldStrength

    public com.ctre.phoenix.sensors.MagnetFieldStrength getMagnetFieldStrength()

Get the magnetic field strength, if available.

Specified by:
  `getMagnetFieldStrength` in class `SwerveEncoder<edu.wpi.first.wpilibj.AnalogEncoder>`
Returns:
  CTRE MagneticFieldStrength Enum.

#### getAbsolutePosition

    public double getAbsolutePosition()

Get the absolute position in degrees.

Specified by:
  `getAbsolutePosition` in class `SwerveEncoder<edu.wpi.first.wpilibj.AnalogEncoder>`
Returns:
  Absolute position (0, 360]

#### getVelocity

    public double getVelocity()

Get the velocity of the absolute encoder in degrees per second.

Specified by:
  `getVelocity` in class `SwerveEncoder<edu.wpi.first.wpilibj.AnalogEncoder>`
Returns:
  Velocity in degrees per second.

#### setOffset

    public void setOffset​(double offset)

Configure the magnetic offset for the AbsoluteEncoder.

Specified by:
  `setOffset` in class `SwerveEncoder<edu.wpi.first.wpilibj.AnalogEncoder>`
Parameters:
  `offset` - Offset in degrees.

#### reachable

    public boolean reachable()

Is the encoder reachable?

Specified by:
  `reachable` in class `SwerveEncoder<edu.wpi.first.wpilibj.AnalogEncoder>`
Returns:
  True if reachable, false otherwise.

#### setInverted

    public void setInverted​(boolean isInverted)

Configure the sensor direction

Specified by:
  `setInverted` in class `SwerveEncoder<edu.wpi.first.wpilibj.AnalogEncoder>`
Parameters:
  `isInverted` - Inverted or not.