📄 max531.lst
字号:
159 2 break;
160 2 case 0x82: // 2行4列,数字7
161 2 if (count<2)
162 2 {
163 3 wordbuf[count]= '7';
164 3 count++;
165 3 }
166 2 break;
167 2 case 0x14: // 3行1列,数字8
168 2 if (count<2)
169 2 {
170 3 wordbuf[count] = '8';
171 3 count++;
172 3 }
173 2 break;
174 2 case 0x24: // 3行2列,数字9
175 2 if (count<2)
176 2 {
177 3 wordbuf[count]= '9';
178 3 count++;
179 3 }
C51 COMPILER V8.02 MAX531 12/01/2008 21:36:30 PAGE 4
180 2 break;
181 2 case 0x44: // 3行3列,确认键
182 2
183 2 { if(count==2)
184 3 enterflag = 1;} // 确认键按下
185 2
186 2 break;
187 2 case 0x84: // 3行4列,取消键
188 2 {
189 3 count = 0; // 计数清零
190 3 //TempOut=1;
191 3 for(j=0;j<6;j++)
192 3 wordbuf[j]=0x00;
193 3 for(j=0;j<2;j++)
194 3 *(keyascan+j)=0x00;
195 3 }
196 2 break;
197 2 default:break;
198 2 }
199 1
200 1 if ( enterflag==1) // 如果按下确认键
201 1 {
202 2 wordbuf[2]='m';
203 2 wordbuf[3]='V';
204 2 enterflag = 0; // 标志位置回0
205 2 count = 0; // 密码位计数器清零
206 2 for(j=0;j<2;j++)
207 2 *(keyascan+j)=wordbuf[j];
208 2 // change=0;
209 2
210 2 }
211 1 }
212
213 /*************************lcd1602程序**************************/
214
215 void wr_com(unsigned char com)//写状态字//
216 {
217 1 delay1ms(1);
218 1 RS=0;
219 1 RW=0;
220 1 EN=0;
221 1 P0=com;
222 1 delay1ms(1);
223 1 EN=1;
224 1 delay1ms(1);
225 1 EN=0;
226 1 }
227
228 void wr_dat(unsigned char dat)//写数据//
229 {
230 1 delay1ms(1);;
231 1 RS=1;
232 1 RW=0;
233 1 EN=0;
234 1 P0=dat;
235 1 delay1ms(1);
236 1 EN=1;
237 1 delay1ms(1);
238 1 EN=0;
239 1 }
240
241 void lcd_init()//初始化设置//
C51 COMPILER V8.02 MAX531 12/01/2008 21:36:30 PAGE 5
242 {
243 1 delay1ms(15);
244 1 wr_com(0x38);delay1ms(5);
245 1 wr_com(0x08);delay1ms(5);
246 1 wr_com(0x01);delay1ms(5);
247 1 wr_com(0x06);delay1ms(5);
248 1 wr_com(0x0c);delay1ms(5);
249 1 }
250
251
252 void display(unsigned char *p)//显示//
253 {
254 1 while(*p!='\0')
255 1 {
256 2 wr_dat(*p);
257 2 p++;
258 2 delay1ms(1);
259 2 }
260 1 }
261
262 init_play()//初始化显示
263 {
264 1 lcd_init();
265 1 wr_com(0x80);
266 1 display(str1);
267 1 wr_com(0xc0);
268 1 display(str2);
269 1 wr_com(0x86);
270 1 wr_dat(wordbuf[0]);//显示十位
271 1 wr_com(0x87);
272 1 wr_dat(wordbuf[1]);//显示个位
273 1 wr_com(0x88);
274 1 wr_dat(wordbuf[2]);//显示m
275 1 wr_com(0x89);
276 1 wr_dat(wordbuf[3]);//显示V
277 1 }
278
279 /*jsdisdisplay()//计数显示
280 {
281
282 wr_com(0x8A);
283 wr_dat(JS[0]);//显示'0'
284 wr_com(0x8B);
285 wr_dat(JS[1]);//显示'0'
286 wr_com(0x8C);
287 wr_dat(JS[2]);//显示':'
288 wr_com(0x8D);
289 wr_dat(JS[3]);//显示'0'
290 wr_com(0x8E);
291 wr_dat(JS[4]);//显示'0'
292
293 } */
294
295
296 void main()
297 {
298 1 init_play();//初始化显示
299 1 //jsdisdisplay();
300 1 while(1)
301 1 {
302 2 getscan();
303 2 if(key!=0)
C51 COMPILER V8.02 MAX531 12/01/2008 21:36:30 PAGE 6
304 2 init_play();
305 2 da_out531(1000);
306 2
307 2 }
308 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 749 ----
CONSTANT SIZE = 14 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 10 7
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 + -