Fixed LED modes and drive CAN id
This commit is contained in:
parent
4fede0ef59
commit
13d60c54f3
@ -13,8 +13,8 @@ package frc.robot;
|
|||||||
* constants are needed, to reduce verbosity.
|
* constants are needed, to reduce verbosity.
|
||||||
*/
|
*/
|
||||||
public final class Constants {
|
public final class Constants {
|
||||||
public static final int MOTEUR_DROIT = 2;
|
public static final int MOTEUR_DROIT = 1;
|
||||||
public static final int MOTEUR_GAUCHE = 1;
|
public static final int MOTEUR_GAUCHE = 2;
|
||||||
|
|
||||||
public static final int LED_PORT = 0;
|
public static final int LED_PORT = 0;
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,10 @@ package frc.robot;
|
|||||||
import edu.wpi.first.wpilibj.GenericHID;
|
import edu.wpi.first.wpilibj.GenericHID;
|
||||||
import edu.wpi.first.wpilibj.XboxController;
|
import edu.wpi.first.wpilibj.XboxController;
|
||||||
import edu.wpi.first.wpilibj2.command.Command;
|
import edu.wpi.first.wpilibj2.command.Command;
|
||||||
|
import edu.wpi.first.wpilibj2.command.RunCommand;
|
||||||
import frc.robot.commands.Drive;
|
import frc.robot.commands.Drive;
|
||||||
import frc.robot.subsystems.DriveTrain;
|
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
|
* 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...
|
// The robot's subsystems and commands are defined here...
|
||||||
private final DriveTrain driveTrain = new DriveTrain();
|
private final DriveTrain driveTrain = new DriveTrain();
|
||||||
|
private final Led led = new Led();
|
||||||
|
|
||||||
private final Drive drive = new Drive(driveTrain, () -> -controller.getLeftY(), () -> controller.getLeftX());
|
private final Drive drive = new Drive(driveTrain, () -> -controller.getLeftY(), () -> controller.getLeftX());
|
||||||
|
|
||||||
@ -31,6 +34,7 @@ public class RobotContainer {
|
|||||||
configureButtonBindings();
|
configureButtonBindings();
|
||||||
|
|
||||||
driveTrain.setDefaultCommand(drive);
|
driveTrain.setDefaultCommand(drive);
|
||||||
|
led.setDefaultCommand(new RunCommand(() -> led.rainbow(), led));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,9 +37,9 @@ public class Led extends SubsystemBase {
|
|||||||
led.setData(buffer);
|
led.setData(buffer);
|
||||||
led.start();
|
led.start();
|
||||||
|
|
||||||
layout.add(new RunCommand(() -> rainbow(), this));
|
layout.add(new RunCommand(() -> rainbow(), this).withName("Rainbow"));
|
||||||
layout.add(new RunCommand(() -> colorCycle(), this));
|
layout.add(new RunCommand(() -> colorCycle(), this).withName("Color Cycle"));
|
||||||
layout.add(new RunCommand(() -> chase(), this));
|
layout.add(new RunCommand(() -> chase(), this).withName("Chase"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rainbow() {
|
public void rainbow() {
|
||||||
@ -48,15 +48,15 @@ public class Led extends SubsystemBase {
|
|||||||
buffer.setHSV(i, hue, 255, 128);
|
buffer.setHSV(i, hue, 255, 128);
|
||||||
}
|
}
|
||||||
rainbowFirstPixelHue += 3;
|
rainbowFirstPixelHue += 3;
|
||||||
rainbowFirstPixelHue %= 181;
|
rainbowFirstPixelHue %= 180;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void colorCycle() {
|
public void colorCycle() {
|
||||||
for (int i = 0; i < buffer.getLength(); i++) {
|
for (int i = 0; i < buffer.getLength(); i++) {
|
||||||
buffer.setHSV(i, cycleHue, 255, 128);
|
buffer.setHSV(i, cycleHue, 255, 128);
|
||||||
}
|
}
|
||||||
cycleHue += 2;
|
cycleHue += 1;
|
||||||
cycleHue %= 181;
|
cycleHue %= 180;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void chase() {
|
public void chase() {
|
||||||
@ -78,8 +78,8 @@ public class Led extends SubsystemBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
chaseFirstPixel += 2;
|
chaseFirstPixel += 1;
|
||||||
chaseFirstPixel %= 181;
|
chaseFirstPixel %= buffer.getLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user