A timer class.
Note that if the user calls SimHooks.restartTiming(), they should also reset the timer so get() won't return a negative duration.
◆ Timer()
edu.wpi.first.wpilibj.Timer.Timer |
( |
| ) |
|
◆ advanceIfElapsed()
boolean edu.wpi.first.wpilibj.Timer.advanceIfElapsed |
( |
double | seconds | ) |
|
Check if the period specified has passed and if it has, advance the start time by that period. This is useful to decide if it's time to do periodic work without drifting later by the time it took to get around to checking.
- Parameters
-
seconds | The period to check. |
- Returns
- Whether the period has passed.
◆ delay()
static void edu.wpi.first.wpilibj.Timer.delay |
( |
final double | seconds | ) |
|
|
static |
Pause the thread for a specified time. Pause the execution of the thread for a specified period of time given in seconds. Motors will continue to run at their last assigned values, and sensors will continue to update. Only the task containing the wait will pause until the wait time is expired.
- Parameters
-
seconds | Length of time to pause |
◆ get()
double edu.wpi.first.wpilibj.Timer.get |
( |
| ) |
|
Get the current time from the timer. If the clock is running it is derived from the current system clock the start time stored in the timer class. If the clock is not running, then return the time when it was last stopped.
- Returns
- Current time value for this timer in seconds
◆ getFPGATimestamp()
static double edu.wpi.first.wpilibj.Timer.getFPGATimestamp |
( |
| ) |
|
|
static |
Return the system clock time in seconds. Return the time from the FPGA hardware clock in seconds since the FPGA started.
- Returns
- Robot running time in seconds.
◆ getMatchTime()
static double edu.wpi.first.wpilibj.Timer.getMatchTime |
( |
| ) |
|
|
static |
Return the approximate match time. The FMS does not send an official match time to the robots, but does send an approximate match time. The value will count down the time remaining in the current period (auto or teleop). Warning: This is not an official time (so it cannot be used to dispute ref calls or guarantee that a function will trigger before the match ends) The Practice Match function of the DS approximates the behavior seen on the field.
- Returns
- Time remaining in current match period (auto or teleop) in seconds
◆ hasElapsed()
boolean edu.wpi.first.wpilibj.Timer.hasElapsed |
( |
double | seconds | ) |
|
Check if the period specified has passed.
- Parameters
-
seconds | The period to check. |
- Returns
- Whether the period has passed.
◆ reset()
final void edu.wpi.first.wpilibj.Timer.reset |
( |
| ) |
|
Reset the timer by setting the time to 0.
Make the timer startTime the current time so new requests will be relative now.
◆ restart()
void edu.wpi.first.wpilibj.Timer.restart |
( |
| ) |
|
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.
◆ start()
void edu.wpi.first.wpilibj.Timer.start |
( |
| ) |
|
Start the timer running. Just set the running flag to true indicating that all time requests should be relative to the system clock. Note that this method is a no-op if the timer is already running.
◆ stop()
void edu.wpi.first.wpilibj.Timer.stop |
( |
| ) |
|
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 clock.
The documentation for this class was generated from the following file:
- D:/SDASVN/2024/RaspberryPi/VSCode/Source/edu/wpi/first/wpilibj/Timer.java