|
Fang-Robotics-MCB
Fang Robotics Team Codebase
|
#include <polling_timer.hpp>
Public Member Functions | |
| PollingTimer () | |
| void | setDuration (Microseconds duration) |
| void | restart () |
| bool | isFinished () const |
| Microseconds | getTimePastAlarm () const |
| Microseconds | getTimePastAlarmAndReset () |
| Microseconds | getTimeLeft () const |
| void | reset () |
This is designed to be able to compare between elapsed time in polling loops. So you can have an event timed around a delay without having to stop execution
such as if (pollingTimer.isFinished) { doThis(); compensateDuration(pollingTimer.getTimePastAlarmAndReset()); }
Can time stuff up to 71 days within microsecond precision or 47 minutes double check modm
| fang::chrono::PollingTimer::PollingTimer | ( | ) |
Automatically sets current moment to that of its creation :) Sounds a bit mystical imo
| Microseconds fang::chrono::PollingTimer::getTimeLeft | ( | ) | const |
This will provide a negative value if it has finished
This will allow you to compensate.
| Microseconds fang::chrono::PollingTimer::getTimePastAlarm | ( | ) | const |
This will provide a negative value if it has not finished
This will allow you to compensate.
| Microseconds fang::chrono::PollingTimer::getTimePastAlarmAndReset | ( | ) |
This is a special call that will allow you to precisely reset the timer AND get the time past alarm without uncounted delay it usees the unique implementation of SimplerTimer's getDurationAndReset
| bool fang::chrono::PollingTimer::isFinished | ( | ) | const |
true if the timer has elapsed >= comparison
| void fang::chrono::PollingTimer::reset | ( | ) |
Resets the count
| void fang::chrono::PollingTimer::restart | ( | ) |
Has the timer to begin timing now
| void fang::chrono::PollingTimer::setDuration | ( | Microseconds | duration | ) |
The duration for the timer to wait.
The default duration is zero. Hopefully, this won't crash anything.