blob: b428e03c5a904d6dc36367b12dce1b5d6876e335 [file] [log] [blame]
Brian Silverman8fce7482020-01-05 13:18:21 -08001/*----------------------------------------------------------------------------*/
Austin Schuh1e69f942020-11-14 15:06:14 -08002/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */
Brian Silverman8fce7482020-01-05 13:18:21 -08003/* 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 Schuh1e69f942020-11-14 15:06:14 -080010#include <units/time.h>
Brian Silverman8fce7482020-01-05 13:18:21 -080011
12namespace frc {
13
14void Wait(double seconds) { frc2::Wait(units::second_t(seconds)); }
15
16double GetTime() { return frc2::GetTime().to<double>(); }
17
18} // namespace frc
19
20using namespace frc;
21
Brian Silverman8fce7482020-01-05 13:18:21 -080022Timer::Timer() { Reset(); }
23
24double Timer::Get() const { return m_timer.Get().to<double>(); }
25
26void Timer::Reset() { m_timer.Reset(); }
27
28void Timer::Start() { m_timer.Start(); }
29
30void Timer::Stop() { m_timer.Stop(); }
31
32bool Timer::HasPeriodPassed(double period) {
33 return m_timer.HasPeriodPassed(units::second_t(period));
34}
35
36double Timer::GetFPGATimestamp() {
37 return frc2::Timer::GetFPGATimestamp().to<double>();
38}
39
40double Timer::GetMatchTime() {
41 return frc2::Timer::GetMatchTime().to<double>();
42}