📄 hclcd.lst
字号:
254 2 if(time0_1s==0)
255 2 {
256 3 time0_1s=0x05;
257 3 led1_8=_crol_(led1_8,1);
258 3 led18count++;
259 3 if(led18count==0x09){led1_8=0xfe;led18count=0x01;}
260 3 P1=led1_8;
261 3
262 3 }
263 2 timenewbit=1;
264 2 timecount2--;
265 2 if(timecount2==0)
266 2 {
267 3 timecount2=0x32;
268 3 b_wbit = !b_wbit;
269 3 if(b_wbit==0)
270 3 {
271 4 newbmpbit=1;
272 4 newbmpcount++;
273 4 if(newbmpcount==0x03)
274 4 {newbmpcount=0x01;}
275 4 }
276 3 }
277 2 }
278 1
279 1 if(newtimebit==1&&recpcokbit==1)
280 1 {
281 2 //设定新的系统时间
282 2 Uchar *pcfsetip;
283 2 newtimebit=0;
284 2 recpcokbit=0;
285 2 pcfsetip=&recdata[1];
286 2 SetPCF8563(pcfsetip);
287 2 WritePCF8563(0x00,0x00);
288 2 WritePCF8563(0x01,0x00);
289 2 WritePCF8563(0x0d,0x83);
290 2 }
291 1 }
292
293 //以下为串行口中断程序,用于接收串行数据
294 void rs232(void) interrupt 4
295 {
296 1 if(RI==1)
297 1 {
298 2
299 2 //原输入格式为AA 秒,分,时 日,星期,月年
300 2 if (SBUF==0xaa)
301 2 {
302 3 newtimebit=1;
C51 COMPILER V7.07 HCLCD 06/16/2005 23:43:25 PAGE 6
303 3 pcpointer=0;
304 3 }
305 2 RI = 0;
306 2 recdata[pcpointer++]=SBUF;
307 2 if(pcpointer==8)
308 2 {
309 3 pcpointer =0;
310 3 recpcokbit =1; //指针还原,置收到完整的控制码
311 3 }
312 2 }
313 1 else
314 1 {
315 2 TI = 0;
316 2 }
317 1 }
318
319 void time2(void) interrupt 5
320 {
321 1 TF2 = 0;
322 1 TH2 = 0x4c; //50ms
323 1 TL2 = 0x00;
324 1 }
325
326
327
328 /*---------------LCD驱动要用到的一些子程序--------------------*/
329 /*向LCD写指令*/
330 void lcdwrite_cmd(Uchar cmd_dat)
331 {
332 1 D_I = 0;
333 1 R_W = 0;
334 1 E = 0;
335 1 LCDPORT = cmd_dat;
336 1 SomeNOP();
337 1 E = 1;
338 1 SomeNOP();
339 1 E = 0;
340 1 }
341 /*向LCD写数据*/
342 void lcdwrite_dat(Uchar dot_dat)
343 {
344 1 D_I = 1;
345 1 R_W = 0;
346 1 E = 0;
347 1 LCDPORT = dot_dat;
348 1 SomeNOP();
349 1 E = 1;
350 1 SomeNOP();
351 1 E = 0;
352 1 }
353 /*判断LCD是否处于*/
354 void lcd_busy()
355 {
356 1 Uchar i;
357 1 D_I = 0;
358 1 R_W = 1;
359 1 while(1)
360 1 {
361 2 E = 0;
362 2 LCDPORT = 0xff;
363 2 SomeNOP();
364 2 E = 1;
C51 COMPILER V7.07 HCLCD 06/16/2005 23:43:25 PAGE 7
365 2 SomeNOP();
366 2 i = LCDPORT;
367 2 E = 0;
368 2 if(i<0x80) break;
369 2 }
370 1 }
371
372 Uchar lcdread_dat(void)
373 { Uchar i;
374 1 D_I = 1;
375 1 R_W = 1;
376 1 E = 0;
377 1 LCDPORT = 0xff;
378 1 SomeNOP();
379 1 E =1;
380 1 SomeNOP();
381 1 i = LCDPORT;
382 1 E = 0;
383 1 LCDPORT =0xff;
384 1 SomeNOP();
385 1 E = 1;
386 1 SomeNOP();
387 1 i =LCDPORT;
388 1 E =0;
389 1 return(i);
390 1 }
391
392 //开LCD显示
393 void lcddispon(void)
394 {
395 1 CS1=0;CS2=1;
396 1 lcdwrite_cmd(0x3f);
397 1 CS1=1;CS2=0;
398 1 lcdwrite_cmd(0x3f);
399 1 }
400 //关LCD显示
401 void lcddispoff(void)
402 {
403 1 CS1=0;CS2=1;
404 1 lcdwrite_cmd(0x3e);
405 1 CS1=1;CS2=0;
406 1 lcdwrite_cmd(0x3e);
407 1 }
408 //对整屏清除,就是写空的数据
409 void lcdclrall(void)
410 {
411 1 Uchar i,j;
412 1 for(i=0;i<8;i++)
413 1 {
414 2 CS1=0;CS2=1;
415 2 lcdwrite_cmd(i|0xb8);
416 2 lcdwrite_cmd(0x40);
417 2 for(j=64;j>0;j--)
418 2 {
419 3 lcdwrite_dat(0x00);
420 3 lcd_busy();
421 3 // P3_1=!P3_1;
422 3 }
423 2
424 2 CS1=1;CS2=0;
425 2 lcdwrite_cmd(i|0xb8);
426 2 lcdwrite_cmd(0x40);
C51 COMPILER V7.07 HCLCD 06/16/2005 23:43:25 PAGE 8
427 2 for(j=64;j>0;j--)
428 2 {
429 3 lcdwrite_dat(0x00);
430 3 lcd_busy();
431 3 }
432 2 }
433 1 }
434
435 //LCD初始化
436 void lcdini(void)
437 {
438 1 CS1=0;CS2=1;
439 1 lcdwrite_cmd(0xc0); //从第0行开始显示
440 1 CS1=1;CS2=0;
441 1 lcdwrite_cmd(0xc0);
442 1 lcddispon();
443 1 }
444
445
446 /*在指定的行列上显示12点阵的汉字*/
447
448 void HZ12disp(Uchar Nowrow,Uchar Nowcol,Uchar CHplace)
449 {
450 1 Uchar i,tmp1,tmp2,k=12;
451 1 Uint j;
452 1 j = (CHplace-1)*24;
453 1 if((Nowrow%2)==0) //
454 1 {
455 2 switch(Nowrow)
456 2 {
457 3 case 0: i=0;break;
458 3 case 2: i=3;break;
459 3 default: i=6;
460 3 }
461 2 while(k!=0)
462 2 {
463 3 if(Nowcol<0x40)
464 3 {CS1=0;CS2=1;}
465 3 else
466 3 { if(Nowcol<0x80)
467 4 {CS1=1;CS2=0;}
468 4 else
469 4 {break;}
470 4 }
471 3 lcdwrite_cmd(i|0xb8);
472 3 lcdwrite_cmd(Nowcol|0x40);
473 3 lcdwrite_dat(Hzk12[j]);
474 3 lcd_busy();
475 3 lcdwrite_cmd((i+1)|0xb8); //到下一页
476 3 lcdwrite_cmd(Nowcol|0x40);
477 3 tmp1 = lcdread_dat();
478 3 lcdwrite_cmd(Nowcol|0x40);
479 3 lcdwrite_dat((Hzk12[j+12]&0x0f)|(tmp1&0xf0));
480 3 j++;
481 3 Nowcol++;
482 3 k--;
483 3 }
484 2 }
485 1 else
486 1 {
487 2 switch(Nowrow)
488 2 {
C51 COMPILER V7.07 HCLCD 06/16/2005 23:43:25 PAGE 9
489 3 case 1: i=1;break;
490 3 default: i=4;
491 3 }
492 2 while(k!=0)
493 2 {
494 3 if(Nowcol<0x40)
495 3 {CS1=0;CS2=1;}
496 3 else
497 3 {
498 4 if(Nowcol<0x80)
499 4 {CS1=1;CS2=0;}
500 4 else
501 4 {break;}
502 4 }
503 3 lcdwrite_cmd(i|0xb8);
504 3 lcdwrite_cmd(Nowcol|0x40);
505 3 tmp1=lcdread_dat();
506 3 tmp1=tmp1&0x0f;
507 3 tmp1=(Hzk12[j]<<4)|tmp1;
508 3 tmp2=(Hzk12[j+12]<<4)|(Hzk12[j]>>4);
509 3 lcdwrite_cmd(Nowcol|0x40);
510 3 lcdwrite_dat(tmp1);
511 3 lcd_busy();
512 3 lcdwrite_cmd((i+1)|0xb8);
513 3 lcdwrite_cmd(Nowcol|0x40);
514 3 lcdwrite_dat(tmp2);
515 3 j++;
516 3 Nowcol++;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -