Skip to content

Commit b1900c8

Browse files
committed
fixed spark flexes
1 parent 08249e9 commit b1900c8

File tree

1 file changed

+59
-7
lines changed

1 file changed

+59
-7
lines changed

src/main/java/org/carlmontrobotics/lib199/MotorControllerFactory.java

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,10 @@ public static SparkFlex createSparkFlex(int id, SparkBaseConfig config) {
186186

187187
return spark;
188188
}
189-
190-
189+
/**
190+
* @deprecated Use {@link #baseSparkMaxConfig()} instead.
191+
*/
192+
@Deprecated // Probably should not be used as even though it technically returns a SparkBaseConfig, it can only be used a SparkMaxConfig, and so it does essentially the same thing as baseSparkMaxConfig
191193
public static SparkBaseConfig baseSparkConfig() {
192194
SparkMaxConfig config = new SparkMaxConfig();
193195

@@ -206,7 +208,9 @@ public static SparkBaseConfig baseSparkConfig() {
206208
}
207209
/**
208210
* Overrides an old config - but does not change other settings.
211+
* @deprecated Use {@link #baseSparkMaxConfig(SparkMaxConfig)} instead.
209212
*/
213+
@Deprecated // Probably should not be used as even though it technically returns a SparkBaseConfig, it can only be used a SparkMaxConfig, and so it does essentially the same thing as baseSparkMaxConfig
210214
public static SparkBaseConfig baseSparkConfig(SparkMaxConfig config) {
211215
config.idleMode(IdleMode.kBrake);
212216

@@ -226,20 +230,68 @@ public static SparkBaseConfig baseSparkConfig(SparkMaxConfig config) {
226230
*/
227231
public static SparkMaxConfig baseSparkMaxConfig(SparkMaxConfig config){
228232
//typical operating voltage: 12V.
229-
return (SparkMaxConfig) baseSparkConfig(config);//FIXME apply needed config changes for each controller
233+
config.idleMode(IdleMode.kBrake);
234+
235+
config.voltageCompensation(12);//FIXME does this need to be different for different motors?
236+
config.smartCurrentLimit(50);
237+
238+
config.closedLoop
239+
.minOutput(-1)
240+
.maxOutput(1)
241+
.pid(0,0,0)
242+
.velocityFF(0);
243+
244+
return config;
230245
}
231246
public static SparkMaxConfig baseSparkMaxConfig(){
232-
return (SparkMaxConfig) baseSparkConfig();
247+
SparkMaxConfig config = new SparkMaxConfig();
248+
249+
config.idleMode(IdleMode.kBrake);
250+
251+
config.voltageCompensation(12);//FIXME does this need to be different for different motors?
252+
config.smartCurrentLimit(50);
253+
254+
config.closedLoop
255+
.minOutput(-1)
256+
.maxOutput(1)
257+
.pid(0,0,0)
258+
.velocityFF(0);
259+
260+
return config;
233261
}
234262
/**
235263
* Overrides an old config - but does not change other settings.
236264
*/
237-
public static SparkFlexConfig baseSparkFlexConfig(SparkMaxConfig config){
265+
public static SparkFlexConfig baseSparkFlexConfig(SparkFlexConfig config){
238266
//typical operating voltage: 12V. ( same as sparkMax )
239-
return (SparkFlexConfig) baseSparkConfig(config);//criminal casting usage
267+
config.idleMode(IdleMode.kBrake);
268+
269+
config.voltageCompensation(12);//FIXME does this need to be different for different motors?
270+
config.smartCurrentLimit(50);
271+
272+
config.closedLoop
273+
.minOutput(-1)
274+
.maxOutput(1)
275+
.pid(0,0,0)
276+
.velocityFF(0);
277+
278+
return config;
240279
}
241280
public static SparkFlexConfig baseSparkFlexConfig(){//why? no Se.
242-
return (SparkFlexConfig) baseSparkConfig();
281+
SparkFlexConfig config = new SparkFlexConfig();
282+
283+
config.idleMode(IdleMode.kBrake);
284+
285+
config.voltageCompensation(12);//FIXME does this need to be different for different motors?
286+
config.smartCurrentLimit(50);
287+
288+
config.closedLoop
289+
.minOutput(-1)
290+
.maxOutput(1)
291+
.pid(0,0,0)
292+
.velocityFF(0);
293+
294+
return config;
243295
}
244296

245297
/**

0 commit comments

Comments
 (0)