macro_rules! setInterval {
($f:expr, $period_ms:expr) => { ... };
($f:expr, $period_ms:expr, $( $param:expr ),*) => { ... };
}
Expand description
Macro for setting up a periodic interval to execute a function.
§Syntax
setInterval!(function, period_ms);
setInterval!(function, period_ms, param1, param2, ...);
§Examples
setInterval!(my_function, 1000);
setInterval!(my_function_with_params, 1000, arg1, arg2);
§Arguments
$f
- The function to be executed.$period_ms
- The period in milliseconds after which the function should be called.$( $param:expr ),*
- Optional parameters to pass to the function.
§Behavior
- Initializes a static
Tick
variable. - Checks if the elapsed time since the last execution is greater than or equal to the specified period.
- If so, resets the
Tick
and calls the function with or without parameters.