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:
Prateek Machiraju
2019-08-17 00:56:48 -04:00
committed by Peter Johnson
parent f1d71da8a9
commit c07ac23532
15 changed files with 136 additions and 35 deletions

View File

@@ -15,6 +15,8 @@
#include <utility>
#include <hal/Types.h>
#include <units/units.h>
#include <wpi/deprecated.h>
#include <wpi/mutex.h>
#include "frc/ErrorBase.h"
@@ -58,8 +60,18 @@ class Notifier : public ErrorBase {
*
* @param delay Seconds to wait before the handler is called.
*/
WPI_DEPRECATED("Use unit-safe StartSingle method instead.")
void StartSingle(double delay);
/**
* Register for single event notification.
*
* A timer event is queued for a single event after the specified delay.
*
* @param delay Amount of time to wait before the handler is called.
*/
void StartSingle(units::second_t delay);
/**
* Register for periodic event notification.
*
@@ -70,8 +82,21 @@ class Notifier : public ErrorBase {
* @param period Period in seconds to call the handler starting one period
* after the call to this method.
*/
WPI_DEPRECATED("Use unit-safe StartPeriodic method instead.")
void StartPeriodic(double period);
/**
* Register for periodic event notification.
*
* A timer event is queued for periodic event notification. Each time the
* interrupt occurs, the event will be immediately requeued for the same time
* interval.
*
* @param period Period to call the handler starting one period
* after the call to this method.
*/
void StartPeriodic(units::second_t period);
/**
* Stop timer events from occuring.
*