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

📄 lcdlong.c

📁 c8051f020的fyd12864 c程序 keilc
💻 C
📖 第 1 页 / 共 2 页
字号:
	FUNCTION_BASIC();
	Delay1us(60);
	LCD_DISP_ON();				    	//开显示
	Delay1us(150);
	LCD_CLEAR();						//清屏
	Delay1ms(20);
	LCD_ENTRYMODE_INC();			    //光标移动方式为增加
	}


/**************************************************************************
------坐标变换子程序-------------------------------------------------------
***************************************************************************
说明:入口参数:坐标,坐标
	  出口参数:成功与否
**************************************************************************/
unsigned char LCD_Goto(unsigned char x,unsigned char y)
	{unsigned char cur;
	x=x-1;y=y-1;
	if((y>=0)&&(y<8))
		switch(x)
			{case 0:	 
				{
				cur=y;
				LCD_SETADD();
				break;
				}
			case 1:
				{
				cur=16+y;
				LCD_SETADD();
				break;}
			case 2:
				{
				cur=8+y;
				LCD_SETADD();
				break;
				}
			case 3:
				{
				cur=24+y;
				LCD_SETADD();
				break;
				}
			default:
				{break;}
			}
	else	
		return	ERR;
	}


/**************************************************************************
------向指定坐标位置写字符子程序-------------------------------------------------------
***************************************************************************
说明:入口参数:坐标,坐标,字符
	  出口参数:成功与否
**************************************************************************/

void LCD_PutChar(unsigned char x,unsigned char y, unsigned char ch)
	{LCD_Goto(x,y);
	 LCD_WriteData(ch);
	}
			
/**************************************************************************
------向LCD指定位置写汉字子程序--------------------------------------------
***************************************************************************
说明:每次只能写一个汉字
	  入口参数:坐标,坐标,待写字符
	  出口参数:成功与否
***************************************************************************/	
void LCD_PutHZ(unsigned char x,unsigned char y,char *ptr)
	{
	LCD_Goto(x,y);
	LCD_WriteData(*ptr);
	ptr++;
	LCD_WriteData(*ptr);
	}

/**************************************************************************
------向LCD指定位置写汉字子程序--------------------------------------------
***************************************************************************
说明:每次只能写一个汉字
	  入口参数:坐标,坐标,待写字符
	  出口参数:成功与否
***************************************************************************/	
void LCD_PutAD(unsigned char x,unsigned char y,char ptr)
	{
	LCD_Goto(x,y);
	LCD_WriteData(ptr);
	ptr++;
	LCD_WriteData(ptr);
	}

/**************************************************************************
------向LCD指定位置写字符串子程序------------------------------------------
***************************************************************************
说明:入口参数:坐标,坐标,待写字符口串
	  出口参数:成功与否
***************************************************************************/
void LCD_Printf(unsigned char x,unsigned char y,char *ptr)
	{unsigned char i;
	LCD_Goto(x,y);
	for(i=0;*(ptr+i)!=0;i++)
		LCD_WriteData(*(ptr+i));
	}



/**************************************************************************
------图形文本方式变换子程序-----------------------------------------------
***************************************************************************
说明:入口参数:液晶显示方式0:文本;1:图形
	  出口参数:无
***************************************************************************/
void LCD_ChangMode(unsigned char mode)
	{
	switch(mode)
		{
		case 0:
			{
			FUNCTION_BASIC();
			LCD_DISP_ON();
			break;
			}
		case 1:
			{
			LCD_CURSOR_OFF();
			FUNCTION_EXTEND();
			LCD_GRAPH_CLEAR();
			LCD_GRAPH_ON();
			
			break;
			}
		default:
			break;
		}
   }

/************************************************************************
-------图形方式下坐标变换子程序------------------------------------------
*************************************************************************
说明:入口参数:坐标,坐标
 	  出口参数:是否成功
************************************************************************/  
unsigned char LCD_CoorShift(unsigned char x,unsigned char y)
	{
	x=x-1;y=y-1;
	x=x>>4;
	if(x<0||x>8)	return	ERR;
	if(y>=0&&y<32)
			{
			LCD_WriteCommand(0x80+y);
			LCD_WriteCommand(0x80+x);
			}
	else
			{
			LCD_WriteCommand(0x80+y-32);
			LCD_WriteCommand(0x80+x+8);
			}
	}

code unsigned short Position[]={0x8000,0x4000,0x2000,0x1000,
						 	   0x0800,0x0400,0x0200,0x0100,
						 	   0x0080,0x0040,0x0020,0x0010,
						 	   0x0008,0x0004,0x0002,0x0001
						 	   };
/************************************************************************
-------图形方式下画点子程序------------------------------------------
*************************************************************************
说明:入口参数:坐标,坐标
 	  出口参数:无
************************************************************************/ 
void LCD_PutPiex(unsigned char x,unsigned char y)
	{unsigned short temp;
	unsigned char	temp_H,temp_L;
	LCD_CoorShift(x,y);
	x=x-1;
	x=x%16;
	temp=Position[x];
	temp_L=temp&0x00ff;
	temp_H=(temp>>8)&0x00ff;
//	temp_H|=LCD_ReadData();
//	temp_L|=LCD_ReadData();
	LCD_WriteData(temp_H);
	LCD_WriteData(temp_L);
	}






/************************************************************************
-------图形方式下打印BMP图画子程序------------------------------------------
*************************************************************************
说明:入口参数:图画的点数组指针
 	  出口参数:无
************************************************************************/ 

void LCD_PutBMP(unsigned char *ptr)
	{unsigned char i,j;
	for(i=0;i<0x20;i++)
    	{for(j=0;j<8;j++)
			{
			LCD_WriteCommand(0x80+i);
			LCD_WriteCommand(0x80+j);
			LCD_WriteData(*ptr);
			ptr++;
			LCD_WriteData(*ptr);
			ptr++;
			}
		}
	for(i=0;i<0x20;i++)
		{for(j=0;j<8;j++)
			{
			LCD_WriteCommand(0x80+i);
			LCD_WriteCommand(0x80+j+8);
			LCD_WriteData(*ptr++);
			LCD_WriteData(*ptr++);
		   }
   		}
   }

/************************************************************************
-------图形方式下WINDOWS窗口子程序---------------------------------------
*************************************************************************
说明:入口参数:TITLE OF THE WINDOWS
 	  出口参数:无
************************************************************************/ 
void WindowsFront(unsigned char *ptr)
	{
	LCD_CLEAR();
	Delay1ms(100);
	LCD_ChangMode(1);
	LCD_PutBMP(WindowsFronts);
	Delay1ms(100);
	LCD_ChangMode(0);
	LCD_CURSOR_OFF();
	LCD_Printf(1,1,ptr);
	}
	
	

/*

   main()
	{
	unsigned char i;
	// unsigned char hz[]="十八组”;
	LCD_Config();
	LCD_Init();
	LCD_ChangMode(1);
	LCD_PutPiex(6,7);
//	LCD_ChangMode(0);
//	LCD_Printf(1,1,"lcd init");
//	LCD_CURSOR_OFF();

//	for(i=0;i<10;i++)
//		Delay1ms(200);
//	LCD_ChangMode(1);
//	LCD_PutPiex(6,7);
//	for(i=0;i<10;i++)
//		Delay1ms(200);
		
	LCD_ChangMode(0);
	LCD_CURSOR_OFF();
	LCD_PutHZ(1,1,"十" );
	LCD_PutHZ(1,2,"八");
	LCD_PutHZ(1,3,"组");
	while(1);
while(1);
/*
	unsigned char i;
	unsigned char num[4];
	num[2]='%';num[3]=0;
	config();
	LCD_Init();
	LCD_ChangMode(1);
	LCD_PutBMP(screen0);
	Delay1ms(1);
	LCD_ChangMode(0);
	LCD_CURSOR_OFF();
	LCD_Printf(4,1,"Copyright Team18");
	for(i=0;i<5;i++)
		Delay1ms(200);
	LCD_CLEAR();
	for(i=0;i<10;i++)
		{LCD_Printf(1,1,"System Star...");
		Delay1ms(100);
		}
 	for(i=0;i<64;i++)
   		{LCD_Printf(2,1,"Hardware Init.");
		switch(i%4)
			{
			case 0:	{LCD_PutChar(2,8,'-');Delay1ms(80);break;}
			case 1:	{LCD_PutChar(2,8,92);Delay1ms(80);break;}
			case 2:	{LCD_PutChar(2,8,'|');Delay1ms(80);break;}
			case 3:	{LCD_PutChar(2,8,'/');Delay1ms(80);break;}
			}
        }
	LCD_Printf(3,1,"C8051F020 CPU!");
	for(i=0;i<5;i++)
		Delay1ms(100);
	LCD_Printf(3,1,"OK!!!         ");
	for(i=0;i<5;i++)
		Delay1ms(100);
	LCD_Printf(4,1,"SYSTEM CLOCK!!");
	for(i=0;i<5;i++)
		Delay1ms(100);
	LCD_Printf(4,1,"OK!!!8M       ");
	for(i=0;i<5;i++)
		Delay1ms(100);
	LCD_CLEAR();
	for(i=0;i<=100;i++)
		{
		LCD_Printf(1,1,"MEMORY TEST.");
		Delay1ms(40);
		num[0]=i/10+0x30;
		num[1]=i%10+0x30;
		LCD_Printf(1,7,num);
		Delay1ms(10);
        }
	LCD_Printf(2,1,"Basic Mem  256B");
	Delay1ms(100);
	LCD_Printf(3,1,"Exten Mem 4096B");
	Delay1ms(100);
	LCD_Printf(4,1,"Flash Mem  64KB");
	for(i=0;i<10;i++)
			Delay1ms(150);
    LCD_CLEAR();
    for(i=0;i<5;i++)
		{
		Delay1ms(100);
		LCD_Printf(1,1,"128*64 LCD..");
		}
	LCD_Printf(1,7,"OK");
	for(i=0;i<10;i++)
		Delay1ms(100);
	LCD_Printf(2,1,"KEYBOARD TEST!");
	for(i=0;i<5;i++)
		Delay1ms(100);
	LCD_Printf(2,1,"ERR!!!!!      ");
	for(i=0;i<5;i++)
		Delay1ms(100);
	LCD_Printf(3,1,"SYSTEM TEST END");
	LCD_Printf(4,1,"   WELCOME!!!  ");
	for(i=0;i<10;i++)
		Delay1ms(200);
	LCD_CLEAR();
	Delay1ms(20);
	LCD_ChangMode(1);		
	LCD_PutBMP(screen2);
	Delay1ms(20);
    LCD_ChangMode(0);
	LCD_WriteCommand(0x0f);
	LCD_Goto(4,2);
	Delay1ms(200);
	Delay1ms(200);
	Delay1ms(200);
	WindowsFront("  超声测距系统  ");
	while(1)
		{_nop_();}

	}

*/

⌨️ 快捷键说明

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