Add JoystickButton objects and constants for Drivetrain, Climer, Intake, and Shooter
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / OI.java
1 package org.usfirst.frc.team3501.robot;
2
3 import org.usfirst.frc.team3501.robot.commands.climber.MaintainClimbedPosition;
4 import org.usfirst.frc.team3501.robot.commands.climber.RunWinchContinuous;
5 import org.usfirst.frc.team3501.robot.commands.driving.ToggleGear;
6 import org.usfirst.frc.team3501.robot.commands.intake.ReverseIntakeContinuous;
7 import org.usfirst.frc.team3501.robot.commands.intake.RunIntakeContinuous;
8 import org.usfirst.frc.team3501.robot.commands.shooter.ReverseIndexWheelContinuous;
9 import org.usfirst.frc.team3501.robot.commands.shooter.RunFlyWheelContinuous;
10 import org.usfirst.frc.team3501.robot.commands.shooter.RunIndexWheelContinuous;
11
12 import edu.wpi.first.wpilibj.Joystick;
13 import edu.wpi.first.wpilibj.buttons.Button;
14 import edu.wpi.first.wpilibj.buttons.JoystickButton;
15
16 public class OI {
17 private static OI oi;
18 public static Joystick leftJoystick;
19 public static Joystick rightJoystick;
20 public static Button toggleWinch;
21 private boolean isClimbing = false;
22
23 public static Button runIndexWheel;
24 public static Button reverseIndexWheel;
25 public static Button toggleFlyWheel;
26
27 public static Button toggleGear;
28
29 public static Button runIntake;
30 public static Button reverseIntake;
31
32 public OI() {
33 leftJoystick = new Joystick(Constants.OI.LEFT_STICK_PORT);
34 rightJoystick = new Joystick(Constants.OI.RIGHT_STICK_PORT);
35
36 runIndexWheel = new JoystickButton(leftJoystick,
37 Constants.OI.TOGGLE_INDEXWHEEL_PORT);
38 runIndexWheel.whileHeld(new RunIndexWheelContinuous());
39
40 reverseIndexWheel = new JoystickButton(leftJoystick,
41 Constants.OI.REVERSE_INDEXWHEEL_PORT);
42 reverseIndexWheel.whileHeld(new ReverseIndexWheelContinuous());
43
44 toggleFlyWheel = new JoystickButton(leftJoystick,
45 Constants.OI.TOGGLE_FLYWHEEL_PORT);
46 toggleFlyWheel.toggleWhenPressed(new RunFlyWheelContinuous());
47
48 toggleGear = new JoystickButton(leftJoystick,
49 Constants.OI.TOGGLE_GEAR_PORT);
50 toggleGear.whenPressed(new ToggleGear());
51
52 runIntake = new JoystickButton(leftJoystick,
53 Constants.OI.TOGGLE_INTAKE_PORT);
54 runIntake.whileHeld(new RunIntakeContinuous());
55
56 reverseIntake = new JoystickButton(leftJoystick,
57 Constants.OI.REVERSE_INTAKE_PORT);
58 reverseIntake.whileHeld(new ReverseIntakeContinuous());
59
60 toggleWinch = new JoystickButton(leftJoystick,
61 Constants.OI.TOGGLE_WINCH_PORT);
62 if (!isClimbing) {
63 toggleWinch.whenPressed(new RunWinchContinuous());
64 isClimbing = true;
65 } else {
66 toggleWinch.whenPressed(new MaintainClimbedPosition());
67 isClimbing = false;
68 }
69 }
70
71 public static OI getOI() {
72 if (oi == null)
73 oi = new OI();
74 return oi;
75 }
76 }