📄 1335c51.lst
字号:
C51 COMPILER V8.15 1335C51 10/29/2008 21:06:48 PAGE 8
//============================== 西文显示演示程序 ==============================
// 仅仅用于文本方式下的西文字符串显示,本函数只写入第3显示区
void TextDisp( uchar Ox,uchar Oy, uchar *ptr )
{
uchar TexLength=0,ii;
uint iTemp;
while(ptr[TexLength]>0x1f) {TexLength++;}; // 获取字串长度
iTemp = Oy*paraP9+Ox;
//WriteCommand( CsrForm ); // 光标形状设置,代码0x5d
//WriteData( 0x07 ); // 设置光标水平点为CSX=8
//WriteData( 0x07 ); // 光标为块状形式,垂直点为CSY=8
//WriteCommand( DispOn ); // 写入指令DISP ON/OFF代码,后续参数:
//WriteData( 0x56 ); // 01 01 01 10显示1~4区开显示,光标闪烁显示
iTemp = (uint)Oy * paraP9 + Ox; // 光标位置到实际ram地址换算
WriteCommand( CsrDirR ); // 自动右移光标指向
WriteCommand( CsrW ); // 制定光标位置
WriteData( (uchar)(iTemp &0xff) ); // 设置光标地址CSR
WriteData( (uchar)(iTemp /256 + BasePart1) );
WriteCommand( mWrite ); // 当前位置写入数据指令
for(ii=0;ii < TexLength;ii++) {
WriteData( ptr[ii] ); // 写入显示字符代码
}
WriteCommand( DispOn );
WriteData( 0x54 );
}
#endif
466
467 //数字显示,por为是表示负数,要显示“-”
468 void NumDisp(uchar x0, uchar y0, int dat)
469 {
470 1 uint temp;
471 1 uint tempPtr;
472 1 tempPtr = (uint)y0*paraP9+x0-1;
473 1 WriteCommand(CsrDirR);
474 1 WriteCommand( CsrW ); // 制定光标位置
475 1 WriteData( (uchar)(tempPtr &0xff) ); // 设置光标地址CSR
476 1 WriteData( (uchar)(tempPtr /256 + BasePart1) );
477 1
478 1 WriteCommand( mWrite ); // 当前位置写入数据指令
479 1 if(dat<0)
480 1 {
481 2 WriteData('-');
482 2 dat-=1;
483 2 dat=~dat;
484 2 }
485 1 else
486 1 {
487 2 WriteData(' ');
488 2 }
489 1 WriteData(dat/1000+48);
C51 COMPILER V8.15 1335C51 10/29/2008 21:06:48 PAGE 9
490 1 temp=dat%1000;
491 1 WriteData(temp/100+48);
492 1 temp%=100;
493 1 WriteData(temp/10+48);
494 1 WriteData(temp%10+48);
495 1 }
496
497 //8*16点阵数字显示,res为0表示不反色显示,要显示正负号,res为1表示第一位反色显示,如此类推
498 void NumDisp_816(uchar x0, uchar y0,uchar res, int dat)
499 {
500 1 uint temp;
501 1 if(res==0)
502 1 {
503 2 if(dat<0)
504 2 {
505 3 PutSdotInGraph(x0, y0, "-");
506 3 dat-=1;
507 3 dat=~dat;
508 3 }
509 2 else
510 2 {
511 3 PutSdotInGraph(x0, y0, "+");
512 3 }
513 2 x0++;
514 2 }
515 1 if(res==1)
516 1 {
517 2 Disp816(x0,y0,dat/1000,1);
518 2 }
519 1 else
520 1 {
521 2 Disp816(x0,y0,dat/1000,0);
522 2 }
523 1 temp=dat%1000;
524 1 if(res==2)
525 1 {
526 2 Disp816(x0+1,y0,temp/100,1);
527 2 }
528 1 else
529 1 {
530 2 Disp816(x0+1,y0,temp/100,0);
531 2 }
532 1 temp%=100;
533 1 if(res==3)
534 1 {
535 2 Disp816(x0+2,y0,temp/10,1);
536 2 }
537 1 else
538 1 {
539 2 Disp816(x0+2,y0,temp/10,0);
540 2 }
541 1 if(res==4)
542 1 {
543 2 Disp816(x0+3,y0,temp%10,1);
544 2 }
545 1 else
546 1 {
547 2 Disp816(x0+3,y0,temp%10,0);
548 2 }
549 1 }
550
551 //显示8*16点阵数字,res指定是否需要反色显示(非0为反色显示)
C51 COMPILER V8.15 1335C51 10/29/2008 21:06:48 PAGE 10
552 void Disp816(uchar x0,uchar y0,uchar num,uchar res)
553 {
554 1 switch(num)
555 1 {
556 2 case 0:
557 2 {
558 3 if(!res)
559 3 PutSdotInGraph(x0,y0,"0");
560 3 else
561 3 PutSdotInGraph_V(x0,y0,"0");
562 3 break;
563 3 }
564 2 case 1:
565 2 {
566 3 if(!res)
567 3 PutSdotInGraph(x0,y0,"1");
568 3 else
569 3 PutSdotInGraph_V(x0,y0,"1");
570 3 break;
571 3 }
572 2 case 2:
573 2 {
574 3 if(!res)
575 3 PutSdotInGraph(x0,y0,"2");
576 3 else
577 3 PutSdotInGraph_V(x0,y0,"2");
578 3 break;
579 3 }
580 2 case 3:
581 2 {
582 3 if(!res)
583 3 PutSdotInGraph(x0,y0,"3");
584 3 else
585 3 PutSdotInGraph_V(x0,y0,"3");
586 3 break;
587 3 }
588 2 case 4:
589 2 {
590 3 if(!res)
591 3 PutSdotInGraph(x0,y0,"4");
592 3 else
593 3 PutSdotInGraph_V(x0,y0,"4");
594 3 break;
595 3 }
596 2 case 5:
597 2 {
598 3 if(!res)
599 3 PutSdotInGraph(x0,y0,"5");
600 3 else
601 3 PutSdotInGraph_V(x0,y0,"5");
602 3 break;
603 3 }
604 2 case 6:
605 2 {
606 3 if(!res)
607 3 PutSdotInGraph(x0,y0,"6");
608 3 else
609 3 PutSdotInGraph_V(x0,y0,"6");
610 3 break;
611 3 }
612 2 case 7:
613 2 {
C51 COMPILER V8.15 1335C51 10/29/2008 21:06:48 PAGE 11
614 3 if(!res)
615 3 PutSdotInGraph(x0,y0,"7");
616 3 else
617 3 PutSdotInGraph_V(x0,y0,"7");
618 3 break;
619 3 }
620 2 case 8:
621 2 {
622 3 if(!res)
623 3 PutSdotInGraph(x0,y0,"8");
624 3 else
625 3 PutSdotInGraph_V(x0,y0,"8");
626 3 break;
627 3 }
628 2 case 9:
629 2 {
630 3 if(!res)
631 3 PutSdotInGraph(x0,y0,"9");
632 3 else
633 3 PutSdotInGraph_V(x0,y0,"9");
634 3 break;
635 3 }
636 2 }
637 1 }
638 /********************************************/
639 /*画线。任意方向的斜线,直线数学方程 aX+bY=1 */
640 /********************************************/
641 // 参数类型有待修改
642 void Linexy(uint x0,uchar y0,uint xt,uchar yt,uchar att)
643 {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -