mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Remove obsolete timer functions and replace with std::chrono (#64)
Removed delayTicks(), delayMillis(), delaySeconds(), HAL_NO_WAIT, HAL_WAIT_FOREVER, niTimestamp32(), and niTimestamp64(). Replaced clock_gettime() and usleep() with std::chrono.
This commit is contained in:
committed by
Peter Johnson
parent
4af0bbddee
commit
fa8bb3fa91
@@ -7,9 +7,9 @@
|
||||
|
||||
#include "Timer.h"
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
#include "HAL/HAL.h"
|
||||
#include "Utility.h"
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
*/
|
||||
void Wait(double seconds) {
|
||||
if (seconds < 0.0) return;
|
||||
delaySeconds(seconds);
|
||||
std::this_thread::sleep_for(std::chrono::duration<double>(seconds));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -41,12 +41,9 @@ double GetClock() { return Timer::GetFPGATimestamp(); }
|
||||
* on Saturday.
|
||||
*/
|
||||
double GetTime() {
|
||||
struct timespec tp;
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &tp);
|
||||
double realTime = (double)tp.tv_sec + (double)((double)tp.tv_nsec * 1e-9);
|
||||
|
||||
return (realTime);
|
||||
using namespace std::chrono;
|
||||
return duration_cast<duration<double>>(system_clock::now().time_since_epoch())
|
||||
.count();
|
||||
}
|
||||
|
||||
// for compatibility with msvc12--see C2864
|
||||
@@ -167,9 +164,3 @@ double Timer::GetFPGATimestamp() {
|
||||
// Call the helper GetFPGATime() in Utility.cpp
|
||||
return GetFPGATime() * 1.0e-6;
|
||||
}
|
||||
|
||||
// Internal function that reads the PPC timestamp counter.
|
||||
extern "C" {
|
||||
uint32_t niTimestamp32(void);
|
||||
uint64_t niTimestamp64(void);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user