Skip to content

Commit

Permalink
Added IdleMode to VikingMAX
Browse files Browse the repository at this point in the history
  • Loading branch information
towner-10 committed Feb 19, 2020
1 parent dead390 commit d2ebca1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main/java/viking/controllers/rev/VikingMAX.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.revrobotics.CANPIDController;
import com.revrobotics.CANSparkMax;
import com.revrobotics.ControlType;
import com.revrobotics.CANSparkMax.IdleMode;
import com.revrobotics.CANSparkMaxLowLevel.MotorType;

public class VikingMAX {
Expand Down Expand Up @@ -39,6 +40,7 @@ public VikingMAX(int id, boolean inverted,

setPIDF(kP, kI, kD, kF);
setSmartMotion(velocity, acceleration);
setIdleMode(IdleMode.kBrake);
}

/**
Expand All @@ -56,6 +58,8 @@ public VikingMAX(int id, boolean inverted) {
encoder = motor.getEncoder();

pidController.setOutputRange(-1, 1);

setIdleMode(IdleMode.kBrake);
}

/**
Expand Down Expand Up @@ -177,6 +181,14 @@ public void zeroEncoder() {
encoder.setPosition(0);
}

/**
* Set the current idle mode (coast / break)
* @param mode the mode to set
*/
public void setIdleMode(IdleMode mode) {
motor.setIdleMode(mode);
}

/**
* Returns the CANSparkMax controller for lower access control
* @return the CANSparkMax controller
Expand Down

0 comments on commit d2ebca1

Please sign in to comment.