From 42421b51afb115a0e892fb995b86f60d5f956aab Mon Sep 17 00:00:00 2001 From: aarav18 Date: Sat, 12 Mar 2022 17:43:17 -0700 Subject: [PATCH] change --- src/main/java/frc4388/robot/Robot.java | 7 ++++ .../java/frc4388/robot/RobotContainer.java | 36 +++++++++++-------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/main/java/frc4388/robot/Robot.java b/src/main/java/frc4388/robot/Robot.java index e89f8d9..416d090 100644 --- a/src/main/java/frc4388/robot/Robot.java +++ b/src/main/java/frc4388/robot/Robot.java @@ -270,6 +270,13 @@ public class Robot extends TimedRobot { */ @Override public void teleopPeriodic() { + boolean robotManual = m_robotContainer.manual; + + if (robotManual) { + m_robotContainer.configureManualButtonBindings(); + } else { + m_robotContainer.configureAutomaticButtonBindings(); + } } @Override diff --git a/src/main/java/frc4388/robot/RobotContainer.java b/src/main/java/frc4388/robot/RobotContainer.java index e0241b7..df8cd63 100644 --- a/src/main/java/frc4388/robot/RobotContainer.java +++ b/src/main/java/frc4388/robot/RobotContainer.java @@ -132,6 +132,9 @@ public class RobotContainer { // Function that removes the ".path" from the end of a string. private static final Function PATH_EXTENSION_REMOVER = ((Function) Pattern .compile(".path")::matcher).andThen(m -> m.replaceFirst("")); + + + public boolean manual = false; /** * The container for the robot. Contains subsystems, OI devices, and commands. @@ -292,17 +295,13 @@ public class RobotContainer { // new JoystickButton(getOperatorController(), XboxController.Button.kB.value) // .whenPressed(new TrackTarget(m_robotTurret, m_robotBoomBoom, m_robotHood, m_robotSwerveDrive, m_robotVisionOdometry)); - - - - /* Button Box Buttons */ new JoystickButton(getButtonFox(), ButtonBox.Button.kLeftSwitch.value) - .whenPressed(new InstantCommand(() -> configureManualButtonBindings())) - .whenReleased(new InstantCommand(() -> configureButtonBindings())); + .whenPressed(new RunCommand(() -> setManual(true))) + .whenReleased(new RunCommand(() -> setManual(false))); - new JoystickButton(getButtonFox(), ButtonBox.Button.kMiddleSwitch.value) - .whileHeld(new RunCommand(() -> System.out.println("MiddleSwitch"))); + // new JoystickButton(getButtonFox(), ButtonBox.Button.kMiddleSwitch.value) + // .whileHeld(new RunCommand(() -> System.out.println("MiddleSwitch"))); new JoystickButton(getButtonFox(), ButtonBox.Button.kRightSwitch.value) .whileHeld(new RunCommand(() -> System.out.println("RightSwitch"))); @@ -314,13 +313,18 @@ public class RobotContainer { .whileHeld(new RunCommand(() -> System.out.println("RightButton"))); } - public void configureManualButtonBindings() - { + public void configureManualButtonBindings() { + new JoystickButton(getButtonFox(), ButtonBox.Button.kMiddleSwitch.value) - .whileHeld(new RunCommand(() -> System.out.println("Deez Nuts"))); - - new JoystickButton(getButtonFox(), ButtonBox.Button.kRightSwitch.value) - .whileHeld(new RunCommand(() -> System.out.println("Inna mouth"))); + .whileHeld(new RunCommand(() -> System.out.println("MANUAL"))); + + } + + public void configureAutomaticButtonBindings() { + + new JoystickButton(getButtonFox(), ButtonBox.Button.kMiddleSwitch.value) + .whileHeld(new RunCommand(() -> System.out.println("AUTOMATIC"))); + } /** @@ -363,6 +367,10 @@ public class RobotContainer { return m_buttonFox; } + public void setManual(boolean set) { + this.manual = set; + } + /** * Get odometry. *