Fixed LED modes and drive CAN id

This commit is contained in:
Olivier Demers 2022-05-02 19:17:03 -04:00
parent 4fede0ef59
commit 13d60c54f3
3 changed files with 14 additions and 10 deletions

View File

@ -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;
}

View File

@ -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));
}

View File

@ -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