Skip to content

Commit

Permalink
add debouncer
Browse files Browse the repository at this point in the history
  • Loading branch information
cire694 committed Jan 23, 2024
1 parent c99cd3a commit 3219a0f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/com/stuypulse/robot/constants/Ports.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ public interface Gamepad {

public interface Conveyor {
int CONVEYOR_MOTOR_PORT = 10;
int SHOOTER_FEEDER_MOTOR_PORT = 9;
int SHOOTER_FEEDER_MOTOR_PORT = 11;

int IR_SENSOR_PORT = 12;

}
}
1 change: 1 addition & 0 deletions src/main/java/com/stuypulse/robot/constants/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public interface Conveyor {
SmartNumber GANDALF_AMP_SPEED = new SmartNumber("Conveyor/Gandalf Amp Speed", 0);
SmartNumber SHOOTER_FEEDER_SPEED = new SmartNumber("Conveyor/Shooter Feeder Speed", -0.9);

SmartNumber DEBOUNCE_TIME = new SmartNumber("Conveyor/Debounce Time", 0.2);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,42 @@

import com.revrobotics.CANSparkMax;
import com.revrobotics.CANSparkLowLevel.MotorType;
import com.stuypulse.stuylib.streams.booleans.BStream;
import com.stuypulse.stuylib.streams.booleans.filters.BDebounceRC;

import edu.wpi.first.math.filter.Debouncer.DebounceType;
import edu.wpi.first.wpilibj.DigitalInput;

import static com.stuypulse.robot.constants.Ports.Conveyor.*;
import static com.stuypulse.robot.constants.Settings.Conveyor.*;
import static com.stuypulse.robot.constants.Motors.Conveyor.*;


public class ConveyorImpl extends Conveyor {

private final CANSparkMax gandalfMotor;
private final CANSparkMax shooterFeederMotor;
private final DigitalInput IRSensor;

private BStream isAtShooter;

protected ConveyorImpl(){
gandalfMotor = new CANSparkMax(CONVEYOR_MOTOR_PORT, MotorType.kBrushless);
shooterFeederMotor = new CANSparkMax(SHOOTER_FEEDER_MOTOR_PORT, MotorType.kBrushless);

IRSensor = new DigitalInput(IR_SENSOR_PORT);

GANDALF_MOTOR.configure(gandalfMotor);
SHOOTER_FEEDER_MOTOR.configure(shooterFeederMotor);

isAtShooter =
BStream.create(this::isLoaded)
.filtered(new BDebounceRC.Rising(DEBOUNCE_TIME));
}


public boolean isLoaded() {
return !IRSensor.get();
}

@Override
Expand Down

0 comments on commit 3219a0f

Please sign in to comment.