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

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

找不到的就私聊我

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

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

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • Python ( )、[ ]、{}的区别「建议收藏」

    Python ( )、[ ]、{}的区别「建议收藏」python语言最常见的括号有三种,分别是:小括号()、中括号[]和大括号也叫做花括号{},分别用来代表不同的python基本内置数据类型。如果要创建一个字典列表,如下:

  • Ubuntu 忘记root密码_ubuntu怎么获取root权限

    Ubuntu 忘记root密码_ubuntu怎么获取root权限Ubuntu14.04中root密码忘记解决方法[转载+17.04亲测可用]Ubuntu14.04中root密码忘记解决方法Ubuntu 14.04中root密码忘记解决方法方法一:如果用户具有sudo权限,那么直接可以运行如下命令:#sudosuroot#passwd#更改密码或者直接运行sudopasswdroot命令就可以直接更改root密码…

    2022年10月29日
  • 执行pip 命令出现Could not install packages due to an EnvironmentError错误的解决办法「建议收藏」

    执行pip 命令出现Could not install packages due to an EnvironmentError错误的解决办法「建议收藏」今天想安装一个pyspider,但是却出现了下图的错误因为环境的错误导致的原因,嗯…….搜了一下,只需把命令改为pipinstall–userpyspider就可以了。网上的回答是直接这样就行了,但是我的却出现了另一个问题。这个包是安装成功了,但是调用时输入pyspiderall,却返回了pyspider不是内部或外部命令的提示,注意看安装成功之前有几行…

  • Ext4文件系统fsck后损坏修复方法-linux数据恢复案例[通俗易懂]

    Ext4文件系统fsck后损坏修复方法-linux数据恢复案例[通俗易懂]在数据恢复案例开始之前有几个概念需要了解块组:Ext4文件系统的全部空间被划分为若干个块组,每个块组内的结构都是大致相同的。块组描述符表:每个块组都对应一个块组描述符,这些块组描述符统一放在文件系统的前部,称为块组描述符表。每个块组描述符大小为32字节,其主要描述块位图、i-节点位图及i-节点表的地址等信息。超级块(Superblock):用于存储文件系统的配置参数(如块大小、总块数、i-节点数…

  • AngularJS笔记「建议收藏」

    AngularJS笔记「建议收藏」1.   AngularJS通过ng-directives扩展了HTML。  ng-app指令定义一个AngularJS应用程序。  ng-model指令把元素值(比如输入域的值)绑定到应用程序。  ng-bind指令把应用程序数据绑定到HTML视图。2.  HTML5允许扩展的(自制的)属性,以data-开头。  AngularJS属性以n…

  • 2188. 无源汇上下界可行流(无源汇上下界最大流)

    2188. 无源汇上下界可行流(无源汇上下界最大流)给定一个包含 n 个点 m 条边的有向图,每条边都有一个流量下界和流量上界。求一种可行方案使得在所有点满足流量平衡条件的前提下,所有边满足流量限制。输入格式第一行包含两个整数 n 和 m。接下来 m 行,每行包含四个整数 a,b,c,d 表示点 a 和 b 之间存在一条有向边,该边的流量下界为 c,流量上界为 d。点编号从 1 到 n。输出格式如果存在可行方案,则第一行输出 YES,接下来 m 行,每行输出一个整数,其中第 i 行的整数表示输入的第 i 条边的流量。如果不存在可行方案,直接输

发表回复

您的电子邮箱地址不会被公开。

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