STM32L010驱动2.7寸电子水墨屏心得亲测可用

#STM32L010驱动2.7寸电子水墨屏心得

经过几天的折腾调试2.7寸电子水墨屏的驱动,驱动芯片使用GDEW027W3芯片,厂家给了调试驱动,但是一开始使用原厂给的Demon移植过来无法实现局部刷新,经过几天的排查发现硬件的升压电路存在问题总是升压不够导致刷新不了,要么就是刷新不完全不稳定。2.7寸电子水墨屏的特点是低功耗,但是刷新速度比较慢,我的调试代码亲测可用。
void pic_display_white(void)
{
unsigned int i;

	EPD_W21_WriteCMD(0x13);
	for(i=0;i<5808;i++)	     
	{
			EPD_W21_WriteDATA(0xff);  
	}  
	driver_delay_xms(2);		

EPD_W21_WriteCMD(0x10);
	for(i=0;i<5808;i++)	     
	{
			EPD_W21_WriteDATA(0xff);  
	}  
	driver_delay_xms(2);		

}

void full_display(void pic_display(void))
{

	pic_display(); //picture
	lut(); //Power settings
	EPD_W21_WriteCMD(0x12);			//DISPLAY REFRESH 	
	driver_delay_xms(100);	    //!!!The delay here is necessary, 200uS at least!!!     
	lcd_chkstatus();

}

void lcd_chkstatus(void)
{
unsigned char busy;
do
{
EPD_W21_WriteCMD(0x71);
busy =isEPD_W21_BUSY;
busy =!(busy & 0x01);
}
while(busy);
driver_delay_xms(200);
}

void lut(void)
{
unsigned int count;
{
EPD_W21_WriteCMD(0x20); //vcom
for(count=0;count<44;count++)
{EPD_W21_WriteDATA(lut_vcomDC[count]);}

	EPD_W21_WriteCMD(0x21);							//ww 
	for(count=0;count<42;count++)	     
		{EPD_W21_WriteDATA(lut_ww[count]);}   
	
	EPD_W21_WriteCMD(0x22);							//bw r
	for(count=0;count<42;count++)	     
		{EPD_W21_WriteDATA(lut_bw[count]);} 

	EPD_W21_WriteCMD(0x23);							//wb w
	for(count=0;count<42;count++)	     
		{EPD_W21_WriteDATA(lut_bb[count]);} 

	EPD_W21_WriteCMD(0x24);							//bb b
	for(count=0;count<42;count++)	     
		{EPD_W21_WriteDATA(lut_wb[count]);} 
}	         

}

void lut1(void)

{
unsigned int count;
{
EPD_W21_WriteCMD(0x20); //vcom
for(count=0;count<44;count++)
{EPD_W21_WriteDATA(lut_vcom1[count]);}

	EPD_W21_WriteCMD(0x21);							//ww --
	for(count=0;count<42;count++)	     
		{EPD_W21_WriteDATA(lut_ww1[count]);}   
	
	EPD_W21_WriteCMD(0x22);							//bw r
	for(count=0;count<42;count++)	     
		{EPD_W21_WriteDATA(lut_bw1[count]);} 

	EPD_W21_WriteCMD(0x23);							//wb w
	for(count=0;count<42;count++)	     
		{EPD_W21_WriteDATA(lut_wb1[count]);} 

	EPD_W21_WriteCMD(0x24);							//bb b
	for(count=0;count<42;count++)	     
		{EPD_W21_WriteDATA(lut_bb1[count]);} 
		
}	         

}

void Display(u16 x,u16 y,u16 w,u16 l ,int numberold,int numNew,unsigned char mode)

{

partial_display5(x,y,w,l ,Num_64_64Image[numberold],Num_64_64Image[numNew], mode);

}

void partial_display5(u16 x,u16 y,u16 w,u16 l ,const unsigned char *old_data,const unsigned char *new_data,unsigned char mode) //partial display
{
unsigned int i,count;

	count=w*l/8;	
	EPD_W21_WriteCMD(0x82);			//vcom_DC setting  	
EPD_W21_WriteDATA (0x08);	
	EPD_W21_WriteCMD(0X50);
	EPD_W21_WriteDATA(0x47);		
	lut1();	
  EPD_W21_WriteCMD(0x91);		//This command makes the display enter partial mode
	EPD_W21_WriteCMD(0x90);		//resolution setting

EPD_W21_WriteCMD(0x14); //write old data
	EPD_W21_WriteDATA(0);	    //x-start
	EPD_W21_WriteDATA(x);     //x-end
	EPD_W21_WriteDATA(0);	    //y-start
	EPD_W21_WriteDATA(y);	    //y-end
	EPD_W21_WriteDATA(0);	    //w-start
	EPD_W21_WriteDATA(w);	    //w-end
	EPD_W21_WriteDATA(0);	    //l-start
	EPD_W21_WriteDATA(l);	    //l-end
if(mode==0)
for(i=0;i

}
else //white
{
for(i=0;i {
EPD_W21_WriteDATA(0);
}
}

EPD_W21_WriteCMD(0x16); //write display position
	EPD_W21_WriteDATA(0);	    //x-start
	EPD_W21_WriteDATA(x);     //x-end
	EPD_W21_WriteDATA(0);	    //y-start
	EPD_W21_WriteDATA(y);	    //y-end
	EPD_W21_WriteDATA(0);	    //w-start
	EPD_W21_WriteDATA(w);	    //w-end
	EPD_W21_WriteDATA(0);	    //l-start
	EPD_W21_WriteDATA(l);	    //l-end
  lcd_chkstatus();
}

void EPD_display_init(void)
{

   unsigned char HRES_byte1,HRES_byte2,VRES_byte1,VRES_byte2;
  HRES_byte1=0x00;			//176
  HRES_byte2=0xb0;
  VRES_byte1=0x01;			//264
  VRES_byte2=0x08;
EPD_W21_Init();      //reset
	EPD_W21_WriteCMD(0x01); 		 //POWER SETTING 
	EPD_W21_WriteDATA (0x03);	     
	EPD_W21_WriteDATA (0x00);
	EPD_W21_WriteDATA (0x2b);
	EPD_W21_WriteDATA (0x2b);

	EPD_W21_WriteCMD(0x06);         //boostÉ趨
	EPD_W21_WriteDATA (0x07);   //A    
	EPD_W21_WriteDATA (0x07);   //B
  EPD_W21_WriteDATA (0x17);   //C  
		//	EPD_W21_WriteDATA (0x27);   //C 
	EPD_W21_WriteCMD(0x16);
	EPD_W21_WriteDATA(0x00);	

  EPD_W21_WriteCMD(0x04);
	lcd_chkstatus();

	EPD_W21_WriteCMD(0x00);     //panel setting
	EPD_W21_WriteDATA(0xbf);		//KW-BF   KWR-AF	BWROTP 0f

	EPD_W21_WriteCMD(0x30);			//PLL setting
	EPD_W21_WriteDATA (0x3a);   //90 50HZ  3A 100HZ   29 150Hz 39 200HZ	31 171HZ

	EPD_W21_WriteCMD(0x61);			//resolution setting
	EPD_W21_WriteDATA (HRES_byte1);
	EPD_W21_WriteDATA (HRES_byte2);    //176 	 
	EPD_W21_WriteDATA (VRES_byte1);		
	EPD_W21_WriteDATA (VRES_byte2);		//264

	EPD_W21_WriteCMD(0x82);				//vcom_DC setting
//	EPD_W21_WriteDATA (0x08);			//0x28:-2.0V,0x12:-0.9V		
	EPD_W21_WriteDATA (0x12);			//0x28:-2.0V,0x12:-0.9V		
	driver_delay_xms(2);	 
	EPD_W21_WriteCMD(0X50);			//VCOM AND DATA INTERVAL SETTING			
	EPD_W21_WriteDATA(0x97);		//WBmode:VBDF 17|D7 VBDW 97 VBDB 57		WBRmode:VBDF F7 VBDW 77 VBDB 37  VBDR B7

}
void partial_display(u16 x,u16 y,u16 w,u16 l ,void partial_old(void),void partial_new(void)) //partial display
{
EPD_W21_WriteCMD(0x82); //vcom_DC setting
EPD_W21_WriteDATA (0x08);
EPD_W21_WriteCMD(0X50);
EPD_W21_WriteDATA(0x47);
lut1();
EPD_W21_WriteCMD(0x91); //This command makes the display enter partial mode
EPD_W21_WriteCMD(0x90); //resolution setting

EPD_W21_WriteCMD(0x14); //write old data
	EPD_W21_WriteDATA(0);	    //x-start
	EPD_W21_WriteDATA(x);     //x-end
	EPD_W21_WriteDATA(0);	    //y-start
	EPD_W21_WriteDATA(y);	    //y-end
	EPD_W21_WriteDATA(0);	    //w-start
	EPD_W21_WriteDATA(w);	    //w-end
	EPD_W21_WriteDATA(0);	    //l-start
	EPD_W21_WriteDATA(l);	    //l-end
	partial_old();

EPD_W21_WriteCMD(0x15); //write new data
	EPD_W21_WriteDATA(0);	    //x-start
	EPD_W21_WriteDATA(x);     //x-end
	EPD_W21_WriteDATA(0);	    //y-start
	EPD_W21_WriteDATA(y);	    //y-end
	EPD_W21_WriteDATA(0);	    //w-start
	EPD_W21_WriteDATA(w);	    //w-end
	EPD_W21_WriteDATA(0);	    //l-start
	EPD_W21_WriteDATA(l);	    //l-end
	partial_new();

EPD_W21_WriteCMD(0x16); //write display position
	EPD_W21_WriteDATA(0);	    //x-start
	EPD_W21_WriteDATA(x);     //x-end
	EPD_W21_WriteDATA(0);	    //y-start
	EPD_W21_WriteDATA(y);	    //y-end
	EPD_W21_WriteDATA(0);	    //w-start
	EPD_W21_WriteDATA(w);	    //w-end
	EPD_W21_WriteDATA(0);	    //l-start
	EPD_W21_WriteDATA(l);	    //l-end
  lcd_chkstatus();

}

void EPD_init(void)
{
EPD_W21_Init();

	EPD_W21_WriteCMD(0x06);         //boost soft start
	EPD_W21_WriteDATA (0x07);		//A
	EPD_W21_WriteDATA (0x07);		//B
	EPD_W21_WriteDATA (0x17);		//C       

	EPD_W21_WriteCMD(0x04);  
	lcd_chkstatus();

	EPD_W21_WriteCMD(0x00);			//panel setting
	EPD_W21_WriteDATA(0x17);		//LUT from OTP,320x300

	EPD_W21_WriteCMD(0x16);
	EPD_W21_WriteDATA(0x00);					

	EPD_W21_WriteCMD(0xF8);         //boost??
	EPD_W21_WriteDATA (0x60);
	EPD_W21_WriteDATA(0xa5);

	EPD_W21_WriteCMD(0xF8);         //boost??
	EPD_W21_WriteDATA (0x73);
	EPD_W21_WriteDATA (0x23);

	EPD_W21_WriteCMD(0xF8);         //boost??
	EPD_W21_WriteDATA (0x7C);
	EPD_W21_WriteDATA(0x00);
	
	EPD_W21_WriteCMD(0X50);
	EPD_W21_WriteDATA(0x97);		//WBmode:VBDF 17|D7 VBDW 97 VBDB 57		WBRmode:VBDF F7 VBDW 77 VBDB 37  VBDR B7

}

void EPD_display_Clean(void)
{
unsigned int i;

	EPD_W21_WriteCMD(0x13);
	for(i=0;i<5808;i++)	     
	{
		EPD_W21_WriteDATA(0xff);  
	} 
	
	driver_delay_xms(2);	
	EPD_W21_WriteCMD(0x10);
	for(i=0;i<5808;i++)	     
	{
			EPD_W21_WriteDATA(0xff);  
	}  
	driver_delay_xms(2);	

}

void EPD_refresh(void)
{
EPD_W21_WriteCMD(0x12); //DISPLAY REFRESH
driver_delay_xms(200); //!!!The delay here is necessary, 200uS at least!!!
lcd_chkstatus();
}

void partial_full00(void)
{
unsigned int i;
for(i=0;i<5808;i++)
{
EPD_W21_WriteDATA(0);
}
}

void partial_full03(void)
{
unsigned int i;
for(i=0;i<5808;i++)
{
EPD_W21_WriteDATA(~gImage_1[i]);
}
}

void EPD_sleep(void) //Enter deep sleep mode
{
EPD_W21_WriteCMD(0X50);
EPD_W21_WriteDATA(0xf7);
EPD_W21_WriteCMD(0X02); //power off
lcd_chkstatus();
EPD_W21_WriteCMD(0X07); //deep sleep
EPD_W21_WriteDATA(0xA5);
}

主函数测试代码:

        void main()
       {
			EPD_display_init();//EPD init
				full_display(pic_display_white); //pic_white
		 
			/**********************È«ÆÁÏÔʾ********************************/
			
				EPD_display_init();//EPD init
				partial_display(0,0,176,264,partial_full00, partial_full03); //partial full display	
				driver_delay_xms(1000); 

}


下图为硬件电路图:

注意硬件电路的外围参数必须按照提供的电路图的参数配置,否则升压电路工作异常,
![红色标注的](https://img-blog.csdnimg.cn/20200404235206419.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzI1MTQ1NjQ3,size_16,color_FFFFFF,t_70#pic_center)
红色标注的地方一定按照此参数配置,MOS管的型号必须按照此Mos管否则不保证会正常工作。



你可能感兴趣的:(stm32,芯片)