added LED
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
|
||||
package frc.robot;
|
||||
|
||||
import static edu.wpi.first.units.Units.Second;
|
||||
|
||||
import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX;
|
||||
|
||||
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
|
||||
@@ -11,6 +13,7 @@ import edu.wpi.first.wpilibj.util.Color;
|
||||
import edu.wpi.first.wpilibj2.command.Command;
|
||||
import edu.wpi.first.wpilibj2.command.Commands;
|
||||
import edu.wpi.first.wpilibj2.command.RunCommand;
|
||||
import edu.wpi.first.wpilibj2.command.WaitCommand;
|
||||
import edu.wpi.first.wpilibj2.command.button.CommandPS5Controller;
|
||||
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
|
||||
import edu.wpi.first.wpilibj2.command.button.Trigger;
|
||||
@@ -64,9 +67,15 @@ public class RobotContainer {
|
||||
|
||||
Trigger highFiveTrigger = new Trigger(highFive::SwitchDigitalInput);
|
||||
|
||||
highFiveTrigger.whileTrue(
|
||||
new RunCommand(() -> leds.setAll(Color.kRed), leds)
|
||||
highFiveTrigger.onFalse(
|
||||
leds.blinkColorchange(Color.kGreen, Color.kRed, Color.kBlue, 0.5, 2)
|
||||
.andThen(
|
||||
//new WaitCommand(5),
|
||||
leds.setAll(Color.kBlack)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
Shuffleboard.getTab("HighFive")
|
||||
|
||||
@@ -37,15 +37,47 @@ public class LEDs extends SubsystemBase {
|
||||
);
|
||||
}
|
||||
|
||||
public Command blinkColor(Color color, double delayTime) {
|
||||
return Commands.repeatingSequence(
|
||||
setAll(color),
|
||||
new WaitCommand(delayTime),
|
||||
setAll(Color.kBlack),
|
||||
new WaitCommand(delayTime)
|
||||
);
|
||||
|
||||
|
||||
|
||||
public Command blinkColor(Color color, double delayTime, int times) {
|
||||
Command sequence = Commands.none(); // start with an empty command
|
||||
|
||||
for (int i = 0; i < times; i++) {
|
||||
sequence = Commands.sequence(
|
||||
sequence,
|
||||
setAll(color),
|
||||
new WaitCommand(delayTime),
|
||||
setAll(Color.kBlack),
|
||||
new WaitCommand(delayTime)
|
||||
);
|
||||
}
|
||||
|
||||
return sequence;
|
||||
}
|
||||
|
||||
public Command blinkColorchange(Color color, Color color2, Color color3, double delayTime, int times) {
|
||||
Command sequence = Commands.none(); // start with an empty command
|
||||
|
||||
for (int i = 0; i < times; i++) {
|
||||
sequence = Commands.sequence(
|
||||
sequence,
|
||||
setAll(color),
|
||||
new WaitCommand(delayTime),
|
||||
setAll(color2),
|
||||
new WaitCommand(delayTime),
|
||||
setAll(color3),
|
||||
new WaitCommand(delayTime)
|
||||
);
|
||||
}
|
||||
|
||||
return sequence;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Command setAll(Color color) {
|
||||
return runOnce(() -> {
|
||||
for(int i = 0; i < buffer.getLength(); i++) {
|
||||
|
||||
Reference in New Issue
Block a user