📄 gsm-
字号:
C51 COMPILER V7.06 LCD12864 06/13/2010 15:40:36 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE LCD12864
OBJECT MODULE PLACED IN LCD12864.OBJ
COMPILER INVOKED BY: E:\WorkSpace\Keil\C51\BIN\C51.EXE LCD12864.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 #ifndef _LCD12864_INCLUDED_
2 #define _LCD12864_INCLUDE
3 #include "common.h"
4 /**************************************************************
5 iO口宏定义区
6 ***************************************************************/
7 sbit CS =P2^2;
8 sbit SID=P2^3;//r/w
9 sbit SCK=P2^4;//e
10 /*******************************************************************
11 常量声明区
12 ********************************************************************/
13 unsigned char code AC_TABLE[]={ //坐标编码
14 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,
15 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,
16 0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
17 0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,
18 };
19 /****************************************************************
20 声明:建议读者先查阅我们提供的12864word文档资料,理解12864定坐标的
21 方式。
22 发送一个字节
23 *****************************************************************/
24 void SendByte(unsigned char Dbyte)
25 {
26 1 unsigned char i;
27 1 for(i=0;i<8;i++)
28 1 {
29 2 SCK = 0;
30 2 Dbyte=Dbyte<<1;
31 2 SID = CY;
32 2 SCK = 1;
33 2 SCK = 0;
34 2 }
35 1 }
36 /**********************************************************
37 接收一个字节
38 ***********************************************************/
39
40 unsigned char ReceiveByte(void)
41 {
42 1 unsigned char i,temp1,temp2;
43 1 temp1=temp2=0;
44 1 for(i=0;i<8;i++)
45 1 {
46 2 temp1=temp1<<1;
47 2 SCK = 0;
48 2 SCK = 1;
49 2 SCK = 0;
50 2 if(SID) temp1++;
51 2 }
52 1 for(i=0;i<8;i++)
53 1 {
54 2 temp2=temp2<<1;
55 2 SCK = 0;
C51 COMPILER V7.06 LCD12864 06/13/2010 15:40:36 PAGE 2
56 2 SCK = 1;
57 2 SCK = 0;
58 2 if(SID) temp2++;
59 2 }
60 1 return ((0xf0&temp1)+(0x0f&temp2));
61 1 }
62 /****************************************************************
63 检查忙状态
64 ******************************************************************/
65 void CheckBusy( void )
66 {
67 1 do SendByte(0xfc); //11111,RW(1),RS(0),0
68 1 while(0x80&ReceiveByte());
69 1 }
70
71 /******************************************************************
72 写一个字节的指令
73 *******************************************************************/
74 void WriteCommand( unsigned char Cbyte )
75 {
76 1 CS = 1;
77 1 CheckBusy();
78 1 SendByte(0xf8); //11111,RW(0),RS(0),0
79 1 SendByte(0xf0&Cbyte);
80 1 SendByte(0xf0&Cbyte<<4);
81 1 CS = 0;
82 1 }
83 /*************************************************************
84 写一个字节的数据
85 **************************************************************/
86 void WriteData( unsigned char Dbyte )
87 {
88 1 CS = 1;
89 1 CheckBusy();
90 1 SendByte(0xfa); //11111,RW(0),RS(1),0
91 1 SendByte(0xf0&Dbyte);
92 1 SendByte(0xf0&Dbyte<<4);
93 1 CS = 0;
94 1 }
95
96 /******************************************************************
97 lcd初始化函数
98 *******************************************************************/
99 void LcmInit( void )
100 {
101 1 WriteCommand(0x30);
102 1 WriteCommand(0x03);
103 1 WriteCommand(0x0c);
104 1 WriteCommand(0x01);
105 1 WriteCommand(0x06);
106 1 }
107
108 /*******************************************************************************************************
109 设定光标函数
110 ********************************************************************************************************/
111 void Location_xy_12864(unsigned char x,unsigned char y)
112 {
113 1 switch(x)
114 1 {
115 2 case 0:
116 2 x=0x80;break;
117 2 case 1:
C51 COMPILER V7.06 LCD12864 06/13/2010 15:40:36 PAGE 3
118 2 x=0x90;break;
119 2 case 2:
120 2 x=0x88;break;
121 2 case 3:
122 2 x=0x98;break;
123 2 default:
124 2 x=0x80;
125 2 }
126 1 y=y&0x07;
127 1 WriteCommand(0x30);
128 1 WriteCommand(y+x);
129 1 WriteCommand(y+x);
130 1
131 1 }
132 /***********************************************************************************
133 清除文本
134 ************************************************************************************/
135 void LcmClearTXT( void )
136 {
137 1 unsigned char i;
138 1 WriteCommand(0x30);
139 1 WriteCommand(0x80);
140 1 for(i=0;i<64;i++)
141 1 WriteData(0x20);
142 1 Location_xy_12864(0,0);
143 1 }
144 /**************************************************************************************
145 清除图片
146 *****************************************************************************************/
147 void LcmClearBMP( void )
148 {
149 1 unsigned char i,j;
150 1 WriteCommand(0x34);
151 1 WriteCommand(0x36);
152 1 for(i=0;i<32;i++)
153 1 {
154 2 WriteCommand(0x80|i);
155 2 WriteCommand(0x80);
156 2 for(j=0;j<32;j++)
157 2 WriteData(0);
158 2 }
159 1 }
160
161 //显示温度
162 void PutTemp(unsigned char row,unsigned char col)
163 {
164 1 WriteCommand(0x30);
165 1 WriteCommand(AC_TABLE[8*row+col]);
166 1 WriteData((zhengshu%100)/10+48);
167 1 WriteData(zhengshu%10+48);
168 1 WriteData('.');
169 1 WriteData(xiaoshu1+48);
170 1 }
171
172 /****************************************************************************************
173 显示字符串
174 *****************************************************************************************/
175 void PutStr(unsigned char row,unsigned char col,unsigned char *puts)
176 {
177 1 WriteCommand(0x30);
178 1 WriteCommand(AC_TABLE[8*row+col]);
179 1 while(*puts != '\0')
C51 COMPILER V7.06 LCD12864 06/13/2010 15:40:36 PAGE 4
180 1 {
181 2 if(col==8)
182 2 {
183 3 col=0;
184 3 row++;
185 3 }
186 2 if(row==4) row=0;
187 2 WriteCommand(AC_TABLE[8*row+col]);
188 2 WriteData(*puts);
189 2 puts++;
190 2 if(*puts != '\0')
191 2 {
192 3 WriteData(*puts);
193 3 puts++;
194 3 col++;
195 3 }
196 2 }
197 1 }
198 /*
199 //显示一个四位的数字
200 void PutNum(unsigned char row,unsigned char col,unsigned int num)
201 {
202 WriteCommand(0x30);
203 WriteCommand(AC_TABLE[8*row+col]);
204 WriteData((num/1000)+48);
205 WriteData(((num%1000)/100)+48);
206 WriteData(((num%100)/10)+48);
207 WriteData((num%10)+48);
208 }*/
209
210
211 //显示一个两位的数字
212 void PutTime(void)
213 {
214 1 WriteCommand(0x30);
215 1 WriteCommand(AC_TABLE[19]);
216 1 WriteData(((times[6]%100)/10)+48);
217 1 WriteData((times[6]%10)+48);
218 1 WriteData('/');
219 1 WriteData(((times[4]%100)/10)+48);
220 1 WriteData((times[4]%10)+48);
221 1 WriteData('/');
222 1 WriteData(((times[3]%100)/10)+48);
223 1 WriteData((times[3]%10)+48);
224 1
225 1 WriteCommand(0x30);
226 1 WriteCommand(AC_TABLE[27]);
227 1 WriteData(((times[2]%100)/10)+48);
228 1 WriteData((times[2]%10)+48);
229 1 WriteData(':');
230 1 WriteData(((times[1]%100)/10)+48);
231 1 WriteData((times[1]%10)+48);
232 1 WriteData(':');
233 1 WriteData(((times[0]%100)/10)+48);
234 1 WriteData((times[0]%10)+48);
235 1 }
236
237 #endif
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 599 ----
C51 COMPILER V7.06 LCD12864 06/13/2010 15:40:36 PAGE 5
CONSTANT SIZE = 32 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 2
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -