1026 |
mija |
1 |
/* |
|
|
2 |
DEMO FILE FOR ALCATEL HT1 LCD |
|
|
3 |
mija 7.1.2008 ver.: 1.0 |
|
|
4 |
*/ |
|
|
5 |
|
|
|
6 |
//************************************************************** |
|
|
7 |
|
|
|
8 |
#ifndef LCD_CS |
|
|
9 |
#define LCD_CS PIN_B0 |
|
|
10 |
#define LCD_DATA PIN_B1 |
|
|
11 |
#define LCD_CLK PIN_B2 |
|
|
12 |
#define LCD_A0 PIN_B3 |
|
|
13 |
#define LCD_RESET PIN_B4 |
|
|
14 |
#endif |
|
|
15 |
|
|
|
16 |
BYTE const LCD_INIT_STRING[6] = {0x61,0x3D,0x70,0x42,0x57,0x7B}; |
|
|
17 |
|
|
|
18 |
//datacheet S1D12305 |
|
|
19 |
|
|
|
20 |
//************************************************************** |
|
|
21 |
|
|
|
22 |
void LCD_init(void); |
|
|
23 |
|
|
|
24 |
void LCD_putc(int8 data); |
|
|
25 |
void LCD_send_command(int8 data); |
|
|
26 |
void LCD_send_data(int8 data); |
|
|
27 |
void LCD_clear(); |
|
|
28 |
void LCD_gotoxy(int8 x, int8 y); |
|
|
29 |
void LCD_send(int8 data); |
|
|
30 |
|
|
|
31 |
void LCD_corsor_off(void); |
|
|
32 |
void LCD_cursor_on(void); |
|
|
33 |
|
|
|
34 |
void LCD_contrast(int8 contrast); |
|
|
35 |
void LCD_icon(int8 icon,int8 segment); |
|
|
36 |
|
|
|
37 |
//************************************************************** |
|
|
38 |
|
|
|
39 |
void LCD_init(void) |
|
|
40 |
{ |
|
|
41 |
int8 i; |
|
|
42 |
|
|
|
43 |
output_low(LCD_RESET); |
|
|
44 |
output_high(LCD_CS); |
|
|
45 |
delay_ms(5); |
|
|
46 |
output_high(LCD_RESET); |
|
|
47 |
delay_ms(5); |
|
|
48 |
for (i=0;i<6;i++) LCD_send_command(LCD_INIT_STRING[i]); |
|
|
49 |
delay_ms(20); |
|
|
50 |
LCD_clear(); |
|
|
51 |
} |
|
|
52 |
|
|
|
53 |
void LCD_putc(int8 data) |
|
|
54 |
{ |
|
|
55 |
if (data == '\n') {LCD_send_command(0xC0);return;} |
|
|
56 |
data+=4; |
|
|
57 |
LCD_send_data(data); |
|
|
58 |
} |
|
|
59 |
|
|
|
60 |
void LCD_send_command(int8 data) |
|
|
61 |
{ |
|
|
62 |
output_low(LCD_A0); |
|
|
63 |
LCD_send(data); |
|
|
64 |
output_high(LCD_A0); |
|
|
65 |
} |
|
|
66 |
|
|
|
67 |
void LCD_send_data(int8 data) |
|
|
68 |
{ |
|
|
69 |
output_high(LCD_A0); |
|
|
70 |
LCD_send(data); |
|
|
71 |
} |
|
|
72 |
|
|
|
73 |
void LCD_clear() |
|
|
74 |
{ |
|
|
75 |
int8 a; |
|
|
76 |
|
|
|
77 |
LCD_send_command(0xB0); |
|
|
78 |
for (a=0;a<=11;a++) LCD_putc(0x20); |
|
|
79 |
LCD_send_command(0xC0); |
|
|
80 |
for (a=0;a<=11;a++) LCD_putc(0x20); |
|
|
81 |
LCD_send_command(0xF0); |
|
|
82 |
for (a=0;a<=11;a++) LCD_send_data(0x0); |
|
|
83 |
LCD_gotoxy(1,1); |
|
|
84 |
} |
|
|
85 |
|
|
|
86 |
void LCD_gotoxy(int8 x, int8 y) |
|
|
87 |
{ |
|
|
88 |
x--;y--; |
|
|
89 |
if ( x>11 || y>1 ) return; |
|
|
90 |
if (y) LCD_send_command(0xC0|x); |
|
|
91 |
else LCD_send_command(0xB0|x); |
|
|
92 |
} |
|
|
93 |
|
|
|
94 |
void LCD_send(int8 data) |
|
|
95 |
{ |
|
|
96 |
int8 a; |
|
|
97 |
|
|
|
98 |
output_low(LCD_CS); |
|
|
99 |
for (a=0;a<=7;a++) |
|
|
100 |
{ |
|
|
101 |
output_low(LCD_CLK); |
|
|
102 |
output_low(LCD_DATA); |
|
|
103 |
if (data & 0x80) output_high(LCD_DATA); |
|
|
104 |
output_high(LCD_CLK); |
|
|
105 |
data<<=1; |
|
|
106 |
} |
|
|
107 |
output_high(LCD_CS); |
|
|
108 |
} |
|
|
109 |
|
|
|
110 |
void LCD_cursor_off(void) |
|
|
111 |
{ |
|
|
112 |
LCD_send_command(0x31); |
|
|
113 |
} |
|
|
114 |
|
|
|
115 |
void LCD_cursor_on(void) |
|
|
116 |
{ |
|
|
117 |
LCD_send_command(0x3D); |
|
|
118 |
} |
|
|
119 |
|
|
|
120 |
void LCD_contrast(int8 contrast) |
|
|
121 |
{ |
|
|
122 |
LCD_send_command(0x70|(0x0F & contrast)); |
|
|
123 |
} |
|
|
124 |
|
|
|
125 |
void LCD_icon(int8 znak,int8 segment) |
|
|
126 |
{ |
|
|
127 |
LCD_send_command(znak); |
|
|
128 |
LCD_send_data(segment); |
|
|
129 |
} |
|
|
130 |
|
|
|
131 |
//************************************************************** |
|
|
132 |
//*** defines for segments icons *** |
|
|
133 |
|
|
|
134 |
#define LCD_SEGMENT_OFF 0x0 |
|
|
135 |
|
|
|
136 |
#define LCD_BATTERIE 0xF0 |
|
|
137 |
#define SEG_BAT_EMP 0x4 |
|
|
138 |
#define SEG_BAT_LOW 0xC |
|
|
139 |
#define SEG_BAT_FULL 0xE |
|
|
140 |
#define LCD_PC 0xF2 |
|
|
141 |
#define SEG_PC 0x10 |
|
|
142 |
#define LCD_OFF_RING 0xF3 |
|
|
143 |
#define SEG_RING 0x8 |
|
|
144 |
#define LCD_CALL_MISSED 0xF4 |
|
|
145 |
#define SEG_MISSED 0x10 |
|
|
146 |
#define LCD_CASSETTE 0xF5 |
|
|
147 |
#define SEG_CASSETTE 0x8 |
|
|
148 |
#define LCD_MESSAGE 0xF6 |
|
|
149 |
#define SEG_MESSAGE 0x10 |
|
|
150 |
#define SEG_MESS_FULL 0x18 |
|
|
151 |
#define LCD_CALL_DIVERT 0xF8 |
|
|
152 |
#define SEG_DIVERT 0x4 |
|
|
153 |
#define LCD_CLOCK 0xF9 |
|
|
154 |
#define SEG_CLOCK 0x8 |
|
|
155 |
#define LCD_SIGNALL 0xFB |
|
|
156 |
#define SEG_SIGNALL1 0x2 |
|
|
157 |
#define SEG_SIGNALL2 0xA |
|
|
158 |
#define SEG_SIGNALL3 0xE |
|
|
159 |
#define SEG_SIGNALL4 0x1E |
|
|
160 |
|
|
|
161 |
//************************************************************** |
|
|
162 |
//*** ASCII char *** |
|
|
163 |
|
|
|
164 |
#define ASCII_CLOCK 0xD0 |
|
|
165 |
#define ASCII_ARROW_UP 0xDA |
|
|
166 |
#define ASCII_ARROW_DOWN 0xD7 |
|
|
167 |
#define ASCII_ARROW_R 0xD8 |
|
|
168 |
#define ASCII_ARROW_L 0xD9 |
|
|
169 |
#define ASCII_ARROW_UR 0xE7 |
|
|
170 |
#define ASCII_ARROW_DR 0xE8 |