2023-11-17 06:16:32 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <sys/time.h>
|
2023-11-17 18:36:05 +02:00
|
|
|
|
2023-11-30 00:44:00 +02:00
|
|
|
typedef enum TimerState {
|
|
|
|
|
TIMER_RUNNING,
|
|
|
|
|
TIMER_PAUSED,
|
|
|
|
|
TIMER_STOPPED,
|
|
|
|
|
} TimerState;
|
2023-11-17 06:16:32 +02:00
|
|
|
|
|
|
|
|
typedef struct Timer {
|
2023-11-30 00:44:00 +02:00
|
|
|
float start;
|
|
|
|
|
float elapsed;
|
2023-11-17 06:16:32 +02:00
|
|
|
float duration;
|
2023-11-30 00:44:00 +02:00
|
|
|
TimerState state;
|
2023-11-17 06:16:32 +02:00
|
|
|
} Timer;
|
|
|
|
|
|
|
|
|
|
double get_time();
|
|
|
|
|
void start_internal_timer();
|
|
|
|
|
bool timer_ended(Timer *timer);
|
|
|
|
|
void timer_start(Timer *timer, float duration);
|
2023-11-21 02:52:15 +02:00
|
|
|
void timer_stop(Timer *timer);
|
2023-11-17 06:16:32 +02:00
|
|
|
void timer_reset(Timer *timer);
|
|
|
|
|
float timer_remaining(Timer *timer);
|
|
|
|
|
float timer_elapsed(Timer *timer);
|
2023-11-30 00:44:00 +02:00
|
|
|
void timer_pause(Timer *timer);
|
|
|
|
|
void timer_resume(Timer *timer);
|