[wpilib] Add Timer::Restart() (#4963)

This commit is contained in:
Sriman Achanta
2023-01-23 17:50:46 -05:00
committed by GitHub
parent 00aa66e4fd
commit 917906530a
3 changed files with 29 additions and 0 deletions

View File

@@ -100,6 +100,19 @@ public class Timer {
}
}
/**
* Restart the timer by stopping the timer, if it is not already stopped, resetting the
* accumulated time, then starting the timer again. If you want an event to periodically reoccur
* at some time interval from the start time, consider using advanceIfElapsed() instead.
*/
public void restart() {
if (m_running) {
stop();
}
reset();
start();
}
/**
* Stop the timer. This computes the time as of now and clears the running flag, causing all
* subsequent time requests to be read from the accumulated time rather than looking at the system