Ajout fichier timer pour le chronomètre
This commit is contained in:
parent
f05ecf8ce3
commit
15f1406e24
6
include/timer.h
Normal file
6
include/timer.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef TIMER_H
|
||||
#define TIMER_H
|
||||
|
||||
void start_timer(void);
|
||||
|
||||
#endif
|
24
src/timer.c
Normal file
24
src/timer.c
Normal file
@ -0,0 +1,24 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
#include<graph.h>
|
||||
#define delta 1000000L
|
||||
|
||||
void start_timer(void) {
|
||||
unsigned long int start = Microsecondes();
|
||||
unsigned int minute = 0;
|
||||
unsigned int a = 0;
|
||||
|
||||
char buf[100];
|
||||
while(1){
|
||||
unsigned long int seconde = ((Microsecondes() - start) / 1000000)-a;
|
||||
|
||||
if (seconde>=60) {
|
||||
minute +=1;
|
||||
a += 60;
|
||||
}
|
||||
|
||||
snprintf(buf, 100, "temps : %02d:%02d", minute, seconde);
|
||||
|
||||
EcrireTexte(20,20, buf, 1);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user