Skip to content

Commit

Permalink
Common Repo Cleanup
Browse files Browse the repository at this point in the history
Commented all files in input folder
  • Loading branch information
Mason-Lam committed Nov 25, 2023
1 parent 8b64749 commit c1fa0e2
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 268 deletions.
2 changes: 1 addition & 1 deletion src/main/java/common/core/NAR_Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* @author Mason Lam
*/
public class NAR_Robot extends IterativeRobotBase {
@SuppressWarnings("MemberName")
@SuppressWarnings("MemberName")
static class Callback implements Comparable<Callback> {
public Runnable func;
public double period;
Expand Down
172 changes: 0 additions & 172 deletions src/main/java/common/core/subsystems/NAR_StateSpaceSubsystem.java

This file was deleted.

50 changes: 21 additions & 29 deletions src/main/java/common/hardware/input/NAR_ButtonBoard.java
Original file line number Diff line number Diff line change
@@ -1,54 +1,46 @@
package common.hardware.input;

import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.GenericHID;
import edu.wpi.first.wpilibj2.command.button.Trigger;

/**
* Wrapper for the WPILib Joystick class. Works with device that can be recognized as joystick as driverstation.
* Custom GenericHID class for team 3128's button board setup
* @since 2023 Charged UP
* @author Peter Ma, Arav Chadha
* @author Peter Ma, Arav Chadha, Mason Lam
*/
public class NAR_ButtonBoard {

private Joystick stick;
private GenericHID device;

private Trigger[] buttons;

public NAR_ButtonBoard(int deviceNumber) {
/**
* Creates a new button board object.
* @param port The port on DriverStation the button board is connected to.
*/
public NAR_ButtonBoard(int port) {
buttons = new Trigger[16];
stick = new Joystick(deviceNumber);

// 2023 btnboard has 12 buttons & 4 axis direction
device = new GenericHID(port);

// 2023 buttonBoard has 12 buttons & 4 axis direction
for (int i = 0; i < 12; i++) {
int buttonId = i;
buttons[buttonId] = new Trigger(() -> stick.getRawButton(buttonId + 1));
buttons[buttonId] = new Trigger(() -> device.getRawButton(buttonId + 1));
}

buttons[12] = new Trigger(() -> stick.getX() == -1.0);
buttons[13] = new Trigger(() -> stick.getX() == 1.0);
buttons[14] = new Trigger(() -> stick.getY() == 1.0);
buttons[15] = new Trigger(() -> stick.getY() == -1.0);
buttons[12] = new Trigger(() -> device.getRawAxis(0) == -1.0);
buttons[13] = new Trigger(() -> device.getRawAxis(0) == 1.0);
buttons[14] = new Trigger(() -> device.getRawAxis(1) == 1.0);
buttons[15] = new Trigger(() -> device.getRawAxis(1) == -1.0);

}

/**
* Returns a button on the board
* @param i The ID of the button
* @return Trigger to store the command to run
*/
public Trigger getButton(int i) {
return buttons[i-1];
}

public Trigger getPosXButton() {
return buttons[12];
}

public Trigger getNegXButton() {
return buttons[13];
}

public Trigger getPosYButton() {
return buttons[14];
}

public Trigger getNegYButton() {
return buttons[15];
}
}
20 changes: 13 additions & 7 deletions src/main/java/common/hardware/input/NAR_Joystick.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ public class NAR_Joystick {

private final Trigger[] buttons;

/**
* POV convention: 0 = up, 45 = top right, 90 = right, 135 = buttom right, 180 = down, 225 = bottom left, 270 = left, 315 = top left
* We assign indices as angle / 45 [0,7]
*/
private final Trigger[] povButtons;

private double xDeadband = 0.05;
Expand All @@ -28,12 +24,12 @@ public class NAR_Joystick {

/**
* Creates a new NAR_Joystick object
* @param deviceNumber The port the joystick is connected on driver station
* @param port The port the joystick is connected on driver station
*/
public NAR_Joystick(int deviceNumber) {
public NAR_Joystick(int port) {
buttons = new Trigger[16];
povButtons = new Trigger[8];
stick = new Joystick(deviceNumber);
stick = new Joystick(port);

// Thrustmaster joystick has 16 buttons

Expand Down Expand Up @@ -82,6 +78,16 @@ public double getThrottle() {
return mappedThrottle;
}

/**
* Sets the throttle bounds for the joystick.
* @param lowerBound [0, 1] lowest possible throttle value.
* @param upperBound [0, 1] highest possible throttle value.
*/
public void setThrottleBounds(double lowerBound, double upperBound) {
throttleLowerBound = lowerBound;
throttleUpperBound = upperBound;
}

/**
* Returns the button of the Joystick
* @param i The ID of the button
Expand Down
Loading

0 comments on commit c1fa0e2

Please sign in to comment.