-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
317 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/java/org/frc5687/powerup/robot/utils/AxisButton.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.frc5687.powerup.robot.utils; | ||
|
||
import edu.wpi.first.wpilibj.GenericHID; | ||
import edu.wpi.first.wpilibj.buttons.Button; | ||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; | ||
|
||
/** | ||
* Created by Ben Bernard on 3/15/2018. | ||
*/ | ||
public class AxisButton extends Button { | ||
private final GenericHID m_joystick; | ||
private final int m_axisNumber; | ||
private double _minRange; | ||
private double _maxRange; | ||
|
||
public AxisButton(GenericHID joystick, int axisNumber, double minRange, double maxRange) { | ||
this.m_joystick = joystick; | ||
this.m_axisNumber = axisNumber; | ||
_minRange = minRange; | ||
_maxRange = maxRange; | ||
} | ||
|
||
public boolean get() { | ||
double val = this.m_joystick.getRawAxis(this.m_axisNumber); | ||
return val >= _minRange && val <= _maxRange; | ||
} | ||
|
||
|
||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/org/frc5687/powerup/robot/utils/JoystickLight.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.frc5687.powerup.robot.utils; | ||
|
||
/** | ||
* Created by Ben Bernard on 3/14/2018. | ||
*/ | ||
import edu.wpi.first.wpilibj.Joystick; | ||
|
||
/** | ||
* Utility class to make it easier to set (and read) the state of a joystick light | ||
*/ | ||
public class JoystickLight { | ||
|
||
private final Joystick m_joystick; | ||
private final int m_outputNumber; | ||
private boolean m_value = false; | ||
|
||
/** | ||
* Create a joystick button for triggering commands. | ||
* | ||
* @param joystick The Joystick object that has the lights (e.g. Joystick, Launchpad, etc) | ||
* @param outputNumber The output number | ||
*/ | ||
public JoystickLight(Joystick joystick, int outputNumber) { | ||
m_joystick = joystick; | ||
m_outputNumber = outputNumber; | ||
} | ||
|
||
/** | ||
* Gets the value of the joystick button. | ||
* | ||
* @return The value of the joystick button | ||
*/ | ||
public boolean get() { | ||
return m_value; | ||
} | ||
|
||
public void set(boolean value) { | ||
m_joystick.setOutput(m_outputNumber, m_value = value); | ||
} | ||
|
||
} |
Oops, something went wrong.