Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leds #14

Closed
wants to merge 4 commits into from
Closed

Leds #14

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import edu.wpi.first.wpilibj2.command.WaitCommand;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import frc.robot.Robot.RobotRunType;
import frc.robot.subsystems.LEDs;
import frc.robot.subsystems.ballMechanism.ballMechanism;
import frc.robot.subsystems.ballMechanism.ballMechanismIO;
import frc.robot.subsystems.ballMechanism.ballMechanismReal;
Expand All @@ -31,13 +32,15 @@
public class RobotContainer {
/* Controllers */
private final CommandXboxController driver = new CommandXboxController(Constants.driverID);

// Initialize AutoChooser Sendable
private final SendableChooser<String> autoChooser = new SendableChooser<>();

/* Subsystems */
private Drivetrain drivetrain;
private Hatch hatch;
private ballMechanism intake;
private LEDs leds;

/**
* The container for the robot. Contains subsystems, OI devices, and commands.
Expand Down Expand Up @@ -98,8 +101,10 @@ private void configureButtonBindings() {
driver.getHID().setRumble(RumbleType.kBothRumble, 0);
})));
driver.b().whileTrue(hatch.setHatchNeutral());
driver.leftTrigger().whileTrue(intake.intakeCommand(Color.kPurple, Color.kWhiteSmoke));
driver.rightTrigger().whileTrue(intake.outtakeCommand());
driver.leftTrigger().whileTrue(
intake.intakeCommand().andThen(leds.flashCommand(Color.kPurple, Color.kWhite)));
driver.rightTrigger().whileTrue(
intake.outtakeCommand().andThen(leds.flashCommand(Color.kBrown, Color.kPink)));
}

/**
Expand Down
32 changes: 14 additions & 18 deletions src/main/java/frc/robot/subsystems/LEDs.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import edu.wpi.first.wpilibj.AddressableLED;
import edu.wpi.first.wpilibj.AddressableLEDBuffer;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.util.Color;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands;
Expand Down Expand Up @@ -111,25 +112,20 @@ public Color getColor(int index) {
}

public Command flashCommand(Color color, Color altColor) {
int flashingDelay = 0;
return Commands.runEnd(null, null, null)
}

private int flashingDelay = 0;


public void flash(Color color, Color altColor) {
if (flashingDelay < 10) {
for (var i = 0; i < getLength(); i++) {
setColor(i, color);
}
} else {
for (var i = 0; i < getLength(); i++) {
setColor(i, altColor);
return Commands.run(() -> alterNateFlash(color, altColor), this);

public void alterNateFlash(Color color, Color altColor) {
Timer timer = new Timer();
timer.start();
for (int i = 0; i < 3; i++) {
if (i % 2 == 0) {
setColor(color);
timer.advanceIfElapsed(.25);
} else {
setColor(altColor);
timer.advanceIfElapsed(.25);
}

}
setData();
flashingDelay++;
flashingDelay %= 20;
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package frc.robot.subsystems.ballMechanism;

import org.littletonrobotics.junction.Logger;
import edu.wpi.first.wpilibj.util.Color;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.subsystems.LEDs;

public class ballMechanism extends SubsystemBase {
ballMechanismIO io;
ballMechanismInputsAutoLogged intakeAutoLogged = new ballMechanismInputsAutoLogged();
LEDs lights = new LEDs(9, 100);

public ballMechanism(ballMechanismIO io) {
this.io = io;
Expand All @@ -36,13 +33,14 @@ public boolean getOuttakeBeamBrakeStatus() {
return intakeAutoLogged.outtakeBeamBrake;
}

public Command intakeCommand(Color color, Color altColor) {
public Command intakeCommand() {
return Commands.startEnd(() -> {
setBallMotor(1);
}, () -> {
setBallMotor(0);
}, this).until(() -> getIntakeBeamBreakStatus()).unless(() -> getIntakeBeamBreakStatus())
.andThen(() -> lights.flash(color, altColor)).andThen();
}, this).until(() -> getIntakeBeamBreakStatus()).unless(() -> getIntakeBeamBreakStatus());



}

Expand Down
Loading