mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
[wpilib] Add timestamp getters with configurable time base (#7378)
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "frc/RobotController.h"
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
#include <hal/CAN.h>
|
||||
@@ -15,6 +16,10 @@
|
||||
|
||||
using namespace frc;
|
||||
|
||||
std::function<uint64_t()> RobotController::m_timeSource = [] {
|
||||
return RobotController::GetFPGATime();
|
||||
};
|
||||
|
||||
int RobotController::GetFPGAVersion() {
|
||||
int32_t status = 0;
|
||||
int version = HAL_GetFPGAVersion(&status);
|
||||
@@ -49,6 +54,14 @@ int32_t RobotController::GetTeamNumber() {
|
||||
return HAL_GetTeamNumber();
|
||||
}
|
||||
|
||||
void RobotController::SetTimeSource(std::function<uint64_t()> supplier) {
|
||||
m_timeSource = supplier;
|
||||
}
|
||||
|
||||
uint64_t RobotController::GetTime() {
|
||||
return m_timeSource();
|
||||
}
|
||||
|
||||
uint64_t RobotController::GetFPGATime() {
|
||||
int32_t status = 0;
|
||||
uint64_t time = HAL_GetFPGATime(&status);
|
||||
|
||||
Reference in New Issue
Block a user