This repository has been archived by the owner on Mar 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib_lcd.h
105 lines (92 loc) · 1.71 KB
/
lib_lcd.h
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//Dados referentes ao LCS
#define LCD P2
#define EN P3_1
#define RS P3_0
void configLCD(void); //configuração inicial do LCS
void line1(void); //coloca o cursor na linha 1
void line2(void); // coloca o cursor na linha 2
void writeMSG(char msg[]); //escreve uma mensagem no display
void wrCMD(void); //escreve comando
void wrCHAR(void); //escreve caractere
void clearLCD(); //limpa o LCD
void mensagemInicial(); //imprime a mensagem inicial da aplicação (utilizada para definir o intervalo)
void mensagemAguaInicial(); //imprime mensagem de início de dispenser da água
void mensagemAguaFinal(); //imprime mensagem de fim de dispenser da água
void turnOnLCD();
void configLCD(void)
{
LCD = 0x38;
wrCMD();
LCD = 0x06;
wrCMD();
turnOnLCD();
clearLCD();
}
void line1(void)
{
LCD = 0x00;
wrCMD();
}
void line2(void)
{
LCD = 0xC0;
wrCMD();
}
void writeMSG(char msg[])
{
unsigned char i;
for (i = 0; i < 16 && msg[i] != '\0'; i++) //modificada para aceitar mensagens que sejam menores que 16
{
LCD = msg[i];
wrCHAR();
}
}
void wrCMD(void)
{
RS = 0;
EN = 1;
delayT0(1);
EN = 0;
delayT0(1);
}
void wrCHAR(void)
{
RS = 1;
EN = 1;
delayT0(5);
EN = 0;
delayT0(5);
}
void clearLCD()
{
LCD = 0x01;
wrCMD();
return;
}
void mensagemInicial()
{
clearLCD();
line1();
writeMSG("Qual o intervalo");
line2();
writeMSG("para tomar agua?");
return;
}
void turnOnLCD(){
LCD = 0x0C;
wrCMD();
}
void mensagemAguaInicial()
{
clearLCD();
line1();
writeMSG("Hora da agua!!!");
}
void mensagemAguaFinal()
{
clearLCD();
line1();
writeMSG("Tome sua agua!!!");
delayT0(1500);
clearLCD();
}