From fea24831cfa5bd4673460a9066e4fd79cfbcfd23 Mon Sep 17 00:00:00 2001 From: FRCTeam3042 Date: Sat, 24 Oct 2015 11:16:36 -0500 Subject: [PATCH 1/2] Straight Drive Triggers --- src/org/team3042/sweep/OI.java | 6 +++++- .../sweep/commands/DriveTrainTankDrive.java | 14 +++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/org/team3042/sweep/OI.java b/src/org/team3042/sweep/OI.java index 69ea5f1..36ad820 100644 --- a/src/org/team3042/sweep/OI.java +++ b/src/org/team3042/sweep/OI.java @@ -2,6 +2,8 @@ package org.team3042.sweep; import edu.wpi.first.wpilibj.Joystick; +import edu.wpi.first.wpilibj.buttons.Button; +import edu.wpi.first.wpilibj.buttons.JoystickButton; /** * This class is the glue that binds the controls on the physical operator @@ -16,6 +18,8 @@ public class OI { public Joystick stickRight = new Joystick( RobotMap.RIGHT_JOY_USB_PORT_2); // Button button = new JoystickButton(stick, buttonNumber); + public Button lTrigger = new JoystickButton(stickLeft, 1); + public Button rTrigger = new JoystickButton(stickRight, 1); // Another type of button you can create is a DigitalIOButton, which is // a button or switch hooked up to the cypress module. These are useful if // you want to build a customized operator interface. @@ -39,6 +43,6 @@ public class OI { // Start the command when the button is released and let it run the command // until it is finished as determined by it's isFinished method. - // button.whenReleased(new ExampleCommand()); + // button.whenReleased(new ExampleCommand()); } diff --git a/src/org/team3042/sweep/commands/DriveTrainTankDrive.java b/src/org/team3042/sweep/commands/DriveTrainTankDrive.java index edb506f..63adeec 100644 --- a/src/org/team3042/sweep/commands/DriveTrainTankDrive.java +++ b/src/org/team3042/sweep/commands/DriveTrainTankDrive.java @@ -11,6 +11,9 @@ */ public class DriveTrainTankDrive extends CommandBase { + private static double leftPower; + private static double rightPower; + public DriveTrainTankDrive() { // Use requires() here to declare subsystem dependencies // eg. requires(chassis); @@ -23,7 +26,16 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run protected void execute() { - driveTrain.drive(-oi.stickLeft.getY(), -oi.stickRight.getY()); + leftPower = -oi.stickLeft.getY(); + rightPower = -oi.stickRight.getY(); + + if(oi.lTrigger.get()){ + rightPower = leftPower; + } + else if (oi.rTrigger.get()){ + leftPower = rightPower; + } + driveTrain.drive(leftPower, rightPower); } // Make this return true when this Command no longer needs to run execute() From 3efc4635c7eb8ae239b5749b0914eea17d448775 Mon Sep 17 00:00:00 2001 From: zneb97 Date: Tue, 27 Oct 2015 19:21:36 -0500 Subject: [PATCH 2/2] Update OI.java --- src/org/team3042/sweep/OI.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/team3042/sweep/OI.java b/src/org/team3042/sweep/OI.java index 36ad820..a81fc65 100644 --- a/src/org/team3042/sweep/OI.java +++ b/src/org/team3042/sweep/OI.java @@ -43,6 +43,6 @@ public class OI { // Start the command when the button is released and let it run the command // until it is finished as determined by it's isFinished method. - // button.whenReleased(new ExampleCommand()); + }