?? disp.lst
字號:
C51 COMPILER V7.50 DISP 07/01/2008 15:53:05 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE DISP
OBJECT MODULE PLACED IN Disp.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE Disp.c BROWSE DEBUG OBJECTEXTEND
line level source
1 /*
2 ****************************************************
3
4 顯示
5
6 ****************************************************
7 */
8
9 #include <reg52.H>
10 #include "Typedef.H"
11 #include "UserDef.H"
12 #include "Disp.h"
13 #include "Font.H"
14
15
16 /* 端口定義 */
17 #define DISPDATAPORT P0 //數據端口
18 sbit Pin_CS1 = P2^1; //片選
19 sbit Pin_CS2 = P2^0; //片選
20 sbit Pin_RS = P2^2; //指令、數據選擇(0=指令;1=數據)
21 sbit Pin_RW = P2^3; //讀寫選擇(0=寫,1=讀)
22 sbit Pin_E = P2^4; //鎖存(下降沿有效)
23 sbit Pin_RST = P2^5; //鎖存(下降沿有效)
24
25
26 /* 全局變量 */
27 static INT8U idata DispPro[2][MAXDISPLEN]; //顯示屬性緩沖區
28 static INT8U CurRow = 0;
29 static INT8U CurCol = 0;
30 static INT8U CurFont = 0;
31 //顯示屬性定義
32 #define PRO_BLINK (1<<1) //閃爍
33
34
35 /***************************************
36
37 LCD忙等待
38
39 ****************************************/
40 void Busy(void)
41 {
42 1 INT8U bf;
43 1
44 1 Pin_E = 0;
45 1 DISPDATAPORT = 0xFF; //使端口為輸入狀態
46 1 Pin_RW = 1; //讀
47 1 Pin_RS = 0; //指令
48 1
49 1 while (1)
50 1 {
51 2 Pin_E = 1;
52 2 bf = DISPDATAPORT;
53 2 Pin_E = 0;
54 2 if ((bf & 0x80) == 0)
55 2 break;
C51 COMPILER V7.50 DISP 07/01/2008 15:53:05 PAGE 2
56 2 }
57 1 }
58
59
60 /***************************************
61
62 LCD數據寫
63
64 ****************************************/
65 void LCD_Data(INT8U Data)
66 {
67 1 Busy();
68 1
69 1 Pin_E = 0;
70 1 Pin_RW = 0; //寫
71 1 Pin_RS = 1; //數據
72 1
73 1 Pin_E = 1;
74 1
75 1 DISPDATAPORT = Data;
76 1
77 1 Pin_E = 0;
78 1 }
79
80 /***************************************
81
82 LCD命令寫
83
84 ****************************************/
85 void LCD_Cmd(INT8U cmd)
86 {
87 1 Busy();
88 1
89 1 Pin_E = 0;
90 1 Pin_RW = 0; //寫
91 1 Pin_RS = 0; //指令
92 1
93 1 Pin_E = 1;
94 1
95 1 DISPDATAPORT = cmd;
96 1
97 1 Pin_E = 0;
98 1 }
99
100 /***************************************
101
102
103
104 ****************************************/
105 void LCD_Disp_Pattern(INT8U img,INT8U len)
106 {
107 1 INT8U col;
108 1
109 1 col = CurCol;
110 1 if (col<64)
111 1 Pin_CS1 = 1;
112 1 else
113 1 {
114 2 col -= 64;
115 2 Pin_CS2 = 1;
116 2 }
117 1
C51 COMPILER V7.50 DISP 07/01/2008 15:53:05 PAGE 3
118 1 LCD_Cmd(0xB8|CurRow);
119 1 LCD_Cmd(0x40|col);
120 1
121 1 while (len != 0)
122 1 {
123 2 LCD_Data(img);
124 2 len --;
125 2 col ++;
126 2 CurCol ++;
127 2 if (col>=64)
128 2 {
129 3 Pin_CS1 = 0;
130 3 Pin_CS2 = 1;
131 3 LCD_Cmd(0xB8|CurRow);
132 3 LCD_Cmd(0x40|0);
133 3 col -= 64;
134 3 }
135 2 }
136 1 Pin_CS1 = 0;
137 1 Pin_CS2 = 0;
138 1 }
139
140
141 /***************************************
142
143
144
145 ****************************************/
146 void LCD_Disp_Pic(INT8U * img,INT8U len)
147 {
148 1 INT8U col;
149 1
150 1 col =CurCol;
151 1
152 1 if (col<64)
153 1 Pin_CS1 = 1;
154 1 else
155 1 {
156 2 col -= 64;
157 2 Pin_CS2 = 1;
158 2 }
159 1 LCD_Cmd(0xB8|CurRow);
160 1 LCD_Cmd(0x40|col);
161 1
162 1 do
163 1 {
164 2 LCD_Data(*img);
165 2 len --;
166 2 col ++;
167 2 CurCol ++;
168 2 img ++;
169 2 if (col>=64)
170 2 {
171 3 Pin_CS1 = 0;
172 3 Pin_CS2 = 1;
173 3 LCD_Cmd(0xB8|CurRow);
174 3 LCD_Cmd(0x40|0);
175 3 col -= 64;
176 3 }
177 2 }while (len != 0);
178 1 Pin_CS1 = 0;
179 1 Pin_CS2 = 0;
C51 COMPILER V7.50 DISP 07/01/2008 15:53:05 PAGE 4
180 1 }
181
182 /***************************************
183
184 顯示掃描刷新程序
185
186 ****************************************/
187 void DispRef(void)
188 {
189 1 static INT8U BlinkCnt = 0; //閃爍顯示計數器
190 1 static BOOLEAN BlinkStatus = 0; //當前閃爍狀態
191 1
192 1 /* 計算顯示閃爍狀態 */
193 1 BlinkCnt ++;
194 1 BlinkCnt %= T_BLINK;
195 1 if (BlinkCnt == 0)
196 1 BlinkStatus = !BlinkStatus;
197 1
198 1 }
199
200
201 /***************************************
202
203 獲取整數的長度
204
205 ****************************************/
206 static INT8U GetIntLen(INT32U val)
207 {
208 1 INT8U len;
209 1
210 1 len = 0;
211 1 while (val != 0)
212 1 {
213 2 val /= 10;
214 2 len ++;
215 2 }
216 1
217 1 if (len == 0)
218 1 len = 1;
219 1
220 1 return len;
221 1 }
222
223
224
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -