Skip to content

Commit 4b8eee7

Browse files
committed
add createSpark
1 parent 26c3893 commit 4b8eee7

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,32 @@ public static WPI_TalonSRX createTalon(int id) {
5656

5757
return talon;
5858
}
59+
/**
60+
* To use the configAccessor, use {@link MotorControllerFactory#getConfigAccessor(SparkBase...)}
61+
*
62+
* @param id the port of the motor controller
63+
* @param motorConfig the motor configuration to use
64+
*/
65+
public static SparkBase createSpark(int id, MotorConfig motorConfig) {
66+
return createSpark(id, motorConfig, sparkConfig(motorConfig));
67+
}
68+
/**
69+
* To use the configAccessor, use {@link MotorControllerFactory#getConfigAccessor(SparkBase...)}
70+
*
71+
* @param id the port of the motor controller
72+
* @param motorConfig the motor configuration to use
73+
*/
74+
public static SparkBase createSpark(int id, MotorConfig motorConfig, SparkBaseConfig config) {
75+
switch(motorConfig.controllerType){
76+
case SPARK_MAX:
77+
return createSparkMax(id, motorConfig, config);
78+
case SPARK_FLEX:
79+
return createSparkFlex(id, motorConfig, config);
80+
default:
81+
return null;
82+
}
83+
}
84+
5985
/**
6086
* Create a default sparkMax controller (NEO or 550).
6187
*
@@ -88,6 +114,7 @@ public static SparkMax createSparkMax(int id, MotorConfig motorConfig, SparkBase
88114

89115
return spark;
90116
}
117+
91118
/**
92119
* Create a default SparkFlex-Vortex controller.
93120
*

0 commit comments

Comments
 (0)