8b5cdacb84b0a96ea8be573add14da2e85042ef7
[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.climber.ToggleWinch;
6 import org.usfirst.frc.team3501.robot.commands.driving.ToggleGear;
7 import org.usfirst.frc.team3501.robot.commands.intake.ReverseIntakeContinuous;
8 import org.usfirst.frc.team3501.robot.commands.intake.RunIntakeContinuous;
9 import org.usfirst.frc.team3501.robot.commands.shooter.DecreaseShootingSpeed;
10 import org.usfirst.frc.team3501.robot.commands.shooter.IncreaseShootingSpeed;
11 import org.usfirst.frc.team3501.robot.commands.shooter.ReverseIndexWheelContinuous;
12 import org.usfirst.frc.team3501.robot.commands.shooter.RunFlyWheelContinuous;
13 import org.usfirst.frc.team3501.robot.commands.shooter.RunIndexWheelContinuous;
14
15 import edu.wpi.first.wpilibj.Joystick;
16 import edu.wpi.first.wpilibj.buttons.Button;
17 import edu.wpi.first.wpilibj.buttons.JoystickButton;
18
19 public class OI {
20 private static OI oi;
21 public static Joystick leftJoystick;
22 public static Joystick rightJoystick;
23 public static Button toggleWinch;
24 private boolean isClimbing = false;
25
26 public static Button runIndexWheel;
27 public static Button reverseIndexWheel;
28 public static Button toggleFlyWheel;
29
30 public static Button toggleGear;
31
32 public static Button runIntake;
33 public static Button reverseIntake;
34
35 public static Button increaseShooterSpeed;
36 public static Button decreaseShooterSpeed;
37
38 public OI() {
39 leftJoystick = new Joystick(Constants.OI.LEFT_STICK_PORT);
40 rightJoystick = new Joystick(Constants.OI.RIGHT_STICK_PORT);
41
42 runIndexWheel = new JoystickButton(rightJoystick,
43 Constants.OI.RUN_INDEXWHEEL_PORT);
44 runIndexWheel.whileHeld(new RunIndexWheelContinuous());
45
46 reverseIndexWheel = new JoystickButton(leftJoystick,
47 Constants.OI.REVERSE_INDEXWHEEL_PORT);
48 reverseIndexWheel.whileHeld(new ReverseIndexWheelContinuous());
49
50 toggleFlyWheel = new JoystickButton(rightJoystick,
51 Constants.OI.TOGGLE_FLYWHEEL_PORT);
52 toggleFlyWheel.toggleWhenPressed(new RunFlyWheelContinuous());
53
54 toggleGear = new JoystickButton(leftJoystick,
55 Constants.OI.TOGGLE_GEAR_PORT);
56
57 toggleGear.whenPressed(new ToggleGear());
58
59 runIntake = new JoystickButton(leftJoystick,
60 Constants.OI.RUN_INTAKE_PORT);
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);
69 toggleWinch.whenPressed(new ToggleWinch());
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());
78
79 if (!isClimbing) {
80 toggleWinch.whenPressed(new RunWinchContinuous());
81 isClimbing = true;
82 } else {
83 toggleWinch.whenPressed(new MaintainClimbedPosition());
84 isClimbing = false;
85 }
86 }
87
88 public static OI getOI() {
89 if (oi == null)
90 oi = new OI();
91 return oi;
92 }
93 }