diff --git a/wpilibc/athena/include/PWMSpeedController.h b/wpilibc/athena/include/PWMSpeedController.h index 9060413c85..941d31cf3d 100644 --- a/wpilibc/athena/include/PWMSpeedController.h +++ b/wpilibc/athena/include/PWMSpeedController.h @@ -20,14 +20,13 @@ class PWMSpeedController : public SafePWM, public SpeedController { virtual ~PWMSpeedController() = default; void Set(double value) override; double Get() const override; + void SetInverted(bool isInverted) override; + bool GetInverted() const override; void Disable() override; void StopMotor() override; void PIDWrite(double output) override; - void SetInverted(bool isInverted) override; - bool GetInverted() const override; - protected: explicit PWMSpeedController(int channel); diff --git a/wpilibc/athena/src/PWMSpeedController.cpp b/wpilibc/athena/src/PWMSpeedController.cpp index 6c5ed5a82b..6c6b5c0d97 100644 --- a/wpilibc/athena/src/PWMSpeedController.cpp +++ b/wpilibc/athena/src/PWMSpeedController.cpp @@ -36,36 +36,19 @@ void PWMSpeedController::Set(double speed) { */ double PWMSpeedController::Get() const { return GetSpeed(); } -/** - * Common interface for disabling a motor. - */ -void PWMSpeedController::Disable() { SetDisabled(); } - -/** - * Common interface for inverting direction of a speed controller. - * - * @param isInverted The state of inversion, true is inverted. - */ void PWMSpeedController::SetInverted(bool isInverted) { m_isInverted = isInverted; } -/** - * Common interface for the inverting direction of a speed controller. - * - * @return isInverted The state of inversion, true is inverted. - * - */ bool PWMSpeedController::GetInverted() const { return m_isInverted; } +void PWMSpeedController::Disable() { SetDisabled(); } + +void PWMSpeedController::StopMotor() { SafePWM::StopMotor(); } + /** * Write out the PID value as seen in the PIDOutput base object. * * @param output Write out the PWM value as was found in the PIDController */ void PWMSpeedController::PIDWrite(double output) { Set(output); } - -/** - * Common interface to stop the motor until Set is called again. - */ -void PWMSpeedController::StopMotor() { this->SafePWM::StopMotor(); } diff --git a/wpilibc/athena/include/SpeedController.h b/wpilibc/shared/include/SpeedController.h similarity index 91% rename from wpilibc/athena/include/SpeedController.h rename to wpilibc/shared/include/SpeedController.h index 3458e7f8ff..a274994eec 100644 --- a/wpilibc/athena/include/SpeedController.h +++ b/wpilibc/shared/include/SpeedController.h @@ -32,22 +32,24 @@ class SpeedController : public PIDOutput { virtual double Get() const = 0; /** - * Common interface for inverting direction of a speed controller. - * @param isInverted The state of inversion, true is inverted. - */ - virtual void SetInverted(bool isInverted) = 0; - /** - - * Common interface for disabling a motor. + * Common interface for inverting direction of a speed controller. + * + * @param isInverted The state of inversion, true is inverted. */ - virtual void Disable() = 0; + virtual void SetInverted(bool isInverted) = 0; /** * Common interface for returning the inversion state of a speed controller. + * * @return isInverted The state of inversion, true is inverted. */ virtual bool GetInverted() const = 0; + /** + * Common interface for disabling a motor. + */ + virtual void Disable() = 0; + /** * Common interface to stop the motor until Set is called again. */ diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/PWMSpeedController.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/PWMSpeedController.java index a08a0c8c51..27d7f1a2fb 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/PWMSpeedController.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/PWMSpeedController.java @@ -37,26 +37,6 @@ public abstract class PWMSpeedController extends SafePWM implements SpeedControl feed(); } - /** - * Common interface for inverting direction of a speed controller. - * - * @param isInverted The state of inversion true is inverted - */ - @Override - public void setInverted(boolean isInverted) { - m_isInverted = isInverted; - } - - /** - * Common interface for the inverting direction of a speed controller. - * - * @return isInverted The state of inversion, true is inverted. - */ - @Override - public boolean getInverted() { - return m_isInverted; - } - /** * Get the recently set value of the PWM. * @@ -67,6 +47,16 @@ public abstract class PWMSpeedController extends SafePWM implements SpeedControl return getSpeed(); } + @Override + public void setInverted(boolean isInverted) { + m_isInverted = isInverted; + } + + @Override + public boolean getInverted() { + return m_isInverted; + } + /** * Write out the PID value as seen in the PIDOutput base object. * diff --git a/wpilibj/src/shared/java/edu/wpi/first/wpilibj/SpeedController.java b/wpilibj/src/shared/java/edu/wpi/first/wpilibj/SpeedController.java index f48d45acce..b4a65b098c 100644 --- a/wpilibj/src/shared/java/edu/wpi/first/wpilibj/SpeedController.java +++ b/wpilibj/src/shared/java/edu/wpi/first/wpilibj/SpeedController.java @@ -11,6 +11,12 @@ package edu.wpi.first.wpilibj; * Interface for speed controlling devices. */ public interface SpeedController extends PIDOutput { + /** + * Common interface for setting the speed of a speed controller. + * + * @param speed The speed to set. Value should be between -1.0 and 1.0. + */ + void set(double speed); /** * Common interface for getting the current set speed of a speed controller. @@ -19,13 +25,6 @@ public interface SpeedController extends PIDOutput { */ double get(); - /** - * Common interface for setting the speed of a speed controller. - * - * @param speed The speed to set. Value should be between -1.0 and 1.0. - */ - void set(double speed); - /** * Common interface for inverting direction of a speed controller. *