Added all of the main joystick buttons and connected them with commands
[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.commandgroups.PrepareToShoot;
4 import org.usfirst.frc.team3501.robot.commandgroups.Shoot;
5 import org.usfirst.frc.team3501.robot.commands.climber.RunWinchContinuous;
6 import org.usfirst.frc.team3501.robot.commands.driving.ToggleGear;
7 import org.usfirst.frc.team3501.robot.commands.driving.Turn90Left;
8 import org.usfirst.frc.team3501.robot.commands.driving.Turn90Right;
9 import org.usfirst.frc.team3501.robot.commands.intake.ReverseIntakeContinuous;
10 import org.usfirst.frc.team3501.robot.commands.intake.RunIntakeContinuous;
11 import org.usfirst.frc.team3501.robot.commands.intake.StopIntake;
12 import org.usfirst.frc.team3501.robot.commands.shooter.DecreaseShootingSpeed;
13 import org.usfirst.frc.team3501.robot.commands.shooter.IncreaseShootingSpeed;
14 import org.usfirst.frc.team3501.robot.commands.shooter.RunIndexWheelContinuous;
15 import org.usfirst.frc.team3501.robot.commands.shooter.StopIndexWheel;
16
17 import edu.wpi.first.wpilibj.Joystick;
18 import edu.wpi.first.wpilibj.buttons.Button;
19 import edu.wpi.first.wpilibj.buttons.JoystickButton;
20
21 public class OI {
22 private static OI oi;
23 public static Joystick leftJoystick;
24 public static Joystick rightJoystick;
25
26 public static Button toggleWinch;
27
28 public static Button toggleIndexWheel;
29 public static Button toggleFlyWheel;
30
31 public static Button toggleIntake;
32 public static Button toggleReverseIntake;
33
34 public static Button toggleGearSpeed;
35
36 public static Button increaseShootSpeed;
37 public static Button decreaseShootSpeed;
38
39 public static Button turn90Right;
40 public static Button turn90Left;
41
42 public static Button readyShooter;
43 public static Button shootButton;
44
45 public OI() {
46 System.out.println("OI is open");
47 leftJoystick = new Joystick(Constants.OI.LEFT_STICK_PORT);
48 rightJoystick = new Joystick(Constants.OI.RIGHT_STICK_PORT);
49
50 shootButton = new JoystickButton(rightJoystick,
51 Constants.OI.RIGHT_TRIGGER_BUTTON);
52 toggleWinch = new JoystickButton(rightJoystick,
53 Constants.OI.RIGHT_BUTTON_1);
54 readyShooter = new JoystickButton(rightJoystick,
55 Constants.OI.RIGHT_BUTTON_2);
56 increaseShootSpeed = new JoystickButton(rightJoystick,
57 Constants.OI.RIGHT_BUTTON_5);
58 decreaseShootSpeed = new JoystickButton(rightJoystick,
59 Constants.OI.RIGHT_BUTTON_6);
60
61 toggleIntake = new JoystickButton(leftJoystick,
62 Constants.OI.LEFT_TRIGGER_BUTTON);
63 toggleGearSpeed = new JoystickButton(leftJoystick,
64 Constants.OI.LEFT_BUTTON_2);
65 toggleIndexWheel = new JoystickButton(leftJoystick,
66 Constants.OI.LEFT_BUTTON_2);
67 toggleFlyWheel = new JoystickButton(leftJoystick,
68 Constants.OI.LEFT_BUTTON_2);
69 // toggleIntake = new JoystickButton(leftJoystick,
70 // Constants.OI.LEFT_BUTTON_3);
71 toggleReverseIntake = new JoystickButton(leftJoystick,
72 Constants.OI.LEFT_BUTTON_4);
73 turn90Right = new JoystickButton(leftJoystick, Constants.OI.LEFT_BUTTON_5);
74 turn90Left = new JoystickButton(leftJoystick, Constants.OI.LEFT_BUTTON_6);
75
76 toggleWinch.whenActive(new RunWinchContinuous(1));
77 // toggleWinch.whenReleased(new KeepWinchInPlace());
78
79 toggleIndexWheel.whenPressed(new RunIndexWheelContinuous(1));
80
81 toggleIntake.whenActive(new RunIntakeContinuous());
82 toggleReverseIntake.whenActive(new ReverseIntakeContinuous());
83 toggleIntake.whenReleased(new StopIntake());
84 toggleReverseIntake.whenReleased(new StopIntake());
85
86 toggleGearSpeed.whenPressed(new ToggleGear());
87
88 increaseShootSpeed.whenPressed(new IncreaseShootingSpeed());
89 decreaseShootSpeed.whenPressed(new DecreaseShootingSpeed());
90
91 turn90Right.whenPressed(new Turn90Right());
92 turn90Left.whenPressed(new Turn90Left());
93
94 readyShooter.whenPressed(new PrepareToShoot());
95 shootButton.whenActive(new Shoot());
96 shootButton.whenReleased(new StopIndexWheel());
97 }
98
99 public static OI getOI() {
100 if (oi == null)
101 oi = new OI();
102 return oi;
103 }
104 }