mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-28 02:11:43 +00:00
[wpilib] Add way to silence joystick connection warnings (#2845)
Warnings cannot be silenced when connected to FMS.
This commit is contained in:
committed by
GitHub
parent
7a73946ce1
commit
2ef67f20a7
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -431,6 +431,23 @@ class DriverStation : public ErrorBase {
|
||||
*/
|
||||
void WakeupWaitForData();
|
||||
|
||||
/**
|
||||
* Allows the user to specify whether they want joystick connection warnings
|
||||
* to be printed to the console. This setting is ignored when the FMS is
|
||||
* connected -- warnings will always be on in that scenario.
|
||||
*
|
||||
* @param silence Whether warning messages should be silenced.
|
||||
*/
|
||||
void SilenceJoystickConnectionWarning(bool silence);
|
||||
|
||||
/**
|
||||
* Returns whether joystick connection warnings are silenced. This will
|
||||
* always return false when connected to the FMS.
|
||||
*
|
||||
* @return Whether joystick connection warnings are silenced.
|
||||
*/
|
||||
bool IsJoystickConnectionWarningSilenced() const;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Copy data from the DS task for the user.
|
||||
@@ -482,6 +499,8 @@ class DriverStation : public ErrorBase {
|
||||
wpi::condition_variable m_waitForDataCond;
|
||||
int m_waitForDataCounter;
|
||||
|
||||
bool m_silenceJoystickWarning = false;
|
||||
|
||||
// Robot state status variables
|
||||
bool m_userInDisabled = false;
|
||||
bool m_userInAutonomous = false;
|
||||
|
||||
Reference in New Issue
Block a user