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;
|
2023-03-05 22:05:22 -06:00
|
|
|
double interval; // Time of timer
|
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;
|
2023-01-19 10:44:29 -06:00
|
|
|
int owndata;
|
2023-03-05 22:05:22 -06:00
|
|
|
int next;
|
2022-06-21 12:48:19 -05:00
|
|
|
};
|
|
|
|
|
2023-01-19 10:44:29 -06:00
|
|
|
struct timer *timer_make(double interval, void (*callback)(void *param), void *param, int own);
|
2023-01-18 17:15:36 -06:00
|
|
|
struct timer *id2timer(int id);
|
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);
|
2022-12-28 16:50:54 -06:00
|
|
|
void timer_update(double dt);
|
2022-12-16 11:54:05 -06:00
|
|
|
void timerr_settime(struct timer *t, double interval);
|
2022-06-21 12:48:19 -05:00
|
|
|
|
2022-11-25 07:12:31 -06:00
|
|
|
#endif
|