-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlasmaAxis.java
66 lines (57 loc) · 1.36 KB
/
PlasmaAxis.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package frc.robot.controllers;
import edu.wpi.first.wpilibj.*;
public class PlasmaAxis {
private final int joystickPort;
private final int axisNum;
private final int dirMultiplier;
/**
* Constructor for plasma axis
*
* @param axisNum - ID number of axis
* @param joystickPort - Port of joystick that the axis is on
* @param isReverse - True if axis input is reversed
*
* @author Nic A
*/
public PlasmaAxis(int axisNum, int joystickPort, boolean isReverse) {
this.joystickPort = joystickPort;
this.axisNum = axisNum;
this.dirMultiplier = (isReverse) ? -1 : 1;
}
/**
* Constructor for plasma axis
*
* @param axisNum - ID number of axis
* @param joystickPort - Port of joystick that the axis is on
*
* @author Nic A
*/
public PlasmaAxis(int axisNum, int joystickPort) {
this(axisNum, joystickPort, false);
}
/**
* Returns the raw value from axis after reversal
*
* @return Axis value
*
* @author Nic A
*/
public double getTrueAxis(){
return DriverStation.getStickAxis(joystickPort, axisNum) * dirMultiplier;
}
/**
* Returns the value of the axis after reversal and deadband calculations
*
* @return Axis value after deadband
*
* @author Nic A
*/
public double getFilteredAxis(){
if(Math.abs(getTrueAxis()) > JoystickConstants.deadBand){
return getTrueAxis();
}
else{
return 0;
}
}
}