Skip to content

Commit

Permalink
[2023] Update StuyLib to 2023 (#69)
Browse files Browse the repository at this point in the history
* [2023] Use NT4 in Network Library (#67)

* Port to 2023

* Update Network Tables to NT4

Co-authored-by: Ivan Chen <[email protected]>

* Update Limelight to 2023

* Update to use Topics

* Update to use Topics instead of NetworkTableEntry

* Update javadocs to use Topics instead of NetworkTableEntry

Co-authored-by: Vincent Wang <[email protected]>

* [2023] Replace Buttons with Triggers (#68)

* Port to 2023

* Update WPILib Version

* Use Triggers instead of deprecated Buttons

Co-authored-by: Vincent Wang <[email protected]>

* Update Spotless Apply settings

* Pass around GenericEntry instead of Topic

* Set GoogleJavaFormat to 1.13.0

* Fix javadoc errors

* fix license header

* spotlessapply

* Use DoubleEntry & DoubleArrayEntry

* make timingEntry a BooleanEntry

* Change values to IntegerTopics

* Add missing import

* Update build.gradle

* Update WPILib version to beta-5

* Update WPILib to beta-6

* Fix network library

* Update WPILib version to beta-7

* Update wpilib version

* spotlessapply

Co-authored-by: Vincent Wang <[email protected]>
  • Loading branch information
anivanchen and vincentw921 authored Jan 7, 2023
1 parent 93c7875 commit ef0e572
Show file tree
Hide file tree
Showing 117 changed files with 419 additions and 355 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.WPI_VER = "2022.4.1"
ext.WPI_VER = "2023.1.1"
}

plugins {
Expand All @@ -8,8 +8,8 @@ plugins {
id "maven-publish"

id "edu.wpi.first.GradleRIO" version "${WPI_VER}"
id "com.diffplug.spotless" version "6.1.0"
id "com.github.spotbugs" version "4.7.0"
id "com.diffplug.spotless" version "6.11.0"
id "com.github.spotbugs" version "5.0.13"
}

group = 'com.stuypulse'
Expand Down Expand Up @@ -76,7 +76,7 @@ spotless {
"""

googleJavaFormat().aosp()
googleJavaFormat('1.13.0').aosp()

trimTrailingWhitespace()
endWithNewline()
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=permwrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=permwrapper/dists
2 changes: 1 addition & 1 deletion src/com/stuypulse/stuylib/control/Controller.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2022 StuyPulse Robotics. All rights reserved. */
/* Copyright (c) 2023 StuyPulse Robotics. All rights reserved. */
/* This work is licensed under the terms of the MIT license */
/* found in the root directory of this project. */

Expand Down
2 changes: 1 addition & 1 deletion src/com/stuypulse/stuylib/control/ControllerGroup.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2022 StuyPulse Robotics. All rights reserved. */
/* Copyright (c) 2023 StuyPulse Robotics. All rights reserved. */
/* This work is licensed under the terms of the MIT license */
/* found in the root directory of this project. */

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2022 StuyPulse Robotics. All rights reserved. */
/* Copyright (c) 2023 StuyPulse Robotics. All rights reserved. */
/* This work is licensed under the terms of the MIT license */
/* found in the root directory of this project. */

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2022 StuyPulse Robotics. All rights reserved. */
/* Copyright (c) 2023 StuyPulse Robotics. All rights reserved. */
/* This work is licensed under the terms of the MIT license */
/* found in the root directory of this project. */

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2022 StuyPulse Robotics. All rights reserved. */
/* Copyright (c) 2023 StuyPulse Robotics. All rights reserved. */
/* This work is licensed under the terms of the MIT license */
/* found in the root directory of this project. */

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2022 StuyPulse Robotics. All rights reserved. */
/* Copyright (c) 2023 StuyPulse Robotics. All rights reserved. */
/* This work is licensed under the terms of the MIT license */
/* found in the root directory of this project. */

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2022 StuyPulse Robotics. All rights reserved. */
/* Copyright (c) 2023 StuyPulse Robotics. All rights reserved. */
/* This work is licensed under the terms of the MIT license */
/* found in the root directory of this project. */

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2022 StuyPulse Robotics. All rights reserved. */
/* Copyright (c) 2023 StuyPulse Robotics. All rights reserved. */
/* This work is licensed under the terms of the MIT license */
/* found in the root directory of this project. */

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2022 StuyPulse Robotics. All rights reserved. */
/* Copyright (c) 2023 StuyPulse Robotics. All rights reserved. */
/* This work is licensed under the terms of the MIT license */
/* found in the root directory of this project. */

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2022 StuyPulse Robotics. All rights reserved. */
/* Copyright (c) 2023 StuyPulse Robotics. All rights reserved. */
/* This work is licensed under the terms of the MIT license */
/* found in the root directory of this project. */

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2022 StuyPulse Robotics. All rights reserved. */
/* Copyright (c) 2023 StuyPulse Robotics. All rights reserved. */
/* This work is licensed under the terms of the MIT license */
/* found in the root directory of this project. */

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2022 StuyPulse Robotics. All rights reserved. */
/* Copyright (c) 2023 StuyPulse Robotics. All rights reserved. */
/* This work is licensed under the terms of the MIT license */
/* found in the root directory of this project. */

Expand Down
158 changes: 79 additions & 79 deletions src/com/stuypulse/stuylib/input/Gamepad.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2022 StuyPulse Robotics. All rights reserved. */
/* Copyright (c) 2023 StuyPulse Robotics. All rights reserved. */
/* This work is licensed under the terms of the MIT license */
/* found in the root directory of this project. */

Expand All @@ -8,7 +8,7 @@

import edu.wpi.first.util.sendable.Sendable;
import edu.wpi.first.util.sendable.SendableBuilder;
import edu.wpi.first.wpilibj2.command.button.Button;
import edu.wpi.first.wpilibj2.command.button.Trigger;

/**
* An class for using gamepads with different interfaces. You can implement this class in another
Expand Down Expand Up @@ -201,159 +201,159 @@ public final boolean getRightTriggerPressed() {
return getRightTrigger() > ANALOG_THRESHOLD;
}

/**************************************************/
/*** BUTTONS BASED OFF OF IMPLEMENTED FUNCTIONS ***/
/**************************************************/
/***************************************************/
/*** TRIGGERS BASED OFF OF IMPLEMENTED FUNCTIONS ***/
/***************************************************/

// Sticks //
/**
* @return Button that activates when {@link #getLeftY()} is greater than +{@link
* @return Trigger that activates when {@link #getLeftY()} is greater than +{@link
* #ANALOG_THRESHOLD}
*/
public final Button getLeftStickUp() {
return new Button(() -> getLeftY() > +ANALOG_THRESHOLD);
public final Trigger getLeftStickUp() {
return new Trigger(() -> getLeftY() > +ANALOG_THRESHOLD);
}

/**
* @return Button that activates when {@link #getLeftY()} is less than -{@link
* @return Trigger that activates when {@link #getLeftY()} is less than -{@link
* #ANALOG_THRESHOLD}
*/
public final Button getLeftStickDown() {
return new Button(() -> getLeftY() < -ANALOG_THRESHOLD);
public final Trigger getLeftStickDown() {
return new Trigger(() -> getLeftY() < -ANALOG_THRESHOLD);
}

/**
* @return Button that activates when {@link #getLeftX()} is less than -{@link
* @return Trigger that activates when {@link #getLeftX()} is less than -{@link
* #ANALOG_THRESHOLD}
*/
public final Button getLeftStickLeft() {
return new Button(() -> getLeftX() < -ANALOG_THRESHOLD);
public final Trigger getLeftStickLeft() {
return new Trigger(() -> getLeftX() < -ANALOG_THRESHOLD);
}

/**
* @return Button that activates when {@link #getLeftX()} is greater than +{@link
* @return Trigger that activates when {@link #getLeftX()} is greater than +{@link
* #ANALOG_THRESHOLD}
*/
public final Button getLeftStickRight() {
return new Button(() -> getLeftX() > +ANALOG_THRESHOLD);
public final Trigger getLeftStickRight() {
return new Trigger(() -> getLeftX() > +ANALOG_THRESHOLD);
}

/**
* @return Button that activates when {@link #getRightY()} is greater than +{@link
* @return Trigger that activates when {@link #getRightY()} is greater than +{@link
* #ANALOG_THRESHOLD}
*/
public final Button getRightStickUp() {
return new Button(() -> getRightY() > +ANALOG_THRESHOLD);
public final Trigger getRightStickUp() {
return new Trigger(() -> getRightY() > +ANALOG_THRESHOLD);
}

/**
* @return Button that activates when {@link #getRightY()} is less than -{@link
* @return Trigger that activates when {@link #getRightY()} is less than -{@link
* #ANALOG_THRESHOLD}
*/
public final Button getRightStickDown() {
return new Button(() -> getRightY() < -ANALOG_THRESHOLD);
public final Trigger getRightStickDown() {
return new Trigger(() -> getRightY() < -ANALOG_THRESHOLD);
}

/**
* @return Button that activates when {@link #getRightX()} is less than -{@link
* @return Trigger that activates when {@link #getRightX()} is less than -{@link
* #ANALOG_THRESHOLD}
*/
public final Button getRightStickLeft() {
return new Button(() -> getRightX() < -ANALOG_THRESHOLD);
public final Trigger getRightStickLeft() {
return new Trigger(() -> getRightX() < -ANALOG_THRESHOLD);
}

/**
* @return Button that activates when {@link #getRightX()} is greater than +{@link
* @return Trigger that activates when {@link #getRightX()} is greater than +{@link
* #ANALOG_THRESHOLD}
*/
public final Button getRightStickRight() {
return new Button(() -> getRightX() > +ANALOG_THRESHOLD);
public final Trigger getRightStickRight() {
return new Trigger(() -> getRightX() > +ANALOG_THRESHOLD);
}

// D-Pad //
/** @return Button that activates with {@link #getRawDPadUp()} */
public final Button getDPadUp() {
return new Button(this::getRawDPadUp);
/** @return Trigger that activates with {@link #getRawDPadUp()} */
public final Trigger getDPadUp() {
return new Trigger(this::getRawDPadUp);
}

/** @return Button that activates with {@link #getRawDPadDown()} */
public final Button getDPadDown() {
return new Button(this::getRawDPadDown);
/** @return Trigger that activates with {@link #getRawDPadDown()} */
public final Trigger getDPadDown() {
return new Trigger(this::getRawDPadDown);
}

/** @return Button that activates with {@link #getRawDPadLeft()} */
public final Button getDPadLeft() {
return new Button(this::getRawDPadLeft);
/** @return Trigger that activates with {@link #getRawDPadLeft()} */
public final Trigger getDPadLeft() {
return new Trigger(this::getRawDPadLeft);
}

/** @return Button that activates with {@link #getRawDPadRight()} */
public final Button getDPadRight() {
return new Button(this::getRawDPadRight);
/** @return Trigger that activates with {@link #getRawDPadRight()} */
public final Trigger getDPadRight() {
return new Trigger(this::getRawDPadRight);
}

// Bumpers //
/** @return Button that activates with {@link #getRawLeftBumper()} */
public final Button getLeftBumper() {
return new Button(this::getRawLeftBumper);
/** @return Trigger that activates with {@link #getRawLeftBumper()} */
public final Trigger getLeftBumper() {
return new Trigger(this::getRawLeftBumper);
}

/** @return Button that activates with {@link #getRawRightBumper()} */
public final Button getRightBumper() {
return new Button(this::getRawRightBumper);
/** @return Trigger that activates with {@link #getRawRightBumper()} */
public final Trigger getRightBumper() {
return new Trigger(this::getRawRightBumper);
}

// Triggers //
/** @return Button that activates with {@link #getLeftTriggerPressed()} */
public final Button getLeftTriggerButton() {
return new Button(this::getLeftTriggerPressed);
/** @return Trigger that activates with {@link #getLeftTriggerPressed()} */
public final Trigger getLeftTriggerButton() {
return new Trigger(this::getLeftTriggerPressed);
}

/** @return Button that activates with {@link #getRightTriggerPressed()} */
public final Button getRightTriggerButton() {
return new Button(this::getRightTriggerPressed);
/** @return Trigger that activates with {@link #getRightTriggerPressed()} */
public final Trigger getRightTriggerButton() {
return new Trigger(this::getRightTriggerPressed);
}

// Face Buttons //
/** @return Button that activates with {@link #getRawTopButton()} */
public final Button getTopButton() {
return new Button(this::getRawTopButton);
// Face Triggers //
/** @return Trigger that activates with {@link #getRawTopButton()} */
public final Trigger getTopButton() {
return new Trigger(this::getRawTopButton);
}

/** @return Button that activates with {@link #getRawBottomButton()} */
public final Button getBottomButton() {
return new Button(this::getRawBottomButton);
/** @return Trigger that activates with {@link #getRawBottomButton()} */
public final Trigger getBottomButton() {
return new Trigger(this::getRawBottomButton);
}

/** @return Button that activates with {@link #getRawLeftButton()} */
public final Button getLeftButton() {
return new Button(this::getRawLeftButton);
/** @return Trigger that activates with {@link #getRawLeftButton()} */
public final Trigger getLeftButton() {
return new Trigger(this::getRawLeftButton);
}

/** @return Button that activates with {@link #getRawRightButton()} */
public final Button getRightButton() {
return new Button(this::getRawRightButton);
/** @return Trigger that activates with {@link #getRawRightButton()} */
public final Trigger getRightButton() {
return new Trigger(this::getRawRightButton);
}

// Select / Start / Option //
/** @return Button that activates with {@link #getRawSelectButton()} */
public final Button getSelectButton() {
return new Button(this::getRawSelectButton);
/** @return Trigger that activates with {@link #getRawSelectButton()} */
public final Trigger getSelectButton() {
return new Trigger(this::getRawSelectButton);
}

/** @return Button that activates with {@link #getRawStartButton()} */
public final Button getStartButton() {
return new Button(this::getRawStartButton);
/** @return Trigger that activates with {@link #getRawStartButton()} */
public final Trigger getStartButton() {
return new Trigger(this::getRawStartButton);
}

// Analog Stick Buttons //
/** @return Button that activates with {@link #getRawLeftStickButton()} */
public final Button getLeftStickButton() {
return new Button(this::getRawLeftStickButton);
// Analog Stick Triggers //
/** @return Trigger that activates with {@link #getRawLeftStickButton()} */
public final Trigger getLeftStickButton() {
return new Trigger(this::getRawLeftStickButton);
}

/** @return Button that activates with {@link #getRawRightStickButton()} */
public final Button getRightStickButton() {
return new Button(this::getRawRightStickButton);
/** @return Trigger that activates with {@link #getRawRightStickButton()} */
public final Trigger getRightStickButton() {
return new Trigger(this::getRawRightStickButton);
}

/*******************************/
Expand Down
2 changes: 1 addition & 1 deletion src/com/stuypulse/stuylib/input/GamepadState.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2022 StuyPulse Robotics. All rights reserved. */
/* Copyright (c) 2023 StuyPulse Robotics. All rights reserved. */
/* This work is licensed under the terms of the MIT license */
/* found in the root directory of this project. */

Expand Down
10 changes: 5 additions & 5 deletions src/com/stuypulse/stuylib/input/WPIGamepad.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* Copyright (c) 2022 StuyPulse Robotics. All rights reserved. */
/* Copyright (c) 2023 StuyPulse Robotics. All rights reserved. */
/* This work is licensed under the terms of the MIT license */
/* found in the root directory of this project. */

package com.stuypulse.stuylib.input;

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

/**
* WPI Gamepad extends Gamepad and adds functions that makes interacting with the underlying
Expand Down Expand Up @@ -79,10 +79,10 @@ public final boolean getRawButton(int button) {

/**
* @param button Joystick button id
* @return Button that activates with {@link #getRawButton(int)}
* @return Trigger that activates with {@link #getRawButton(int)}
*/
public final Button getButton(int button) {
return new Button(() -> getRawButton(button));
public final Trigger getButton(int button) {
return new Trigger(() -> getRawButton(button));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/com/stuypulse/stuylib/input/gamepads/AutoGamepad.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2022 StuyPulse Robotics. All rights reserved. */
/* Copyright (c) 2023 StuyPulse Robotics. All rights reserved. */
/* This work is licensed under the terms of the MIT license */
/* found in the root directory of this project. */

Expand Down
Loading

0 comments on commit ef0e572

Please sign in to comment.