• 大小: 63KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-14
  • 语言: 其他
  • 标签: proteus  89c51  12864  

资源简介

基础程序,便于学习proteus这一软件和仿真单片机中的12864显示

资源截图

代码片段和文件信息

/********************************** LCD12864曲线显示*******************************************/
/*********作者:王胜文。QQ:95201972  email:nunk@163.com 希望与大家交流2007。08。03**********/

#include
#include
#include
#include
//#include
#define Graphic_Clear 0x01   //檫除点
#define Graphic_Not 0x02     //反相点
#define Graphic_Draw 0x03  //画点

uchar j=0i=0;
uchar r=32;
/***********************在LCD上任意坐标画点********************************/

void DrawPoint(uchar Xuchar Yuchar Type) 
{  //X,Y化点的坐标Type画点的类型:反相点,檫除点,画点
                                                    
   uchar DX = (Y >> 3);               //计算出属于哪个字节 
   uchar BX = Y - (DX << 3);           //计算出属于字节哪一位 
   uchar TempData = 0; 
    
    
   if (X > 63) 
   { 
    chip_select=2;
      X -= 64; 
   } 
   else 
   { 
      chip_select=1; 
   } 

   SetPage(DX);             //设行地址
   SetColumn(X);  //设列地址
    
   TempData = ReadData();   //读出所画点所在字节的内容
    
   switch (Type)            //对该字节进行相应操作
   { 
       case Graphic_Clear:
           TempData &= ~(1<          break; 
      case Graphic_Not:
          TempData ^= (1 << BX); 
           break; 
      case Graphic_Draw: 
           TempData |= (1 << BX);  
break;
  default: break;
   } 
    
   SetPage(DX);            //设置行地址
   SetColumn(X);   //设置列地址
   WriteData(TempData);  //把修改后的字节送回LCD,达到画点目的


/********插值法画任意两点之间直线的函数,函数中只用加减法,程序运行效率很高**********/

DrawLine(uchar x1uchar y1uchar x2uchar y2)
{                           //x1y1起点坐标;x2y2终点坐标;
    uchar xy; 
    uchar d_xd_y;     
    char err=0;
    uchar temp=0;

    if(y2    d_y=y2-y1;
    if (d_y==0)
        {
        if (x1>x2) {x=x1;x1=x2;x2=x;}
        for ( x=x1;x<=x2;x++ ) DrawPoint(xy1Graphic_Draw);
        }
    else
        {
    if(x2>=x1){temp=1;d_x=x2-x1;}else d_x=x1-x2;
    x=x1;y=y1;DrawPoint(xyGraphic_Draw);
    if(temp&&(d_y<=d_x))
        while(x!=x2)
            {if(err<0){x=x+1;err=err+(y2-y);}
            else {x=x+1;y=y+1;err=err+(y2-y)-(x2-x);}
            DrawPoint(xyGraphic_Draw);
            }
    else if(temp&&(d_y>d_x))
        while(y!=y2)
            {d_x=x2-x;d_y=y2-y; 
            if(err<0){x=x+1;y=y+1;err=err+d_y-d_x;}
            else {y=y+1;err=err-d_x;}
            DrawPoint(xyGraphic_Draw);
            }
    else if(!temp&&(d_y<=d_x))
        while(x!=x2)
            {d_x=x-x2;d_y=y2-y; 
            if(err<0){x=x-1;err=err+d_y;}
            else {x=x-1;y=y+1;err=err+d_y-d_x;}
            DrawPoint(xyGraphic_Draw);
            }
    else if(!temp &&(d_y>d_x))
        while(y!=y2)
            {d_x=x-x2;d_y=y2-y; 
            if(err<0){x=x-1;y=y+1;err=err+d_y-d_x;}
            else {y=y+1;err=err-d_x;}
            DrawPoint(xyGraphic_Draw);
            }
        }    
}                              

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     106689  2007-11-13 10:26  Proteus中单片机89C51在LCD12864上画曲线\draw.DSN

     文件       1412  2007-11-13 10:26  Proteus中单片机89C51在LCD12864上画曲线\draw.PWI

     文件      20150  2007-11-13 09:38  Proteus中单片机89C51在LCD12864上画曲线\drawing_line

     文件       5241  2007-11-15 15:29  Proteus中单片机89C51在LCD12864上画曲线\drawing_line.c

     文件       8460  2007-11-13 09:38  Proteus中单片机89C51在LCD12864上画曲线\drawing_line.hex

     文件         41  2007-11-13 09:38  Proteus中单片机89C51在LCD12864上画曲线\drawing_line.lnp

     文件      10007  2007-11-15 15:29  Proteus中单片机89C51在LCD12864上画曲线\drawing_line.LST

     文件      22088  2007-11-13 09:38  Proteus中单片机89C51在LCD12864上画曲线\drawing_line.M51

     文件      22446  2007-11-15 15:29  Proteus中单片机89C51在LCD12864上画曲线\drawing_line.OBJ

     文件       1070  2007-11-21 09:16  Proteus中单片机89C51在LCD12864上画曲线\drawing_line.Opt

     文件        219  2007-11-21 09:16  Proteus中单片机89C51在LCD12864上画曲线\drawing_line.plg

     文件       2004  2007-11-09 19:04  Proteus中单片机89C51在LCD12864上画曲线\drawing_line.Uv2

    .......      1370  2007-11-15 18:51  Proteus中单片机89C51在LCD12864上画曲线\drawing_line_Opt.Bak

    .......      2005  2007-11-09 11:00  Proteus中单片机89C51在LCD12864上画曲线\drawing_line_Uv2.Bak

     文件       3728  2007-08-16 14:10  Proteus中单片机89C51在LCD12864上画曲线\drive_functions.h

     文件       1051  2007-08-08 09:47  Proteus中单片机89C51在LCD12864上画曲线\get_keys.h

     文件     106850  2007-08-27 13:09  Proteus中单片机89C51在LCD12864上画曲线\Last Loaded draw.DBK

     目录          0  2007-11-21 09:16  Proteus中单片机89C51在LCD12864上画曲线

----------- ---------  ---------- -----  ----

               314831                    18


评论

共有 条评论