From 25884773d62710978895184104346d85fa593d62 Mon Sep 17 00:00:00 2001 From: Lyanis Souidi Date: Thu, 8 Dec 2022 09:54:54 +0100 Subject: [PATCH] =?UTF-8?q?Cr=C3=A9ation=20d'une=20fonction=20wait()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - La fonction wait() permet de mettre en pause le fonctionnement du programme. --- include/timer.h | 2 ++ src/timer.c | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/include/timer.h b/include/timer.h index 2a5b7c9..021ceb1 100644 --- a/include/timer.h +++ b/include/timer.h @@ -8,4 +8,6 @@ unsigned long int start_timer(unsigned long int start); unsigned long int stop_timer(unsigned long int start); +void wait(int sec); + #endif \ No newline at end of file diff --git a/src/timer.c b/src/timer.c index 08cd261..29cc0a5 100644 --- a/src/timer.c +++ b/src/timer.c @@ -30,4 +30,9 @@ unsigned long int start_timer(unsigned long int start) { unsigned long int stop_timer(unsigned long int start) { return Microsecondes() - start; +} + +void wait(int sec) { + unsigned long int end = Microsecondes() + (sec * DELTA); + while (Microsecondes() <= end); } \ No newline at end of file