Add JoystickButton objects and constants for Drivetrain, Climer, Intake, and Shooter
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / OI.java
CommitLineData
38a404b3
KZ
1package org.usfirst.frc.team3501.robot;
2
ffb43c5c
RR
3import org.usfirst.frc.team3501.robot.commands.climber.MaintainClimbedPosition;
4import org.usfirst.frc.team3501.robot.commands.climber.RunWinchContinuous;
9dc69158 5import org.usfirst.frc.team3501.robot.commands.climber.ToggleWinch;
7935bf26 6import org.usfirst.frc.team3501.robot.commands.driving.ToggleGear;
cef1f36d
RR
7import org.usfirst.frc.team3501.robot.commands.intake.ReverseIntakeContinuous;
8import org.usfirst.frc.team3501.robot.commands.intake.RunIntakeContinuous;
5e93f308
CZ
9import org.usfirst.frc.team3501.robot.commands.shooter.DecreaseShootingSpeed;
10import org.usfirst.frc.team3501.robot.commands.shooter.IncreaseShootingSpeed;
cef1f36d
RR
11import org.usfirst.frc.team3501.robot.commands.shooter.ReverseIndexWheelContinuous;
12import org.usfirst.frc.team3501.robot.commands.shooter.RunFlyWheelContinuous;
13import org.usfirst.frc.team3501.robot.commands.shooter.RunIndexWheelContinuous;
7935bf26 14
38a404b3 15import edu.wpi.first.wpilibj.Joystick;
de8c65d3
SG
16import edu.wpi.first.wpilibj.buttons.Button;
17import edu.wpi.first.wpilibj.buttons.JoystickButton;
38a404b3
KZ
18
19public class OI {
cca02549 20 private static OI oi;
38a404b3
KZ
21 public static Joystick leftJoystick;
22 public static Joystick rightJoystick;
83fa645c 23 public static Button toggleWinch;
ffb43c5c 24 private boolean isClimbing = false;
38a404b3 25
cef1f36d
RR
26 public static Button runIndexWheel;
27 public static Button reverseIndexWheel;
2291f7b3 28 public static Button toggleFlyWheel;
29
7935bf26
AD
30 public static Button toggleGear;
31
cef1f36d
RR
32 public static Button runIntake;
33 public static Button reverseIntake;
34
5e93f308
CZ
35 public static Button increaseShooterSpeed;
36 public static Button decreaseShooterSpeed;
37
38a404b3
KZ
38 public OI() {
39 leftJoystick = new Joystick(Constants.OI.LEFT_STICK_PORT);
40 rightJoystick = new Joystick(Constants.OI.RIGHT_STICK_PORT);
cef1f36d 41
5e93f308
CZ
42 runIndexWheel = new JoystickButton(rightJoystick,
43 Constants.OI.RUN_INDEXWHEEL_PORT);
cef1f36d
RR
44 runIndexWheel.whileHeld(new RunIndexWheelContinuous());
45
46 reverseIndexWheel = new JoystickButton(leftJoystick,
47 Constants.OI.REVERSE_INDEXWHEEL_PORT);
48 reverseIndexWheel.whileHeld(new ReverseIndexWheelContinuous());
49
5e93f308 50 toggleFlyWheel = new JoystickButton(rightJoystick,
2291f7b3 51 Constants.OI.TOGGLE_FLYWHEEL_PORT);
cef1f36d
RR
52 toggleFlyWheel.toggleWhenPressed(new RunFlyWheelContinuous());
53
7935bf26
AD
54 toggleGear = new JoystickButton(leftJoystick,
55 Constants.OI.TOGGLE_GEAR_PORT);
d0b0d55d 56
7935bf26 57 toggleGear.whenPressed(new ToggleGear());
cef1f36d
RR
58
59 runIntake = new JoystickButton(leftJoystick,
5e93f308 60 Constants.OI.RUN_INTAKE_PORT);
cef1f36d
RR
61 runIntake.whileHeld(new RunIntakeContinuous());
62
63 reverseIntake = new JoystickButton(leftJoystick,
64 Constants.OI.REVERSE_INTAKE_PORT);
65 reverseIntake.whileHeld(new ReverseIntakeContinuous());
66
67 toggleWinch = new JoystickButton(leftJoystick,
68 Constants.OI.TOGGLE_WINCH_PORT);
25ef99e6 69 toggleWinch.whenPressed(new ToggleWinch());
5e93f308
CZ
70
71 increaseShooterSpeed = new JoystickButton(leftJoystick,
72 Constants.OI.INCREASE_SHOOTER_SPEED_PORT);
73 increaseShooterSpeed.whenPressed(new IncreaseShootingSpeed());
74
75 decreaseShooterSpeed = new JoystickButton(leftJoystick,
76 Constants.OI.DECREASE_SHOOTER_SPEED_PORT);
77 decreaseShooterSpeed.whenPressed(new DecreaseShootingSpeed());
ffb43c5c
RR
78
79 if (!isClimbing) {
80 toggleWinch.whenPressed(new RunWinchContinuous());
81 isClimbing = true;
82 } else {
83 toggleWinch.whenPressed(new MaintainClimbedPosition());
84 isClimbing = false;
85 }
38a404b3 86 }
cf086549
SG
87
88 public static OI getOI() {
89 if (oi == null)
90 oi = new OI();
91 return oi;
cca02549 92 }
38a404b3 93}