2022-06-21 12:48:19 -05:00
|
|
|
#ifndef TIMER
|
|
|
|
#define TIMER
|
|
|
|
|
|
|
|
struct timer {
|
|
|
|
int timerid;
|
2022-08-22 08:55:54 -05:00
|
|
|
int on;
|
2022-08-25 15:48:15 -05:00
|
|
|
double fire_time; // Time the timer will fire
|
|
|
|
double interval; // Time of timer
|
|
|
|
double start_time; // Time the timer started this loop
|
2022-08-22 08:55:54 -05:00
|
|
|
int repeat;
|
2022-08-25 15:48:15 -05:00
|
|
|
double remain_time; // How much time until the timer executes
|
2022-08-22 08:55:54 -05:00
|
|
|
void (*cb)(void *data);
|
|
|
|
void *data;
|
2022-06-21 12:48:19 -05:00
|
|
|
};
|
|
|
|
|
2022-08-22 08:55:54 -05:00
|
|
|
struct timer *timer_make(double interval, void (*callback)(void *param), void *param);
|
2022-06-21 12:48:19 -05:00
|
|
|
void timer_remove(struct timer *t);
|
2022-08-22 08:55:54 -05:00
|
|
|
void timer_start(struct timer *t);
|
|
|
|
void timer_pause(struct timer *t);
|
|
|
|
void timer_stop(struct timer *t);
|
|
|
|
void timer_update(double s);
|
|
|
|
void timer_settime(struct timer *t, double interval);
|
2022-06-21 12:48:19 -05:00
|
|
|
|
2022-08-26 09:19:17 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void *arrfind(void *arr, int (*valid)(void *arr, void *cmp), void *cmp);
|
|
|
|
void arrwalk(void *arr, void (*fn)(void *data));
|
|
|
|
|
2022-06-21 12:48:19 -05:00
|
|
|
#endif
|