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

📄 lcd_chinese.c

📁 利用61板、SPR模组、SPLC501液晶模组和4×4键盘建立手机通讯录模型
💻 C
字号:
//======================================================
// 文件名称:	LCD_Chinese.c
// 功能描述:	在LCD上显示汉字的程序
// 维护记录:	2006-09-20	v1.0
//======================================================

#include "..\include\splc501user.h"
#include "..\include\4096.h"

unsigned int CurX, CurY;
unsigned long Hz_StartAddr;

//========================================================================
//	语法格式:	void LCD501_SetPos(const unsigned int x, const unsigned int y)
//	实现功能:	定位即将显示的字符
//	参数:		x - 横坐标
//				y - 纵坐标
//	返回值:	无
//========================================================================
void LCD501_SetPos(const unsigned int x, const unsigned int y)
{
	CurX = x;
	CurY = y;
}

//========================================================================
//	语法格式:	void LCD501_GetPos(unsigned int *x, unsigned int *y)
//	实现功能:	获取即将显示字符的坐标定位
//	参数:		x - 横坐标存储地址
//				y - 纵坐标存储地址
//	返回值:	无
//========================================================================
void LCD501_GetPos(unsigned int *x, unsigned int *y)
{
	*x = CurX;
	*y = CurY;
}

//========================================================================
//	语法格式:	void LCD501_SetHZStartAddr(unsigned long StartAddr)
//	实现功能:	设置汉字库在SPR4096中的起始存储地址
//	参数:		StartAddr - 汉字库的起始地址
//	返回值:	无
//========================================================================
void LCD501_SetHZStartAddr(unsigned long StartAddr)
{
	Hz_StartAddr = StartAddr;
}

//========================================================================
//	语法格式:	void LCD501_PutHZ(const unsigned char *HZ)
//	实现功能:	在LCD上显示汉字
//	参数:		HZ - 汉字编码
//	返回值:	无
//========================================================================
void LCD501_PutHZ(const unsigned char *HZ)
{
	unsigned long HZ_Offset = Hz_StartAddr;
	unsigned int HZ_DotBuf[17], i;

	HZ_DotBuf[0] = 0x1010;						// 字模的第一个word存储字模的宽度和高度
	HZ_Offset += (unsigned long)(94 * (*HZ - 0xA1) + (*(HZ + 1) - 0xA1)) << 5 ;
	for(i = 1; i < 17; i++)
	{
		HZ_DotBuf[i] = SP_SIOReadAWord(HZ_Offset);
		HZ_Offset += 2;
	}
	if(CurX > SCR_MAX_COL - 16)			// 换行
	{
		CurX = 0;
		CurY += 16;
	}
	if(CurY <= SCR_MAX_COL - 8)			// 最底行如能显示半个字符则显示
	{
		LCD501_Bitmap(CurX, CurY, HZ_DotBuf);
		CurX += 16;
	}

}


//========================================================================
//	语法格式:	void LCD501_Print(const unsigned char *CharBuf)
//	实现功能:	在LCD上显示字符串(可以是汉字和英文混合)
//	参数:		CharBuf - 字符串起始地址
//	返回值:	无
//========================================================================
void LCD501_Print(const unsigned char *CharBuf)
{
	while(*CharBuf!='\0')
	{
		if(*CharBuf > 0x80)						// 汉字
		{
			LCD501_PutHZ(CharBuf);
			CharBuf += 2;			
		}
		else									// 字符
		{
			LCD501_FontSet(1);
			if(CurX > SCR_MAX_COL - 8)			// 换行
			{
				CurX = 0;
				CurY += 16;
			}
			if(CurY <= SCR_MAX_COL - 8)			// 最底行如能显示半个字符则显示
			{
				LCD501_PutChar(CurX, CurY, *CharBuf);
				CurX += 8;
			}
			CharBuf++;
		}
	}
}

//========================================================================
//	语法格式:	void LCD501_PrintPacked(const unsigned char* StrBuf)
//	实现功能:	在LCD上显示以"压缩方式"存储的字符串
//	参数:		StrBuf	要显示的字符串
//	返回值:	无
//========================================================================
void LCD501_PrintPacked(const unsigned char *CharBuf)
{
	const unsigned char *p_StrBuf;
	unsigned char HZ_Buf[2];
	
	p_StrBuf = CharBuf;
	while(*p_StrBuf!='\0')
	{
		if(*p_StrBuf>0x80)
		{
			HZ_Buf[0] = *p_StrBuf & 0x00ff;
			HZ_Buf[1] = *p_StrBuf >> 8;
			LCD501_PutHZ(HZ_Buf);
		}
		else
		{
			LCD501_FontSet(1);
			if(CurX > SCR_MAX_COL - 8)			// 换行
			{
				CurX = 0;
				CurY += 16;
			}
			if(CurY <= SCR_MAX_COL - 8)			// 最底行如能显示半个字符则显示
			{
				LCD501_PutChar(CurX, CurY, *p_StrBuf);
				CurX += 8;
			}
		}
		p_StrBuf++;
	}
}

⌨️ 快捷键说明

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