001// Copyright (c) FIRST and other WPILib contributors.
002// Open Source Software; you can modify and/or share it under the terms of
003// the WPILib BSD license file in the root directory of this project.
004
005package edu.wpi.first.wpilibj.pidwrappers;
006
007import edu.wpi.first.wpilibj.AnalogInput;
008import edu.wpi.first.wpilibj.PIDSource;
009import edu.wpi.first.wpilibj.PIDSourceType;
010
011/**
012 * Wrapper so that PIDSource is implemented for AnalogInput for old PIDController.
013 *
014 * @deprecated Use {@link edu.wpi.first.math.controller.PIDController} which doesn't require this
015 *     wrapper.
016 */
017@Deprecated(since = "2022", forRemoval = true)
018public class PIDAnalogInput extends AnalogInput implements PIDSource {
019  protected PIDSourceType m_pidSource = PIDSourceType.kDisplacement;
020
021  public PIDAnalogInput(int channel) {
022    super(channel);
023  }
024
025  @Override
026  public void setPIDSourceType(PIDSourceType pidSource) {
027    m_pidSource = pidSource;
028  }
029
030  @Override
031  public PIDSourceType getPIDSourceType() {
032    return m_pidSource;
033  }
034
035  /**
036   * Get the average voltage for use with PIDController.
037   *
038   * @return the average voltage
039   */
040  @Override
041  public double pidGet() {
042    return getAverageVoltage();
043  }
044}