⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcd.c

📁 DSP关于F240的实例程序
💻 C
📖 第 1 页 / 共 2 页
字号:
  LCD_WR_COM(CSRW);                        //CSRW 代码
  LCD_WR_DATA(LB);                       //设置参数光标指针低8位 
  LCD_WR_DATA(HB);                       //设置参数光标指针高8位 

LCD_WR_COM(MWRITE); 
  for(i=0;i<16;i++)
 {  
//write data	
 
    LCD_WR_DATA(*p++);
    
 }

LCD_WR_COM(CSRDIR_R); 
}


/*------------------------------------------------------------------------------
  源文件 / 文字 : C:\Documents and Settings\fengguo\My Documents\Snap1.bmp
  宽×高(像素): 320×1
------------------------------------------------------------------------------*/
void ShowBitmap(unsigned int layer,unsigned char *Bmp)
{	
	  unsigned int xdata i;
	  
      unsigned int xdata  init_high8,init_low8;
     
     p=Bmp;
     if(layer == 1)
        {init_high8 = SED1335LAY1_h; init_low8 = SED1335LAY1_l;}
   else if(layer == 2)
         {init_high8 = SED1335LAY2_h; init_low8 = SED1335LAY2_l;}
   else if(layer == 3)
         {init_high8 = SED1335LAY3_h; init_low8 = SED1335LAY3_l;}
   else{return;}
//set address	ly1
  LCD_WR_COM(CSRW);                        //CSRW 代码
  LCD_WR_DATA(init_low8);                       //设置参数光标指针低8位 
  LCD_WR_DATA(init_high8);                       //设置参数光标指针高8位 
//write data	
	LCD_WR_COM(MWRITE);  
	
	for(i=0;i<(40*240);i++)
	{
		
		LCD_WR_DATA(*p++);
			
	}	

}


//在区一的Py行(范围是1~30),Px列(范围是1~40),显示字母zimu
void plot_ZiMu(unsigned char Px,unsigned char Py,char ZiMu)
{
    int xdata offset,addr;
   unsigned char LB,HB;

   if(Px < 1 ||Px >40 ||Py <1 ||Py>30)   return;
   
   offset = (Py-1)*40 + Px-1;
   addr = ((unsigned int)SED1335LAY1_h << 8) + SED1335LAY1_l;
   addr = addr + offset;
   
   LB = addr & 0x00ff;
   HB = addr >> 8;

  //set address	ly1
  LCD_WR_COM(CSRW);                        //CSRW 代码
  LCD_WR_DATA(LB);                       //设置参数光标指针低8位 
  LCD_WR_DATA(HB);                       //设置参数光标指针高8位 
//write data	
	LCD_WR_COM(MWRITE); 
    LCD_WR_DATA(ZiMu); 
   
}


//在区一的Py行(范围是1~30),Px列(范围是1~40),显示字符串ZiChuan
void plot_ZiChuan(unsigned char Px,unsigned char Py,unsigned char *ZiChuan)
{
    int xdata offset,addr;
   unsigned char LB,HB;
   
   if(Px < 1 ||Px >40 ||Py <1 ||Py>30)   return;
   
   p = ZiChuan;
   offset = (Py-1)*40 + Px-1;
   addr = ((unsigned int)SED1335LAY1_h << 8) + SED1335LAY1_l;
   addr = addr + offset;
   
   LB = addr & 0x00ff;
   HB = addr >> 8;

  //set address	ly1
  LCD_WR_COM(CSRW);                        //CSRW 代码
  LCD_WR_DATA(LB);                       //设置参数光标指针低8位 
  LCD_WR_DATA(HB);                       //设置参数光标指针高8位 
//write data	
	LCD_WR_COM(MWRITE); 
for(;;)
  { 
    LCD_WR_DATA(*p++); 
    if(*p == '\0')  break;
   }
}
// --------->Px
// |
// |
// |  Py
// V 
//在区二的Py行(范围是1~240),Px列(范围是1~320)处显示点
//flag == 1 draw   point
//flag == 0 cancel point
void plot_point(unsigned int layer ,unsigned int Px,unsigned int Py,char flag)
{
    int xdata offset,addr;
   unsigned int xdata  init_high8,init_low8;
   unsigned char LB,HB,dw,temp;

  if(Px < 1 ||Px >320 ||Py <1 ||Py>240)   return;

   offset = (Py-1)*40 + (Px >> 3);//与写字母不同,相差1
  if(layer == 1)
        {init_high8 = SED1335LAY1_h; init_low8 = SED1335LAY1_l;}
   else if(layer == 2)
         {init_high8 = SED1335LAY2_h; init_low8 = SED1335LAY2_l;}
   else if(layer == 3)
         {init_high8 = SED1335LAY3_h; init_low8 = SED1335LAY3_l;}
   else{return;}

   addr = (init_high8  << 8) + init_low8;
   addr = addr + offset;
   
   dw = (Px & 0x0007);
   if(dw == 0x00)   addr=addr-1;

   LB = addr & 0x00ff;
   HB = addr >> 8;
// 读取当前显示数据
  //set address	ly1
  LCD_WR_COM(CSRW);                        //CSRW 代码
  LCD_WR_DATA(LB);                       //设置参数光标指针低8位 
  LCD_WR_DATA(HB);                       //设置参数光标指针高8位 

 LCD_WR_COM(MREAD);
 temp = LCD_READ_DATA()  ;
  
//write data 
  LCD_WR_COM(CSRW);                        //CSRW 代码
  LCD_WR_DATA(LB);                       //设置参数光标指针低8位 
  LCD_WR_DATA(HB);                       //设置参数光标指针高8位 
     
  LCD_WR_COM(MWRITE); 
      if(flag==0)  {LCD_WR_DATA( (~dw_point[dw] )& temp );}
      else
       { LCD_WR_DATA(( dw_point[dw] |temp) ); }// 写入合成数据

}

int min(int x1,int x2)
{   if(x1>x2)  return x2;
      else     return x1;
}
//draw line function
//函数格式为result  = K1(begin - m) +n

void plot_line(unsigned int layer,unsigned int Px1,unsigned int Py1,unsigned int Px2,unsigned int Py2)
{
   int xdata delta_x, delta_y,number, m,n;
   unsigned int    result_int;
   char flag;
   float   K1,result;
   int  Orgin ,i; 
  
   delta_x =abs( Px2-Px1);
   delta_y =abs( Py2-Py1);

   if(delta_x > delta_y) 
        { 
         number =delta_x;
         K1= ((float) Py2-Py1)/( (float)Px2-Px1);
         Orgin =min(Px1,Px2);
         m=Px1; n=Py1;
         flag=1;
        }
   else if( (delta_x==0) &&  (delta_y==0) ) 
        {return;}
   else   
        { 
         number =delta_y;
         K1= ( (float)Px2-Px1)/( (float)Py2-Py1);
         Orgin =min(Py1,Py2);
         m=Py1; n=Px1;
         flag=0;
         }

  
     for(i=0;i<number+1;i++)
          {
             result=K1*((Orgin+i) -m)+n;
             result_int = (unsigned int)result;
             if(  (result - result_int) >=0.5  )   result_int++;

             if(flag==1)
                { 
                   plot_point( layer,(unsigned int)(Orgin+i), result_int,1);
                 }
             else if(flag==0)  
                {  
                    plot_point( layer,result_int,(unsigned int)(Orgin+i), 1);
                 }

          }
}

void draw_ZuoBiaoZhou( unsigned int layer )
{  unsigned int xdata i;
   
plot_Chinese(layer,4,1,bmp_dian);
plot_Chinese(layer,6,1,bmp_ya);
plot_Chinese(layer,8,1,bmp_V);



   plot_line(layer,  20,20,    20,220);//纵轴
   plot_line(layer,  1,131,    280,131);//横轴

   plot_line(layer,  24,28,    20,20);
   plot_line(layer,  16,28,    20,20);

   plot_line(layer,  272,135,  280,131 );
   plot_line(layer,  272,127,  280,131 );

   for(i=1;i<=6;i++)
{
   plot_line(layer,17, (131-i*18),19,(131-i*18));

}

  
  plot_Number(layer,2,106,bmp_1);
  plot_Number(layer,2,106-18,bmp_2);
  plot_Number(layer,2,106-2*18,bmp_3);
  plot_Number(layer,2,106-3*18,bmp_4);
  plot_Number(layer,2,106-4*18,bmp_5);
  plot_Number(layer,2,106-5*18,bmp_6);

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -