Skip to content

Commit

Permalink
testing stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
sofiebudman committed Mar 27, 2024
1 parent b7acc8e commit 48638f9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion simgui.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
0.0,
0.8500000238418579
],
"height": 338
"height": 177
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/carlmontrobotics/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static final class Led {


public static final Color8Bit DEFAULT_COLOR_BLUE = new Color8Bit(0, 0, 200);
public static final Color8Bit DETECT_NOTE_ORANGE = new Color8Bit(250,140,3);
public static final Color8Bit DETECT_NOTE_YELLOW = new Color8Bit(255,255,0);
public static final Color8Bit HOLDING_GREEN = new Color8Bit(0,250,0);
public static final int ledPort = 0;
//TODO: figure out how to get port of LED, it could be 0 or
Expand Down
35 changes: 26 additions & 9 deletions src/main/java/org/carlmontrobotics/subsystems/Led.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.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj.util.Color8Bit;
import edu.wpi.first.wpilibj2.command.SubsystemBase;

Expand All @@ -14,6 +15,8 @@ public class Led extends SubsystemBase{
private final AddressableLED led = new AddressableLED(9);
private final IntakeShooter intakeshooter;
private int midpoint = (int)ledBuffer.getLength()/2;
private int color = 1;

//rounds down
// public static final double midpoint = Math.floor(ledLength/2);
//public static final int ledLength = led.getLength();
Expand All @@ -23,11 +26,13 @@ public Led(IntakeShooter intakeShooter){
this.intakeshooter = intakeShooter;
led.setLength(ledBuffer.getLength());
led.setData(ledBuffer);
led.start();
led.start();

setLedColor(DEFAULT_COLOR_BLUE, 0 , getLength());
SmartDashboard.putNumber("color", color);

}

public void setLedColor(Color8Bit color, int start, int end) {
for (int i = start; i < end ; i++)
ledBuffer.setRGB(i, color.red, color.green, color.blue);
Expand All @@ -38,15 +43,28 @@ public int getLength(){
}
@Override
public void periodic(){
System.err.println("skdjfksd");
if (intakeshooter.intakeDetectsNote() && !intakeshooter.outakeDetectsNote()) {
setLedColor(DETECT_NOTE_ORANGE, 0, midpoint);
//System.err.println("skdjfksd");

//testing
if (SmartDashboard.getNumber("color", color) == 1) {
setLedColor(DETECT_NOTE_YELLOW, 0,getLength());
//when intake TOF detects, but outtake TOF does not the bottom half of the LEDs become orange

}
else if(!intakeshooter.intakeDetectsNote() && intakeshooter.outakeDetectsNote()){
setLedColor(DETECT_NOTE_ORANGE,midpoint, getLength());
//when outtake TOF detects, but intake TOF does not the top half of the LEDs become orange
else if (SmartDashboard.getNumber("color", color) ==2) {
setLedColor(HOLDING_GREEN, 0, getLength());
//when both TOFs detect and the end efforcter is holding the note the LEDS turn green

}
else if (SmartDashboard.getNumber("color", color) == 3){
setLedColor(DEFAULT_COLOR_BLUE, 0, getLength());
//otherwise LEds are blue
}

/*if (intakeshooter.intakeDetectsNote() && !intakeshooter.outakeDetectsNote()) {
setLedColor(DETECT_NOTE_YELLOW, 0,getLength());
//when intake TOF detects, but outtake TOF does not the bottom half of the LEDs become orange
}
else if (intakeshooter.intakeDetectsNote() && intakeshooter.outakeDetectsNote()) {
setLedColor(HOLDING_GREEN, 0, getLength());
Expand All @@ -57,8 +75,7 @@ else if (intakeshooter.intakeDetectsNote() && intakeshooter.outakeDetectsNote())
setLedColor(DEFAULT_COLOR_BLUE, 0, getLength());
//otherwise LEds are blue
}

setLedColor(DEFAULT_COLOR_BLUE, 0, getLength());
*/



Expand Down

0 comments on commit 48638f9

Please sign in to comment.