Formula Student Electronics & Software
The code for the embedded software
|
Our own implementation of Metro class. More...
#include <metro.h>
Public Member Functions | |
Metro (unsigned long interval_millis, uint8_t autoreset=0) | |
Constructor to initialize the timer with a given interval and autoreset behavior. | |
void | interval (unsigned long interval_millis) |
Sets a new interval for the timer. | |
bool | check () |
Checks if the interval has passed and resets the timer if true. | |
bool | checkWithoutReset () const |
Checks if the interval has passed without resetting the timer. | |
void | reset () |
Resets the timer to the current time. | |
Our own implementation of Metro class.
This class provides functionality to check if a certain amount of time has passed since the last time the check was true. It adds to the public implementation of the Metro class the possibility to check if the time has passed without resetting the timer.
|
inline |
Constructor to initialize the timer with a given interval and autoreset behavior.
interval_millis | The interval in milliseconds for the timer |
autoreset | If set to non-zero, the timer will reset automatically upon a successful check |
This constructor allows the user to specify both the interval and the autoreset behavior. If autoreset
is set to zero, the timer will follow Benjamin Soelberg's check behavior where the timer will update based on the interval instead of resetting to the current time.
Definition at line 71 of file metro.h.
|
inline |
Checks if the interval has passed and resets the timer if true.
This method checks whether the specified interval has passed since the last reset. If the interval has passed, the timer is reset according to the autoreset behavior. If autoreset is enabled, the timer resets to the current time; otherwise, it increments by the interval.
Definition at line 91 of file metro.h.
|
inline |
Checks if the interval has passed without resetting the timer.
This method performs a check similar to check()
, but it does not reset the timer upon a successful check. It is useful when you want to verify the passage of time without affecting the internal state.
Definition at line 116 of file metro.h.
|
inline |
Sets a new interval for the timer.
interval_millis | The new interval in milliseconds |
This method allows the user to change the interval dynamically at runtime. The interval will be used for subsequent checks.
Definition at line 78 of file metro.h.
void Metro::reset | ( | ) |