Skip to content

Commit

Permalink
add proper LED
Browse files Browse the repository at this point in the history
  • Loading branch information
Rishay Jain authored and Rishay Jain committed Oct 25, 2023
1 parent 847fcc0 commit 9593bb3
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions src/main/java/frc/robot/subsystems/AryaMech.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package frc.robot.subsystems;

import edu.wpi.first.wpilibj.AnalogOutput;
import edu.wpi.first.wpilibj.PWM;
import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.util.Color;
Expand All @@ -26,14 +28,13 @@ public class AryaMech extends SubsystemBase{
private Timer audio_timer;
private final double time_to_wait_before_turning_off_audio_signal;

private final LEDStrip ledStrip;
private final LEDLayer baseLayer;
private final int LED_LENGTH = 0;
private final AnalogOutput ledStrip;
private final int LED_PWM_PORT = 0;
private Timer ledTimer;

public AryaMech(Solenoid shortSolenoid, Solenoid longSolenoid){
// this.shortSolenoid = shortSolenoid;
// this.longSolenoid = longSolenoid;
this.shortSolenoid = shortSolenoid;
this.longSolenoid = longSolenoid;

//ik this looks sus but its for ease of change
shortOut = 0;
Expand All @@ -48,8 +49,8 @@ public AryaMech(Solenoid shortSolenoid, Solenoid longSolenoid){
audio_timer = new Timer();
time_to_wait_before_turning_off_audio_signal = 1.0;

ledStrip = new LEDStrip(LED_PWM_PORT, LED_LENGTH);
baseLayer = new LEDLayer(LED_LENGTH);
ledStrip = new AnalogOutput(LED_PWM_PORT);
ledTimer = new Timer();

timer= new Timer();
timer.start();
Expand All @@ -58,7 +59,14 @@ public AryaMech(Solenoid shortSolenoid, Solenoid longSolenoid){

public void periodic() {

audioPub.set(1.0); // this publishes the trigger signal to networktables, which gets picked up by the driverstation python script
if(ledTimer.hasElapsed(0.25)){
ledStrip.setVoltage(0.0);
ledTimer.stop();
ledTimer.reset();
ledTimer.start();
}

// audioPub.set(1.0); // this publishes the trigger signal to networktables, which gets picked up by the driverstation python script
if(audio_timer.hasElapsed(time_to_wait_before_turning_off_audio_signal)){
audioPub.set(0.0); // Set the value on networktables to zero so we don't restart the audio
audio_timer.stop();
Expand All @@ -77,17 +85,17 @@ else if (timer.hasElapsed(longOut)){
audio_timer.reset(); // setting a timer so that we can stop sending the signal after an appropriate amount of time
audio_timer.start(); // if we don't stop sending the trigger signal, the audio might start playing again

baseLayer.fillColor(new Color(255, 50, 0));
ledStrip.setVoltage(5.0);
ledTimer.reset();
ledTimer.start();

longSolenoid.set(true);
}
else if (timer.advanceIfElapsed(longIn)){
longSolenoid.set(false);
ledStrip.setVoltage(0.0);
}

ledStrip.addLayer(baseLayer);


}

}

0 comments on commit 9593bb3

Please sign in to comment.