mirror of
https://github.com/Team4388/Robot-Essentials.git
synced 2026-06-09 00:38:01 -06:00
Implement new Command Based Framework
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -7,44 +7,28 @@
|
||||
|
||||
package frc4388.robot.commands.LED;
|
||||
|
||||
import frc4388.robot.RobotContainer;
|
||||
import edu.wpi.first.wpilibj2.command.InstantCommand;
|
||||
|
||||
import frc4388.robot.constants.LEDPatterns;
|
||||
import frc4388.robot.subsystems.LED;
|
||||
|
||||
import edu.wpi.first.wpilibj.command.Command;
|
||||
|
||||
public class SetLEDPattern extends Command {
|
||||
// NOTE: Consider using this command inline, rather than writing a subclass. For more
|
||||
// information, see:
|
||||
// https://docs.wpilib.org/en/latest/docs/software/commandbased/convenience-features.html
|
||||
public class SetLEDPattern extends InstantCommand {
|
||||
|
||||
private final LED m_led;
|
||||
public static LEDPatterns m_pattern;
|
||||
|
||||
public SetLEDPattern(LEDPatterns pattern) {
|
||||
public SetLEDPattern(LED subsystem, LEDPatterns pattern) {
|
||||
m_led = subsystem;
|
||||
m_pattern = pattern;
|
||||
addRequirements(m_led);
|
||||
}
|
||||
|
||||
// Called just before this Command runs the first time
|
||||
// Called when the command is initially scheduled.
|
||||
@Override
|
||||
protected void initialize() {
|
||||
}
|
||||
|
||||
// Called repeatedly when this Command is scheduled to run
|
||||
@Override
|
||||
protected void execute() {
|
||||
RobotContainer.m_robotLED.setPattern(m_pattern);
|
||||
}
|
||||
|
||||
// Make this return true when this Command no longer needs to run execute()
|
||||
@Override
|
||||
protected boolean isFinished() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Called once after isFinished returns true
|
||||
@Override
|
||||
protected void end() {
|
||||
}
|
||||
|
||||
// Called when another command which requires one or more of the same
|
||||
// subsystems is scheduled to run
|
||||
@Override
|
||||
protected void interrupted() {
|
||||
public void initialize() {
|
||||
m_led.setPattern(m_pattern);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user