Package com.thegongoliers.hardware
Class Hardware
- java.lang.Object
-
- com.thegongoliers.hardware.Hardware
-
public class Hardware extends java.lang.Object
Miscellaneous hardware functions.
-
-
Constructor Summary
Constructors Constructor Description Hardware()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static edu.wpi.first.wpilibj.buttons.Button
combineButtons(edu.wpi.first.wpilibj.buttons.Button button1, edu.wpi.first.wpilibj.buttons.Button... buttons)
Combines multiple buttons into a single button.static edu.wpi.first.wpilibj.interfaces.Potentiometer
create10TurnPotentiometer(int port, double zeroPoint)
Creates a 10 turn potentiometer as sold by Andymark.static Drivetrain
createDrivetrain(edu.wpi.first.wpilibj.drive.DifferentialDrive robotDrive)
static edu.wpi.first.wpilibj.interfaces.Potentiometer
createPotentiometer(int port, double degreeRange, double zeroPoint)
Creates potentiometer.static edu.wpi.first.wpilibj.interfaces.Gyro
invertGyro(edu.wpi.first.wpilibj.interfaces.Gyro gyro)
Invert the direction of the Gyro.static edu.wpi.first.wpilibj.interfaces.Potentiometer
invertPotentiometer(edu.wpi.first.wpilibj.interfaces.Potentiometer potentiometer)
Inverts a potentiometer.static edu.wpi.first.wpilibj.buttons.Button
makeButton(java.util.function.BooleanSupplier booleanSupplier)
Creates a button from a boolean supplier.static ResettableSwitch
makeResettableSwitch(Switch aSwitch)
Creates a resettable switch from a switch.static Switch
makeSwitch(java.util.function.BooleanSupplier booleanSupplier)
Creates a switch from a boolean supplier.static edu.wpi.first.wpilibj.buttons.Trigger
makeTrigger(java.util.function.BooleanSupplier booleanSupplier)
Creates a trigger from a boolean supplier.static edu.wpi.first.wpilibj.buttons.Trigger
switchToTrigger(Switch aSwitch)
Creates a trigger from a switch.static edu.wpi.first.wpilibj.buttons.Button
triggerToButton(edu.wpi.first.wpilibj.buttons.Trigger trigger)
Creates a button from a trigger.static double
voltageToPWM(double voltage, VoltageSensor batteryVoltageSensor)
Convert a voltage to a PWM signal (percent power) based on the current voltage of the battery
-
-
-
Method Detail
-
combineButtons
public static edu.wpi.first.wpilibj.buttons.Button combineButtons(edu.wpi.first.wpilibj.buttons.Button button1, edu.wpi.first.wpilibj.buttons.Button... buttons)
Combines multiple buttons into a single button.- Parameters:
button1
- The first button.buttons
- The rest of the buttons.- Returns:
- A Button which is pressed only when ALL of the buttons are pressed.
-
makeButton
public static edu.wpi.first.wpilibj.buttons.Button makeButton(java.util.function.BooleanSupplier booleanSupplier)
Creates a button from a boolean supplier.- Parameters:
booleanSupplier
- The boolean supplier to become a button.- Returns:
- The button which is pressed when the boolean supplier is true.
-
triggerToButton
public static edu.wpi.first.wpilibj.buttons.Button triggerToButton(edu.wpi.first.wpilibj.buttons.Trigger trigger)
Creates a button from a trigger.- Parameters:
trigger
- The trigger to become a button.- Returns:
- The button which is pressed when the trigger is triggered.
-
switchToTrigger
public static edu.wpi.first.wpilibj.buttons.Trigger switchToTrigger(Switch aSwitch)
Creates a trigger from a switch.- Parameters:
aSwitch
- The switch to become a trigger.- Returns:
- The trigger which is triggered when the switch is triggered.
-
makeTrigger
public static edu.wpi.first.wpilibj.buttons.Trigger makeTrigger(java.util.function.BooleanSupplier booleanSupplier)
Creates a trigger from a boolean supplier.- Parameters:
booleanSupplier
- The boolean supplier to become a trigger.- Returns:
- The trigger which is triggered when the boolean supplier is true.
-
makeSwitch
public static Switch makeSwitch(java.util.function.BooleanSupplier booleanSupplier)
Creates a switch from a boolean supplier.- Parameters:
booleanSupplier
- The boolean supplier to become a switch.- Returns:
- The switch which is triggered when the boolean supplier is true.
-
makeResettableSwitch
public static ResettableSwitch makeResettableSwitch(Switch aSwitch)
Creates a resettable switch from a switch.- Parameters:
aSwitch
- The switch to become a resettable switch.- Returns:
- The resettable switch, which will remain true if the switch becomes triggered.
-
invertGyro
public static edu.wpi.first.wpilibj.interfaces.Gyro invertGyro(edu.wpi.first.wpilibj.interfaces.Gyro gyro)
Invert the direction of the Gyro.- Parameters:
gyro
- The Gyro to invert.- Returns:
- The inverted Gyro.
-
invertPotentiometer
public static edu.wpi.first.wpilibj.interfaces.Potentiometer invertPotentiometer(edu.wpi.first.wpilibj.interfaces.Potentiometer potentiometer)
Inverts a potentiometer. If a potentiometer goes from 0 to -100 degrees (after scale and zero point), but should be 0 to 100, use this method.- Parameters:
potentiometer
- The potentiometer to invert.- Returns:
- The inverted potentiometer.
-
createPotentiometer
public static edu.wpi.first.wpilibj.interfaces.Potentiometer createPotentiometer(int port, double degreeRange, double zeroPoint)
Creates potentiometer.- Parameters:
port
- The analog port that the potentiometer is plugged into.degreeRange
- The total range in degrees that the potentiometer can turnzeroPoint
- The zero point of the potentiometer. If you expect a position to be 0, but it is reading X degrees, put X here. (ex. actual 1000 to 1100 degrees, expected 0 to 100 degrees. Put 1000 here.)- Returns:
- A potentiometer.
-
create10TurnPotentiometer
public static edu.wpi.first.wpilibj.interfaces.Potentiometer create10TurnPotentiometer(int port, double zeroPoint)
Creates a 10 turn potentiometer as sold by Andymark.- Parameters:
port
- The analog port that the potentiometer is plugged into.zeroPoint
- The zero point of the potentiometer. If you expect a position to be 0, but it is reading X degrees, put X here. (ex. actual 1000 to 1100 degrees, expected 0 to 100 degrees. Put 1000 here.)- Returns:
- A 10 turn potentiometer.
-
createDrivetrain
public static Drivetrain createDrivetrain(edu.wpi.first.wpilibj.drive.DifferentialDrive robotDrive)
-
voltageToPWM
public static double voltageToPWM(double voltage, VoltageSensor batteryVoltageSensor)
Convert a voltage to a PWM signal (percent power) based on the current voltage of the battery- Parameters:
voltage
- the desired voltagebatteryVoltageSensor
- the battery voltage sensor- Returns:
- the PWM signal [-1, 1] which delivers the desired voltage
-
-