1
0

Ajout fichier timer pour le chronomètre

This commit is contained in:
Tom MOGULJAK 2022-11-23 17:15:02 +01:00
parent f05ecf8ce3
commit 15f1406e24
2 changed files with 30 additions and 0 deletions

6
include/timer.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef TIMER_H
#define TIMER_H
void start_timer(void);
#endif

24
src/timer.c Normal file
View 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);
}
}