Skip to content

Commit

Permalink
Stop test mode crashing
Browse files Browse the repository at this point in the history
  • Loading branch information
nab138 committed Feb 13, 2025
1 parent 64639df commit 18ea6a1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
5 changes: 5 additions & 0 deletions simgui.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
"window": {
"visible": true
}
},
"/SmartDashboard/Scheduler": {
"window": {
"visible": true
}
}
}
},
Expand Down
1 change: 0 additions & 1 deletion src/main/java/frc/robot/subsystems/LEDs/LEDs.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package frc.robot.subsystems.LEDs;

import edu.wpi.first.units.measure.Time;
import edu.wpi.first.wpilibj.LEDPattern;
import edu.wpi.first.wpilibj.util.Color;
import edu.wpi.first.wpilibj2.command.Command;
Expand Down
29 changes: 17 additions & 12 deletions src/main/java/frc/robot/subsystems/LEDs/LEDsIORio.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package frc.robot.subsystems.LEDs;


import edu.wpi.first.wpilibj.AddressableLED;
import edu.wpi.first.wpilibj.AddressableLEDBuffer;
import edu.wpi.first.wpilibj.LEDPattern;
Expand All @@ -17,8 +16,7 @@ public class LEDsIORio implements LEDsIO {
private final AddressableLED LEDStrip = new AddressableLED(PWM);
private final AddressableLEDBuffer buffer = new AddressableLEDBuffer(length);


public void LEDsIORio() {
public LEDsIORio() {
LEDStrip.setLength(buffer.getLength());
LEDStrip.start();
}
Expand All @@ -45,18 +43,22 @@ public void setSpinningColor(Color color1, Color color2) {
LEDStrip.setData(buffer);
}

@Override
@Override
public void makeMorseCode(String phrase) {
if (ToMorseCode.toMorseCode(phrase).get(LEDsIOInputs.indexOfStr).toString().charAt(LEDsIOInputs.indexOfChar) == '.') {
if (ToMorseCode.toMorseCode(phrase).get(LEDsIOInputs.indexOfStr).toString()
.charAt(LEDsIOInputs.indexOfChar) == '.') {
LEDsIOInputs.currentTime = Seconds.of(edu.wpi.first.wpilibj.Timer.getFPGATimestamp());
setSolidColor(LEDPattern.solid(Color.kYellow));
if (LEDsIOInputs.timeOfDot.plus(LEDsIOInputs.currentTime).lt(Seconds.of(edu.wpi.first.wpilibj.Timer.getFPGATimestamp()))) {
if (ToMorseCode.toMorseCode(phrase).get(LEDsIOInputs.indexOfStr).toString().length() < LEDsIOInputs.indexOfChar) {
if (LEDsIOInputs.timeOfDot.plus(LEDsIOInputs.currentTime)
.lt(Seconds.of(edu.wpi.first.wpilibj.Timer.getFPGATimestamp()))) {
if (ToMorseCode.toMorseCode(phrase).get(LEDsIOInputs.indexOfStr).toString()
.length() < LEDsIOInputs.indexOfChar) {
LEDsIOInputs.indexOfChar = 0;
LEDsIOInputs.indexOfStr++;
LEDsIOInputs.currentTime = Seconds.of(edu.wpi.first.wpilibj.Timer.getFPGATimestamp());
setSolidColor(LEDPattern.solid(Color.kYellow));
if (LEDsIOInputs.currentTime.lt(LEDsIOInputs.timeOfDot.plus(LEDsIOInputs.timeOfDot).plus(LEDsIOInputs.timeOfDot))) {
if (LEDsIOInputs.currentTime
.lt(LEDsIOInputs.timeOfDot.plus(LEDsIOInputs.timeOfDot).plus(LEDsIOInputs.timeOfDot))) {
setSolidColor(LEDPattern.solid(Color.kPurple));
}
} else {
Expand All @@ -67,19 +69,22 @@ public void makeMorseCode(String phrase) {
} else {
LEDsIOInputs.currentTime = Seconds.of(edu.wpi.first.wpilibj.Timer.getFPGATimestamp());
setSolidColor(LEDPattern.solid(Color.kYellow));
if (LEDsIOInputs.currentTime.plus(LEDsIOInputs.timeOfDash).lt(Seconds.of(edu.wpi.first.wpilibj.Timer.getFPGATimestamp()))) {
if (ToMorseCode.toMorseCode(phrase).get(LEDsIOInputs.indexOfStr).toString().length() < LEDsIOInputs.indexOfChar) {
if (LEDsIOInputs.currentTime.plus(LEDsIOInputs.timeOfDash)
.lt(Seconds.of(edu.wpi.first.wpilibj.Timer.getFPGATimestamp()))) {
if (ToMorseCode.toMorseCode(phrase).get(LEDsIOInputs.indexOfStr).toString()
.length() < LEDsIOInputs.indexOfChar) {
LEDsIOInputs.indexOfChar = 0;
LEDsIOInputs.indexOfStr++;
LEDsIOInputs.currentTime = Seconds.of(edu.wpi.first.wpilibj.Timer.getFPGATimestamp());
setSolidColor(LEDPattern.solid(Color.kYellow));
if (LEDsIOInputs.currentTime.lt(LEDsIOInputs.timeOfDot.plus(LEDsIOInputs.timeOfDot).plus(LEDsIOInputs.timeOfDot))) {
if (LEDsIOInputs.currentTime
.lt(LEDsIOInputs.timeOfDot.plus(LEDsIOInputs.timeOfDot).plus(LEDsIOInputs.timeOfDot))) {
setSolidColor(LEDPattern.solid(Color.kPurple));
}
} else {
LEDsIOInputs.indexOfChar++;
}
}
}
}
}
}

0 comments on commit 18ea6a1

Please sign in to comment.