+ +
+ +

Class PWMDutyCycleEncoderSwerve

+
+
java.lang.Object +
swervelib.encoders.SwerveAbsoluteEncoder +
swervelib.encoders.PWMDutyCycleEncoderSwerve
+
+
+
+
+
public class PWMDutyCycleEncoderSwerve +extends SwerveAbsoluteEncoder
+
DutyCycle encoders such as "US Digital MA3 with PWM Output, the CTRE Mag Encoder, the Rev Hex Encoder, and the AM Mag + Encoder." attached via a PWM lane. +

+ Credits to + + p2reneker25 for building this.

+
+
+ +
+
+
    + +
  • +
    +

    Field Details

    +
      +
    • +
      +

      encoder

      +
      private final edu.wpi.first.wpilibj.DutyCycleEncoder encoder
      +
      Duty Cycle Encoder.
      +
      +
    • +
    • +
      +

      isInverted

      +
      private boolean isInverted
      +
      Inversion state.
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      PWMDutyCycleEncoderSwerve

      +
      public PWMDutyCycleEncoderSwerve(int pin)
      +
      Constructor for the PWM duty cycle encoder.
      +
      +
      Parameters:
      +
      pin - PWM lane for the encoder.
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      configure

      +
      public void configure(boolean inverted)
      +
      Configure the inversion state of the encoder.
      +
      +
      Specified by:
      +
      configure in class SwerveAbsoluteEncoder
      +
      Parameters:
      +
      inverted - Whether the encoder is inverted.
      +
      +
      +
    • +
    • +
      +

      getAbsolutePosition

      +
      public double getAbsolutePosition()
      +
      Get the absolute position of the encoder.
      +
      +
      Specified by:
      +
      getAbsolutePosition in class SwerveAbsoluteEncoder
      +
      Returns:
      +
      Absolute position in degrees from [0, 360).
      +
      +
      +
    • +
    • +
      +

      getAbsoluteEncoder

      +
      public Object getAbsoluteEncoder()
      +
      Get the encoder object.
      +
      +
      Specified by:
      +
      getAbsoluteEncoder in class SwerveAbsoluteEncoder
      +
      Returns:
      +
      DutyCycleEncoder from the class.
      +
      +
      +
    • +
    • +
      +

      factoryDefault

      +
      public void factoryDefault()
      +
      Reset the encoder to factory defaults.
      +
      +
      Specified by:
      +
      factoryDefault in class SwerveAbsoluteEncoder
      +
      +
      +
    • +
    • +
      +

      clearStickyFaults

      +
      public void clearStickyFaults()
      +
      Clear sticky faults on the encoder.
      +
      +
      Specified by:
      +
      clearStickyFaults in class SwerveAbsoluteEncoder
      +
      +
      +
    • +
    +
    +
  • +
+
+ +