Add delay to version check (#466)

Rate limits version check spam print

Co-authored-by: Chris Gerth <gerth2@users.noreply.github.com>
This commit is contained in:
Matt
2022-10-21 20:53:28 -04:00
committed by GitHub
parent aff163fc6a
commit def40484e3
3 changed files with 22 additions and 5 deletions

View File

@@ -30,6 +30,7 @@
#include <networktables/NetworkTable.h>
#include <networktables/NetworkTableEntry.h>
#include <networktables/NetworkTableInstance.h>
#include <units/time.h>
#include <wpi/deprecated.h>
#include "photonlib/PhotonPipelineResult.h"
@@ -66,7 +67,7 @@ class PhotonCamera {
* Returns the latest pipeline result.
* @return The latest pipeline result.
*/
PhotonPipelineResult GetLatestResult() const;
PhotonPipelineResult GetLatestResult();
/**
* Toggles driver mode.
@@ -136,7 +137,7 @@ class PhotonCamera {
*/
WPI_DEPRECATED(
"This method should be replaced with PhotonPipelineResult::HasTargets()")
bool HasTargets() const { return GetLatestResult().HasTargets(); }
bool HasTargets() { return GetLatestResult().HasTargets(); }
inline static void SetVersionCheckEnabled(bool enabled) {
PhotonCamera::VERSION_CHECK_ENABLED = enabled;
@@ -158,9 +159,10 @@ class PhotonCamera {
mutable Packet packet;
private:
units::second_t lastVersionCheckTime = 0_s;
inline static bool VERSION_CHECK_ENABLED = true;
void VerifyVersion() const;
void VerifyVersion();
};
} // namespace photonlib