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

📄 lcddrv.c

📁 本代码采用C语言编写
💻 C
📖 第 1 页 / 共 4 页
字号:
        
    LCD_wbyte(PART1,LCD_CMD,LCD_RESET);//LCD 1 RESET

	LCD_wbyte(PART1,LCD_CMD,ADC_SELECT_R);//ADC :0
	LCD_wbyte(PART1,LCD_CMD,STATIC_OFF);//normal display operation
	LCD_wbyte(PART1,LCD_CMD,DUTY_SLE_32);//duty 1/32
		
	LCD_wbyte(PART2,LCD_CMD,LCD_RESET);// LCD 2 RESET
		
	LCD_wbyte(PART2,LCD_CMD,ADC_SELECT_R);//ADC :0
	LCD_wbyte(PART2,LCD_CMD,STATIC_OFF);//normal display operation
	LCD_wbyte(PART2,LCD_CMD,DUTY_SLE_32);//duty 1/32
     ///1.Display OFF
    LCD_wbyte(PART1,LCD_CMD,DISP_OFF);//lcd1 off
    LCD_wbyte(PART2,LCD_CMD,DISP_OFF);//lcd2 off
     
     
   
     ///2.1 CLEAR DISPLAY RAM LCD1
     
     // IO0SET=(0x01<<5);//select LCD1
     
#if 1     
       	for(i=0;i<4;i++)
       	{
          	LCD_wbyte(PART1,LCD_CMD,0xb8+i);//select page
          	for(j=0;j<61;j++)
           	{
             	LCD_wbyte(PART1,LCD_CMD,j);//select column
             	LCD_wbyte(PART1,LCD_DATA,0x00);//clear data in RAM    
           	}	
     	}
#endif        
        ///2.2 CLEAR DISPLAY RAM LCD2
       // IO0SET=(0x01<<6);//select LCD2
       
#if 1     
       	for(i=0;i<4;i++)
        {
          	LCD_wbyte(PART2,LCD_CMD,0xb8+i);//select page
          	for(j=0;j<61;j++)
           	{
             	LCD_wbyte(PART2,LCD_CMD,j);//select column
             	LCD_wbyte(PART2,LCD_DATA,0x00);//clear data in RAM    
           	}	
        }
#endif 
     ///3.Display ON	
    
     LCD_wbyte(PART2,LCD_CMD,DISP_ON);//lcd2 on
     LCD_wbyte(PART1,LCD_CMD,DISP_ON);//lcd1 on
     
    //display data 
      
     
        for(i=0;i<61;i++)
      {
		LCD_wbyte(PART1,LCD_CMD,PAGE_2);//set page
		LCD_wbyte(PART1,LCD_CMD,i);//set column
		
	    LCD_wbyte(PART1,LCD_DATA,0x0f);//write data in RAM	
	    }
	       for(i=0;i<51;i++)
        {
		LCD_wbyte(PART1,LCD_CMD,PAGE_2);//set page
		LCD_wbyte(PART1,LCD_CMD,i);//set column
		
	    LCD_wbyte(PART1,LCD_DATA,0x0f);//write data in RAM	
	     }
	    
	       for(i=0;i<41;i++)
        {
		LCD_wbyte(PART1,LCD_CMD,PAGE_3);//set page
		LCD_wbyte(PART1,LCD_CMD,i);//set column
		
	    LCD_wbyte(PART1,LCD_DATA,0x0f);//write data in RAM	
	    }
	       for(i=0;i<31;i++)
        {
		LCD_wbyte(PART1,LCD_CMD,PAGE_4);//set page
		LCD_wbyte(PART1,LCD_CMD,i);//set column
		
	    LCD_wbyte(PART1,LCD_DATA,0x0f);//write data in RAM	
	    }
	     for(i=0;i<61;i++)
      {
		LCD_wbyte(PART2,LCD_CMD,PAGE_1);//set page
		LCD_wbyte(PART2,LCD_CMD,i);//set column
		
	    LCD_wbyte(PART2,LCD_DATA,0x0f);//write data in RAM	
	    }
	       for(i=0;i<51;i++)
        {
		LCD_wbyte(PART2,LCD_CMD,PAGE_2);//set page
		LCD_wbyte(PART2,LCD_CMD,i);//set column
		
	    LCD_wbyte(PART2,LCD_DATA,0x0f);//write data in RAM	
	     }
	    
	       for(i=0;i<41;i++)
        {
		LCD_wbyte(PART2,LCD_CMD,PAGE_3);//set page
		LCD_wbyte(PART2,LCD_CMD,i);//set column
		
	    LCD_wbyte(PART2,LCD_DATA,0x0f);//write data in RAM	
	    }
	       for(i=0;i<31;i++)
        {
		LCD_wbyte(PART2,LCD_CMD,PAGE_4);//set page
		LCD_wbyte(PART2,LCD_CMD,i);//set column
		
	    LCD_wbyte(PART2,LCD_DATA,0x0f);//write data in RAM	
	    }
	   
}


//column=x*8;
//x:0-13,y:0-1
void setposit(uint x,uint y)
{
	if(x<=6)
	{
	    currentbase=COLUMNBASE_L1;
	    if(y==0)
	     {
	     LCD_wbyte(PART1,LCD_CMD,PAGE_1);
	     currentlcd=PART1;
	     currentpage=PAGE_1;
	      }
	   else if(y==1)
	     
	     {
	      LCD_wbyte(PART1,LCD_CMD,PAGE_2);
	       currentlcd=PART1;
	       currentpage=PAGE_2;
	      }
	}
	if((x>=7)&&(x<=13))  //  7<=x<=13
	{
	    currentbase=COLUMNBASE_L2;
	    if(y==0)
	     {
	     LCD_wbyte(PART2,LCD_CMD,PAGE_1);
	       currentlcd=PART2;
	       currentpage=PAGE_1;
	      }
	   else if(y==1)
	     {
	      LCD_wbyte(PART2,LCD_CMD,PAGE_2);
	       currentlcd=PART2;
	       currentpage=PAGE_2;
	      }
	}
}
	
void DispChar(uint x, uchar* ch)
{
  uchar	i, p;
  uint charbase;
  uint Length, Length_tmp;
  uint a,b,column;

 //if((strlen((char *)ch))>(14-x))
 //length=14-x;
 //else
 	Length=strlen((char *)ch);
 	Length_tmp = 0x00;
 	if(Length>14-x)
 	{
 		Length_tmp = Length -14+x;
 		Length = 14-x;
 	}
  	for(a=0;a<Length;a++)
  	{
   		charbase=(ch[a]-0x20)*16;
   		setposit(x+a,0);
   		if((x+a)<=6) column=(x+a)*8;
  		if(((x+a)>=7)&&((x+a)<=13)) column=(x+a-7)*8;
  		for(i=0;i<8;i++)
  		{
	   		b=Bmp001[i+charbase];
	   		LCD_wbyte(currentlcd,LCD_CMD,currentbase+column+i);
	   		LCD_wbyte(currentlcd,LCD_DATA,b);
  		}
  		for(i=8;i<16;i++)
  		{
	 		b=Bmp001[i+charbase];
	  		LCD_wbyte(currentlcd,LCD_CMD,currentpage+1);
	  		LCD_wbyte(currentlcd,LCD_CMD,currentbase+column+i-8);
	  		LCD_wbyte(currentlcd,LCD_DATA,b);
  		}	
 		p=1;
  	}
  	if(Length_tmp>0)
  	{
  		for(a=0;a<Length_tmp;a++)
	  	{
	   		charbase=(ch[a+14]-0x20)*16;
	   		setposit(a,1);
	   		if(a<=6) column=a*8;
	  		if((a>=7)&&(a<=13)) column=(a-7)*8;
	  		for(i=0;i<8;i++)
	  		{
		   		b=Bmp001[i+charbase];
		   		LCD_wbyte(currentlcd,LCD_CMD,currentbase+column+i);
		   		LCD_wbyte(currentlcd,LCD_DATA,b);
	  		}
	  		for(i=8;i<16;i++)
	  		{
		 		b=Bmp001[i+charbase];
		  		LCD_wbyte(currentlcd,LCD_CMD,currentpage+1);
		  		LCD_wbyte(currentlcd,LCD_CMD,currentbase+column+i-8);
		  		LCD_wbyte(currentlcd,LCD_DATA,b);
	  		}	
	 		p=1;
	  	}
	}
}

void ClrScreen(void)
{
    uint i,j;
    #if 1     
       for(i=0;i<4;i++)
        {
           LCD_wbyte(PART1,LCD_CMD,0xb8+i);//select page
         
         
          for(j=0;j<61;j++)
           {
             LCD_wbyte(PART1,LCD_CMD,j);//select column
             LCD_wbyte(PART1,LCD_DATA,0x00);//clear data in RAM
            
           }	
        }
#endif        
        ///2.2 CLEAR DISPLAY RAM LCD2
       // IO0SET=(0x01<<6);//select LCD2
       
#if 1     
       for(i=0;i<4;i++)
        {
           LCD_wbyte(PART2,LCD_CMD,0xb8+i);//select page
         
         
          for(j=0;j<61;j++)
           {
             LCD_wbyte(PART2,LCD_CMD,j);//select column
             LCD_wbyte(PART2,LCD_DATA,0x00);//clear data in RAM
            
           }	
        }
#endif 
}
/*
void blightctrl(uint8 on)
{
if(on==1)
 IO0SET=(0x01<<16);// set P0.16 as 1. blacklight is on 
if(on==0)
IO0CLR=(0x01<<16);// set P0.16 as 0. blacklight is off
} */

void LcdLightCtr(uchar ctrl)
{
    if(ctrl)
    {
		LIGHT_ON;
   	}
    else
    {
		LIGHT_OFF;
	}
}

⌨️ 快捷键说明

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