File tree Expand file tree Collapse file tree 4 files changed +97
-98
lines changed
src/main/java/frc/robot/lib Expand file tree Collapse file tree 4 files changed +97
-98
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ package frc .robot .lib .GenericMotors ;
2
+
3
+ /**
4
+ * An unofficial generic for motors, similiar to MotorController interface. Not entirely intended for every-day use cases.
5
+ */
6
+ public interface GenericMotor {
7
+
8
+ void setSpeed (double speedPercentage );
9
+
10
+ double getSpeed ();
11
+
12
+ void setInverted (boolean isInverted );
13
+
14
+ boolean getInverted ();
15
+
16
+
17
+
18
+
19
+
20
+ }
Original file line number Diff line number Diff line change
1
+ package frc .robot .lib .GenericMotors ;
2
+
3
+ import com .revrobotics .CANSparkMax ;
4
+ import com .revrobotics .CANSparkLowLevel .MotorType ;
5
+
6
+ public class GenericSparkMax implements GenericMotor {
7
+ int motorID ;
8
+
9
+ CANSparkMax motorSparkMax ;
10
+ MotorType motorType ;
11
+
12
+ public GenericSparkMax (int motorID , MotorType motorType ){
13
+ this .motorID = motorID ;
14
+ this .motorType = motorType ;
15
+
16
+ this .motorSparkMax = new CANSparkMax (this .motorID , this .motorType );
17
+ System .out .printf ("New CanSparkMax constructed with GenericSparkMax at motor ID: %d" , this .motorID );
18
+ }
19
+
20
+ @ Override
21
+ public void setSpeed (double speedPercentage ) {
22
+ motorSparkMax .set (speedPercentage );
23
+ }
24
+
25
+ @ Override
26
+ public double getSpeed () {
27
+ return motorSparkMax .get ();
28
+ }
29
+
30
+ @ Override
31
+ public void setInverted (boolean isInverted ) {
32
+ motorSparkMax .setInverted (isInverted );
33
+ }
34
+
35
+ @ Override
36
+ public boolean getInverted () {
37
+ return motorSparkMax .getInverted ();
38
+ }
39
+
40
+ }
Original file line number Diff line number Diff line change
1
+ package frc .robot .lib .GenericMotors ;
2
+
3
+
4
+ import com .ctre .phoenix6 .hardware .TalonFX ;
5
+
6
+ public class GenericTalonFX implements GenericMotor {
7
+ TalonFX motorTalon ;
8
+ int motorID ;
9
+
10
+ public GenericTalonFX (int motorID ){
11
+ this .motorID = motorID ;
12
+
13
+ this .motorTalon = new TalonFX (this .motorID );
14
+ System .out .printf ("New TalonFX constructed with GenericTalonFX at motor ID: %d" , this .motorID );
15
+ }
16
+
17
+ @ Override
18
+ public void setSpeed (double speedPercentage ) {
19
+ motorTalon .set (speedPercentage );
20
+ }
21
+
22
+ @ Override
23
+ public double getSpeed () {
24
+ return motorTalon .get ();
25
+ }
26
+
27
+ @ Override
28
+ public void setInverted (boolean isInverted ) {
29
+ motorTalon .setInverted (isInverted );
30
+ }
31
+
32
+ @ Override
33
+ public boolean getInverted () {
34
+ return motorTalon .getInverted ();
35
+ }
36
+
37
+ }
You can’t perform that action at this time.
0 commit comments