diff --git a/tasks/lesson2-indexer-task/simgui-ds.json b/tasks/lesson2-indexer-task/simgui-ds.json index 69b1a3c..2bf389e 100644 --- a/tasks/lesson2-indexer-task/simgui-ds.json +++ b/tasks/lesson2-indexer-task/simgui-ds.json @@ -1,4 +1,9 @@ { + "Keyboard 0 Settings": { + "window": { + "visible": true + } + }, "keyboardJoysticks": [ { "axisConfig": [ diff --git a/tasks/lesson2-indexer-task/src/main/java/frc/robot/RobotContainer.java b/tasks/lesson2-indexer-task/src/main/java/frc/robot/RobotContainer.java index 1500ca0..e2d0df7 100644 --- a/tasks/lesson2-indexer-task/src/main/java/frc/robot/RobotContainer.java +++ b/tasks/lesson2-indexer-task/src/main/java/frc/robot/RobotContainer.java @@ -19,9 +19,9 @@ public class RobotContainer { public RobotContainer() { configureBindings(); } - + private void configureBindings() { - // TODO: Bind indexForSeconds(1.5) to joystick button 1 + joystick.button(1).onTrue(indexer.indexForSeconds(1.5)); } public Command getAutonomousCommand() { diff --git a/tasks/lesson2-indexer-task/src/main/java/frc/robot/subsystems/Indexer.java b/tasks/lesson2-indexer-task/src/main/java/frc/robot/subsystems/Indexer.java index e89f0e5..75d9e4f 100644 --- a/tasks/lesson2-indexer-task/src/main/java/frc/robot/subsystems/Indexer.java +++ b/tasks/lesson2-indexer-task/src/main/java/frc/robot/subsystems/Indexer.java @@ -5,21 +5,23 @@ package frc.robot.subsystems; import edu.wpi.first.wpilibj2.command.SubsystemBase; +import edu.wpi.first.wpilibj2.command.Command; +import edu.wpi.first.wpilibj2.command.Commands; public class Indexer extends SubsystemBase { - // TODO: Add indexing state variable here - + public boolean indexing; // Index State Variable + /** Creates a new Indexer subsystem. */ public Indexer() {} /** Starts the indexing process. */ public void startIndexing() { - // TODO: Set indexing state to true + indexing = true; // Set indexing to True } /** Stops the indexing process. */ public void stopIndexing() { - // TODO: Set indexing state to false + indexing = false; // Set indexing to False } /** @@ -28,11 +30,20 @@ public void stopIndexing() { * @return true if indexing, false otherwise */ public boolean isIndexing() { - // TODO: Return indexing state - return false; + return indexing; // Return Value of Indexing } - // TODO: Implement indexForSeconds() command factory + /** + * Returns a command that start indexing, waits for seconds, then stops indexing. + * + * @param seconds + * @return Command Object + */ + public Command indexForSeconds(double seconds) { + return Commands.runOnce(() -> startIndexing()) // Return Value of indexForSeconds + .andThen(Commands.waitSeconds(seconds)) + .andThen(() -> stopIndexing()); + } @Override public void periodic() {