From a044c74ac992ce5f8418de4b18ce401f2d367507 Mon Sep 17 00:00:00 2001 From: Weston Date: Sat, 2 Nov 2024 15:54:51 -0700 Subject: [PATCH] NEW CODE for LEDs no need to write an essay - David --- .../team841/calliope/drive/Drivetrain.java | 1 + .../calliope/superstructure/lights/LED.java | 4 +-- .../superstructure/lights/LEDIOSpark.java | 30 ++++++++++++++----- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/team841/calliope/drive/Drivetrain.java b/src/main/java/com/team841/calliope/drive/Drivetrain.java index 33d8ccc..2e5eaf6 100644 --- a/src/main/java/com/team841/calliope/drive/Drivetrain.java +++ b/src/main/java/com/team841/calliope/drive/Drivetrain.java @@ -250,6 +250,7 @@ public boolean inRangeToSpeaker(){ @Override public void periodic() { + /* var PoseEstimate = LimelightHelpers.getBotPoseEstimate_wpiBlue(Swerve.Vision.kLimelightFrontName); if (PoseEstimate.tagCount >= 2) { diff --git a/src/main/java/com/team841/calliope/superstructure/lights/LED.java b/src/main/java/com/team841/calliope/superstructure/lights/LED.java index d884380..39ee06b 100644 --- a/src/main/java/com/team841/calliope/superstructure/lights/LED.java +++ b/src/main/java/com/team841/calliope/superstructure/lights/LED.java @@ -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"); } } } diff --git a/src/main/java/com/team841/calliope/superstructure/lights/LEDIOSpark.java b/src/main/java/com/team841/calliope/superstructure/lights/LEDIOSpark.java index 33828eb..d79d7bf 100644 --- a/src/main/java/com/team841/calliope/superstructure/lights/LEDIOSpark.java +++ b/src/main/java/com/team841/calliope/superstructure/lights/LEDIOSpark.java @@ -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); } }