Skip to content

Commit af7cf1a

Browse files
committed
Spam warnings if a WsSpark is configured as a follower
1 parent 78dd530 commit af7cf1a

File tree

1 file changed

+19
-2
lines changed
  • src/main/java/org/wildstang/hardware/roborio/outputs

1 file changed

+19
-2
lines changed

src/main/java/org/wildstang/hardware/roborio/outputs/WsSpark.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,17 @@ public WsSpark(String name, int channel, WsMotorControllers controller, double p
6666
isUsingController = false;
6767
isChanged = true;
6868
controlType = ControlType.kDutyCycle;
69+
70+
warnFollower();
71+
}
72+
73+
/**
74+
* WsSpark should never be a follower. It is possible that follower state can get burned into the flash, this warns in that case.
75+
*/
76+
public void warnFollower() {
77+
if (motor.isFollower()) {
78+
Log.error("WsSpark is set as a follower!");
79+
}
6980
}
7081

7182
/**
@@ -209,18 +220,20 @@ public void sendDataToOutput() {
209220
}
210221

211222
/**
212-
* Wraps setValue().
223+
* Wraps CANSparkBase.setSpeed().
213224
* @param value New motor percent speed, from -1.0 to 1.0.
214225
*/
215226
@Override
216227
public void setSpeed(double value){
217-
if (controlType == ControlType.kDutyCycle && super.getValue()==value){
228+
if (controlType == ControlType.kDutyCycle && super.getValue() == value){
218229
isChanged = false;
219230
} else {
220231
isChanged = true;
221232
}
222233
controlType = ControlType.kDutyCycle;
223234
super.setSpeed(value);
235+
236+
warnFollower();
224237
}
225238

226239
/**
@@ -284,6 +297,10 @@ public void initClosedLoop(double P, double I, double D, double FF, AbsoluteEnco
284297
slotID = 0;
285298
}
286299

300+
/**
301+
* Returns the motor controller's PID controller.
302+
* @return PID Controller object
303+
*/
287304
public SparkPIDController getPIDController(){
288305
return motor.getPIDController();
289306
}

0 commit comments

Comments
 (0)