mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
wpilibc: Add overloads for units (#1815)
Add unit-taking overloads to the following classes: - IterativeRobotBase - LinearFilter - Notifier - TimedRobot - Timer (HasPeriodPassed only) - frc2::PIDController The corresponding non-units-taking functions have been deprecated. The return value of TimedRobot::GetPeriod() was updated. This is a breaking change, users should use to<double> to get the value in seconds. Other return values, e.g. Timer::Get(), have NOT been updated due to much wider use.
This commit is contained in:
committed by
Peter Johnson
parent
f1d71da8a9
commit
c07ac23532
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -43,7 +43,9 @@ void TimedRobot::StartCompetition() {
|
||||
}
|
||||
}
|
||||
|
||||
double TimedRobot::GetPeriod() const { return m_period; }
|
||||
units::second_t TimedRobot::GetPeriod() const {
|
||||
return units::second_t(m_period);
|
||||
}
|
||||
|
||||
TimedRobot::TimedRobot(double period) : IterativeRobotBase(period) {
|
||||
int32_t status = 0;
|
||||
@@ -54,6 +56,15 @@ TimedRobot::TimedRobot(double period) : IterativeRobotBase(period) {
|
||||
HALUsageReporting::kFramework_Timed);
|
||||
}
|
||||
|
||||
TimedRobot::TimedRobot(units::second_t period) : IterativeRobotBase(period) {
|
||||
int32_t status = 0;
|
||||
m_notifier = HAL_InitializeNotifier(&status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_Framework,
|
||||
HALUsageReporting::kFramework_Timed);
|
||||
}
|
||||
|
||||
TimedRobot::~TimedRobot() {
|
||||
int32_t status = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user