STM32 LCD12864 原理和实现代码

55 篇文章 8 订阅
16 篇文章 4 订阅

硬件原理图

在这里插入图片描述

LCD12864.c

你主要看每个功能函数是如何实现的

/****************************************
 * 按照自己的硬件电路图来设置
 * --------------------------
 *          |  PB.09: (LCD_BLK)        |
 *          |  PC.06: (LCD_RST)        |
 *          |  PE.09: (LCD_EN,LCD_CLK) |
 *          |  PE.08: (LCD_RW,LCD_DAT) |
 *          |  PE.07: (LCD_RS,LCD_CS)  |
 *          |  PD.08: (LCD_DB0)        |
 *          |  PD.09: (LCD_DB1)        |
 *          |  PD.10: (LCD_DB2)        |
 *          |  PD.11: (LCD_DB3)        |
 *          |  PD.12: (LCD_DB4)        |
 *          |  PD.13: (LCD_DB5)        |
 *          |  PD.14: (LCD_DB6)        |
 *          |  PD.15: (LCD_DB7)        |
 *           --------------------------    			

**********************************************************************************/
#include "lcd12864.h"
#include "comm.h"

u8 Drawx = 0x90;	//--ÓÃÓÚÇå³ý·´°×,ĬÈϵØַΪ¹¦ÄÜÑ¡Ôñ½çÃæ
u8 Drawy = 0x90;	//--ÓÃÓÚÇå³ý·´°×,ĬÈϵØַΪ¹¦ÄÜÑ¡Ôñ½çÃæ
u8 Drwxy = 0;	 //--ÓÃÓÚÇå³ýÏ»®Ïß,ĬÈÏΪ¸ß×Ö½Ú
u8 Bytenum = 0;

void 	Lcd_Delay_us(u16 x)
{
	while(x--);
}


/*
 * º¯ÊýÃû£ºLCD12864_GPIO_Config
 * ÃèÊö  £ºÅäÖÃLCD12864Óõ½µÄI/O
 * ÊäÈë  £ºÎÞ
 * Êä³ö  £ºÎÞ
 * µ÷Óà  £ºÄÚ²¿µ÷ÓÃ
 */
void Lcd_GPIOConfigOut(void)
{
	GPIO_InitTypeDef GPIO_InitStructure;

	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOE, ENABLE);
	GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_0 | GPIO_Pin_1;//RW¡¢EN
	GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_Out_PP;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_Init(GPIOB, &GPIO_InitStructure);
	
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;//RS
	GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_Out_PP;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_Init(GPIOC, &GPIO_InitStructure);
	
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;//RST
	GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_Out_PP;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_Init(GPIOB, &GPIO_InitStructure);
	
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;//BLK±³¹â
	GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_Out_PP;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_Init(GPIOB, &GPIO_InitStructure);
	ResetLcdBLK;
//	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15;//°´¼üÒý½Å
//	GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_IN_FLOATING;
//	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
//	GPIO_Init(GPIOE, &GPIO_InitStructure);
	
//	RCC->APB2ENR |= 0x00000020;
//	RCC->APB2ENR|=1<<3;//¿ªÆôBʱÖÓ
//	RCC->APB2ENR|=1<<6;//¿ªÆôEʱÖÓ
//	
//	GPIOD->CRL = (GPIOD->CRL&0x000fffff)|0x33300000;
//	GPIOD->CRH = (GPIOD->CRH&0x00000000)|0x33333333;	
//	GPIOD->ODR|=0XFF00;//ÉÏÀ­Êä³ö			
//	GPIOB->CRH = (GPIOB->CRH&0xfff0ffff)|0x00030000;		
//	GPIOE->CRH = (GPIOE->CRH&0x0000ffff)|0x44440000;
}	

void Lcd_GPIOConfigIn(void)                 //ͨ¹ýÁ½¸öºê¶¨Ò壬ʡÊÂÒ»ÏÂ×ÓÅäÖÃÁËÆ߸öGPIO¿Ú
{
	GPIO_InitTypeDef GPIO_InitStructure;

	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE);
	GPIO_InitStructure.GPIO_Pin   = LCD_DATA_PIN;
	GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_IPD;//±ØÐëÅäÖóÉÏÂÀ­ÊäÈë
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_Init(LCD_PORT, &GPIO_InitStructure);	

//		GPIOD->CRH = (GPIOD->CRH&0x00000000)|0x44444444; 
}

void Lcd_GPIOD_Out(void)
{
	GPIOD->CRH = (GPIOD->CRH&0x00000000)|0x33333333;	
}

void Lcd_CheckBusy(void)
{	
	ResetLcdRS;
	SetLcdRW;
	SetLcdEN;
	//ÏÂÃæÕâ¾äºÜÖØÒª
	GPIOD->ODR = GPIOD->ODR&0X00ff;//ÒòLCDÊý¾ÝÒý½Å±»ÅäÖóÉÁ˸¡¿ÕÊäÈ룬ËùÒÔÔÚ¶ÁLCDÒý½ÅÊý¾ÝÇ°ÏÈд0£¬ÒÔ±£Ö¤Òý½ÅµçƽÎȶ¨£¬¶ÁÈ¡µÄÊý¾Ý¿É¿¿
	Lcd_GPIOConfigIn();

	while((GPIOD->IDR>>8)&0x80);
	ResetLcdEN;
	
	Lcd_GPIOD_Out();		
}

void Lcd_WriteCmd(uint8_t cmd)
{
	Lcd_CheckBusy();

	ResetLcdRS;
	ResetLcdRW;
	SetLcdEN;
	LCD_PORT->ODR = ((LCD_PORT->ODR&0x00ff)|(cmd<<8));  //¶ÁLCDÒý½ÅÊý¾ÝÇ°ÏÈд0£¬ÒÔ±£Ö¤Òý½ÅµçƽÎȶ¨£¬¶ÁÈ¡µÄÊý¾Ý¿É¿¿

	ResetLcdEN;
}

void Lcd_WriteData(uint8_t dat)
{
	Lcd_CheckBusy();

	SetLcdRS;
	ResetLcdRW;
	SetLcdEN;
	
	LCD_PORT->ODR = ((LCD_PORT->ODR&0x00ff)|(dat<<8));  //¶ÁLCDÒý½ÅÊý¾ÝÇ°ÏÈд0£¬ÒÔ±£Ö¤Òý½ÅµçƽÎȶ¨£¬¶ÁÈ¡µÄÊý¾Ý¿É¿¿

	ResetLcdEN;
}

unsigned char ReadByte_12864(void)
{
	unsigned char dat;
	
	Lcd_CheckBusy();
	Lcd_GPIOConfigIn();	

	SetLcdRS;
	SetLcdRW;
  SetLcdEN;
	dat = (uint8_t)(LCD_PORT->IDR>>8); 
	ResetLcdEN;	
	
	Lcd_GPIOD_Out();
	
	return dat;		
}

void Lcd_Init(void)
{
	Lcd_Delay_us(100);
	SetLcdRST;
//	SetLcdPSB;
	Lcd_Delay_us(LCD_DELAY);
	Lcd_WriteCmd(0x30);
	Lcd_Delay_us(LCD_DELAY);
	Lcd_WriteCmd(0x0c);
	Lcd_Delay_us(LCD_DELAY);
	Lcd_WriteCmd(0x01);
	Lcd_Delay_us(LCD_DELAY);
	Lcd_WriteCmd(0x06);
	Lcd_Delay_us(LCD_DELAY);
}

void Lcd_ClearDRAM(void)
{
	Lcd_WriteCmd(0x30);
	Lcd_WriteCmd(0x01);//ÇåDDRAM£¬Ðèʱ4.6ms
//	Lcd_Delay_us(20000);	//´ËÑÓʱºÜ¹Ø¼ü£¬Ö±½ÓÓ°Ïìµ½LCDË¢ÆÁËÙ¶È
}

void Lcd_ClearLineFB(uint8_t addr_x, uint8_t addr_y, uint8_t num)
{
	uint8_t x = 0, y = 0;

	Lcd_WriteCmd(0x34); //ʹÓÃÀ©³äÖ¸Á

	for(y=0; y<16; y++)
	{	 		
		for(x=0; x<num; x++)
		{
		  Lcd_WriteCmd(addr_y + y);// ÏȽ«´¹Ö±µÄλԪ×é×ø±ê(Y) дÈëGDRAM
			Lcd_WriteCmd(addr_x + x);// ÔÙ½«Ë®Æ½×ø±ê(X) дÈëGDRAM
			
			Lcd_WriteData(0x00);//дÊý¾Ý¸ß°Ëλ
			Lcd_WriteData(0x00);//дÊý¾ÝµÍ°Ëλ	
		}
//		Lcd_WriteCmd(0x36);	// Ñ¡Ôñ8λÊý¾ÝÁ÷,À©³äÖ¸Áî, »æͼÏÔʾ¿ª
	}
	Lcd_WriteCmd(0x36);
	Lcd_WriteCmd(0x30);	
}

void Lcd_LineFB(uint8_t addr_x, uint8_t addr_y, uint8_t num)
{
	uint8_t x = 0, y = 0;
	
	if((Drawx!=addr_x) || (Drawy!=addr_y) || (Bytenum!=num))
	{
		Lcd_ClearLineFB(Drawx, Drawy, Bytenum);
		Drawx = addr_x;
		Drawy = addr_y;
		Bytenum = num;	
	}

	Lcd_WriteCmd(0x34); 

	for(y=0; y<16; y++)
	{			
		for(x=0; x<num; x++)
		{
			Lcd_WriteCmd(addr_y + y);
			Lcd_WriteCmd(addr_x + x);
			
			Lcd_WriteData(0xff);
			Lcd_WriteData(0xff);	
		}
		Lcd_WriteCmd(0x36);
	}
	Lcd_WriteCmd(0x30);	
}

void Draw_Pic(uint8_t addr_x, uint8_t addr_y, uint8_t const *pdat, uint8_t wide, uint8_t high)
{
	uint16_t hang, lie;
	
	Lcd_WriteCmd(0x34);//À©Õ¹Ö¸Á
	Lcd_WriteCmd(0x36);//¹Ø»æͼ¹¦ÄÜ
	
	if(wide%8 == 0) wide >>= 3;
	else wide = (wide>>3)+1;
	
	for(hang=0; hang<high; hang++)
	{
		if(addr_y+hang>31)
		{
			Lcd_WriteCmd(0x80+addr_y+hang-32);
			Lcd_WriteCmd(0x88+addr_x);
		}
		else
		{
			Lcd_WriteCmd(0x80+addr_y+hang);
			Lcd_WriteCmd(0x80+addr_x);
		}
		for(lie=0; lie<wide; lie++)
		{
			Lcd_WriteData(pdat[hang*wide+lie]);
		}
	}
		Lcd_WriteCmd(0x36);// Ñ¡Ôñ8 λÊý¾ÝÁ÷,À©³äÖ¸Áî, »æͼÏÔʾ¿ª
		Lcd_WriteCmd(0x30);
}


void Lcd_Pos(unsigned char x,unsigned char y)
{
	unsigned char pos;
	switch(x)
	{
		case 0:x=0x80;break;
		case 1:x=0x90;break;
		case 2:x=0x88;break;
		case 3:x=0x98;break;
		default:x=0x80;
			break;
	}
	pos=x+y;
	Lcd_WriteCmd(pos);
}

void Draw_Font_16x16(uint8_t addr_x, uint8_t addr_y, uint8_t width, uint8_t const *pAry, uint8_t num)
{
	uint8_t x = 0, y = 0;
//	uint8_t res = 2*width;

	Lcd_WriteCmd(0x34); //ʹÓÃÀ©³äÖ¸Á
	
	for(x=0; x<num; x++)
	{
			for(y=0; y<width; y++)
			{	 		
					Lcd_WriteCmd(addr_y + y);// ÏȽ«´¹Ö±µÄλԪ×é×ø±ê(Y) дÈëGDRAM
					Lcd_WriteCmd(addr_x + x);// ÔÙ½«Ë®Æ½×ø±ê(X) дÈëGDRAM

//					Lcd_WriteData(pAry[y+res*x]);//дÊý¾Ý¸ß°Ëλ
//					Lcd_WriteData(pAry[y+width+res*x]);//дÊý¾ÝµÍ°Ëλ	
					Lcd_WriteData(pAry[y]);//дÊý¾Ý¸ß°Ëλ
					Lcd_WriteData(pAry[y+width]);//дÊý¾ÝµÍ°Ëλ	
			}
//			Lcd_WriteCmd(0x36);	// Ñ¡Ôñ8λÊý¾ÝÁ÷,À©³äÖ¸Áî, »æͼÏÔʾ¿ª
	}	
	Lcd_WriteCmd(0x36);
	Lcd_WriteCmd(0x30);		
}


void Draw_Dot(unsigned char x, unsigned char y)
{
	unsigned char x_byte,x_bit;//ÔÚºá×ø±êµÄÄÄÒ»¸ö×Ö½Ú£¬ÄÄÒ»¸öλ
	unsigned char y_byte,y_bit;//ÔÚÄÄÒ»Ò³
	unsigned char temp_h,temp_l; //ÕâÁ½±äÁ¿ÓÃÀ´´æ·Å¶Á³öÀ´µÄÊý¾Ý
	x &= 0x7f; //ÏÞ¶¨xµÄÊýÖµ·¶Î§ÔÚ0¡«127Ö®¼ä
	y &= 0x3f; //ÏÞ¶¨yµÄÊýÖµ·¶Î§ÔÚ0¡«63Ö®¼ä
	x_byte = x >> 4;//Ëã³öÔÚÄÄÒ»¸ö×Ö½Ú£¨µØÖ·£©£¬Ò»¸öµØÖ·ÊÇ16λ
	x_bit = x & 0x0f;//Ëã³öÔÚÄÄÒ»¸öλ
	y_byte = y >> 5; //È·¶¨ÔÚÉÏ°ëÆÁ»¹ÊÇÏ°ëÆÁ 0-ÉÏ  1-ÏÂ	
	y_bit = y & 0x1f;
	Lcd_WriteCmd(0x34);//À©Õ¹Ö¸Á
	Lcd_WriteCmd(0x36);//¹Ø»æͼ¹¦ÄÜ
	Lcd_WriteCmd(0x80 + y_bit);//ÏÈд´¹Ö±µØÖ·£¬×î¸ßλ±ØÐëΪ1
	Lcd_WriteCmd(0x80 + x_byte + 8 * y_byte);//ˮƽ×ø±ê
	//Ï°ëÆÁµÄˮƽ×ø±êÆðʼµØַΪ0X88
	//8 * y_byte ¾ÍÊÇÓÃÀ´È·¶¨ÔÚÉÏ°ëÆÁ»¹ÊÇÏ°ëÆÁ
	ReadByte_12864();//ÏÈ¿Õ¶ÁÒ»´Î
  temp_h = ReadByte_12864();//¶Á¸ßλ
	temp_l = ReadByte_12864();	//¶ÁµÍλ
	//¶Á²Ù×÷»á¸Ä±äAC£¬ËùÒÔÒªÖØÐÂÉèÖÃÒ»´Î
	Lcd_WriteCmd(0x80 + y_bit);//ÏÈд´¹Ö±µØÖ·£¬×î¸ßλ±ØÐëΪ1
	Lcd_WriteCmd(0x80 + x_byte + 8 * y_byte);//ˮƽ×ø±ê
	if(x_bit < 8)
	{
		Lcd_WriteData(temp_h | (0x01 << (7 - x_bit)));//д¸ß×Ö½Ú¡£ÒòΪ×ø±êÊÇ´Ó×óÏòÓÒµÄ,//¶øGDRAM¸ßλÔÚ×󣬵×λÔÚÓÒ	
		Lcd_WriteData(temp_l); //Ô­Êý¾ÝËÍ»Ø 
	}
	else
	{	 
		Lcd_WriteData(temp_h);
		Lcd_WriteData(temp_l | (0x01 << (15 - x_bit)));			
	}
	Lcd_WriteCmd(0x36);// Ñ¡Ôñ8 λÊý¾ÝÁ÷,À©³äÖ¸Áî, »æͼÏÔʾ¿ª
	Lcd_WriteCmd(0x30);
}

void Draw_Line(unsigned char  x1, unsigned char y1, unsigned char x2, unsigned char y2)
{
	int x, y, dx, dy, s1, s2, p, temp, interchange, i;
	x = x1;
	y = y1;
	dx = x2 > x1 ? (x2 - x1) : (x1 - x2);
	dy = y2 > y1 ? (y2 - y1) : (y1 - y2);
	if(x2 > x1)
	   s1 = 1;
	else
	   s1 = -1;
	if(y2>y1)
	   s2 = 1;
	else
	   s2 = -1;
	if(dy > dx)
	{
	   temp = dx;
	   dx = dy;
	   dy = temp;
	   interchange = 1;
	}
	else
	   interchange = 0;
	p = (dy << 1) - dx;
	for(i = 0;i <= dx;i++)
	{
	  	Draw_Dot(x,y);
	   	if(p >= 0)
	   	{
	    	if(interchange == 0)
	     		y = y + s2;
	   		else
	     		x = x + s1;
	     	p = p - (dx << 1);
	   	}
	   	if(interchange == 0)
	   		x = x + s1; 
	   	else
		   y = y + s2;
		p = p + (dy << 1);
	}
}

void Lcd_ClearGRAM(void)
{
	uint8_t y, x,z;
  	uint8_t addr_y, addr_x;
  	addr_y = 0x80;
  	addr_x = 0x80;
  	Lcd_WriteCmd(0x34);
  	for(z=0; z<2; z++)
  	{
    	for(y=0; y<32; y++)
    	{
      		for(x=0; x<8; x++)//°Ë¸öÖÐÎÄ×Ö
      		{
        		Lcd_WriteCmd(addr_y+y); // ½«´¹Ö±µÄλԪ×é×ø±ê( Y) дÈëGDRAM
  	    		Lcd_WriteCmd(addr_x+x); // ÏȽ«Ë®Æ½µ¥ÔªÐ´Èëºá×ø±ê£¨X£©) дÈëGDRAM 
        		Lcd_WriteData(0x00);	//дÊý¾Ý¸ß°Ë룬16*16
        		Lcd_WriteData(0x00); //дÊý¾ÝµÍ°Ëλ
       		}//for(x=0; x<8; x++) end
       		Lcd_WriteCmd(0x36);  // Ñ¡Ôñ8 λÊý¾ÝÁ÷,À©³äÖ¸Áî, »æͼÏÔʾ¿ª
	 	}//for(y=0; y<32; y++)	end
		addr_x = 0x88;
  	}//for(z=0; z<2; z++)  end
		Lcd_WriteCmd(0x30); 
}

void Lcd_Printf(uint8_t add, uint8_t *pdat)
{
	Lcd_WriteCmd(add);
	while(*pdat != '\0')
	{
		Lcd_WriteData(*pdat++);
	//	Lcd_Delay_us(5);
	}
}

/
/*----------------È¡ÏûÏ»®Ïß/Ìî³äº¯Êý---------------------------------*/
void UnLcdDrw(uint8_t addr_x, uint8_t addr_y)
{
  	uint8_t y, x;

  	Lcd_WriteCmd(0x34);
  	for(y=0; y<15; y++)
  	{
    	for(x=0; x<1; x++)
    	{
	   		Lcd_WriteCmd(addr_y+y); // ÏȽ«´¹Ö±µÄλԪ×é×ø±ê( Y) дÈëGDRAM
       		Lcd_WriteCmd(addr_x+x); // ÔÙ½«Ë®Æ½×ø±ê( X) дÈëGDRAM         
	   		Lcd_WriteData(0x00);	//дÊý¾Ý¸ß°Ëλ
       		Lcd_WriteData(0x00); //дÊý¾ÝµÍ°Ëλ
    	}//for(x=0; x<1; x++) end       
    	Lcd_WriteCmd(0x36);  // Ñ¡Ôñ8 λÊý¾ÝÁ÷,À©³äÖ¸Áî, »æͼÏÔʾ¿ª
  	}//for(y=0; y<16; y++) end
		
		Lcd_WriteCmd(0x30);
}

/*----------------µ¥×Ö½Ú·´°×/»­Ï»®Ïß---------------------------------*/

void LcdDrw(uint8_t addr_x, uint8_t addr_y, uint8_t num, uint8_t fl)
{
  	uint8_t y, x, i;
	if(fl == LINE) i = 14;
	else i = 0;

  	if((Drawx!=addr_x)||(Drawy!=addr_y)||(Drwxy!=num))
  	{	
	   	UnLcdDrw(Drawx,Drawy);
	   	Drawx=addr_x;   
       	Drawy=addr_y;
       	Drwxy=num;
  	}//if((Drawx!=addr_x)||(Drawy!=addr_y)||(Drwxy!=num))	end
  	Lcd_WriteCmd(0x34);
  	for(y=i; y<15; y++)
  	{
    	for(x=0; x<1; x++)
    	{
	   		Lcd_WriteCmd(addr_y+y); // ÏȽ«´¹Ö±µÄλԪ×é×ø±ê( Y) дÈëGDRAM
       	Lcd_WriteCmd(addr_x+x); // ÔÙ½«Ë®Æ½×ø±ê( X) дÈëGDRAM         
	   		if (num == 0)//Ê××Ö½Ú·´°×
       	{
		  		Lcd_WriteData(0xff);	//дÊý¾Ý¸ß°Ëλ
          Lcd_WriteData(0x00); //дÊý¾ÝµÍ°Ëλ
       	}//if (num == 0) end
	   		else if (num == 1)//´Î×Ö½Ú·´°×
       	{
          Lcd_WriteData(0x00);	//дÊý¾Ý¸ß°Ëλ
          Lcd_WriteData(0xff); //дÊý¾ÝµÍ°Ëλ		  
	   		}//else if (num == 1) end
    	}//for(x=0; x<1; x++) end       
    	Lcd_WriteCmd(0x36);  // Ñ¡Ôñ8 λÊý¾ÝÁ÷,À©³äÖ¸Áî, »æͼÏÔʾ¿ª
  	}//for(y=0; y<16; y++) end	
		Lcd_WriteCmd(0x30);
}

/*----------------×Ö·´°×/»­Ï»®Ïß---------------------------------*/
void LcdDrwWord(uint8_t addr_x, uint8_t addr_y, uint8_t fl)
{
  uint8_t y, x, i;
	if(fl == LINE) i = 14;
	else i = 0;

  	if((Drawx!=addr_x)||(Drawy!=addr_y))
  	{	
	   	UnLcdDrw(Drawx, Drawy);
	   	Drawx=addr_x;   
      Drawy=addr_y;
  	}//if((Drawx!=addr_x)||(Drawy!=addr_y)||(Drwxy!=num))	end
  	Lcd_WriteCmd(0x34);
  	for(y=i; y<15; y++)
  	{
    	for(x=0; x<1; x++)
    	{
	   		Lcd_WriteCmd(addr_y+y); // ÏȽ«´¹Ö±µÄλԪ×é×ø±ê( Y) дÈëGDRAM
       	Lcd_WriteCmd(addr_x+x); // ÔÙ½«Ë®Æ½×ø±ê( X) дÈëGDRAM
			  Lcd_WriteData(0xff);	//дÊý¾Ý¸ß°Ëλ
        Lcd_WriteData(0xff); //дÊý¾ÝµÍ°Ëλ
		  }	               
   	Lcd_WriteCmd(0x36);  // Ñ¡Ôñ8 λÊý¾ÝÁ÷,À©³äÖ¸Áî, »æͼÏÔʾ¿ª
  	}//for(y=0; y<16; y++) end
	Lcd_WriteCmd(0x30);	
}

// * º¯ÊýÃû£ºLCD12864_Init
// * ÃèÊö  £ºLCD12864³õʼ»¯
// * ÊäÈë  £ºÎÞ
// * Êä³ö  £ºÎÞ
// * µ÷Óà  £ºÍⲿµ÷ÓÃ
// */
void LCD12864_Init(void)
{
	Lcd_GPIOConfigOut();

	Lcd_Init();
	SetLcdBLK;	
	
	Lcd_ClearDRAM();
	Lcd_ClearGRAM(); 
}

//1¡¢80-87
//2¡¢90-97
//3¡¢88-8f
//4¡¢98-9f

void Ready_Mea_Scr(void)
{
	Lcd_Printf(0x81, "");
	Lcd_Printf(0x90, "  ÕýÔÚ×¼±¸²âÁ¿" );
	Lcd_Printf(0x88, "    ÇëÉÔµÈ... " );

}

LCD12864.h

#ifndef __LCD12864_H
#define	__LCD12864_H

#include "stm32f10x.h"

#define  FB		0  //LCDµ¥×Ö½Ú·´°×ÏÔʾ
#define  LINE   1  //LCDµ¥×Ö½ÚÏ»®ÏßÏÔʾ

#define LCD_DELAY  30

#define LCD_PORT GPIOD

#define LCD_DATA_PIN  GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15
#define LCD_RS_PIN    GPIO_Pin_5
#define LCD_RW_PIN    GPIO_Pin_0
#define LCD_EN_PIN    GPIO_Pin_1

#define LCD_BLK_PIN   GPIO_Pin_9
#define LCD_RST_PIN   GPIO_Pin_12

#define SetLcdRS    GPIO_SetBits  (GPIOC, LCD_RS_PIN)
#define ResetLcdRS 	GPIO_ResetBits(GPIOC, LCD_RS_PIN)

#define SetLcdRW	  GPIO_SetBits  (GPIOB, LCD_RW_PIN)
#define ResetLcdRW 	GPIO_ResetBits(GPIOB, LCD_RW_PIN)

#define SetLcdEN	  GPIO_SetBits  (GPIOB, LCD_EN_PIN)
#define ResetLcdEN 	GPIO_ResetBits(GPIOB, LCD_EN_PIN)

#define SetLcdBLK	    GPIO_SetBits(GPIOB, LCD_BLK_PIN)
#define ResetLcdBLK   GPIO_ResetBits(GPIOB, LCD_BLK_PIN)

//#define SetLcdRST	  GPIO_SetBits  (GPIOC, LCD_RST_PIN)
#define SetLcdRST	  GPIO_SetBits  (GPIOB, LCD_RST_PIN)
#define ResetLcdRST GPIO_ResetBits(GPIOB, LCD_RST_PIN)

void Lcd_Delay_us(u16 x);
void LCD12864_Init(void);
//void Scr1(void);
void Lcd_WriteCmd(uint8_t cmd);
void Lcd_WriteData(uint8_t dat);
void Draw_Font_16x16(uint8_t addr_x, uint8_t addr_y, uint8_t width, uint8_t const *pAry, uint8_t num);
void Draw_Line(unsigned char  x1, unsigned char y1, unsigned char x2, unsigned char y2);
void LCD_12864_DrawLine(u16 x1, u16 y1, u16 x2, u16 y2);
void Set_12864_point(u8 x,u8 y);
void Draw_Dot(unsigned char x, unsigned char y);
void Lcd_Pos(unsigned char x,unsigned char y);
void Draw_Pic(uint8_t addr_x, uint8_t addr_y, uint8_t const *pdat, uint8_t wide, uint8_t high);
void Lcd_ClearLineFB(uint8_t addr_x, uint8_t addr_y, uint8_t num);
void Lcd_ClearGRAM(void);
void Lcd_ClearDRAM(void);
void Lcd_Printf(uint8_t add, uint8_t *pdat);
void LcdDrw(uint8_t addr_x, uint8_t addr_y, uint8_t num, uint8_t fl);
void LcdDrwWord(uint8_t addr_x, uint8_t addr_y, uint8_t fl);
void Lcd_LineFB(uint8_t addr_x, uint8_t addr_y, uint8_t num);
void Ready_Mea_Scr(void);
void Show_Uarms_Scr(char *string);


#endif /* __LCD12864_H */

LCD12864参考手册

这个网上一大堆,程序都是按照手册来写的,你可以去某个卖LCD12864的淘宝店,淘宝店页面就会分享有各种配套资料。

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

找不到的就私聊我

  • 4
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

嵌入式Linux系统开发

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值