-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update vendordeps and project organization
- Loading branch information
Showing
60 changed files
with
1,626 additions
and
3,306 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"enableCppIntellisense": false, | ||
"currentLanguage": "java", | ||
"projectYear": "2024", | ||
"projectYear": "2025", | ||
"teamNumber": 340 | ||
} |
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,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. |
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,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
115
src/main/java/com/revrobotics/spark/config/SignalsConfig.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,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); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.