diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 0a0ac8f..559996c 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -20,10 +20,13 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableChooser; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.Commands; +import edu.wpi.first.wpilibj2.command.ParallelCommandGroup; import edu.wpi.first.wpilibj2.command.button.CommandXboxController; import edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine.Direction; import frc.robot.TunerConstants.TunerConstants; +import frc.robot.commands.RainBow; +import frc.robot.subsystems.Bougie; import frc.robot.subsystems.CommandSwerveDrivetrain; import frc.robot.subsystems.Grimpeur; @@ -45,7 +48,7 @@ public class RobotContainer { public final CommandSwerveDrivetrain drivetrain = TunerConstants.createDrivetrain(); private final SendableChooser autoChooser; - + Bougie bougie = new Bougie(); public RobotContainer() { @@ -73,7 +76,11 @@ public class RobotContainer { drivetrain.registerTelemetry(logger::telemeterize); } - public Command getAutonomousCommand() { - return autoChooser.getSelected(); - } + + public Command getAutonomousCommand() { + return new ParallelCommandGroup( + autoChooser.getSelected(), + new RainBow(bougie) + ); + } } diff --git a/src/main/java/frc/robot/commands/RainBow.java b/src/main/java/frc/robot/commands/RainBow.java new file mode 100644 index 0000000..2c4e5e2 --- /dev/null +++ b/src/main/java/frc/robot/commands/RainBow.java @@ -0,0 +1,37 @@ +// 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.robot.commands; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.Bougie; + +/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */ +public class RainBow extends Command { + Bougie bougie; + /** Creates a new RainBow. */ + public RainBow(Bougie bougie) { + this.bougie = bougie; + addRequirements(bougie); + // Use addRequirements() here to declare subsystem dependencies. + } + + // Called when the command is initially scheduled. + @Override + public void initialize() {bougie.RainBow();} + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() {} + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) {bougie.RainBowStop();} + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/subsystems/Bougie.java b/src/main/java/frc/robot/subsystems/Bougie.java new file mode 100644 index 0000000..9876824 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/Bougie.java @@ -0,0 +1,38 @@ +// 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.robot.subsystems; + +import com.ctre.phoenix.led.CANdle; +import com.ctre.phoenix.led.CANdleConfiguration; +import com.ctre.phoenix.led.RainbowAnimation; + +import edu.wpi.first.wpilibj2.command.SubsystemBase; + +public class Bougie extends SubsystemBase { + CANdle candle = new CANdle(5); + CANdleConfiguration config = new CANdleConfiguration(); + RainbowAnimation rainbowAnim = new RainbowAnimation(1, 0.5, 64); + /** Creates a new Bougie. */ + public Bougie() { + config.brightnessScalar = 0.5; + candle.configAllSettings(config); + } + public void Rouge() { + candle.setLEDs(255, 0, 0); + } + public void Vert() { + candle.setLEDs(0, 255, 0); + } + public void Bleu() { + candle.setLEDs(0, 0, 255); + } + public void RainBow(){candle.animate(rainbowAnim);} + public void RainBowStop(){candle.animate(null);} + @Override + public void periodic() { + // This method will be called once per scheduler run + } +} +