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

📄 funclcd.c

📁 Keil C51完整的128X64LCD显示的电子打铃仪代码,内含DS1302X5045等操作代码
💻 C
📖 第 1 页 / 共 3 页
字号:
/*********************************************************************
 *Description:    		SW680GAM Machine LCD Drive Program 
 *File Name:   			LCD_DISPLAY.C
 *Use Compile Lanague: 	KEIL C51
 *Version :    			V1.0
 *Code Author:    		zhouhuanxi
 *Date:					2005-01-14
 CopyRight(C) 			2005 --  SHENZHEN XINSANWEI Machine&Electronics CO.,LTD.
*********************************************************************/
//==== FILE Include And Macro Declare Segment====

#define	LCD_DISP_DEF
#include 	"Config.H"


/*************************************************/
//============ FUNCTION CODE SEGMENT =============
//*************************************************

#ifdef MYUSE
//=================================================
//Function: 	Display_Engils_Line	
//Description: 	Display one System Main Menu
//Parameters: 	num,page_y_in,startcol,len,flag
//Call:			
//Returns: 		NO.
//Side Effects: 
//=================================================
void Display_Engils_Line( uint8 page_y_in,
	 uint8 startcol,uint8 len, bool flag, uint8** menuitem)
{
        uint8 i;
        if ((len*8)>(128-startcol)) return;
		for(i=0;i<len;i++)
		{
			Msingle_font_pattern(menuitem[i],page_y_in,startcol,flag);
			startcol=startcol+8;
		} 		
}


//==========================================================
//Function: 	Display_Pic	
//Description: 	Display one picture(16*128)
//Parameters: 	DispContent--- picture array
//				page0--- display picture row
//Call:			
//Returns: 		NO.
//=================================================
/*void MsgBox(uint8 page0,uint8 *DispContent[])
{
    uint8 k,j;
    for(j=0;j<2;j++)
    {
           SetRAMAddr(page0+j,0);
           for(k=0;k<=127;k++)
           {
               SingleData(k,DispContent[j][k]);
           }
    }    
}*/

//=================================================
//Function: 	del_line	
//Description: 	Send a Command Data to Clear LCD's ROws RAM,Let LCD's Status to Zero
//Parameters: 	row,start_col,end_col	
				//startp	----	Clear LCD RAM First Line Number
				//endp		----	Clear LCD RAM Last Line Number	
//Call:			SetRAMAddr(),SingleData
//Returns: 		NO.
//Side Effects: NO.
//=================================================
void Delete_Line(uint8 row,uint8 start_col,uint8 end_col)
{
  	data uint8 u8page,u8Column;

    for(u8page=row;u8page<=row+1;u8page++)
	{
		SetRAMAddr(u8page,0x00);

		for (u8Column = start_col; u8Column <= end_col; u8Column++) 
		{
  			SingleData(u8Column,0x00);		// erase a column
		}
	}
}

//=================================================
//Function: 	delchar	
//Description: 	Send a Command Data to Clear LCD's ROws RAM,Let LCD's Status to Zero
//Parameters: 	page,cury1,charnum	
				//page		----	Clear LCD RAM First Line Number
				//cury1		----	Clear LCD RAM Last Line Number	
				//charnum	----		
//Call:			SetRAMAddr(),SingleData
//Returns: 		NO.
//Side Effects: NO. 
//=================================================
void Delete_Char(uint8 *page,uint8 *cury1,uint8 *charnum)
{
	uint8 i,cury0;

	cury0=(*cury1)-8;

	if(cury0==0)cury0=0;

	if((*charnum)>0)
	{
		SetRAMAddr(*page,cury0);

		for(i=cury0;i<*cury1;i++)
		{
			SingleData(i,0x00);		
		}

		SetRAMAddr((*page)+1,cury0);

		for(i=cury0;i<*cury1;i++)
		{
			SingleData(i,0x00);		
		}
	
		*charnum=(*charnum)-1;
		(*cury1)=cury0;

		if((*cury1)<8&&(*page)>=2)
		{
			(*page)=(*page)-2;
			(*cury1)=120;
		}
	}
}


//==========================================================
//Function: 	DealWith_MenuFunction	
//Description: 	Display one System Main Menu Item's SubMenu
//Parameters: 	menu	--- main menu(0),submenu(1),subsubmenu(2)
//				menuitem--- Current menu item  index
//				special_falg --- special function flag,0:no special function
//Call:			
//Returns: 		NO.
//=================================================
void Display_FH(uint8 pagen,uint8 coln)
{
    uint8 i;
	SetRAMAddr(pagen,coln);
	if(coln<64)
	{
		for (i=coln;i<=63;i++)
			SingleData(i,0x0f);
	}
	else
	{
		for (i=coln;i<=127;i++)
			SingleData(i,0x0f);
	}
}
#endif

//=================================================
//Function: 	clearRAM	
//Description: 	Send a Command Data to Clear LCD's ROws RAM,Let LCD's Status to Zero
//Parameters: 	startp,endp	
				//startp	----	Clear LCD RAM First Line Number
				//endp		----	Clear LCD RAM Last Line Number	
//Call:			SetRAMAddr(),SingleData
//Returns: 		NO.
//Side Effects: NO.
//=================================================
void ClearRAM(uint8 startp,uint8 endp)
{
  	data uint8 u8Page,u8Column;

  	for (u8Page = startp; u8Page < endp; u8Page++) 
    {
		SetRAMAddr(u8Page,0x00);

		for (u8Column = 0; u8Column < 128; u8Column++) 
		{
      		SingleData(u8Column,0x00);		// erase a column
		}
   	}
}

//=================================================
//Function: 	Display_cursor	
//Description: 	光标控制
//Parameters: 	page_in	--- Row address
//				col_in	---	Col Address
//				fflag	---	Cursor Display or Not Display
//Call:			SingleData,SetRAMAddr
//Returns: 		NO.
//Side Effects: 
//=================================================
void Display_cursor(uint8* Content,uint8 page_in,uint8 col_in,bool fflag)
{
	if(Cursor_Count<8 && fflag==1)
		{
		//SetRAMAddr(page_in,col_in);
		//SingleData(col_in, 0xf0);
		//SetRAMAddr(page_in+1,col_in);
		//SingleData(col_in, 0x0f);
		Msingle_font_pattern(Content, page_in, col_in, 1);
		}
 	else
		{
		//SetRAMAddr(page_in,col_in);
		//SingleData(col_in, 0x00);
		//SetRAMAddr(page_in+1,col_in);
	    //SingleData(col_in, 0x00);
	    Msingle_font_pattern(Content, page_in, col_in, 0);
		}
     	if(Cursor_Count>16) Cursor_Count=0;
}

//=================================================
//Function: 	Msingle_font_pattern	
//Description: 	Send a 8 X 16 Dot of ASCII CHAR to LCD Display
//Parameters: 	*page_num,page_y_in,col_x_in,flag
				//*page_num	---	LCD Display Content's First Address
				//page_y_in --- LCD Display  Char of Row Address
				//col_x_in	--- LCD Display  Char of Col Address
				//flag	---	0 =	Normal Display ;1 = Negative Display
//Call:			SetRAMAddr(),SingleData()
//Returns: 		NO.
//Side Effects: NO.
//=================================================
void Msingle_font_pattern(uint8 *page_num, uint8 page_y, 
									uint8 col_x,bool flag)
{
	data uint8 i;

	SetRAMAddr(page_y,col_x);

	for (i=0;i<8;i++)
	{
		if(flag==0)
			SingleData(col_x,page_num[i]);
		else
			SingleData(col_x, ~(page_num[i]));
	}

	SetRAMAddr(page_y+1,col_x);

	for (i=8;i<16;i++)
	{
		if(flag==0)
			SingleData(col_x,page_num[i]);
		else
			SingleData(col_x,~(page_num[i]));
	}
}

//=================================================
//Function: 	HzDisplay	
//Description: 	Send a 16 X 16 Dot of Chinese CHAR to LCD Display
//Parameters: 	*page_num,page_y_in,col_x_in,flag
				//*page_num	---	LCD Display Content's First Address
				//page_y_in --- LCD Display  Char of Row Address
				//col_x_in	--- LCD Display  Char of Col Address
				//flag	---	0 =	Normal Display ;1 = Negative Display
//Call:			SetRAMAddr(),SingleData()
//Returns: 		NO.
//Side Effects: NO.
//=================================================
void HzDisplay(uint8 *page_num, uint8 page_y, 
						uint8 col_x,bool flag)
{
	data uint8 i;

	SetRAMAddr(page_y,col_x);

	for (i=0;i<16;i++) 
	{
		if(flag==0)
			SingleData(col_x,page_num[i]);
		else
			SingleData(col_x,~(page_num[i]));
	}

	SetRAMAddr(page_y+1,col_x);

	for (i=16;i<32;i++) 
	{
		if(flag==0)
			SingleData(col_x,page_num[i]);
		else
			SingleData(col_x,~(page_num[i]));
	}
}

//=================================================
//Function: 	InitLcd	
//Description: 	Init LCD
//Parameters: 	NO.
//Returns: 		NO.
//Side Effects: 
//=================================================
//-------------------------------
//显示LOGO画面
void LOGO(void)
{
   	int8 j,k;
	uint8 tempkey;

	LCD_LED	=	0;

	for(k=63;k>=0;k--)
	{

		for(j=0;j<8;j++)
		{
        tempkey=127-k;
		SetRAMAddr(j,k);
		SingleData(k,0xFF);
		SetRAMAddr(j,tempkey);
		SingleData(tempkey,0xFF);
		}
 	}

	 Delay(40);

	 //LCD Display Logo Bmp
	 for(k=0;k<=63;k++)
	 	{

		for(j=0;j<8;j++)
			{
            tempkey=127-k;
			SetRAMAddr(j,k);
			SingleData(k,logobmp[j][k]);
			SetRAMAddr(j,tempkey);
			SingleData(tempkey,logobmp[j][tempkey]);
    		}

		Delay(3);
		tempkey=KeyScan();

		if(tempkey !=0xFF)return;

	 	}

     	Delay(40);

	for(k=0;k<=63;k++)
		{
		for(j=0;j<8;j++)
			{
            tempkey=63+k;
			SetRAMAddr(j,k);
			SingleData(k,~logobmp[j][k]);
			SetRAMAddr(j,tempkey);
			SingleData(tempkey,~logobmp[j][tempkey]);
   			}

			Delay(3);
			tempkey=KeyScan();
			if(tempkey !=0xFF)return;
	 	}

	  	j=4;
		do
	 	{
		 	Delay(20);
		 	tempkey=KeyScan();
			if(tempkey !=0xFF)return;
	 	}while(--j!=0);

	 for(k=63;k>=0;k--)
	 	{

	 	for(j=0;j<8;j++)
			{
            tempkey=127-k;
			SetRAMAddr(j,k);
			SingleData(k,logobmp[j][k]);
			SetRAMAddr(j,tempkey);
			SingleData(tempkey,logobmp[j][tempkey]);
   			}

		Delay(3);
		tempkey=KeyScan();
		if(tempkey !=0xFF)return;
	 	}
		//Wait after return
	 	j=50;
		do
	 	{
		 	Delay(40);
		 	tempkey=KeyScan();
			if(tempkey !=0xFF)return;
	 	}while(--j!=0);
}

//=================================================
//Function: 	DispLay_RTC	
//Description: 	Display Date And Time
//Parameters: 	No.
//Call:			HzDisplay,Msingle_font_pattern,Get_Time
//Returns: 		NO.
//Side Effects: 
//=================================================
void	DispRTC(bool fflag,uint8 *Sys_Date_Time)
{
		uint8 tempvar;

		//显示固定字符
		if (fflag==0)
		{
			HzDisplay(Xin,0,2,0);
			HzDisplay(Qi,0,18,0);

			Msingle_font_pattern (mh,0,80,0);
			Msingle_font_pattern (mh,0,104,0);

			HzDisplay(Year,2,40,0);
			HzDisplay(Month,2,72,0);
			HzDisplay(Day,2,104,0);

			Msingle_font_pattern (English_Offset[2],2,8,0);
			Msingle_font_pattern (English_Offset[0],2,16,0);
		}

		//显示星期几于左上角
		HzDisplay(Week[Sys_Date_Time[5]],0,34,0);
		//显示时间于右上角
		//hh
		CY=0;
		Sys_Date_Time[2]&=0x3F;
		tempvar=(Sys_Date_Time[2]&0xF0)>>4;
		Msingle_font_pattern (English_Offset[tempvar],0,64,0);
		tempvar=Sys_Date_Time[2]&0x0F;
		Msingle_font_pattern (English_Offset[tempvar],0,72,0);
		//mm
		CY=0;
		tempvar=(Sys_Date_Time[1]&0xF0)>>4;
		Msingle_font_pattern (English_Offset[tempvar],0,88,0);
		tempvar=Sys_Date_Time[1]&0x0F;
		Msingle_font_pattern (English_Offset[tempvar],0,96,0);
		//ss
		Sys_Date_Time[0]&=0x7F;
		CY=0;
		tempvar=(Sys_Date_Time[0]&0xF0)>>4;
		Msingle_font_pattern (English_Offset[tempvar],0,112,0);
		tempvar=Sys_Date_Time[0]&0x0F;
		Msingle_font_pattern (English_Offset[tempvar],0,120,0);
		
		//显示时间于屏幕中间
		//year
		CY=0;
		tempvar=(Sys_Date_Time[6]&0xF0)>>4;
		Msingle_font_pattern (English_Offset[tempvar],2,24,0);
		tempvar=Sys_Date_Time[6]&0x0F;
		Msingle_font_pattern (English_Offset[tempvar],2,32,0);
		//month
		CY=0;
		tempvar=(Sys_Date_Time[4]&0xF0)>>4;
		Msingle_font_pattern (English_Offset[tempvar],2,56,0);
		tempvar=Sys_Date_Time[4]&0x0F;
		Msingle_font_pattern (English_Offset[tempvar],2,64,0);
		//day
		CY=0;
		tempvar=(Sys_Date_Time[3]&0xF0)>>4;
		Msingle_font_pattern (English_Offset[tempvar],2,88,0);
		tempvar=Sys_Date_Time[3]&0x0F;
		Msingle_font_pattern (English_Offset[tempvar],2,96,0);

		if (fflag==0) fflag=1;
}

//=================================================
//Function: 	Display_Line	
//Description: 	Display one System Main Menu
//Parameters: 	num,page_y_in,startcol,len,flag
//Call:			
//Returns: 		NO.
//Side Effects: 
//=================================================
void Display_Line( uint8 page_y_in,
				uint8 startcol,uint8 len, bool flag, uint8** menuitem)//uint8 menuno,
{
		uint8	i;

		if ((len*16)>(128-startcol)) return;
		for(i=0;i<len;i++)
		{
			HzDisplay(menuitem[i],page_y_in,startcol,flag);
			startcol=startcol+16;
		} 		
}

//=================================================
//Function: 	MainMenu_Show	
//Description: 	Display one System Main Menu
//Parameters: 	index
//GOBAL Var:	Main_Menu[]
//Call:			Display_Line
//Returns: 		NO.
//Side Effects: 
//=================================================
void MainMenuShow(uint8 index)
{

⌨️ 快捷键说明

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