mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
[wpilibc] Remove incorrect timer rollover (#2523)
If the 64 bit FPGA timer rolls over, a 32 bit value is added for the rollover, an artifact of when it was a 32 bit timer. The 64 bit microsecond timer won't rollover for 500k years so remove the check for simplicity. Fixes #2504
This commit is contained in:
@@ -36,9 +36,6 @@ units::second_t GetTime() {
|
||||
|
||||
using namespace frc2;
|
||||
|
||||
// for compatibility with msvc12--see C2864
|
||||
const units::second_t Timer::kRolloverTime = units::second_t((1ll << 32) / 1e6);
|
||||
|
||||
Timer::Timer() { Reset(); }
|
||||
|
||||
Timer::Timer(const Timer& rhs)
|
||||
@@ -77,13 +74,6 @@ units::second_t Timer::Get() const {
|
||||
|
||||
std::scoped_lock lock(m_mutex);
|
||||
if (m_running) {
|
||||
// If the current time is before the start time, then the FPGA clock rolled
|
||||
// over. Compensate by adding the ~71 minutes that it takes to roll over to
|
||||
// the current time.
|
||||
if (currentTime < m_startTime) {
|
||||
currentTime += kRolloverTime;
|
||||
}
|
||||
|
||||
result = (currentTime - m_startTime) + m_accumulatedTime;
|
||||
} else {
|
||||
result = m_accumulatedTime;
|
||||
|
||||
Reference in New Issue
Block a user