Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 1 | /*----------------------------------------------------------------------------*/ |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame^] | 2 | /* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */ |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 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 | |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame^] | 10 | #include <units/time.h> |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 11 | |
| 12 | namespace frc { |
| 13 | |
| 14 | void Wait(double seconds) { frc2::Wait(units::second_t(seconds)); } |
| 15 | |
| 16 | double GetTime() { return frc2::GetTime().to<double>(); } |
| 17 | |
| 18 | } // namespace frc |
| 19 | |
| 20 | using namespace frc; |
| 21 | |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 22 | Timer::Timer() { Reset(); } |
| 23 | |
| 24 | double Timer::Get() const { return m_timer.Get().to<double>(); } |
| 25 | |
| 26 | void Timer::Reset() { m_timer.Reset(); } |
| 27 | |
| 28 | void Timer::Start() { m_timer.Start(); } |
| 29 | |
| 30 | void Timer::Stop() { m_timer.Stop(); } |
| 31 | |
| 32 | bool Timer::HasPeriodPassed(double period) { |
| 33 | return m_timer.HasPeriodPassed(units::second_t(period)); |
| 34 | } |
| 35 | |
| 36 | double Timer::GetFPGATimestamp() { |
| 37 | return frc2::Timer::GetFPGATimestamp().to<double>(); |
| 38 | } |
| 39 | |
| 40 | double Timer::GetMatchTime() { |
| 41 | return frc2::Timer::GetMatchTime().to<double>(); |
| 42 | } |