diff --git a/src/main/java/net/frc5183/librobot/hardware/motor/SparkMaxMotor.java b/src/main/java/net/frc5183/librobot/hardware/motor/SparkMaxMotor.java index e3b8f05..75a55e4 100644 --- a/src/main/java/net/frc5183/librobot/hardware/motor/SparkMaxMotor.java +++ b/src/main/java/net/frc5183/librobot/hardware/motor/SparkMaxMotor.java @@ -9,7 +9,7 @@ import net.frc5183.librobot.hardware.encoder.SparkMaxEncoder; /** - * A wrapper class around CANSparkMax to make it compatible with other motor types + * Represents a Spark Max motor controller. */ public class SparkMaxMotor extends Motor implements EncodedMotor { private final CANSparkMax motor; @@ -68,12 +68,7 @@ public void stopMotor() { motor.stopMotor(); } - @Override - public MotorController getRawMotor() { - return motor; - } - - public CANSparkMax getTrueRawMotor() { + public CANSparkMax getRawMotor() { return motor; } diff --git a/src/main/java/net/frc5183/librobot/hardware/motor/SparkMotor.java b/src/main/java/net/frc5183/librobot/hardware/motor/SparkMotor.java new file mode 100644 index 0000000..d712439 --- /dev/null +++ b/src/main/java/net/frc5183/librobot/hardware/motor/SparkMotor.java @@ -0,0 +1,62 @@ +package net.frc5183.librobot.hardware.motor; + +import edu.wpi.first.wpilibj.motorcontrol.Spark; + +/** + * Represents a Spark motor controller. + */ +public class SparkMotor extends Motor { + private final Spark motor; + + public SparkMotor(int port) { + this.motor = new Spark(port); + } + + public SparkMotor(Spark motor) { + this.motor = motor; + } + + @Override + public void set(double speed) { + motor.set(speed); + } + + @Override + public void periodic() { + motor.feed(); + } + + @Override + public double get() { + return motor.get(); + } + + @Override + public void setSafety(boolean on) { + motor.setSafetyEnabled(on); + } + + @Override + public void setInverted(boolean inverted) { + motor.setInverted(inverted); + } + + @Override + public boolean getInverted() { + return motor.getInverted(); + } + + @Override + public void disable() { + motor.disable(); + } + + @Override + public void stopMotor() { + motor.stopMotor(); + } + + public Spark getRawMotor() { + return motor; + } +} diff --git a/src/main/java/net/frc5183/librobot/hardware/motor/TalonFXMotor.java b/src/main/java/net/frc5183/librobot/hardware/motor/TalonFXMotor.java new file mode 100644 index 0000000..7ca61d6 --- /dev/null +++ b/src/main/java/net/frc5183/librobot/hardware/motor/TalonFXMotor.java @@ -0,0 +1,63 @@ +package net.frc5183.librobot.hardware.motor; + +import com.ctre.phoenix6.hardware.TalonFX; +import edu.wpi.first.wpilibj.motorcontrol.MotorController; + +/** + * Represents a TalonFX motor controller. + */ +public class TalonFXMotor extends Motor { + private final TalonFX motor; + + public TalonFXMotor(int port) { + motor = new TalonFX(port); + } + + public TalonFXMotor(TalonFX motor) { + this.motor = motor; + } + + @Override + public void set(double speed) { + motor.set(speed); + } + + @Override + public void periodic() { + motor.feed(); + } + + @Override + public double get() { + return motor.get(); + } + + @Override + public void setSafety(boolean on) { + motor.setSafetyEnabled(on); + } + + @Override + public void setInverted(boolean inverted) { + motor.setInverted(inverted); + } + + @Override + public boolean getInverted() { + return motor.getInverted(); + } + + @Override + public void disable() { + motor.disable(); + } + + @Override + public void stopMotor() { + motor.stopMotor(); + } + + public TalonFX getRawMotor() { + return motor; + } +}