Fixed NetworkAlerts

This commit is contained in:
thenetworkgrinch
2024-01-17 09:17:39 -06:00
parent f16ca43981
commit 1ca3db242c
19 changed files with 510 additions and 108 deletions

View File

@@ -1,7 +1,7 @@
package swervelib.encoders;
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.DutyCycleEncoder;
import swervelib.telemetry.Alert;
/**
* DutyCycle encoders such as "US Digital MA3 with PWM Output, the CTRE Mag Encoder, the Rev Hex Encoder, and the AM Mag
@@ -22,6 +22,10 @@ public class PWMDutyCycleEncoderSwerve extends SwerveAbsoluteEncoder
* Inversion state.
*/
private boolean isInverted;
/**
* An {@link Alert} for if the encoder cannot report accurate velocities.
*/
private Alert inaccurateVelocities;
/**
* Constructor for the PWM duty cycle encoder.
@@ -31,6 +35,11 @@ public class PWMDutyCycleEncoderSwerve extends SwerveAbsoluteEncoder
public PWMDutyCycleEncoderSwerve(int pin)
{
encoder = new DutyCycleEncoder(pin);
inaccurateVelocities = new Alert(
"Encoders",
"The PWM Duty Cycle encoder may not report accurate velocities!",
Alert.AlertType.WARNING_TRACE);
}
/**
@@ -74,7 +83,7 @@ public class PWMDutyCycleEncoderSwerve extends SwerveAbsoluteEncoder
@Override
public double getVelocity()
{
DriverStation.reportWarning("The PWM Duty Cycle encoder may not report accurate velocities!", true);
inaccurateVelocities.set(true);
return encoder.get();
}