单片机STM32_ds18b20工作原理简述

单片机STM32_ds18b20工作原理简述硬件原理图LCD12864.c你主要看每个功能函数是如何实现的/*****************************************按照自己的硬件电路图来设置*————————–*|PB.09:(LCD_BLK)|*|PC.06:(LCD_RST)…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺

硬件原理图

在这里插入图片描述

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的淘宝店,淘宝店页面就会分享有各种配套资料。

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

找不到的就私聊我

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/194203.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Visio2013 Professional专业版密钥

    Visio2013 Professional专业版密钥Visio2013密钥专业版:VisioProfessional2013KEYC2FG9-N6J68-H8BTJ-BW3QX-RM3B32NYF6-QG2CY-9F8XC-GWMBW-29VV8FJ2N7-W8TXC-JB8KB-DCQ7Q-7T7V3VXX6C-DN3HQ-3CRXG-RF4KT-YG7V3B3C7Q-D6NH2-2VRFW-HHWDG-FVQB6转载自:https://blog.csdn.net/alittleyatou/article/detail.

    2022年6月24日
    61
  • idea怎么集成git(idea中git的使用)

    一、IDEA集成git方法   首先idea集成git我们需要先下载一个小软件,gitbash 地址:https://git-scm.com/downloads 。下载好了之后直接下一步下一步傻瓜试安装。安装好后回在你指定的文件夹下有个git文件夹,文件结构如下:当然如果你对git命令比较熟悉,用这个软件就可以实现所有的git操作了。下面我们来集成进IDEA开发工具。打开I…

    2022年4月18日
    222
  • redis教程详解_pycharm第一次使用教程

    redis教程详解_pycharm第一次使用教程一、Redis基础部分:1、redis介绍与安装比mysql快10倍以上*****************redis适用场合****************1.取最新N个数据的操作2.排行榜应用,取T

    2022年8月1日
    1
  • intercept用法_俄大使称加拿大新制裁仅具象征性

    intercept用法_俄大使称加拿大新制裁仅具象征性“斜率”参数(w,也叫作权重或系数)被保存在coef_属性中,而偏移或截距(b)被保存在intercept_属性中L1正则化时,可以通过coef_中不等于0的个数来确定使用了几个特征np.sum(lasso.coef_!=0)…

    2025年5月31日
    0
  • linux 刷流量ip,程序员同事问shell脚本刷流量,不讨巧帮他填了一个巨坑

    linux 刷流量ip,程序员同事问shell脚本刷流量,不讨巧帮他填了一个巨坑程序员同事闲来无事问我可以用shell脚本写个刷微博访问量的没。于是脑海里想起了病毒营销或者fork×××这些词。依稀操刀稀松吧啦的写了起来。并测试了下,脚本内容是下面这样的:脚本跑起来的样子当然仅仅是为了展示shell脚本威力。当然还是希望大家靠实际的阅读量。拿微信公众号来说,刷量增粉的很多。同样笔者手里也有些软件。但一次都没有使用过。以来防止被中马,二来做人如果都急功近利.光追求虚妄的东西而没…

    2022年9月29日
    0
  • Adapter的notifyDataSetChanged()

    Adapter的notifyDataSetChanged()notifyDataSetInvalidated(),会重绘控件(还原到初始状态)notifyDataSetChanged(),重绘当前可见区域publicvoidnotifyDataSetChanged():该方法内部实现了在每个观察者上面调用onChanged事件。每当发现数据集有改变的情况,或者读取到数据的新状态时,就会调用此方法。 publicvoidnoti

    2022年6月22日
    25

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号