Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
add LED integration to shooter (#72)
Browse files Browse the repository at this point in the history
Co-authored-by: Jade <[email protected]>
  • Loading branch information
SturrockPeter and spacey-sooty authored Aug 12, 2024
1 parent 11af318 commit b0ff1f1
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import frc.robot.generated.TunerConstants;

public final class Constants {
public static final int LEDport = 0;

public static final int driverport = 0;
public static final int codriverport = 1;

Expand Down
34 changes: 34 additions & 0 deletions src/main/java/frc/robot/subsystems/LED.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) 2024 CurtinFRC
// Open Source Software, you can modify it according to the terms
// of the MIT License at the root of this project

package frc.robot.subsystems;

import edu.wpi.first.wpilibj.PWM;
import frc.robot.Constants;

public final class LED {
private static final PWM ledpwm = new PWM(Constants.LEDport);

private LED() {}

public static void Intake() {
ledpwm.setSpeed(0.59); // dark red //
}

public static void Outake() {
ledpwm.setSpeed(0.69); // yellow //
}

public static void Spinup() {
ledpwm.setSpeed(0.63); // red orange, 0.65 for normal orange //
}

public static void Stop() {
ledpwm.setSpeed(0.73); // lime //
}

public static void Maintain() {
ledpwm.setSpeed(0.57); // hot pink //
}
}
9 changes: 5 additions & 4 deletions src/main/java/frc/robot/subsystems/Shooter.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private Command achieveSpeeds(double speed) {
() -> {
var output =
m_pid.calculate(
-1 * Units.rotationsPerMinuteToRadiansPerSecond(m_encoder.getVelocity()));
-1 * Units.rotationsPerMinuteToRadiansPerSecond(m_encoder.getVelocity()), speed);
log_pid_output.append(output);
m_ntPidError.set(m_pid.getVelocityError());
m_ntPidOutput.set(m_pid.getVelocityError());
Expand All @@ -63,11 +63,12 @@ private Command achieveSpeeds(double speed) {
* @return a {@link Command} to get to the desired speed.
*/
public Command spinup(double speed) {
return achieveSpeeds(speed).until(m_pid::atSetpoint);
LED.Spinup();
return runOnce(() -> LED.Spinup()).andThen(achieveSpeeds(speed).until(m_pid::atSetpoint));
}

public Command stop() {
return runOnce(() -> m_motor.set(0));
return runOnce(() -> LED.Stop()).andThen(runOnce(() -> m_motor.set(0)));
}

/**
Expand All @@ -76,7 +77,7 @@ public Command stop() {
* @return A {@link Command} to hold the speed at the setpoint.
*/
public Command maintain() {
return defer(() -> achieveSpeeds(m_pid.getSetpoint()));
return defer(() -> runOnce(() -> LED.Maintain()).andThen(achieveSpeeds(m_pid.getSetpoint())));
}

public Command shoot() {
Expand Down

0 comments on commit b0ff1f1

Please sign in to comment.