Skip to content

Commit 244a436

Browse files
committed
fixed the creation of spark flexes?
1 parent 08249e9 commit 244a436

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

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

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public static SparkFlex createSparkFlex(int id) {
169169
* @param id the port of the motor controller
170170
* @param config the custom config to set
171171
*/
172-
public static SparkFlex createSparkFlex(int id, SparkBaseConfig config) {
172+
public static SparkFlex createSparkFlex(int id, SparkFlexConfig config) {
173173
SparkFlex spark = null;
174174
if (RobotBase.isReal()) {
175175
spark = new SparkFlex(id, SparkLowLevel.MotorType.kBrushless);
@@ -187,7 +187,7 @@ public static SparkFlex createSparkFlex(int id, SparkBaseConfig config) {
187187
return spark;
188188
}
189189

190-
190+
//does this not do the same as baseSparkMaxConfig, as it also creates a Spark MaxConfig?
191191
public static SparkBaseConfig baseSparkConfig() {
192192
SparkMaxConfig config = new SparkMaxConfig();
193193

@@ -207,6 +207,7 @@ public static SparkBaseConfig baseSparkConfig() {
207207
/**
208208
* Overrides an old config - but does not change other settings.
209209
*/
210+
//does this not do the same as baseSparkMaxConfig, as it also creates a Spark MaxConfig?
210211
public static SparkBaseConfig baseSparkConfig(SparkMaxConfig config) {
211212
config.idleMode(IdleMode.kBrake);
212213

@@ -234,12 +235,36 @@ public static SparkMaxConfig baseSparkMaxConfig(){
234235
/**
235236
* Overrides an old config - but does not change other settings.
236237
*/
237-
public static SparkFlexConfig baseSparkFlexConfig(SparkMaxConfig config){
238+
public static SparkFlexConfig baseSparkFlexConfig(SparkFlexConfig config){
238239
//typical operating voltage: 12V. ( same as sparkMax )
239-
return (SparkFlexConfig) baseSparkConfig(config);//criminal casting usage
240+
config.idleMode(IdleMode.kBrake);
241+
242+
config.voltageCompensation(12);//FIXME does this need to be different for different motors?
243+
config.smartCurrentLimit(50);
244+
245+
config.closedLoop
246+
.minOutput(-1)
247+
.maxOutput(1)
248+
.pid(0,0,0)
249+
.velocityFF(0);
250+
251+
return config;
240252
}
241253
public static SparkFlexConfig baseSparkFlexConfig(){//why? no Se.
242-
return (SparkFlexConfig) baseSparkConfig();
254+
SparkFlexConfig config = new SparkFlexConfig();
255+
256+
config.idleMode(IdleMode.kBrake);
257+
258+
config.voltageCompensation(12);//FIXME does this need to be different for different motors?
259+
config.smartCurrentLimit(50);
260+
261+
config.closedLoop
262+
.minOutput(-1)
263+
.maxOutput(1)
264+
.pid(0,0,0)
265+
.velocityFF(0);
266+
267+
return config;
243268
}
244269

245270
/**

0 commit comments

Comments
 (0)