blob: c91bc13c1f9986afcb79a74623208621e424ee7c [file] [log] [blame]
Brian Silverman8fce7482020-01-05 13:18:21 -08001/*----------------------------------------------------------------------------*/
2/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
3/* Open Source Software - may be modified and shared by FRC teams. The code */
4/* must be accompanied by the FIRST BSD license file in the root directory of */
5/* the project. */
6/*----------------------------------------------------------------------------*/
7
8#include "frc/Timer.h"
9
10#include <chrono>
11#include <thread>
12
13#include <hal/FRCUsageReporting.h>
14
15#include "frc/DriverStation.h"
16#include "frc/RobotController.h"
17
18namespace frc {
19
20void Wait(double seconds) { frc2::Wait(units::second_t(seconds)); }
21
22double GetTime() { return frc2::GetTime().to<double>(); }
23
24} // namespace frc
25
26using namespace frc;
27
28const double Timer::kRolloverTime = frc2::Timer::kRolloverTime.to<double>();
29
30Timer::Timer() { Reset(); }
31
32double Timer::Get() const { return m_timer.Get().to<double>(); }
33
34void Timer::Reset() { m_timer.Reset(); }
35
36void Timer::Start() { m_timer.Start(); }
37
38void Timer::Stop() { m_timer.Stop(); }
39
40bool Timer::HasPeriodPassed(double period) {
41 return m_timer.HasPeriodPassed(units::second_t(period));
42}
43
44double Timer::GetFPGATimestamp() {
45 return frc2::Timer::GetFPGATimestamp().to<double>();
46}
47
48double Timer::GetMatchTime() {
49 return frc2::Timer::GetMatchTime().to<double>();
50}