diff --git a/Command Buttons/AndJoystickButton.java b/Command Buttons/AndJoystickButton.java new file mode 100644 index 0000000..4658f3d --- /dev/null +++ b/Command Buttons/AndJoystickButton.java @@ -0,0 +1,23 @@ +package org.usfirst.frc3244.Jupiter2019.util; + +import edu.wpi.first.wpilibj.GenericHID; +import edu.wpi.first.wpilibj.buttons.Button; + +public class AndJoystickButton extends Button { + GenericHID joystick1; + GenericHID joystick2; + int buttonNumber1; + int buttonNumber2; + + public AndJoystickButton(GenericHID joystick1, int buttonNumber1, GenericHID joystick2, int buttonNumber2) { + this.joystick1 = joystick1; + this.buttonNumber1 = buttonNumber1; + this.joystick2 = joystick2; + this.buttonNumber2 = buttonNumber2; + } + + public boolean get() { + return joystick1.getRawButton(buttonNumber1) && joystick2.getRawButton(buttonNumber2); + } + +} diff --git a/Command Buttons/AndNOTJoystickButton2.java b/Command Buttons/AndNOTJoystickButton2.java new file mode 100644 index 0000000..ba1775a --- /dev/null +++ b/Command Buttons/AndNOTJoystickButton2.java @@ -0,0 +1,29 @@ +package org.usfirst.frc3244.Jupiter2019.util; + +import edu.wpi.first.wpilibj.GenericHID; +import edu.wpi.first.wpilibj.buttons.Button; + +/** + * + * @author Copied From Team #1519 (Mechanical Mayhem) + * But changed to and Not Joystick + * + */ +public class AndNOTJoystickButton2 extends Button { + GenericHID joystick1; + GenericHID joystick2; + int buttonNumber1; + int buttonNumber2; + + public AndNOTJoystickButton2(GenericHID joystick1, int buttonNumber1, GenericHID joystick2, int buttonNumber2) { + this.joystick1 = joystick1; + this.buttonNumber1 = buttonNumber1; + this.joystick2 = joystick2; + this.buttonNumber2 = buttonNumber2; + } + + public boolean get() { + return joystick1.getRawButton(buttonNumber1) && !joystick2.getRawButton(buttonNumber2); + } + +} diff --git a/Command Buttons/DisabledOnlyJoystickButton.java b/Command Buttons/DisabledOnlyJoystickButton.java new file mode 100644 index 0000000..491343c --- /dev/null +++ b/Command Buttons/DisabledOnlyJoystickButton.java @@ -0,0 +1,26 @@ +package org.usfirst.frc3244.Jupiter2019.util; + +import edu.wpi.first.wpilibj.DriverStation; +import edu.wpi.first.wpilibj.GenericHID; +import edu.wpi.first.wpilibj.buttons.Button; + +/** + * + * @author Ken Streeter + */ +public class DisabledOnlyJoystickButton extends Button { + + private GenericHID joystick; + private int buttonNumber; + private DriverStation ds; + + public DisabledOnlyJoystickButton(GenericHID joystick, int buttonNumber) { + this.joystick = joystick; + this.buttonNumber = buttonNumber; + ds = DriverStation.getInstance(); + } + + public boolean get() { + return joystick.getRawButton(buttonNumber) && ds.isDisabled(); + } +} diff --git a/Command Buttons/EnabledOnlyJoystickButton.java b/Command Buttons/EnabledOnlyJoystickButton.java new file mode 100644 index 0000000..a189d48 --- /dev/null +++ b/Command Buttons/EnabledOnlyJoystickButton.java @@ -0,0 +1,26 @@ +package org.usfirst.frc3244.Jupiter2019.util; + +import edu.wpi.first.wpilibj.DriverStation; +import edu.wpi.first.wpilibj.GenericHID; +import edu.wpi.first.wpilibj.buttons.Button; + +/** + * + * @author Noel + */ +public class EnabledOnlyJoystickButton extends Button { + + private GenericHID joystick; + private int buttonNumber; + private DriverStation ds; + + public EnabledOnlyJoystickButton(GenericHID joystick, int buttonNumber) { + this.joystick = joystick; + this.buttonNumber = buttonNumber; + ds = DriverStation.getInstance(); + } + + public boolean get() { + return joystick.getRawButton(buttonNumber) && ds.isEnabled(); + } +} diff --git a/Command Buttons/IOButton.java b/Command Buttons/IOButton.java new file mode 100644 index 0000000..8e1731c --- /dev/null +++ b/Command Buttons/IOButton.java @@ -0,0 +1,26 @@ +package org.usfirst.frc3244.Jupiter2019.util; + +import edu.wpi.first.wpilibj.DigitalInput; +import edu.wpi.first.wpilibj.buttons.Button; + + +/** + * + */ +public class IOButton extends Button { + + private DigitalInput button; + + + public IOButton(DigitalInput digitalInput){ + button = digitalInput; + + } + + /** + * Returns the status of a Normaly Open Switch connected to the RoboRio + */ + public boolean get() { + return !button.get(); + } +} diff --git a/Command Buttons/IOButtonOrButton.java b/Command Buttons/IOButtonOrButton.java new file mode 100644 index 0000000..2d0f4e1 --- /dev/null +++ b/Command Buttons/IOButtonOrButton.java @@ -0,0 +1,26 @@ +package org.usfirst.frc3244.Jupiter2019.util; + +import edu.wpi.first.wpilibj.DigitalInput; +import edu.wpi.first.wpilibj.buttons.Button; + + +/** + * + */ +public class IOButtonOrButton extends Button { + + private DigitalInput button1; + private DigitalInput button2; + + public IOButtonOrButton(DigitalInput digitalInput1,DigitalInput digitalInput2){ + button1 = digitalInput1; + button2 = digitalInput2; + } + + /** + * Returns True if switch is closed + */ + public boolean get() { + return !button1.get()||!button2.get(); + } +} diff --git a/Command Buttons/JoystickAxisButton.java b/Command Buttons/JoystickAxisButton.java new file mode 100644 index 0000000..f7f1a87 --- /dev/null +++ b/Command Buttons/JoystickAxisButton.java @@ -0,0 +1,76 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.usfirst.frc3244.Jupiter2019.util; + +import edu.wpi.first.wpilibj.Joystick; +import edu.wpi.first.wpilibj.buttons.Button; + +/** + * + * @author Noel + */ +public class JoystickAxisButton extends Button { + public static final int BOTH_WAYS = 1; + public static final int POSITIVE_ONLY = 2; + public static final int NEGATIVE_ONLY = 3; + + private static final double AXIS_THRESHOLD = 0.2; + + private Joystick joystick; + private Joystick.AxisType axis; + private int axisInt; + private int direction; + + public JoystickAxisButton(Joystick stick, Joystick.AxisType axis) { + this(stick, axis, BOTH_WAYS); + } + + public JoystickAxisButton(Joystick stick, Joystick.AxisType axis, int direction) { + joystick = stick; + this.axis = axis; + this.direction = direction; + } + + public JoystickAxisButton(Joystick stick, int axis) { + this(stick, axis, BOTH_WAYS); + } + + public JoystickAxisButton(Joystick stick, int axis, int direction) { + joystick = stick; + this.axis = null; + axisInt = axis; + this.direction = direction; + } + + public boolean get() { + switch (direction) { + case BOTH_WAYS: + if (axis != null) { + return Math.abs(joystick.getAxis(axis)) > AXIS_THRESHOLD; + } + else { + return Math.abs(joystick.getRawAxis(axisInt)) > AXIS_THRESHOLD; + } + + case POSITIVE_ONLY: + if (axis != null) { + return joystick.getAxis(axis) > AXIS_THRESHOLD; + } + else { + return joystick.getRawAxis(axisInt) > AXIS_THRESHOLD; + } + + case NEGATIVE_ONLY: + if (axis != null) { + return joystick.getAxis(axis) < -AXIS_THRESHOLD; + } + else { + return joystick.getRawAxis(axisInt) < -AXIS_THRESHOLD; + } + } + + return false; + } +} diff --git a/Command Buttons/JoystickPOVButton.java b/Command Buttons/JoystickPOVButton.java new file mode 100644 index 0000000..df39c9a --- /dev/null +++ b/Command Buttons/JoystickPOVButton.java @@ -0,0 +1,34 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.usfirst.frc3244.Jupiter2019.util; + +import edu.wpi.first.wpilibj.Joystick; +import edu.wpi.first.wpilibj.buttons.Button; + +/** + * @author Ken Streeter (1519) + */ +public class JoystickPOVButton extends Button { + public static final int NORTH = 0; + public static final int NORTHEAST = 45; + public static final int EAST = 90; + public static final int SOUTHEAST = 135; + public static final int SOUTH = 180; + public static final int SOUTHWEST = 225; + public static final int WEST = 270; + public static final int NORTHWEST = 315; + + private Joystick joystick; + private int desiredPOV; + + public JoystickPOVButton(Joystick stick, int newDesiredPOV) { + joystick = stick; + desiredPOV = newDesiredPOV; + } + + public boolean get() { + return (joystick.getPOV() == desiredPOV); + } +} diff --git a/Command Buttons/OrAxisTriggerButton.java b/Command Buttons/OrAxisTriggerButton.java new file mode 100644 index 0000000..5277432 --- /dev/null +++ b/Command Buttons/OrAxisTriggerButton.java @@ -0,0 +1,79 @@ +package org.usfirst.frc3244.Jupiter2019.util; + +import edu.wpi.first.wpilibj.GenericHID; +import edu.wpi.first.wpilibj.Joystick; +import edu.wpi.first.wpilibj.buttons.Button; + +public class OrAxisTriggerButton extends Button { + //Button Variables + GenericHID joystick1; + int buttonNumber1; + + //Axis Variables + public static final int BOTH_WAYS = 1; + public static final int POSITIVE_ONLY = 2; + public static final int NEGATIVE_ONLY = 3; + + private static final double AXIS_THRESHOLD = 0.2; + + private Joystick joystick; + private Joystick.AxisType axis; + private int axisInt; + private int direction; + + public OrAxisTriggerButton(GenericHID joystick1, int buttonNumber1, Joystick stick, Joystick.AxisType axis) { + this(joystick1, buttonNumber1,stick, axis, BOTH_WAYS); + } + + public OrAxisTriggerButton(GenericHID joystick1, int buttonNumber1, Joystick stick, Joystick.AxisType axis, int direction) { + this.joystick1 = joystick1; + this.buttonNumber1 = buttonNumber1; + joystick = stick; + this.axis = axis; + this.direction = direction; + } + + public OrAxisTriggerButton(GenericHID joystick1, int buttonNumber1, Joystick stick, int axis) { + this(joystick1, buttonNumber1, stick, axis, BOTH_WAYS); + } + + public OrAxisTriggerButton(GenericHID joystick1, int buttonNumber1, Joystick stick, int axis, int direction) { + this.joystick1 = joystick1; + this.buttonNumber1 = buttonNumber1; + joystick = stick; + this.axis = null; + axisInt = axis; + this.direction = direction; + } + + public boolean get() { + + switch (direction) { + case BOTH_WAYS: + if (axis != null) { + return joystick1.getRawButton(buttonNumber1) || Math.abs(joystick.getAxis(axis)) > AXIS_THRESHOLD; + } + else { + return joystick1.getRawButton(buttonNumber1) || Math.abs(joystick.getRawAxis(axisInt)) > AXIS_THRESHOLD; + } + + case POSITIVE_ONLY: + if (axis != null) { + return joystick1.getRawButton(buttonNumber1) || joystick.getAxis(axis) > AXIS_THRESHOLD; + } + else { + return joystick1.getRawButton(buttonNumber1) || joystick.getRawAxis(axisInt) > AXIS_THRESHOLD; + } + + case NEGATIVE_ONLY: + if (axis != null) { + return joystick1.getRawButton(buttonNumber1) || joystick.getAxis(axis) < -AXIS_THRESHOLD; + } + else { + return joystick1.getRawButton(buttonNumber1) || joystick.getRawAxis(axisInt) < -AXIS_THRESHOLD; + } + } + + return false; + } +} \ No newline at end of file diff --git a/Command Buttons/OrJoystickButton.java b/Command Buttons/OrJoystickButton.java new file mode 100644 index 0000000..a1a0203 --- /dev/null +++ b/Command Buttons/OrJoystickButton.java @@ -0,0 +1,23 @@ +package org.usfirst.frc3244.Jupiter2019.util; + +import edu.wpi.first.wpilibj.GenericHID; +import edu.wpi.first.wpilibj.buttons.Button; + +public class OrJoystickButton extends Button { + GenericHID joystick1; + GenericHID joystick2; + int buttonNumber1; + int buttonNumber2; + + public OrJoystickButton(GenericHID joystick1, int buttonNumber1, GenericHID joystick2, int buttonNumber2) { + this.joystick1 = joystick1; + this.buttonNumber1 = buttonNumber1; + this.joystick2 = joystick2; + this.buttonNumber2 = buttonNumber2; + } + + public boolean get() { + return joystick1.getRawButton(buttonNumber1) || joystick2.getRawButton(buttonNumber2); + } + +} diff --git a/enhance_wpi_classes/MecanumDrive.java b/enhance_wpi_classes/MecanumDrive.java index e77fb81..7b06982 100644 --- a/enhance_wpi_classes/MecanumDrive.java +++ b/enhance_wpi_classes/MecanumDrive.java @@ -5,7 +5,7 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -package com.granitecitygearhead.frc3244.enhance_wpi_classes; +//package com.granitecitygearhead.frc3244.enhance_wpi_classes; import java.util.StringJoiner; import java.util.function.DoubleSupplier;