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

📄 5110.h~

📁 诺基亚5110 LCD资料
💻 H~
📖 第 1 页 / 共 2 页
字号:
void PrintChinese(unsigned char x, unsigned char y);
void PrintBmp(unsigned char x, unsigned char y);
void Delayms(unsigned int ms);                 

void Delayms(unsigned int ms)                 
{
   unsigned char  i;
   while (ms--)
   {
   		for (i=0; i<125; i++);
   }
  
}

/*初始化函数*/
void Initial5110(void)
{
	DDRC = 0XFF;
	PORTC = 0XFF;
    DDRB = 0XFF;
	PORTB = 0XFF;
	DDRD = 0XFF;
	PORTD = 0XFF;
	
	
	RST = 0;			 // 低电平,LCD复位
    Delayms(TIME);
    RST = 1;			  // 关闭LCD
    CE = 0;				  
   /*Delayms(TIME);
	CE = 1;		        // 使能LCD     */
		   	
    Delayms(TIME);
	WriteByte(0x21, 0);	// 扩展命令
    WriteByte(0xc8, 0);	// 设置偏置电压
    WriteByte(0x06, 0);	// 温度校正
    WriteByte(0x13, 0);	// 1:48    
    
    
    WriteByte(0x20, 0);	// 使用基本命令
    Clean();	        // 清屏
    WriteByte(0x0c, 0);	// 设定显示模式,正常显示
    CE = 0;				 // 关闭LCD
}

/*清屏函数*/
void Clean(void)
{
	unsigned int i;
    WriteByte(0x0c, 0);			
    WriteByte(0x80, 0);			
	for (i=0; i<504; i++)
	{
		 WriteByte(0, 1);
	}  			
}


/*写字节函数*/
void WriteByte(unsigned char datas, unsigned char command)
{
	unsigned char i;
    CE = 0;
    if (command == 0)
    {
     	DC = 0;
	}
    else
    {
    	 DC = 1;
	}
	for(i=0;i<8;i++)
	{
		if (datas&0x80)
		{
			SDIN = 1;
		}
		else		
		{
		 	SDIN = 0;
		}			
		SCLK = 0;
		datas = datas << 1;
		SCLK = 1;
	}
  	CE = 1;
}

/*设置坐标函数*/
void SetAddress(unsigned char x, unsigned char y)
{
    WriteByte(0x40 | y, 0);		
    WriteByte(0x80 | x, 0);          	
}

/*输出字符函数*/ 
void PrintChar(unsigned char character)
{
	unsigned char line; 
	character -= 32;
	for (line=0; line<6; line++)
	{
		WriteByte(characterTab[character][line], 1);
	}
    
} 

/*输出字符串函数*/
void PrintString(unsigned char x, unsigned char y, char *pString)
{
    SetAddress(x, y);
    while (*pString) 
    {
	 	PrintChar(*pString);
	 	pString++;
    }
}  
             
/*写汉字函数*/
void PrintChinese(unsigned char x, unsigned char y)
{
	unsigned char i, j;
	
		for (j=0; j<sizeof(chineseTab)/32; j++)
	{
		for (i=0; i<32; i++)				   //0~11写汉字上半部分,12~23写下半部分
		{ 
			SetAddress(x+16*j+i%16, y+ i/16);	
		 	WriteByte(chineseTab[j][i], 1);
		}
	}	
}  
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
/*画图程序*/
void PrintBmp(unsigned char x, unsigned char y)
{
	unsigned char  j;
	for (j=0; j<sizeof(bmpTab); j++)
	{
		SetAddress(x+j%BMPLENGHT, y+j/BMPLENGHT);	
		WriteByte(bmpTab[j], 1);		
	}	
} 
#endif

⌨️ 快捷键说明

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