mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
ADXRS450_Gyro: Add null check around reset (#948)
Reset() is the only function without a null check around it. We call the function on startup, which means if it is unplugged the robot crashes. Also added an accessor for checking if it is connected, as some teams (us) would like to handle the case where it was not connected on startup.
This commit is contained in:
committed by
Peter Johnson
parent
82152e90fe
commit
67de595c85
@@ -80,6 +80,10 @@ public class ADXRS450_Gyro extends GyroBase implements Gyro, PIDSource, Sendable
|
||||
setName("ADXRS450_Gyro", port.value);
|
||||
}
|
||||
|
||||
public boolean isConnected() {
|
||||
return m_spi != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calibrate() {
|
||||
if (m_spi == null) {
|
||||
@@ -128,7 +132,9 @@ public class ADXRS450_Gyro extends GyroBase implements Gyro, PIDSource, Sendable
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
m_spi.resetAccumulator();
|
||||
if (m_spi != null) {
|
||||
m_spi.resetAccumulator();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user