Skip to content

Commit

Permalink
NEW CODE for LEDs
Browse files Browse the repository at this point in the history
no need to write an essay - David
  • Loading branch information
RacconDog committed Nov 2, 2024
1 parent 8b1809c commit a044c74
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/team841/calliope/drive/Drivetrain.java
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ public boolean inRangeToSpeaker(){

@Override
public void periodic() {
/*
var PoseEstimate =
LimelightHelpers.getBotPoseEstimate_wpiBlue(Swerve.Vision.kLimelightFrontName);
if (PoseEstimate.tagCount >= 2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ public void periodic() {
if(msCount < 3000){
//green
msCount += 20;
io.set(0.71);
io.setColor("green");
}
else {
//red
io.set(0.59);
io.setColor("red");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,31 +1,45 @@
package com.team841.calliope.superstructure.lights;

import com.team841.calliope.constants.SC;

import edu.wpi.first.wpilibj.AddressableLED;
import edu.wpi.first.wpilibj.AddressableLEDBuffer;
import edu.wpi.first.wpilibj.motorcontrol.Spark;

public class LEDIOSpark implements LEDIO{
private final Spark LED = new Spark(SC.Intake.kBlinkingID);
private final AddressableLED LED = new AddressableLED(5);
private final AddressableLEDBuffer Buffer = new AddressableLEDBuffer(59);


public LEDIOSpark() {

LED.setLength(Buffer.getLength());
LED.setData(Buffer);
LED.start();
}

@Override
public void updateInputs(LedIOInputs inputs) {
inputs.sparkOutput = LED.get();
// inputs.sparkOutput = LED.get();
}

@Override
public void setColor(String color){
switch (color) {
case "Violet" -> LED.set(0.91);
case "Green" -> LED.set(.77);
case "Orange" -> LED.set(.65);
if(color == "red"){
for(var i = 0; i < Buffer.getLength(); i++)
Buffer.setRGB(i, 255, 0, 0);
LED.setData(Buffer);
}
if(color == "green"){
for(var i = 0; i < Buffer.getLength(); i++)
Buffer.setRGB(i, 0, 255, 0);
LED.setData(Buffer);
}


}

@Override
public void set(double value) {
LED.set(value);
// LED.set(value);
}
}

0 comments on commit a044c74

Please sign in to comment.