Skip to content

Commit

Permalink
Update vendordeps and project organization
Browse files Browse the repository at this point in the history
  • Loading branch information
BR88C committed Nov 9, 2024
1 parent 406cd72 commit 26561d3
Show file tree
Hide file tree
Showing 60 changed files with 1,626 additions and 3,306 deletions.
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"Accl",
"Accum",
"ADIS",
"Backports",
"Bezier",
"Botpose",
"Brushless",
Expand All @@ -65,7 +66,10 @@
"Discretization",
"Discretize",
"Discretizing",
"Doppel",
"DTheta",
"EEPROM",
"Expdelta",
"Falsi",
"Feedforward",
"Fullscreen",
Expand Down Expand Up @@ -106,6 +110,9 @@
"Sendables",
"Setpoint",
"Setpoints",
"Signif",
"Significand",
"Subnormals",
"Subuid",
"TalonFX",
"TalonSRX",
Expand Down
2 changes: 1 addition & 1 deletion .wpilib/wpilib_preferences.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"enableCppIntellisense": false,
"currentLanguage": "java",
"projectYear": "2024",
"projectYear": "2025",
"teamNumber": 340
}
3 changes: 3 additions & 0 deletions src/main/deploy/example.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Files placed in this directory will be deployed to the RoboRIO into the
'deploy' directory in the home folder. Use the 'Filesystem.getDeployDirectory' wpilib function
to get a proper path relative to the deploy directory.
80 changes: 80 additions & 0 deletions src/main/java/com/revrobotics/spark/SparkShim.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.revrobotics.spark;

import com.revrobotics.REVLibError;
import com.revrobotics.jni.CANSparkJNI;
import com.revrobotics.spark.config.ClosedLoopConfig.ClosedLoopSlot;

public final class SparkShim {

private SparkShim() {
throw new AssertionError("This is a utility class!");
}

public static long extractHandle(SparkLowLevel spark) {
return spark.sparkHandle;
}

public static int getFaults(SparkLowLevel spark) {
return CANSparkJNI.c_Spark_GetFaults(spark.sparkHandle);
}

public static int getStickyFaults(SparkLowLevel spark) {
return CANSparkJNI.c_Spark_GetStickyFaults(spark.sparkHandle);
}

public static int getWarnings(SparkLowLevel spark) {
return CANSparkJNI.c_Spark_GetWarnings(spark.sparkHandle);
}

public static int getStickyWarnings(SparkLowLevel spark) {
return CANSparkJNI.c_Spark_GetStickyWarnings(spark.sparkHandle);
}

public static REVLibError setP(SparkLowLevel spark, ClosedLoopSlot slot, double gain) {
return REVLibError.fromInt(
CANSparkJNI.c_Spark_SetParameterFloat32(spark.sparkHandle, 13 + slot.value * 8, (float) gain)
);
}

public static REVLibError setI(SparkLowLevel spark, ClosedLoopSlot slot, double gain) {
return REVLibError.fromInt(
CANSparkJNI.c_Spark_SetParameterFloat32(spark.sparkHandle, 14 + slot.value * 8, (float) gain)
);
}

public static REVLibError setD(SparkLowLevel spark, ClosedLoopSlot slot, double gain) {
return REVLibError.fromInt(
CANSparkJNI.c_Spark_SetParameterFloat32(spark.sparkHandle, 15 + slot.value * 8, (float) gain)
);
}

public static REVLibError setFF(SparkLowLevel spark, ClosedLoopSlot slot, double gain) {
return REVLibError.fromInt(
CANSparkJNI.c_Spark_SetParameterFloat32(spark.sparkHandle, 16 + slot.value * 8, (float) gain)
);
}

public static REVLibError setIZone(SparkLowLevel spark, ClosedLoopSlot slot, double iZone) {
return REVLibError.fromInt(
CANSparkJNI.c_Spark_SetParameterFloat32(spark.sparkHandle, 17 + slot.value * 8, (float) iZone)
);
}

public static REVLibError setDFilter(SparkLowLevel spark, ClosedLoopSlot slot, double gain) {
return REVLibError.fromInt(
CANSparkJNI.c_Spark_SetParameterFloat32(spark.sparkHandle, 18 + slot.value * 8, (float) gain)
);
}

public static REVLibError setOutputMin(SparkLowLevel spark, ClosedLoopSlot slot, double value) {
return REVLibError.fromInt(
CANSparkJNI.c_Spark_SetParameterFloat32(spark.sparkHandle, 19 + slot.value * 8, (float) value)
);
}

public static REVLibError setOutputMax(SparkLowLevel spark, ClosedLoopSlot slot, double value) {
return REVLibError.fromInt(
CANSparkJNI.c_Spark_SetParameterFloat32(spark.sparkHandle, 20 + slot.value * 8, (float) value)
);
}
}
115 changes: 115 additions & 0 deletions src/main/java/com/revrobotics/spark/config/SignalsConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
package com.revrobotics.spark.config;

public class SignalsConfig extends BaseConfig {

/**
* Applies settings from another {@link SignalsConfig} to this one.
*
* <p>Settings in the provided config will overwrite existing values in this object. Settings not
* specified in the provided config remain unchanged.
*
* @param config The {@link SignalsConfig} to copy settings from
* @return The updated {@link SignalsConfig} for method chaining
*/
public SignalsConfig apply(SignalsConfig config) {
super.apply(config);
return this;
}

public SignalsConfig status0Period(int periodMs) {
setPeriod(SparkParameter.kStatus0Period, periodMs);
return this;
}

public SignalsConfig status1Period(int periodMs) {
setPeriod(SparkParameter.kStatus1Period, periodMs);
return this;
}

public SignalsConfig status1Enabled(boolean enabled) {
setEnabled(SparkParameter.kForceEnableStatus1, enabled);
return this;
}

public SignalsConfig status2Period(int periodMs) {
setPeriod(SparkParameter.kStatus2Period, periodMs);
return this;
}

public SignalsConfig status2Enabled(boolean enabled) {
setEnabled(SparkParameter.kForceEnableStatus2, enabled);
return this;
}

public SignalsConfig status3Period(int periodMs) {
setPeriod(SparkParameter.kStatus3Period, periodMs);
return this;
}

public SignalsConfig status3Enabled(boolean enabled) {
setEnabled(SparkParameter.kForceEnableStatus3, enabled);
return this;
}

public SignalsConfig status4Period(int periodMs) {
setPeriod(SparkParameter.kStatus4Period, periodMs);
return this;
}

public SignalsConfig status4Enabled(boolean enabled) {
setEnabled(SparkParameter.kForceEnableStatus4, enabled);
return this;
}

public SignalsConfig status5Period(int periodMs) {
setPeriod(SparkParameter.kStatus5Period, periodMs);
return this;
}

public SignalsConfig status5Enabled(boolean enabled) {
setEnabled(SparkParameter.kForceEnableStatus5, enabled);
return this;
}

public SignalsConfig status6Period(int periodMs) {
setPeriod(SparkParameter.kStatus6Period, periodMs);
return this;
}

public SignalsConfig status6Enabled(boolean enabled) {
setEnabled(SparkParameter.kForceEnableStatus6, enabled);
return this;
}

public SignalsConfig status7Period(int periodMs) {
setPeriod(SparkParameter.kStatus7Period, periodMs);
return this;
}

public SignalsConfig status7Enabled(boolean enabled) {
setEnabled(SparkParameter.kForceEnableStatus7, enabled);
return this;
}

private void setPeriod(SparkParameter parameter, int periodMs) {
int id = parameter.value;
Object value = getParameter(id);
if (value == null) {
putParameter(id, periodMs);
} else {
int currentPeriodMs = (int) value;
putParameter(id, Math.min(currentPeriodMs, periodMs));
}
}

private void setEnabled(SparkParameter parameter, boolean enabled) {
int id = parameter.value;
Object value = getParameter(id);
if (value == null) {
putParameter(id, enabled ? 1 : 0);
} else {
int currentValue = (int) value;
putParameter(id, (currentValue == 1 || enabled) ? 1 : 0);
}
}
}
105 changes: 0 additions & 105 deletions src/main/java/org/team340/lib/controller/Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,51 +57,6 @@ public Trigger pov(int angle) {
return pov(0, angle, loop);
}

@Override
public Trigger povUp() {
return pov(0);
}

@Override
public Trigger povUpRight() {
return pov(45);
}

@Override
public Trigger povRight() {
return pov(90);
}

@Override
public Trigger povDownRight() {
return pov(135);
}

@Override
public Trigger povDown() {
return pov(180);
}

@Override
public Trigger povDownLeft() {
return pov(225);
}

@Override
public Trigger povLeft() {
return pov(270);
}

@Override
public Trigger povUpLeft() {
return pov(315);
}

@Override
public Trigger povCenter() {
return pov(-1);
}

@Override
public Trigger axisLessThan(int axis, double threshold) {
return axisLessThan(axis, threshold, loop);
Expand All @@ -117,66 +72,6 @@ public Trigger axisMagnitudeGreaterThan(int axis, double threshold) {
return axisMagnitudeGreaterThan(axis, threshold, loop);
}

@Override
public Trigger a() {
return a(loop);
}

@Override
public Trigger b() {
return b(loop);
}

@Override
public Trigger x() {
return x(loop);
}

@Override
public Trigger y() {
return y(loop);
}

@Override
public Trigger leftBumper() {
return leftBumper(loop);
}

@Override
public Trigger rightBumper() {
return rightBumper(loop);
}

@Override
public Trigger back() {
return back(loop);
}

@Override
public Trigger start() {
return start(loop);
}

@Override
public Trigger leftStick() {
return leftStick(loop);
}

@Override
public Trigger rightStick() {
return rightStick(loop);
}

@Override
public Trigger leftTrigger(double threshold) {
return leftTrigger(threshold, loop);
}

@Override
public Trigger rightTrigger(double threshold) {
return rightTrigger(threshold, loop);
}

/**
* Constructs a Trigger instance around the axis value of the left trigger.
* @return A {@link Trigger} instance.
Expand Down
Loading

0 comments on commit 26561d3

Please sign in to comment.