Skip to content

Commit

Permalink
Merge pull request #15 from noodleeater99/main
Browse files Browse the repository at this point in the history
LED code v1 TEST
  • Loading branch information
zaneal authored Feb 3, 2024
2 parents 2088a4e + cffab6e commit 9a95a56
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import edu.wpi.first.wpilibj2.command.RunCommand;
import edu.wpi.first.wpilibj2.command.button.JoystickButton;
import frc.robot.commands.DriveCommands;
import frc.robot.commands.SetLEDCommand;
import frc.robot.constants.DrivetrainConstants;
import frc.robot.constants.LEDConstants;
import frc.robot.subsystems.SwerveSubsystem;

/**
Expand Down Expand Up @@ -48,6 +50,16 @@ public void configureButtonBindings(){
swerveSubsystem.zeroGyro();
})
);
new JoystickButton(primaryController, XboxController.Button.kA.value).whileTrue(
new RunCommand(() -> {
SetLEDCommand.run(LEDConstants.Status.TEST_1);
})
);
new JoystickButton(primaryController, XboxController.Button.kB.value).whileTrue(
new RunCommand(() -> {
SetLEDCommand.run(LEDConstants.Status.TEST_2);
})
);
}
/**
* Use this to pass the autonomous command to the main {@link Robot} class.
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/frc/robot/commands/SetLEDCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package frc.robot.commands;

import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.constants.LEDConstants;
import frc.robot.subsystems.LEDSubsystem;

public class SetLEDCommand extends Command {
private static LEDSubsystem subsystem = null;
public SetLEDCommand(LEDSubsystem subsystem) {
this.subsystem = subsystem;
}

//@Override
public static void run(LEDConstants.Status currentStatus) {
switch(currentStatus) {
case TEST_1:
//Confetti
subsystem.setLED(-0.87);
case TEST_2:
//Sinelon, Forest Palette
subsystem.setLED(-0.71);
}
}
}
13 changes: 13 additions & 0 deletions src/main/java/frc/robot/constants/LEDConstants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package frc.robot.constants;

public class LEDConstants {
public static enum Status {
DISABLED,
IDLE,
MOVING,
VISION_MOVING,
TEST_1,
TEST_2
}

}
19 changes: 19 additions & 0 deletions src/main/java/frc/robot/subsystems/LEDSubsystem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package frc.robot.subsystems;

import edu.wpi.first.networktables.DoublePublisher;
import edu.wpi.first.networktables.NetworkTableInstance;
import edu.wpi.first.wpilibj.motorcontrol.Spark;
import edu.wpi.first.wpilibj2.command.SubsystemBase;

public class LEDSubsystem extends SubsystemBase {
Spark BlinkinDriver = new Spark(9);
DoublePublisher LED_NT = NetworkTableInstance.getDefault().getTable("LEDs").getDoubleTopic("LEDValue").publish();
@Override
public void periodic() {
super.periodic();
LED_NT.set(BlinkinDriver.get());
}
public void setLED(double value) {
BlinkinDriver.set(value);
}
}

0 comments on commit 9a95a56

Please sign in to comment.