From 13d60c54f3b295cafa3440f53299126cb9ddf767 Mon Sep 17 00:00:00 2001 From: Olivier Demers Date: Mon, 2 May 2022 19:17:03 -0400 Subject: [PATCH] Fixed LED modes and drive CAN id --- src/main/java/frc/robot/Constants.java | 4 ++-- src/main/java/frc/robot/RobotContainer.java | 4 ++++ src/main/java/frc/robot/subsystems/Led.java | 16 ++++++++-------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 3ebcfb0..1fb2095 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -13,8 +13,8 @@ package frc.robot; * constants are needed, to reduce verbosity. */ public final class Constants { - public static final int MOTEUR_DROIT = 2; - public static final int MOTEUR_GAUCHE = 1; + public static final int MOTEUR_DROIT = 1; + public static final int MOTEUR_GAUCHE = 2; public static final int LED_PORT = 0; } diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index c5a00cb..b82d7e2 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -7,8 +7,10 @@ package frc.robot; import edu.wpi.first.wpilibj.GenericHID; import edu.wpi.first.wpilibj.XboxController; import edu.wpi.first.wpilibj2.command.Command; +import edu.wpi.first.wpilibj2.command.RunCommand; import frc.robot.commands.Drive; import frc.robot.subsystems.DriveTrain; +import frc.robot.subsystems.Led; /** * This class is where the bulk of the robot should be declared. Since Command-based is a @@ -22,6 +24,7 @@ public class RobotContainer { // The robot's subsystems and commands are defined here... private final DriveTrain driveTrain = new DriveTrain(); + private final Led led = new Led(); private final Drive drive = new Drive(driveTrain, () -> -controller.getLeftY(), () -> controller.getLeftX()); @@ -31,6 +34,7 @@ public class RobotContainer { configureButtonBindings(); driveTrain.setDefaultCommand(drive); + led.setDefaultCommand(new RunCommand(() -> led.rainbow(), led)); } diff --git a/src/main/java/frc/robot/subsystems/Led.java b/src/main/java/frc/robot/subsystems/Led.java index aa9af4a..2939765 100644 --- a/src/main/java/frc/robot/subsystems/Led.java +++ b/src/main/java/frc/robot/subsystems/Led.java @@ -37,9 +37,9 @@ public class Led extends SubsystemBase { led.setData(buffer); led.start(); - layout.add(new RunCommand(() -> rainbow(), this)); - layout.add(new RunCommand(() -> colorCycle(), this)); - layout.add(new RunCommand(() -> chase(), this)); + layout.add(new RunCommand(() -> rainbow(), this).withName("Rainbow")); + layout.add(new RunCommand(() -> colorCycle(), this).withName("Color Cycle")); + layout.add(new RunCommand(() -> chase(), this).withName("Chase")); } public void rainbow() { @@ -48,15 +48,15 @@ public class Led extends SubsystemBase { buffer.setHSV(i, hue, 255, 128); } rainbowFirstPixelHue += 3; - rainbowFirstPixelHue %= 181; + rainbowFirstPixelHue %= 180; } public void colorCycle() { for (int i = 0; i < buffer.getLength(); i++) { buffer.setHSV(i, cycleHue, 255, 128); } - cycleHue += 2; - cycleHue %= 181; + cycleHue += 1; + cycleHue %= 180; } public void chase() { @@ -78,8 +78,8 @@ public class Led extends SubsystemBase { } } } - chaseFirstPixel += 2; - chaseFirstPixel %= 181; + chaseFirstPixel += 1; + chaseFirstPixel %= buffer.getLength(); } @Override