mirror of
https://github.com/BroncBotz3481/YAGSL
synced 2026-06-22 06:41:39 +00:00
Fixed NetworkAlerts
This commit is contained in:
@@ -4,9 +4,9 @@ import com.revrobotics.AbsoluteEncoder;
|
||||
import com.revrobotics.CANSparkMax;
|
||||
import com.revrobotics.REVLibError;
|
||||
import com.revrobotics.SparkAbsoluteEncoder.Type;
|
||||
import edu.wpi.first.wpilibj.DriverStation;
|
||||
import java.util.function.Supplier;
|
||||
import swervelib.motors.SwerveMotor;
|
||||
import swervelib.telemetry.Alert;
|
||||
|
||||
/**
|
||||
* SparkMax absolute encoder, attached through the data port.
|
||||
@@ -17,7 +17,15 @@ public class SparkMaxEncoderSwerve extends SwerveAbsoluteEncoder
|
||||
/**
|
||||
* The {@link AbsoluteEncoder} representing the duty cycle encoder attached to the SparkMax.
|
||||
*/
|
||||
public AbsoluteEncoder encoder;
|
||||
public AbsoluteEncoder encoder;
|
||||
/**
|
||||
* An {@link Alert} for if there is a failure configuring the encoder.
|
||||
*/
|
||||
private Alert failureConfiguring;
|
||||
/**
|
||||
* An {@link Alert} for if there is a failure configuring the encoder offset.
|
||||
*/
|
||||
private Alert offsetFailure;
|
||||
|
||||
/**
|
||||
* Create the {@link SparkMaxEncoderSwerve} object as a duty cycle from the {@link CANSparkMax} motor.
|
||||
@@ -36,6 +44,14 @@ public class SparkMaxEncoderSwerve extends SwerveAbsoluteEncoder
|
||||
{
|
||||
throw new RuntimeException("Motor given to instantiate SparkMaxEncoder is not a CANSparkMax");
|
||||
}
|
||||
failureConfiguring = new Alert(
|
||||
"Encoders",
|
||||
"Failure configuring SparkMax Analog Encoder",
|
||||
Alert.AlertType.WARNING_TRACE);
|
||||
offsetFailure = new Alert(
|
||||
"Encoders",
|
||||
"Failure to set Absolute Encoder Offset",
|
||||
Alert.AlertType.WARNING_TRACE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,7 +68,7 @@ public class SparkMaxEncoderSwerve extends SwerveAbsoluteEncoder
|
||||
return;
|
||||
}
|
||||
}
|
||||
DriverStation.reportWarning("Failure configuring encoder", true);
|
||||
failureConfiguring.set(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,7 +140,8 @@ public class SparkMaxEncoderSwerve extends SwerveAbsoluteEncoder
|
||||
return true;
|
||||
}
|
||||
}
|
||||
DriverStation.reportWarning("Failure to set Absolute Encoder Offset Error: " + error, false);
|
||||
offsetFailure.setText("Failure to set Absolute Encoder Offset Error: " + error);
|
||||
offsetFailure.set(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user