Software timer functionality for FuriEventLoop. More...
#include "event_loop.h"
Go to the source code of this file.
Typedefs | |
typedef void(* | FuriEventLoopTimerCallback) (void *context) |
Timer callback type for functions to be called when a timer expires. | |
typedef struct FuriEventLoopTimer | FuriEventLoopTimer |
Opaque event loop timer type. | |
Enumerations | |
enum | FuriEventLoopTimerType { FuriEventLoopTimerTypeOnce = 0 , FuriEventLoopTimerTypePeriodic = 1 } |
Enumeration of possible timer types. More... | |
Functions | |
FuriEventLoopTimer * | furi_event_loop_timer_alloc (FuriEventLoop *instance, FuriEventLoopTimerCallback callback, FuriEventLoopTimerType type, void *context) |
Create a new event loop timer instance. | |
void | furi_event_loop_timer_free (FuriEventLoopTimer *timer) |
Delete an event loop timer instance. | |
void | furi_event_loop_timer_start (FuriEventLoopTimer *timer, uint32_t interval) |
Start a timer or restart it with a new interval. | |
void | furi_event_loop_timer_restart (FuriEventLoopTimer *timer) |
Restart a timer with the previously set interval. | |
void | furi_event_loop_timer_stop (FuriEventLoopTimer *timer) |
Stop a timer without firing its callback. | |
uint32_t | furi_event_loop_timer_get_remaining_time (const FuriEventLoopTimer *timer) |
Get the time remaining before the timer becomes expires. | |
uint32_t | furi_event_loop_timer_get_interval (const FuriEventLoopTimer *timer) |
Get the timer interval. | |
bool | furi_event_loop_timer_is_running (const FuriEventLoopTimer *timer) |
Check if the timer is currently running. | |
Software timer functionality for FuriEventLoop.
typedef void(* FuriEventLoopTimerCallback) (void *context) |
Timer callback type for functions to be called when a timer expires.
In the timer callback, it is ALLOWED:
[in,out] | context | pointer to a user-specific object that was provided during timer creation |
FuriEventLoopTimer * furi_event_loop_timer_alloc | ( | FuriEventLoop * | instance, |
FuriEventLoopTimerCallback | callback, | ||
FuriEventLoopTimerType | type, | ||
void * | context ) |
Create a new event loop timer instance.
[in,out] | instance | pointer to the current FuriEventLoop instance |
[in] | callback | pointer to the callback function to be executed upon timer timeout |
[in] | type | timer type value to determine its behavior (single-shot or periodic) |
[in,out] | context | pointer to a user-specific object (will be passed to the callback) |
void furi_event_loop_timer_free | ( | FuriEventLoopTimer * | timer | ) |
Delete an event loop timer instance.
[in,out] | timer | pointer to the timer instance to be deleted |
uint32_t furi_event_loop_timer_get_interval | ( | const FuriEventLoopTimer * | timer | ) |
Get the timer interval.
[in] | timer | pointer to the timer to be queried |
uint32_t furi_event_loop_timer_get_remaining_time | ( | const FuriEventLoopTimer * | timer | ) |
Get the time remaining before the timer becomes expires.
For stopped or expired timers, this function returns 0.
[in] | timer | pointer to the timer to be queried |
bool furi_event_loop_timer_is_running | ( | const FuriEventLoopTimer * | timer | ) |
Check if the timer is currently running.
A timer is considered running if it has not expired yet.
[in] | timer | pointer to the timer to be queried |
void furi_event_loop_timer_restart | ( | FuriEventLoopTimer * | timer | ) |
Restart a timer with the previously set interval.
[in,out] | timer | pointer to the timer instance to be restarted |
void furi_event_loop_timer_start | ( | FuriEventLoopTimer * | timer, |
uint32_t | interval ) |
Start a timer or restart it with a new interval.
[in,out] | timer | pointer to the timer instance to be (re)started |
[in] | interval | timer interval in ticks |
void furi_event_loop_timer_stop | ( | FuriEventLoopTimer * | timer | ) |
Stop a timer without firing its callback.
It is safe to call this function on an already stopped timer (it will do nothing).
[in,out] | timer | pointer to the timer instance to be stopped |