This commit is contained in:
Samuel
2026-02-04 19:40:05 -05:00
parent 5fe8ffbb41
commit dfd4810da4
2 changed files with 128 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
// 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.Led;
/* 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 RainBowAnim extends Command {
private Led led;
/** Creates a new RainBowAnim. */
public RainBowAnim(Led led) {
this.led = led;
addRequirements(led);
// Use addRequirements() here to declare subsystem dependencies.
}
// Called when the command is initially scheduled.
@Override
public void initialize() {
led.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) {
led.RainBowStop();
}
// Returns true when the command should end.
@Override
public boolean isFinished() {
return false;
}
}

View File

@@ -0,0 +1,87 @@
// 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 java.util.Optional;
import com.ctre.phoenix.led.CANdle;
import com.ctre.phoenix.led.RainbowAnimation;
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
public class Led extends SubsystemBase {
CANdle CANDle = new CANdle(7);
RainbowAnimation rainbowAnim = new RainbowAnimation();
public void bleu(){
CANDle.setLEDs(0, 0, 255);
}
public void Vert(){
CANDle.setLEDs(0,255, 0);
}
public void Rouge(){
CANDle.setLEDs(255,0, 0);
}
public void RainBow(){
CANDle.animate(rainbowAnim);
}
public void RainBowStop(){
CANDle.animate(null);
}
public boolean Equipe(){
Optional<DriverStation.Alliance> alliance = DriverStation.getAlliance();
if(alliance.get() == DriverStation.Alliance.Blue){
return true;
}
else{
return false;
}
}
/** Creates a new Led. */
public Led() {}
@Override
public void periodic() {
double temps = DriverStation.getMatchTime();
if(temps > 20 && temps < 30){
Vert();
}
if(Equipe()){
if(temps > 30 && temps < 55){
bleu();
}
else if(temps > 30 && temps < 80){
Rouge();
}
else if(temps > 80 && temps < 105){
bleu();
}
else if(temps > 105 && temps < 130){
Rouge();
}
else{
RainBow();
}
}
else{
if(temps > 30 && temps < 55){
Rouge();
}
else if(temps > 30 && temps < 80){
bleu();
}
else if(temps > 80 && temps < 105){
Rouge();
}
else if(temps > 105 && temps < 130){
bleu();
}
else{
RainBow();
}
}
// This method will be called once per scheduler run
}
}