mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
Add loop timing to IterativeRobot and TimedRobot (#781)
This commit is contained in:
committed by
Peter Johnson
parent
50b13d2f36
commit
a818c7fd47
@@ -33,36 +33,27 @@ class TimedRobot : public IterativeRobotBase, public ErrorBase {
|
||||
void StartCompetition() override;
|
||||
|
||||
/**
|
||||
* Set time period between calls to Periodic() functions.
|
||||
*
|
||||
* 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 in seconds.
|
||||
*/
|
||||
void SetPeriod(double seconds);
|
||||
|
||||
/**
|
||||
* Get time period between calls to Periodic() functions.
|
||||
* Get the time period between calls to Periodic() functions.
|
||||
*/
|
||||
double GetPeriod() const;
|
||||
|
||||
protected:
|
||||
TimedRobot();
|
||||
/**
|
||||
* Constructor for TimedRobot.
|
||||
*
|
||||
* @param period Period in seconds.
|
||||
*/
|
||||
explicit TimedRobot(double period = kDefaultPeriod);
|
||||
|
||||
~TimedRobot() override;
|
||||
|
||||
private:
|
||||
// Prevents loop from starting if user calls SetPeriod() in RobotInit()
|
||||
bool m_startLoop = false;
|
||||
|
||||
HAL_NotifierHandle m_notifier{0};
|
||||
|
||||
// The absolute expiration time
|
||||
double m_expirationTime = 0;
|
||||
|
||||
// The relative time
|
||||
double m_period = kDefaultPeriod;
|
||||
double m_period;
|
||||
|
||||
/**
|
||||
* Update the HAL alarm time.
|
||||
|
||||
Reference in New Issue
Block a user