[wpilib] Add way to silence joystick connection warnings (#2845)

Warnings cannot be silenced when connected to FMS.
This commit is contained in:
Prateek Machiraju
2020-11-14 15:00:56 -05:00
committed by GitHub
parent 7a73946ce1
commit 2ef67f20a7
5 changed files with 121 additions and 8 deletions

View File

@@ -543,6 +543,14 @@ void DriverStation::GetData() {
SendMatchData();
}
void DriverStation::SilenceJoystickConnectionWarning(bool silence) {
m_silenceJoystickWarning = silence;
}
bool DriverStation::IsJoystickConnectionWarningSilenced() const {
return !IsFMSAttached() && m_silenceJoystickWarning;
}
DriverStation::DriverStation() {
HAL_Initialize(500, 0);
m_waitForDataCounter = 0;
@@ -570,10 +578,12 @@ void DriverStation::ReportJoystickUnpluggedError(const wpi::Twine& message) {
}
void DriverStation::ReportJoystickUnpluggedWarning(const wpi::Twine& message) {
double currentTime = Timer::GetFPGATimestamp();
if (currentTime > m_nextMessageTime) {
ReportWarning(message);
m_nextMessageTime = currentTime + kJoystickUnpluggedMessageInterval;
if (IsFMSAttached() || !m_silenceJoystickWarning) {
double currentTime = Timer::GetFPGATimestamp();
if (currentTime > m_nextMessageTime) {
ReportWarning(message);
m_nextMessageTime = currentTime + kJoystickUnpluggedMessageInterval;
}
}
}