From ec3970dd2d7131e2065e4e95da1790fe76cb6082 Mon Sep 17 00:00:00 2001 From: v1x2 Date: Tue, 12 Nov 2024 19:03:56 -0500 Subject: [PATCH] correct button (bumper) --- .../java/frc/team5115/RobotContainer.java | 2 +- .../team5115/subsystems/lights/Lights.java | 121 +++++++++--------- 2 files changed, 63 insertions(+), 60 deletions(-) diff --git a/src/main/java/frc/team5115/RobotContainer.java b/src/main/java/frc/team5115/RobotContainer.java index 16aca86..618d53c 100644 --- a/src/main/java/frc/team5115/RobotContainer.java +++ b/src/main/java/frc/team5115/RobotContainer.java @@ -232,7 +232,7 @@ public void robotPeriodic() { noteDetectedEntry.setBoolean(feeder.noteDetected()); } // - boolean aligning = joyDrive.getHID().getRawButton(XboxController.Button.kB.value); + boolean aligning = joyManip.getHID().getRightBumperPressed(); boolean inRange = false; // ? if(lights != null){ lights.update(aligning, inRange); diff --git a/src/main/java/frc/team5115/subsystems/lights/Lights.java b/src/main/java/frc/team5115/subsystems/lights/Lights.java index 2d6af8a..bfa2daa 100644 --- a/src/main/java/frc/team5115/subsystems/lights/Lights.java +++ b/src/main/java/frc/team5115/subsystems/lights/Lights.java @@ -44,36 +44,47 @@ public void start(){ public void stop(){ leds.stop(); } - - public void update(boolean aligning, boolean inRange) { - AnimationState state = AnimationState.Idle; - if (inRange) { - state = AnimationState.InRange; - } else if (aligning) { - state = AnimationState.Aligning; - } else if (!reflectiveSensor.get()) { - state = AnimationState.ControllingNote; + public void iterateAllLeds(Function function){ + for(int i = 0; i { + return new Integer[] {r, g, b}; + }); + } + + public void updateIdleAnimation() { + timer_idle ++; + if (timer_idle >= period) { + timer_idle = 0; + } else { + return; + } + + counter_idle += direction_idle; + if (counter_idle == ledCount || counter_idle == -1) { + direction_idle = -direction_idle; + counter_idle += 2 * direction_idle; } + iterateAllLeds((index) -> { + double percent = buffer.getLED(index).red - minPower / 1d / maxPower - decay; + percent = Math.max(percent, 0); + + if (index == counter_idle) { + percent = 1.0; + } + + final double power = (percent * (maxPower - minPower)) + minPower; + return new Integer[] { (int)power, 0, 0 }; + }); } + private void updateAlignAnimation() { timer_align ++; if (timer_align >= period) { @@ -100,43 +111,35 @@ private void updateAlignAnimation() { } }); } + + public void update(boolean aligning, boolean inRange) { + AnimationState state = AnimationState.Idle; - public void updateIdleAnimation() { - timer_idle ++; - if (timer_idle >= period) { - timer_idle = 0; - } else { - return; - } - - counter_idle += direction_idle; - if (counter_idle == ledCount || counter_idle == -1) { - direction_idle = -direction_idle; - counter_idle += 2 * direction_idle; + if (inRange) { + state = AnimationState.InRange; + } else if (aligning) { + state = AnimationState.Aligning; + } else if (!reflectiveSensor.get()) { + state = AnimationState.ControllingNote; } - iterateAllLeds((index) -> { - double percent = buffer.getLED(index).red - minPower / 1d / maxPower - decay; - percent = Math.max(percent, 0); - if (index == counter_idle) { - percent = 1.0; - } - - final double power = (percent * (maxPower - minPower)) + minPower; - return new Integer[] { (int)power, 0, 0 }; - }); - } - public void setUniformColor(int r, int g, int b){ - iterateAllLeds((index) -> { - return new Integer[] {r, g, b}; - }); - } - public void iterateAllLeds(Function function){ - for(int i = 0; i