Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions lib/src/main/java/com/team2813/lib2813/control/Motor.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@ public interface Motor {
*/
Current getAppliedCurrent();

/** Stops the motor. */
void disable();
/**
* Stops the motor.
*
* @deprecated Use {@link #stopMotor()}.
*/
@Deprecated
default void disable() {
stopMotor();
}

/**
* Stops the motor.
*
* @since 2.0.0
*/
default void stopMotor() {
set(ControlMode.VOLTAGE, 0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public Current getAppliedCurrent() {
}

@Override
public void disable() {
public void stopMotor() {
motor.stopMotor();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ public void setNeutralMode(NeutralModeValue mode) {
* @see TalonFXWrapper#setNeutralMode(NeutralModeValue)
*/
@Override
public void disable() {
motor.disable();
public void stopMotor() {
motor.stopMotor();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,7 @@ public final boolean atPosition() {
*/
@Override
public void set(ControlMode mode, double demand, double feedForward) {
if (isEnabled()) {
disable();
}
isEnabled = false;
motor.set(mode, demand, feedForward);
}

Expand All @@ -154,7 +152,7 @@ public Current getAppliedCurrent() {
}

/**
* Engages the PID Controller.
* Engages the PID controller.
*
* <p>The motor voltage will be periodically updated to move the motor towards the current
* setpoint.
Expand All @@ -172,9 +170,10 @@ public void enable() {
* <p>The motor voltage will be set to zero, and the motor will not adjust to move towards the
* current setpoint.
*/
public void disable() {
@Override
public void stopMotor() {
isEnabled = false;
motor.disable();
motor.stopMotor();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public double getFeedForward() {
}

@Override
public void disable() {
public void stopMotor() {
if (controlMode != ControlMode.MOTION_MAGIC) {
set(controlMode, 0);
}
Expand Down
Loading