diff --git a/wpilibc/src/main/native/cpp/AnalogPotentiometer.cpp b/wpilibc/src/main/native/cpp/AnalogPotentiometer.cpp index b650ec7132..8503f040f2 100644 --- a/wpilibc/src/main/native/cpp/AnalogPotentiometer.cpp +++ b/wpilibc/src/main/native/cpp/AnalogPotentiometer.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2016-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -34,7 +34,8 @@ AnalogPotentiometer::AnalogPotentiometer(std::shared_ptr input, } double AnalogPotentiometer::Get() const { - return (m_analog_input->GetVoltage() / RobotController::GetVoltage5V()) * + return (m_analog_input->GetAverageVoltage() / + RobotController::GetVoltage5V()) * m_fullRange + m_offset; } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogPotentiometer.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogPotentiometer.java index 3a6f338f57..ae9d83fdaf 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogPotentiometer.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogPotentiometer.java @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -122,7 +122,8 @@ public class AnalogPotentiometer implements Potentiometer, Sendable, AutoCloseab if (m_analogInput == null) { return m_offset; } - return (m_analogInput.getVoltage() / RobotController.getVoltage5V()) * m_fullRange + m_offset; + return (m_analogInput.getAverageVoltage() / RobotController.getVoltage5V()) + * m_fullRange + m_offset; } @Override