From 2552c790601e542ece79301cd1e2dd313d253e0a Mon Sep 17 00:00:00 2001 From: Cindy Zhang Date: Tue, 16 Feb 2016 16:01:11 -0800 Subject: [PATCH] add multiple diff buttons to save values into diff indexes of potentiometer array of angles --- src/org/usfirst/frc/team3501/robot/OI.java | 16 ++++++++++++---- .../robot/commands/intakearm/RecordPotAngle.java | 9 ++++++--- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/org/usfirst/frc/team3501/robot/OI.java b/src/org/usfirst/frc/team3501/robot/OI.java index c2a09d20..dbd67d94 100644 --- a/src/org/usfirst/frc/team3501/robot/OI.java +++ b/src/org/usfirst/frc/team3501/robot/OI.java @@ -10,7 +10,10 @@ public class OI { public static Joystick leftJoystick; public static Joystick rightJoystick; - public static Button recordPotAngle; + public static Button recordPotAngle1; + public static Button recordPotAngle2; + public static Button recordPotAngle3; + public static Button recordPotAngle4; // // first column of arcade buttons - getting past defenses // public static DigitalButton passPortcullis; @@ -43,9 +46,14 @@ public class OI { leftJoystick = new Joystick(Constants.OI.LEFT_STICK_PORT); rightJoystick = new Joystick(Constants.OI.RIGHT_STICK_PORT); - recordPotAngle = new JoystickButton(leftJoystick, - Constants.OI.LEFT_JOYSTICK_TOP_CENTER_PORT); - recordPotAngle.whenPressed(new RecordPotAngle()); + recordPotAngle1 = new JoystickButton(leftJoystick, 4); + recordPotAngle1.whenPressed(new RecordPotAngle(0)); + recordPotAngle2 = new JoystickButton(leftJoystick, 3); + recordPotAngle2.whenPressed(new RecordPotAngle(1)); + recordPotAngle3 = new JoystickButton(leftJoystick, 5); + recordPotAngle3.whenPressed(new RecordPotAngle(2)); + recordPotAngle4 = new JoystickButton(leftJoystick, 2); + recordPotAngle4.whenPressed(new RecordPotAngle(3)); // passPortcullis = new DigitalButton( // new DigitalInput(Constants.OI.PASS_PORTCULLIS_PORT)); diff --git a/src/org/usfirst/frc/team3501/robot/commands/intakearm/RecordPotAngle.java b/src/org/usfirst/frc/team3501/robot/commands/intakearm/RecordPotAngle.java index bb9a0120..589bcb73 100644 --- a/src/org/usfirst/frc/team3501/robot/commands/intakearm/RecordPotAngle.java +++ b/src/org/usfirst/frc/team3501/robot/commands/intakearm/RecordPotAngle.java @@ -9,14 +9,17 @@ import edu.wpi.first.wpilibj.command.Command; */ public class RecordPotAngle extends Command { - public RecordPotAngle() { + private static int index; + + public RecordPotAngle(int index) { requires(Robot.intakeArm); + this.index = index; } // Called just before this Command runs the first time @Override protected void initialize() { - Robot.intakeArm.potAngles[0] = Robot.intakeArm.getArmAngle(); + Robot.intakeArm.potAngles[index] = Robot.intakeArm.getArmAngle(); } // Called repeatedly when this Command is scheduled to run @@ -27,7 +30,7 @@ public class RecordPotAngle extends Command { // Make this return true when this Command no longer needs to run execute() @Override protected boolean isFinished() { - return false; + return true; } // Called once after isFinished returns true -- 2.30.2