• 大小: 122KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-12
  • 语言: 其他
  • 标签: LCD12864  

资源简介

对DSP上LCD12864画图程序进行编写

资源截图

代码片段和文件信息

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


#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;     
    uchar 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);
            }
        }    
}                                  


/******

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

     文件       2004  2007-08-15 17:27  5-drawing-line\drawing_line.Uv2

     文件       5200  2007-08-17 16:59  5-drawing-line\drawing_line.c

     文件       1051  2007-08-08 09:47  5-drawing-line\get_keys.h

     文件       3728  2007-08-16 14:10  5-drawing-line\drive_functions.h

     文件       1189  2007-08-17 17:02  5-drawing-line\drawing_line.Opt

     文件          0  2007-08-15 13:47  5-drawing-line\drawing_line_Uv2.Bak

     文件       3923  2007-08-17 17:02  5-drawing-line\drawing_line.plg

    .......      1362  2007-08-17 01:42  5-drawing-line\drawing_line_Opt.Bak

     文件      10379  2007-08-17 17:01  5-drawing-line\drawing_line.LST

     文件      19893  2007-08-17 17:01  5-drawing-line\drawing_line

     文件       1102  2007-08-17 17:02  5-drawing-line\draw.PWI

     文件     102555  2007-08-17 16:48  5-drawing-line\draw.DSN

     文件      22294  2007-08-17 17:01  5-drawing-line\drawing_line.M51

     文件       8366  2007-08-17 17:01  5-drawing-line\drawing_line.hex

     文件      22058  2007-08-17 17:01  5-drawing-line\drawing_line.OBJ

     文件     103053  2007-08-15 14:26  5-drawing-line\Last Loaded draw.DBK

     目录          0  2007-08-15 19:34  5-drawing-line

    .......      2004  2007-08-15 17:27  在LCD12864上显示波形\5-drawing-line\drawing_line_Uv2.Bak

     文件       5200  2007-08-17 16:59  在LCD12864上显示波形\5-drawing-line\drawing_line.c

     文件       1051  2007-08-08 09:47  在LCD12864上显示波形\5-drawing-line\get_keys.h

     文件       3728  2007-08-16 14:10  在LCD12864上显示波形\5-drawing-line\drive_functions.h

    .......      1189  2007-08-17 17:02  在LCD12864上显示波形\5-drawing-line\drawing_line_Opt.Bak

     文件       1133  2009-08-10 11:27  在LCD12864上显示波形\5-drawing-line\drawing_line.plg

     文件       1102  2007-08-17 17:02  在LCD12864上显示波形\5-drawing-line\draw.PWI

     文件     102555  2007-08-17 16:48  在LCD12864上显示波形\5-drawing-line\draw.DSN

     文件      22168  2009-08-10 11:21  在LCD12864上显示波形\5-drawing-line\drawing_line.M51

     文件       8366  2009-08-10 11:21  在LCD12864上显示波形\5-drawing-line\drawing_line.hex

     文件     103053  2007-08-15 14:26  在LCD12864上显示波形\5-drawing-line\Last Loaded draw.DBK

     文件      10370  2009-08-10 11:21  在LCD12864上显示波形\5-drawing-line\drawing_line.LST

     文件      22034  2009-08-10 11:21  在LCD12864上显示波形\5-drawing-line\drawing_line.OBJ

............此处省略9个文件信息

评论

共有 条评论