Skip to content

Commit 133dec8

Browse files
committed
Add Leds
1 parent 9728aa2 commit 133dec8

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

src/main/java/frc/team3128/RobotContainer.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ public class RobotContainer {
6262
private Hopper hopper;
6363
private Intake intake;
6464
private Shooter shooter;
65-
66-
6765
private Leds leds;
6866

6967
// private NAR_ButtonBoard judgePad;
@@ -91,6 +89,7 @@ public RobotContainer() {
9189
hopper = Hopper.getInstance();
9290
intake = Intake.getInstance();
9391
shooter = Shooter.getInstance();
92+
leds = Leds.getInstance();
9493

9594
//uncomment line below to enable driving
9695
CommandScheduler.getInstance().setDefaultCommand(swerve, new CmdSwerveDrive(controller::getLeftX,controller::getLeftY, controller::getRightX, true));
@@ -151,7 +150,10 @@ private void configureButtonBindings() {
151150
//Stops shooting when all notes are gone
152151
new Trigger(()-> shooter.noteInRollers()).negate()
153152
.and(()->hopper.hasObjectPresent()).negate()
154-
.onTrue(shooter.setShooting(false));
153+
.onTrue(sequence(
154+
shooter.setShooting(false),
155+
runOnce(() -> leds.setLedColor(Colors.BLUE))
156+
));
155157

156158
//Queues note to hopper
157159
new Trigger(()-> intake.getMeasurement() > 90)
@@ -169,6 +171,7 @@ private void configureButtonBindings() {
169171
.and(()->hopper.hasObjectPresent())
170172
.and(() -> !shooter.getShooting())
171173
.onTrue(sequence(
174+
runOnce(() -> leds.blinkLEDColor(Colors.RED, Colors.GREEN, .25)),
172175
shooter.runKickMotor(KICK_POWER),
173176
hopper.runManipulator(HOPPER_INTAKE_POWER)
174177
))
@@ -178,7 +181,10 @@ private void configureButtonBindings() {
178181
shooter.runKickMotor(0)
179182
));
180183

181-
// new Trigger(() -> shouldEjectNote()).onTrue(ejectNote());
184+
// new Trigger(() -> shouldEjectNote()).onTrue(sequence(
185+
// runOnce(() -> leds.setLedColor(Colors.PURPLE)),
186+
// ejectNote()
187+
// ));
182188

183189
}
184190

@@ -189,6 +195,7 @@ private boolean shouldEjectNote(){
189195
if(shooter.noteInRollers() && hopper.hasObjectPresent() && !ejectTimerStarted){
190196
ejectTimerStarted = true;
191197
ejecTimer.start();
198+
runOnce(() -> leds.blinkLEDColor(Colors.RED, Colors.ORANGE, .25));
192199
}
193200

194201
else if(shooter.noteInRollers() && hopper.hasObjectPresent() && ejectTimerStarted){

src/main/java/frc/team3128/subsystems/Leds.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@
77
import com.ctre.phoenix.led.FireAnimation;
88
import com.ctre.phoenix.led.RainbowAnimation;
99
import com.ctre.phoenix.led.SingleFadeAnimation;
10+
import com.ctre.phoenix.led.StrobeAnimation;
1011

1112
import edu.wpi.first.wpilibj2.command.SubsystemBase;
13+
import edu.wpi.first.wpilibj2.command.WaitCommand;
14+
15+
import static edu.wpi.first.wpilibj2.command.Commands.waitSeconds;
1216
import static frc.team3128.Constants.LedConstants.*;
1317

1418
import frc.team3128.Constants.LedConstants.Colors;
@@ -79,6 +83,14 @@ public void setLedColor(Colors color) {
7983
}
8084
}
8185

86+
public void blinkLEDColor(Colors blinkColor, Colors endColor, double duration) {
87+
resetAnimationSlot(2);
88+
m_candle.animate(new StrobeAnimation(blinkColor.r, blinkColor.g, blinkColor.b, WHITE_VALUE, 1,STARTING_ID + PIVOT_FRONT,STARTING_ID));
89+
waitSeconds(duration);
90+
setLedColor(endColor);
91+
92+
}
93+
8294
public void resetAnimationSlot(int slots) {
8395
m_candle.setLEDs(0,0,0, WHITE_VALUE, STARTING_ID, PIVOT_COUNT);
8496
for (int i = 0; i < slots; i++) {

0 commit comments

Comments
 (0)