-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimer.c
60 lines (52 loc) · 1.03 KB
/
timer.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// #include <stdio.h>
// #include <stdlib.h>
// #include <string.h>
// #include "definicoes_sistema.h"
// #include "timer.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "definicoes_sistema.h"
#include "timer.h"
#define TEMPO 10
int tmr_situacao;
time_t horaInicio;
/*******************************
tmr_iniciar
Aciona ou desaciona o timer
entradas
controle: TRUE:liga FALSE:desliga
saidas
nenhuma
********************************/
void tmr_iniciar(int controle)
{
tmr_situacao = controle;
if (controle)
{
horaInicio = time(NULL);
}
}
/*******************************
tmr_timeout
Retorna se o timer esta em timeout.
entradas
nenhuma
saidas
FALSE: n�o houve estouro do temporizador
TRUE: houve estouro do temporizador
********************************/
int tmr_timeout()
{
time_t horaAtual;
horaAtual = time(NULL);
if (tmr_situacao == false)
{
return false;
}
if ((horaAtual - horaInicio) > TEMPO)
{
return true;
}
return false;
}