2013-12-15 18:30:16 -05:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2019-06-10 22:03:15 -07:00
|
|
|
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
2013-12-15 18:30:16 -05:00
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
2016-01-02 03:02:34 -08:00
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
2013-12-15 18:30:16 -05:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
2018-07-20 00:03:45 -07:00
|
|
|
#include "frc/Timer.h"
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2016-05-26 20:19:23 -07:00
|
|
|
#include <chrono>
|
|
|
|
|
#include <thread>
|
2016-09-25 16:50:13 -07:00
|
|
|
|
2019-11-08 22:53:20 -08:00
|
|
|
#include <hal/FRCUsageReporting.h>
|
2017-08-27 00:11:52 -07:00
|
|
|
|
2018-07-20 00:03:45 -07:00
|
|
|
#include "frc/DriverStation.h"
|
|
|
|
|
#include "frc/RobotController.h"
|
2014-08-04 15:25:41 -04:00
|
|
|
|
2016-11-01 22:33:12 -07:00
|
|
|
namespace frc {
|
|
|
|
|
|
2019-10-26 11:21:40 -04:00
|
|
|
void Wait(double seconds) { frc2::Wait(units::second_t(seconds)); }
|
2017-08-07 17:36:34 -07:00
|
|
|
|
2019-10-26 11:21:40 -04:00
|
|
|
double GetTime() { return frc2::GetTime().to<double>(); }
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2016-11-01 22:33:12 -07:00
|
|
|
} // namespace frc
|
|
|
|
|
|
|
|
|
|
using namespace frc;
|
|
|
|
|
|
2019-10-26 11:21:40 -04:00
|
|
|
const double Timer::kRolloverTime = frc2::Timer::kRolloverTime.to<double>();
|
2018-05-31 20:47:15 -07:00
|
|
|
|
2017-11-16 00:33:51 -08:00
|
|
|
Timer::Timer() { Reset(); }
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2019-10-26 11:21:40 -04:00
|
|
|
double Timer::Get() const { return m_timer.Get().to<double>(); }
|
2019-07-07 19:15:59 -07:00
|
|
|
|
2019-10-26 11:21:40 -04:00
|
|
|
void Timer::Reset() { m_timer.Reset(); }
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2019-10-26 11:21:40 -04:00
|
|
|
void Timer::Start() { m_timer.Start(); }
|
2015-06-25 15:07:55 -04:00
|
|
|
|
2019-10-26 11:21:40 -04:00
|
|
|
void Timer::Stop() { m_timer.Stop(); }
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
bool Timer::HasPeriodPassed(double period) {
|
2019-10-26 11:21:40 -04:00
|
|
|
return m_timer.HasPeriodPassed(units::second_t(period));
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
double Timer::GetFPGATimestamp() {
|
2019-10-26 11:21:40 -04:00
|
|
|
return frc2::Timer::GetFPGATimestamp().to<double>();
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
2016-10-25 19:01:18 -07:00
|
|
|
|
|
|
|
|
double Timer::GetMatchTime() {
|
2019-10-26 11:21:40 -04:00
|
|
|
return frc2::Timer::GetMatchTime().to<double>();
|
2016-10-25 19:01:18 -07:00
|
|
|
}
|