Skip to content

Commit

Permalink
chanigng interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Duckett committed Jan 4, 2024
1 parent c33443a commit 55bf812
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/main/java/frc/lib/hardware/Motors/Motor.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private ControllerType(MotorController mController) {
}

public MotorController config(int canID) {
return mController.config(canID);
return mController.build(canID);
}
}

Expand Down
12 changes: 0 additions & 12 deletions src/main/java/frc/lib/hardware/Motors/Motor2.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,7 @@ protected DCMotor config() {
}
}

public enum ControllerType {
TallonSRX(new Talon_SRX());

MotorController mController;

private ControllerType(MotorController mController) {
this.mController = mController;
}

public MotorController config(int canID) {
return mController.config(canID);
}
}

// -----------------------------------------
private final MotorController mController;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,28 @@

public interface MotorController extends HardwareRequirements {

MotorController config(int canID);
MotorController build(int canID);

// Setting
void runVolts(double num);

void brakeMode(boolean enable);

void setInverted(boolean enable);
void disable();

// Getting
int getCanID();

void disable();
double getAppliedVolts();

double getCurentAmps();

double getBusVoltage();

// Config
MotorController setInverted(boolean enable);

MotorController setCurrentLimit(double CurrentLimit);

void currentLimit();
MotorController setSimulated(double simulated);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class Talon_SRX implements MotorController {

private TalonSRX motor;

public MotorController config(int canID) {
public MotorController build(int canID) {
this.canID = canID;

motor = new TalonSRX(canID);
Expand All @@ -25,21 +25,19 @@ public void runVolts(double num) {

@Override
public void brakeMode(boolean enable) {
if (enable) motor.setNeutralMode(NeutralMode.Brake);
else motor.setNeutralMode(NeutralMode.Coast);
if (enable)
motor.setNeutralMode(NeutralMode.Brake);
else
motor.setNeutralMode(NeutralMode.Coast);
}

/** true inverts it */
@Override
public void setInverted(boolean enable) {
motor.setInverted(enable);
}

public void disable() {
motor.set(ControlMode.Disabled, 0);
}

public void currentLimit() {}
public void currentLimit() {
}

// ----------------------------------------------------------
@Override
Expand All @@ -59,5 +57,43 @@ public boolean connected() {

// Unit Testing
@Override
public void close() throws Exception {}
public void close() throws Exception {
}

@Override
public double getAppliedVolts() {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'getAppliedVolts'");
}

@Override
public double getCurentAmps() {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'getCurentAmps'");
}

@Override
public double getBusVoltage() {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'getBusVoltage'");
}

@Override
public MotorController setInverted(boolean enable) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'setInverted'");
}

@Override
public MotorController setCurrentLimit(double CurrentLimit) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'setCurrentLimit'");
}

@Override
public MotorController setSimulated(double simulated) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'setSimulated'");
}

}
8 changes: 6 additions & 2 deletions src/main/java/frc/lib/hardware/sensor/encoders/Encoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@

public interface Encoder extends HardwareRequirements {

Encoder config();
void zero();

double getPosition();

double getVelocity();

void setGearRatio(double gearRatio);
Encoder setGearRatio(double gearRatio);

Encoder setInverted(boolean inverted);

Encoder setOffset(double offset);
}
27 changes: 20 additions & 7 deletions src/main/java/frc/lib/hardware/sensor/encoders/REVBoreEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ public double getVelocity() {
return 20;
}

@Override
public void setGearRatio(double gearRatio) {
// TODO Auto-generated method stub
}

// ----------------------------------------------------------
@Override
public void toLog(LogTable table) {
Expand All @@ -35,8 +30,26 @@ public boolean connected() {
public void close() throws Exception {}

@Override
public Encoder config() {
public void zero() {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'zero'");
}

@Override
public Encoder setInverted(boolean inverted) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'setInverted'");
}

@Override
public Encoder setOffset(double offset) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'setOffset'");
}

return this;
@Override
public Encoder setGearRatio(double gearRatio) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'setGearRatio'");
}
}

0 comments on commit 55bf812

Please sign in to comment.