Skip to content

Commit

Permalink
Begin cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bryceroethel committed Oct 16, 2024
1 parent 875603d commit e8c96db
Show file tree
Hide file tree
Showing 11 changed files with 360 additions and 394 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"java.inlayHints.parameterNames.enabled": "literals",
"java.inlayHints.parameterNames.exclusions": [
"edu.wpi.first.math.util.Units.*",
"(key, value)",
"(initialValue)",
"(magnitude)",
"(value)"
Expand Down Expand Up @@ -51,6 +52,7 @@
"CTRE",
"Deadband",
"Deadbands",
"Deadzone",
"Decel",
"DeltAng",
"DeltVel",
Expand All @@ -70,6 +72,7 @@
"Grav",
"GRRDashboard",
"Holonomic",
"Intaking",
"Integ",
"Interpolatable",
"Itor",
Expand Down
26 changes: 23 additions & 3 deletions src/main/java/org/team340/lib/util/rev/SparkFlexConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,33 @@
import com.revrobotics.REVLibError;
import org.team340.lib.util.Math2;
import org.team340.lib.util.Sleep;
import org.team340.robot.Constants;

/**
* Config builder for {@link CANSparkFlex}.
*/
public class SparkFlexConfig extends RevConfigBase<CANSparkFlex> {

private static final double FACTORY_DEFAULTS_SLEEP = 0.025;
private static final double kFactoryDefaultsSleep = 0.035;
private static final SparkFlexConfig kDefaults = new SparkFlexConfig()
.clearFaults()
.restoreFactoryDefaults()
.enableVoltageCompensation(Constants.VOLTAGE)
.setPeriodicFramePeriod(Frame.S0, 20)
.setPeriodicFramePeriod(Frame.S1, 20)
.setPeriodicFramePeriod(Frame.S2, 20)
.setPeriodicFramePeriod(Frame.S3, 10000)
.setPeriodicFramePeriod(Frame.S4, 10000)
.setPeriodicFramePeriod(Frame.S5, 10000)
.setPeriodicFramePeriod(Frame.S6, 10000)
.setPeriodicFramePeriod(Frame.S7, 10000);

/**
* Returns a default Spark Flex config.
*/
public static SparkFlexConfig defaults() {
return kDefaults.clone();
}

/**
* Clones this config.
Expand Down Expand Up @@ -555,7 +575,7 @@ public SparkFlexConfig restoreFactoryDefaults() {
addStep(
sparkFlex -> {
REVLibError res = sparkFlex.restoreFactoryDefaults();
Sleep.seconds(FACTORY_DEFAULTS_SLEEP, true);
Sleep.seconds(kFactoryDefaultsSleep, true);
return res;
},
"Restore Factory Defaults"
Expand All @@ -572,7 +592,7 @@ public SparkFlexConfig restoreFactoryDefaults(boolean persist) {
addStep(
sparkFlex -> {
REVLibError res = sparkFlex.restoreFactoryDefaults(persist);
Sleep.seconds(FACTORY_DEFAULTS_SLEEP, true);
Sleep.seconds(kFactoryDefaultsSleep, true);
return res;
},
"Restore Factory Defaults"
Expand Down
25 changes: 22 additions & 3 deletions src/main/java/org/team340/lib/util/rev/SparkMaxConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,26 @@
*/
public class SparkMaxConfig extends RevConfigBase<CANSparkMax> {

private static final double FACTORY_DEFAULTS_SLEEP = 0.050;
private static final double kFactoryDefaultsSleep = 0.050;
private static final SparkMaxConfig kDefaults = new SparkMaxConfig()
.clearFaults()
.restoreFactoryDefaults()
.enableVoltageCompensation(12.0)
.setPeriodicFramePeriod(Frame.S0, 20)
.setPeriodicFramePeriod(Frame.S1, 20)
.setPeriodicFramePeriod(Frame.S2, 20)
.setPeriodicFramePeriod(Frame.S3, 10000)
.setPeriodicFramePeriod(Frame.S4, 10000)
.setPeriodicFramePeriod(Frame.S5, 10000)
.setPeriodicFramePeriod(Frame.S6, 10000)
.setPeriodicFramePeriod(Frame.S7, 10000);

/**
* Returns a default Spark MAX config.
*/
public static SparkMaxConfig defaults() {
return kDefaults.clone();
}

/**
* Clones this config.
Expand Down Expand Up @@ -551,7 +570,7 @@ public SparkMaxConfig restoreFactoryDefaults() {
addStep(
sparkMax -> {
REVLibError res = sparkMax.restoreFactoryDefaults();
Sleep.seconds(FACTORY_DEFAULTS_SLEEP, true);
Sleep.seconds(kFactoryDefaultsSleep, true);
return res;
},
"Restore Factory Defaults"
Expand All @@ -568,7 +587,7 @@ public SparkMaxConfig restoreFactoryDefaults(boolean persist) {
addStep(
sparkMax -> {
REVLibError res = sparkMax.restoreFactoryDefaults(persist);
Sleep.seconds(FACTORY_DEFAULTS_SLEEP, true);
Sleep.seconds(kFactoryDefaultsSleep, true);
return res;
},
"Restore Factory Defaults"
Expand Down
Loading

0 comments on commit e8c96db

Please sign in to comment.