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

@@ -26,6 +26,7 @@ import swervelib.motors.SparkMaxSwerve;
import swervelib.motors.SwerveMotor;
import swervelib.motors.TalonFXSwerve;
import swervelib.motors.TalonSRXSwerve;
import swervelib.telemetry.Alert;
/**
* Device JSON parsed class. Used to access the JSON data.
@@ -33,18 +34,30 @@ import swervelib.motors.TalonSRXSwerve;
public class DeviceJson
{
/**
* An {@link Alert} for if the CAN ID is greater than 40.
*/
private final Alert canIdWarning = new Alert("JSON",
"CAN IDs greater than 40 can cause undefined behaviour, please use a CAN ID below 40!",
Alert.AlertType.WARNING);
/**
* An {@link Alert} for if there is an I2C lockup issue on the roboRIO.
*/
private final Alert i2cLockupWarning = new Alert("IMU",
"I2C lockup issue detected on roboRIO. Check console for more information.",
Alert.AlertType.WARNING);
/**
* The device type, e.g. pigeon/pigeon2/sparkmax/talonfx/navx
*/
public String type;
public String type;
/**
* The CAN ID or pin ID of the device.
*/
public int id;
public int id;
/**
* The CAN bus name which the device resides on if using CAN.
*/
public String canbus = "";
public String canbus = "";
/**
* Create a {@link SwerveAbsoluteEncoder} from the current configuration.
@@ -57,8 +70,7 @@ public class DeviceJson
{
if (id > 40)
{
DriverStation.reportWarning("CAN IDs greater than 40 can cause undefined behaviour, please use a CAN ID below 40!",
false);
canIdWarning.set(true);
}
switch (type)
{
@@ -99,8 +111,7 @@ public class DeviceJson
{
if (id > 40)
{
DriverStation.reportWarning("CAN IDs greater than 40 can cause undefined behaviour, please use a CAN ID below 40!",
false);
canIdWarning.set(true);
}
switch (type)
{
@@ -121,6 +132,7 @@ public class DeviceJson
"\nhttps://docs.wpilib.org/en/stable/docs/yearly-overview/known-issues" +
".html#onboard-i2c-causing-system-lockups",
false);
i2cLockupWarning.set(true);
return new NavXSwerve(I2C.Port.kMXP);
case "navx_usb":
return new NavXSwerve(Port.kUSB);
@@ -145,8 +157,7 @@ public class DeviceJson
{
if (id > 40)
{
DriverStation.reportWarning("CAN IDs greater than 40 can cause undefined behaviour, please use a CAN ID below 40!",
false);
canIdWarning.set(true);
}
switch (type)
{