Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
[utils] Add logStatusCode function for CTRE StatusCodes
Browse files Browse the repository at this point in the history
  • Loading branch information
spacey-sooty committed Jul 9, 2024
1 parent 3879dff commit 2d6c3f0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/main/java/frc/robot/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

package frc.robot;

import com.ctre.phoenix6.StatusCode;
import edu.wpi.first.util.WPIUtilJNI;
import edu.wpi.first.wpilibj.DataLogManager;

/* Utilities used across the codebase */
public final class Utils {
Expand All @@ -30,4 +32,19 @@ public static double now() {
public static double deadzone(double value) {
return (Math.abs(value) > 0.05) ? value : 0;
}

/** A function to log CTRE {@link StatusCode}s to Datalog. */
public static void logStatusCode(StatusCode code) {
if (code.isOK()) {
return;
}

if (code.isWarning()) {
DataLogManager.log("Warning: " + code.getDescription());
}

if (code.isError()) {
DataLogManager.log("Error: " + code.getDescription());
}
}
}

0 comments on commit 2d6c3f0

Please sign in to comment.