38 lines
780 B
C
38 lines
780 B
C
|
#include <stdio.h>
|
||
|
#include <unistd.h>
|
||
|
#include <graph.h>
|
||
|
#define CYCLE 10000L
|
||
|
|
||
|
int seconde=0;
|
||
|
int minute=0;
|
||
|
int seconde_actuel=0;
|
||
|
int old_seconde=0;
|
||
|
char timer[6];
|
||
|
unsigned long int suivant;
|
||
|
|
||
|
void Update_Timer(){
|
||
|
snprintf(timer,6,"%02d:%02d", minute, seconde);
|
||
|
ChoisirCouleurDessin(CouleurParComposante(0,0,0));
|
||
|
RemplirRectangle(0,700,1200,800);
|
||
|
ChoisirCouleurDessin(CouleurParComposante(255,255,255));
|
||
|
EcrireTexte(10,760,timer,2);
|
||
|
}
|
||
|
|
||
|
void Timer(){
|
||
|
if(Microsecondes()> suivant){
|
||
|
suivant = Microsecondes()+CYCLE;
|
||
|
seconde_actuel = (suivant/1000000)%10;
|
||
|
if(seconde_actuel !=old_seconde){
|
||
|
old_seconde = seconde_actuel;
|
||
|
if(seconde == 59){
|
||
|
minute=minute+1;
|
||
|
seconde=0;
|
||
|
Update_Timer();
|
||
|
}else{
|
||
|
seconde = seconde+1;
|
||
|
Update_Timer();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|