diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index aa7d62f..f5a9eaa 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -296,5 +296,7 @@ public class CANConstants { } + public static final int blinkinPort = 0; + } diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index f12bded..9211ad0 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -23,6 +23,12 @@ import monologue.Annotations.Log; import monologue.Logged; import edu.wpi.first.wpilibj.smartdashboard.*; + +import frc.utils.BlinkinState; +import frc.robot.subsystems.LightControl; +import frc.robot.Constants; +import frc.robot.commands.lights.FlashLEDCommand; + import edu.wpi.first.util.datalog.StringLogEntry; /**f @@ -36,6 +42,8 @@ public class Robot extends TimedRobot implements Logged { private RobotContainer m_robotContainer; + private boolean runLEDBeamBreak = true; + @Log.NT @Log.File private CommandScheduler m_Scheduler; @@ -123,19 +131,33 @@ public void robotPeriodic() { Monologue.setFileOnly(DriverStation.isFMSAttached()); Monologue.updateAll(); + + if(runLEDBeamBreak && m_robotContainer.getIndexerBeamBreak()){ + m_robotContainer.getBeamBreakLEDCommand().schedule(); + runLEDBeamBreak = false; + } + else if(!runLEDBeamBreak && !m_robotContainer.getIndexerBeamBreak()){ + runLEDBeamBreak = true; + } } /** This function is called once each time the robot enters Disabled mode. */ @Override - public void disabledInit() {} + public void disabledInit() { + } @Override - public void disabledPeriodic() {} + public void disabledPeriodic() { + } /** This autonomous runs the autonomous command selected by your {@link RobotContainer} class. */ @Override public void autonomousInit() { + + m_robotContainer.getLEDInitCommand().schedule(); + getAllianceInfo(); + m_autonomousCommand = m_robotContainer.getAutonomousCommand(); /* @@ -153,11 +175,16 @@ public void autonomousInit() { /** This function is called periodically during autonomous. */ @Override - public void autonomousPeriodic() {} + public void autonomousPeriodic() { + } @Override public void teleopInit() { + + m_robotContainer.getLEDInitCommand().schedule(); + getAllianceInfo(); + // This makes sure that the autonomous stops running when // teleop starts running. If you want the autonomous to // continue until interrupted by another command, remove @@ -169,7 +196,9 @@ public void teleopInit() { /** This function is called periodically during operator control. */ @Override - public void teleopPeriodic() {} + public void teleopPeriodic() { + + } @Override public void testInit() { diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 4c1968d..a582c2c 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -8,6 +8,7 @@ import edu.wpi.first.math.filter.SlewRateLimiter; import edu.wpi.first.math.geometry.Pose2d; import edu.wpi.first.math.geometry.Rotation2d; +import edu.wpi.first.wpilibj.DriverStation; import edu.wpi.first.wpilibj.Joystick; import edu.wpi.first.wpilibj.XboxController; import frc.robot.Constants.ClimberConstants; @@ -21,6 +22,8 @@ import frc.robot.commands.intake.OuttakePiece; import frc.robot.commands.intake.RunIntake; import frc.robot.commands.intake.StowIntake; +import frc.robot.commands.lights.ContinueFlashLEDCommand; +import frc.robot.commands.lights.FlashStopLEDCommand; import frc.robot.input.AxisButton; import frc.robot.commands.Shooter.RunShooterPower; import frc.robot.commands.Shooter.RunShooterRPM; @@ -38,10 +41,12 @@ import frc.robot.commands.Shooter.PrepareShooter; import frc.robot.subsystems.Climber; import frc.robot.subsystems.IntakeSubsystem; +import frc.robot.subsystems.LightControl; import frc.robot.subsystems.ShooterSubsystem; import frc.robot.subsystems.UmbrellaSubsystem; import frc.robot.subsystems.drive.DriveSubsystem; import frc.robot.subsystems.drive.PhotonCameraWrapper; +import frc.utils.BlinkinState; import monologue.Logged; import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.InstantCommand; @@ -57,7 +62,9 @@ import java.util.function.DoubleSupplier; import java.util.function.Supplier; + import com.fasterxml.jackson.core.sym.Name; + import com.pathplanner.lib.auto.AutoBuilder; import com.pathplanner.lib.auto.NamedCommands; @@ -69,6 +76,7 @@ + /* * This class is where the bulk of the robot should be declared. Since Command-based is a * "declarative" paradigm, very little robot logic should actually be handled in the {@link Robot} @@ -86,11 +94,16 @@ public class RobotContainer implements Logged { //private final UmbrellaSubsystem m_umbrella = new UmbrellaSubsystem(); private final ShooterSubsystem m_shooter = new ShooterSubsystem(); + private final Climber m_Climber = new Climber(); + private final RobotState m_robotState = RobotState.getInstance(); + + private final LightControl m_LightControl = new LightControl(Constants.blinkinPort); + //Robot preferences private DoublePreference intakePower = new DoublePreference("intake/intakePower", 0.5); private DoublePreference intakePosition = new DoublePreference("intake/intakePosition", 100); @@ -160,7 +173,8 @@ public class RobotContainer implements Logged { private final Command resetGyro = new ResetGyro(m_robotDrive); private final Command intakeCommand = new RunIntake(m_robotIntake, intakePower, intakePosition); private final Command extakeCommand = new RunIntake(m_robotIntake, outtakePower, intakePosition); - private final Command intakePiece = new IntakePiece(m_robotIntake, m_shooter, intakePower, intakePosition, indexPower, intakeShooterPosition); + + private final Command intakePiece = new IntakePiece(m_robotIntake, m_LightControl, m_shooter, intakePower, intakePosition, indexPower, intakeShooterPosition); private final Command outTakePiece = new OuttakePiece(m_robotIntake, m_shooter, outtakePower, intakePosition, outdexPower, intakeShooterPosition, outtakeFlywheelPower); private final Command stowIntake = new StowIntake(m_robotIntake); private final Command parkCommand = new ParkCommand(m_robotDrive); @@ -168,9 +182,11 @@ public class RobotContainer implements Logged { private final Command raiseShooter = new PositionShooter(m_shooter, intakeShooterPosition); private final Command spinShooter = new RunShooterPower(m_shooter, shooterPower); private final Command spinIndex = new IndexPower(m_shooter, outdexPower, outtakePower); - private final Command shootSubwoofer = new ShootPiece(m_shooter, subShotAngle, subShotRPM, shooterIndexPower, () -> Operator.driver_leftTrigger.getAsBoolean()); - private final Command shootPodium = new ShootPiece(m_shooter, podiumShotAngle, podiumShotRPM, shooterIndexPower, () -> Operator.driver_leftTrigger.getAsBoolean()); - private final Command shootWing = new ShootPiece(m_shooter, wingShotAngle, wingShotRPM, shooterIndexPower, () -> Operator.driver_leftTrigger.getAsBoolean()); + + private final Command shootSubwoofer = new ShootPiece(m_shooter, m_LightControl, subShotAngle, subShotRPM, shooterIndexPower, () -> Operator.driver_leftTrigger.getAsBoolean()); + private final Command shootPodium = new ShootPiece(m_shooter, m_LightControl, podiumShotAngle, podiumShotRPM, shooterIndexPower, () -> Operator.driver_leftTrigger.getAsBoolean()); + private final Command shootWing = new ShootPiece(m_shooter, m_LightControl, wingShotAngle, wingShotRPM, shooterIndexPower, () -> Operator.driver_leftTrigger.getAsBoolean()); + private final Command spinRPM = new RunShooterRPM(m_shooter, shooterRPM); private final Command preSpinShooter = new PrepareShooter(m_shooter, preSpinDistanceM); private final Command ejectPiece = new EjectPiece(m_shooter); @@ -182,8 +198,9 @@ public class RobotContainer implements Logged { private final Command testTurnPID = new TurnDegrees(m_robotDrive, 15); - private final Command shooterTune = new ShootPiece(m_shooter, tuningPosition, tuningPower, shooterIndexPower, () -> Operator.driver_leftTrigger.getAsBoolean()); + private final Command shooterTune = new ShootPiece(m_shooter, m_LightControl, tuningPosition, tuningPower, shooterIndexPower, () -> Operator.driver_leftTrigger.getAsBoolean()); private final Command shootInterpolated = new ShootInterpolated(m_shooter, m_photonCameraWrapper, shooterIndexPower, () -> Operator.driver_leftTrigger.getAsBoolean()); + private final Command driveToTarget = new DriveToTarget(m_robotDrive, m_photonCameraWrapper, m_robotState::getSpeakerID, @@ -197,7 +214,7 @@ public class RobotContainer implements Logged { private final Command autoAmpRingShot = new AutonShoot(m_shooter, autoAmpRingShotAngle, autoAmpRingShotRPM, shooterIndexPower).withTimeout(2); private final Command ampShotStart = new AutonShoot(m_shooter, ampRingShotOnlyAngle, ampRingShotOnlyRPM, shooterIndexPower).withTimeout(2); private final Command ringToss = new RingToss(m_robotIntake, m_shooter, intakePower, intakePosition, shooterIndexPower, intakeShooterPosition, () -> 1000.0); - private final Command autoIntake = new IntakePiece(m_robotIntake, m_shooter, intakePower, intakePosition, indexPower, intakeShooterPosition).withTimeout(3.75); + private final Command autoIntake = new IntakePiece(m_robotIntake,m_LightControl, m_shooter, intakePower, intakePosition, indexPower, intakeShooterPosition).withTimeout(3.75); //Autonomous Wait Command @@ -207,12 +224,21 @@ public class RobotContainer implements Logged { private final SendableChooser autonChooser; + //light commands + Command defaultLEDCommand = new ContinueFlashLEDCommand(m_LightControl, BlinkinState.Solid_Colors_Red_Orange, BlinkinState.Solid_Colors_Red, 500); + Command initLEDCommand = new FlashStopLEDCommand(m_LightControl, BlinkinState.Solid_Colors_Green, 750, 4); + Command piecePickedUP = new FlashStopLEDCommand(m_LightControl, BlinkinState.Solid_Colors_Red_Orange, 750, 4); + + private final double pathSpeed = 2; // The driver's controller XboxController m_driverController = new XboxController(OIConstants.kDriverControllerPort); XboxController m_manipController = new XboxController(OIConstants.kManipControllerPort); + + private boolean autoInit = true; + private boolean teleopInit = true; private static class Operator { @@ -334,8 +360,6 @@ private void configureButtonBindings() { // new JoystickButton(m_driverController, XboxController.Button.kB.value) // .whileTrue(m_robotDrive.turnSysIdTestBuilder(10, 5)); - - } private void configureDefaultCommands(){ @@ -353,7 +377,7 @@ private void configureDefaultCommands(){ m_robotIntake.setDefaultCommand(stowIntake); m_shooter.setDefaultCommand(stowShooter); - + m_LightControl.setDefaultCommand(defaultLEDCommand); } /** * Use this to pass the autonomous command to the main {@link Robot} class. @@ -363,7 +387,18 @@ private void configureDefaultCommands(){ public Command getAutonomousCommand() { return autonChooser.getSelected(); } - + + public Command getLEDInitCommand(){ + return initLEDCommand; + } + + public boolean getIndexerBeamBreak(){ + return m_shooter.getIndexerBeamBreak(); + } + + public Command getBeamBreakLEDCommand(){ + return piecePickedUP; + } } diff --git a/src/main/java/frc/robot/RobotState.java b/src/main/java/frc/robot/RobotState.java index edd1de6..dfcbae2 100644 --- a/src/main/java/frc/robot/RobotState.java +++ b/src/main/java/frc/robot/RobotState.java @@ -13,9 +13,12 @@ public class RobotState { private Pose2d m_robotPose2d; private Pose2d m_speakerPose2d; private int m_speakerID = 0; + + private boolean m_hasNote = false; private double m_distanceToSpeaker; + private static RobotState single_instance = null; private RobotState() { @@ -63,8 +66,10 @@ public void setDistanceToSpeaker(double d) { m_distanceToSpeaker = d; } + public boolean hasNote() { return m_hasNote; } + } diff --git a/src/main/java/frc/robot/commands/Shooter/ShootPiece.java b/src/main/java/frc/robot/commands/Shooter/ShootPiece.java index 06f6df5..c86c008 100644 --- a/src/main/java/frc/robot/commands/Shooter/ShootPiece.java +++ b/src/main/java/frc/robot/commands/Shooter/ShootPiece.java @@ -7,8 +7,11 @@ import edu.wpi.first.wpilibj.shuffleboard.SuppliedValueWidget; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.ShooterSubsystem; +import frc.robot.subsystems.LightControl; +import frc.utils.BlinkinState; import java.util.function.Supplier; +import frc.utils.Timer; public class ShootPiece extends Command { @@ -17,26 +20,41 @@ public class ShootPiece extends Command { private final Supplier m_rpm; private final Supplier m_indexPower; private final Supplier m_ready; + private final LightControl m_LightControl; + + private int loops; + private Timer timer; /** Creates a new ShootPiece. */ - public ShootPiece(ShooterSubsystem shooter, Supplier position, Supplier rpm, Supplier indexpower, Supplier ready) { + + public ShootPiece(ShooterSubsystem shooter, LightControl lightControl, Supplier position, Supplier rpm, Supplier indexpower, Supplier ready) { + m_shooter = shooter; + m_LightControl = lightControl; m_position = position; m_rpm = rpm; m_indexPower = indexpower; m_ready = ready; // Use addRequirements() here to declare subsystem dependencies. - addRequirements(m_shooter); + addRequirements(m_shooter, m_LightControl); } // Called when the command is initially scheduled. @Override - public void initialize() {} + public void initialize() { + timer.resetTimer(); + } // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - m_shooter.setAngleDegrees(m_position.get()); m_shooter.spinRPM(m_rpm.get()); + m_shooter.setAngleDegrees(m_position.get()); + + if(m_shooter.armAtSetpoint() && m_shooter.atRPM()) + { + m_LightControl.ShootReady(timer); + } + else timer.resetTimer(); //if (m_ready.get() && m_shooter.atSetpoint()){ if (m_ready.get()){ m_shooter.runIndex(m_indexPower.get()); @@ -47,6 +65,7 @@ public void execute() { @Override public void end(boolean interrupted) { m_shooter.stopAll(); + m_LightControl.turnOff(); } // Returns true when the command should end. diff --git a/src/main/java/frc/robot/commands/intake/IntakePiece.java b/src/main/java/frc/robot/commands/intake/IntakePiece.java index ef58990..98fff78 100644 --- a/src/main/java/frc/robot/commands/intake/IntakePiece.java +++ b/src/main/java/frc/robot/commands/intake/IntakePiece.java @@ -9,6 +9,7 @@ import edu.wpi.first.wpilibj2.command.Subsystem; import frc.robot.subsystems.IntakeSubsystem; import frc.robot.subsystems.ShooterSubsystem; +import frc.robot.subsystems.LightControl; import java.util.function.Supplier; @@ -19,6 +20,7 @@ public class IntakePiece extends Command { private final Supplier m_intakePosition; private final Supplier m_indexPower; private final Supplier m_indexPosition; + private final LightControl m_LightControl; private final Timer timer = new Timer(); private final double delaySeconds = 0.02; @@ -26,10 +28,11 @@ public class IntakePiece extends Command { /** Creates a new IntakePiece. */ - public IntakePiece(IntakeSubsystem intake, ShooterSubsystem shooter, Supplier intakePower, Supplier intakePosition, Supplier indexPower, Supplier indexPosition ) { + public IntakePiece(IntakeSubsystem intake, LightControl lightControl, ShooterSubsystem shooter, Supplier intakePower, Supplier intakePosition, Supplier indexPower, Supplier indexPosition ) { m_intake = intake; m_shooter = shooter; + m_LightControl = lightControl; m_intakePower = intakePower; m_intakePosition = intakePosition; m_indexPower = indexPower; diff --git a/src/main/java/frc/robot/commands/lights/ContinueFlashLEDCommand.java b/src/main/java/frc/robot/commands/lights/ContinueFlashLEDCommand.java new file mode 100644 index 0000000..363639c --- /dev/null +++ b/src/main/java/frc/robot/commands/lights/ContinueFlashLEDCommand.java @@ -0,0 +1,53 @@ +package frc.robot.commands.lights; + +import java.util.function.Supplier; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.utils.BlinkinState; +import frc.robot.subsystems.LightControl; +import frc.utils.Timer; + +public class ContinueFlashLEDCommand extends Command { + + private LightControl blinkin; + private final BlinkinState flashPatternFirst; + private final BlinkinState flashPatternSecond; + private int flashTimeMillis; + + private Timer m_Timer; + + public ContinueFlashLEDCommand(LightControl blinkin, BlinkinState flashPatternFirst, BlinkinState flashPatternSecond, int flashTimeMillis) { + this.blinkin = blinkin; + this.flashPatternFirst = flashPatternFirst; + this.flashPatternSecond = flashPatternSecond; + this.flashTimeMillis = flashTimeMillis; + + addRequirements(blinkin); + } + + @Override + public void initialize() { + m_Timer.resetTimer(); + } + + @Override + public void execute() { + if (!blinkin.isActive() && m_Timer.timePassed(flashTimeMillis)){ + m_Timer.resetTimer(); + blinkin.setPattern(flashPatternFirst); + } else if (blinkin.isActive() && m_Timer.timePassed(flashTimeMillis)) { + m_Timer.resetTimer(); + blinkin.setPattern(flashPatternSecond); + } + } + + @Override + public boolean isFinished() { + return false; + } + + @Override + public void end(boolean interrupted) { + blinkin.turnOff(); + } +} \ No newline at end of file diff --git a/src/main/java/frc/robot/commands/lights/FlashLEDCommand.java b/src/main/java/frc/robot/commands/lights/FlashLEDCommand.java new file mode 100644 index 0000000..34749c6 --- /dev/null +++ b/src/main/java/frc/robot/commands/lights/FlashLEDCommand.java @@ -0,0 +1,58 @@ +package frc.robot.commands.lights; + +import java.util.function.Supplier; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.utils.BlinkinState; +import frc.robot.subsystems.LightControl; + +public class FlashLEDCommand extends Command { + + private LightControl blinkin; + private final BlinkinState flashPattern; + private final BlinkinState holdPattern; + private int flashTimeMillis; + private int timesToFlash; + + private int loops; + private long timer; + + public FlashLEDCommand(LightControl blinkin, BlinkinState flashPattern, BlinkinState holdPattern, int flashTimeMillis, int timesToFlash) { + this.blinkin = blinkin; + this.flashPattern = flashPattern; + this.holdPattern = holdPattern; + this.flashTimeMillis = flashTimeMillis; + this.timesToFlash = timesToFlash; + + addRequirements(blinkin); + } + + @Override + public void initialize() { + loops = 0; + timer = System.currentTimeMillis(); + } + + @Override + public void execute() { + if (!blinkin.isActive() && System.currentTimeMillis() > timer + flashTimeMillis) { + timer = System.currentTimeMillis(); + blinkin.setPattern(flashPattern); + loops++; + } else if (blinkin.isActive() && System.currentTimeMillis() > timer + flashTimeMillis) { + timer = System.currentTimeMillis(); + blinkin.turnOff(); + } + if (loops > timesToFlash) blinkin.setPattern(holdPattern); + } + + @Override + public boolean isFinished() { + return false; + } + + @Override + public void end(boolean interrupted) { + blinkin.turnOff(); + } +} \ No newline at end of file diff --git a/src/main/java/frc/robot/commands/lights/FlashStopLEDCommand.java b/src/main/java/frc/robot/commands/lights/FlashStopLEDCommand.java new file mode 100644 index 0000000..f50a8ba --- /dev/null +++ b/src/main/java/frc/robot/commands/lights/FlashStopLEDCommand.java @@ -0,0 +1,56 @@ +package frc.robot.commands.lights; + +import java.util.function.Supplier; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.utils.BlinkinState; +import frc.robot.subsystems.LightControl; +import frc.utils.Timer; + +public class FlashStopLEDCommand extends Command { + + private LightControl blinkin; + private final BlinkinState flashPattern; + private int flashTimeMillis; + private int timesToFlash; + + private int loops; + private Timer m_Timer; + + public FlashStopLEDCommand(LightControl blinkin, BlinkinState flashPattern, int flashTimeMillis, int timesToFlash) { + this.blinkin = blinkin; + this.flashPattern = flashPattern; + this.flashTimeMillis = flashTimeMillis; + this.timesToFlash = timesToFlash; + + addRequirements(blinkin); + } + + @Override + public void initialize() { + loops = 0; + m_Timer.resetTimer();; + } + + @Override + public void execute() { + if (!blinkin.isActive() && m_Timer.timePassed(flashTimeMillis)) { + m_Timer.resetTimer(); + blinkin.setPattern(flashPattern); + loops++; + } else if (blinkin.isActive() && m_Timer.timePassed(flashTimeMillis)) { + m_Timer.resetTimer(); + blinkin.turnOff(); + } + } + + @Override + public boolean isFinished() { + return loops > timesToFlash; + } + + @Override + public void end(boolean interrupted) { + blinkin.turnOff(); + } +} \ No newline at end of file diff --git a/src/main/java/frc/robot/subsystems/LightControl.java b/src/main/java/frc/robot/subsystems/LightControl.java new file mode 100644 index 0000000..fb77c8a --- /dev/null +++ b/src/main/java/frc/robot/subsystems/LightControl.java @@ -0,0 +1,67 @@ +package frc.robot.subsystems; + +import java.util.function.Supplier; +import java.util.regex.Pattern; + +import edu.wpi.first.wpilibj2.command.Command; +import edu.wpi.first.wpilibj2.command.SubsystemBase; +import frc.robot.commands.lights.FlashLEDCommand; +import frc.utils.BlinkinState; +import frc.utils.BlinkinController; +import frc.utils.Timer; + +public class LightControl extends SubsystemBase { + private BlinkinController blinkin; + private BlinkinState pattern; + + private boolean flashPeriodActivated = false; + + public LightControl(int blinkinPort) { + this.blinkin = new BlinkinController(blinkinPort); + } + + public void turnOff() { setPattern(BlinkinState.Solid_Colors_Black); } + + public void setPattern(BlinkinState pattern) { + this.pattern = pattern; + } + + private double getSparkValue() { + if(pattern == null) { + return BlinkinState.Color_1_Pattern_Breath_Slow.sparkValue; + } + + return pattern.sparkValue; + } + + public boolean isActive() { return pattern != BlinkinState.Solid_Colors_Black; } + + @Override + public void periodic() { + double powerOutput = getSparkValue(); + blinkin.setPWM(powerOutput); + } + + public Command getSetLedCommand(Supplier pattern) { + return runOnce(() -> { + this.setPattern(pattern.get()); + }); + } + + public Command getSetLedCommand(BlinkinState state) { + return this.getSetLedCommand(() -> state); + } + + public void ShootReady(Timer timer){ + if (!this.isActive() && timer.timePassed(500)) { + timer.resetTimer(); + this.setPattern(BlinkinState.Solid_Colors_Green); + } else if (this.isActive() && timer.timePassed(500)) { + timer.resetTimer(); + this.turnOff(); + } + } + + } + + diff --git a/src/main/java/frc/utils/BlinkinController.java b/src/main/java/frc/utils/BlinkinController.java new file mode 100644 index 0000000..b7c20ad --- /dev/null +++ b/src/main/java/frc/utils/BlinkinController.java @@ -0,0 +1,16 @@ +package frc.utils; + +import edu.wpi.first.wpilibj.PWM; +import edu.wpi.first.wpilibj.motorcontrol.Spark; + +public class BlinkinController { + private Spark pwm; + + public BlinkinController(int pwmPort) { + pwm = new Spark(pwmPort); + } + + public void setPWM(double pwmValue) { + this.pwm.set(pwmValue); + } +} \ No newline at end of file diff --git a/src/main/java/frc/utils/BlinkinState.java b/src/main/java/frc/utils/BlinkinState.java new file mode 100644 index 0000000..37636f9 --- /dev/null +++ b/src/main/java/frc/utils/BlinkinState.java @@ -0,0 +1,110 @@ +package frc.utils; + +public enum BlinkinState { + Fixed_Rainbow_Rainbow_Palette(-0.99), + Fixed_Rainbow_Party_Palette(-0.97), + Fixed_Rainbow_Ocean_Palette(-0.95), + Fixed_Rainbow_Lave_Palette(-0.93), + Fixed_Rainbow_Forest_Palette(-0.91), + Fixed_Rainbow_with_Glitter(-0.89), + Fixed_Confetti(-0.87), + Fixed_Shot_Red(-0.85), + Fixed_Shot_Blue(-0.83), + Fixed_Shot_White(-0.81), + Fixed_Sinelon_Rainbow_Palette(-0.79), + Fixed_Sinelon_Party_Palette(-0.77), + Fixed_Sinelon_Ocean_Palette(-0.75), + Fixed_Sinelon_Lava_Palette(-0.73), + Fixed_Sinelon_Forest_Palette(-0.71), + Fixed_Beats_per_Minute_Rainbow_Palette(-0.69), + Fixed_Beats_per_Minute_Party_Palette(-0.67), + Fixed_Beats_per_Minute_Ocean_Palette(-0.65), + Fixed_Beats_per_Minute_Lava_Palette(-0.63), + Fixed_Beats_per_Minute_Forest_Palette(-0.61), + Fixed_Fire_Medium(-0.59), + Fixed_Fire_Large(-0.57), + Fixed_Twinkles_Rainbow_Palette(-0.55), + Fixed_Twinkles_Party_Palette(-0.53), + Fixed_Twinkles_Ocean_Palette(-0.51), + Fixed_Twinkles_Lava_Palette(-0.49), + Fixed_Twinkles_Forest_Palette(-0.47), + Fixed_Color_Waves_Rainbow_Palette(-0.45), + Fixed_Color_Waves_Party_Palette(-0.43), + Fixed_Color_Waves_Ocean_Palette(-0.41), + Fixed_Color_Waves_Lava_Palette(-0.39), + Fixed_Color_Waves_Forest_Palette(-0.37), + Fixed_Larson_Scanner_Red(-0.35), + Fixed_Larson_Scanner_Gray(-0.33), + Fixed_Light_Chase_Red(-0.31), + Fixed_Light_Chase_Blue(-0.29), + Fixed_Light_Chase_Gray(-0.27), + Fixed_Heartbeat_Red(-0.25), + Fixed_Heartbeat_Blue(-0.23), + Fixed_Heartbeat_White(-0.21), + Fixed_Heartbeat_Gray(-0.19), + Fixed_Breath_Red(-0.17), + Fixed_Breath_Blue(-0.15), + Fixed_Breath_Gray(-0.13), + Fixed_Strobe_Red(-0.11), + Fixed_Strobe_Blue(-0.09), + Fixed_Strobe_Gold(-0.07), + Fixed_Strobe_White(-0.05), + Color_1_Pattern_End_to_End_Blend_to_Black(-0.03), + Color_1_Pattern_Larson_Scanner(-0.01), + Color_1_Pattern_Light_Chase(0.01), + Color_1_Pattern_Heartbeat_Slow(0.03), + Color_1_Pattern_Heartbeat_Medium(0.05), + Color_1_Pattern_Heartbeat_Fast(0.07), + Color_1_Pattern_Breath_Slow(0.09), + Color_1_Pattern_Breath_Fast(0.11), + Color_1_Pattern_Shot(0.13), + Color_1_Pattern_Strobe(0.15), + Color_2_Pattern_End_to_End_Blend_to_Black(0.17), + Color_2_Pattern_Larson_Scanner(0.19), + Color_2_Pattern_Light_Chase_Dimming(0.21), + Color_2_Pattern_Heartbeat_Slow(0.23), + Color_2_Pattern_Heartbeat_Medium(0.25), + Color_2_Pattern_Heartbeat_Fast(0.27), + Color_2_Pattern_Breath_Slow(0.29), + Color_2_Pattern_Breath_Fast(0.31), + Color_2_Pattern_Shot(0.33), + Color_2_Pattern_Strobe(0.35), + Color_1_and_2_Pattern_Sparkle_Color_1_on_Color_2(0.37), + Color_1_and_2_Pattern_Sparkle_Color_2_on_Color_1(0.39), + Color_1_and_2_Pattern_Color_Gradient_Color_1_and_2(0.41), + Color_1_and_2_Pattern_Beats_per_Minute_Color_1_and_2(0.43), + Color_1_and_2_Pattern_End_to_End_Blend_Color_1_to_2(0.45), + Color_1_and_2_Pattern_End_to_End_Blend(0.47), + Color_1_and_2_Pattern_Color_1_and_Color(0.49), + Color_1_and_2_Pattern_Twinkles_Color_1_and_2(0.51), + Color_1_and_2_Pattern_Color_Waves_Color_1_and_2(0.53), + Color_1_and_2_Pattern_Sinelon_Color_1_and_2(0.55), + Solid_Colors_Hot_Pink(0.57), + Solid_Colors_Dark_red(0.59), + Solid_Colors_Red(0.61), + Solid_Colors_Red_Orange(0.63), + Solid_Colors_Orange(0.65), + Solid_Colors_Gold(0.67), + Solid_Colors_Yellow(0.69), + Solid_Colors_Lawn_Green(0.71), + Solid_Colors_Lime(0.73), + Solid_Colors_Dark_Green(0.75), + Solid_Colors_Green(0.77), + Solid_Colors_Blue_Green(0.79), + Solid_Colors_Aqua(0.81), + Solid_Colors_Sky_Blue(0.83), + Solid_Colors_Dark_Blue(0.85), + Solid_Colors_Blue(0.87), + Solid_Colors_Blue_Violet(0.89), + Solid_Colors_Violet(0.91), + Solid_Colors_White(0.93), + Solid_Colors_Gray(0.95), + Solid_Colors_Dark_Gray(0.97), + Solid_Colors_Black(0.99); + + public final double sparkValue; + + private BlinkinState(double sparkValue) { + this.sparkValue = sparkValue; + } +} \ No newline at end of file diff --git a/src/main/java/frc/utils/Timer.java b/src/main/java/frc/utils/Timer.java new file mode 100644 index 0000000..f434163 --- /dev/null +++ b/src/main/java/frc/utils/Timer.java @@ -0,0 +1,22 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package frc.utils; + +/** Add your docs here. */ +public class Timer { + long timer; + + public long getTimer(){ + return timer; + } + + public void resetTimer(){ + timer = 0; + } + + public boolean timePassed(int milliseconds){ + return System.currentTimeMillis() > timer + milliseconds; + } +}