blob: 5a4cedef9b79b3c2551d3bb69cfba721e44ec23f (
plain)
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
#include "lcd.h"
#include "conf.h"
//LCD Functions Developed by electroSome
void Lcd_Port(char a) {
if (a & 1)
D4 = 1;
else
D4 = 0;
if (a & 2)
D5 = 1;
else
D5 = 0;
if (a & 4)
D6 = 1;
else
D6 = 0;
if (a & 8)
D7 = 1;
else
D7 = 0;
}
void Lcd_Cmd(char a) {
RS = 0; // => RS = 0
Lcd_Port(a);
EN = 1; // => E = 1
__delay_ms(4);
EN = 0; // => E = 0
}
void Lcd_Clear(void) {
Lcd_Cmd(0);
Lcd_Cmd(1);
}
void Lcd_Set_Cursor(char a, char b) {
char temp, z, y;
if (a == 1) {
temp = 0x80 + b - 1;
z = temp >> 4;
y = temp & 0x0F;
Lcd_Cmd(z);
Lcd_Cmd(y);
} else if (a == 2) {
temp = 0xC0 + b - 1;
z = temp >> 4;
y = temp & 0x0F;
Lcd_Cmd(z);
Lcd_Cmd(y);
}
}
void Lcd_Init(void) {
Lcd_Port(0x00);
__delay_ms(20);
Lcd_Cmd(0x03);
__delay_ms(5);
Lcd_Cmd(0x03);
__delay_ms(11);
Lcd_Cmd(0x03);
/////////////////////////////////////////////////////
Lcd_Cmd(0x02);
#ifdef VFD
Vfd_Set_Brightness(0); //Set brightness to max
#endif
Lcd_Cmd(0x02);
Lcd_Cmd(0x08);
Lcd_Cmd(0x00);
Lcd_Cmd(0x0C);
Lcd_Cmd(0x00);
Lcd_Cmd(0x06);
}
void Lcd_Write_Char(char a) {
char temp, y;
temp = a & 0x0F;
y = a & 0xF0;
RS = 1; // => RS = 1
Lcd_Port(y >> 4); //Data transfer
EN = 1;
__delay_us(40);
EN = 0;
Lcd_Port(temp);
EN = 1;
__delay_us(40);
EN = 0;
}
void Lcd_Write_String(char *a) {
int i;
for (i = 0; a[i] != '\0'; i++)
Lcd_Write_Char(a[i]);
}
void Lcd_Shift_Right(void) {
Lcd_Cmd(0x01);
Lcd_Cmd(0x0C);
}
void Lcd_Shift_Left(void) {
Lcd_Cmd(0x01);
Lcd_Cmd(0x08);
}
// For some VFD's like Noritake
void Vfd_Set_Brightness(int level) {
Lcd_Cmd(0x03);
__delay_ms(11);
Lcd_Cmd(0x03);
/////////////////////////////////////////////////////
Lcd_Cmd(0x02);
Lcd_Write_Char(level);
}
|