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

📄 gui.c

📁 EVD测试仪开发源码含测试图片及部分GUI开发源码
💻 C
📖 第 1 页 / 共 4 页
字号:
			if (buf[i] == '-')
			{
				GUI_DrawHLine(rect.x0, rect.x0+Number_X_Pixel-1, rect.y0-Number_Y_Pixel/2);
				rect.x0+=Number_X_Pixel;
			}
			else
			{
				ZK_To_Bitmap(Addr_Base + Addr_Deviate * (buf[i]-'0'), Number_Y_Pixel, Number_X_Pixel, mid);
				rect.x1=rect.x0+Number_X_Pixel-1;
				RegionInsertInDisBuffer(&rect, mid);
				rect.x0=rect.x0+Number_X_Pixel;
			}
		}
	}
}



/*********************************************************************
	Description:显示区域反转
	
	Input:
		x0:左上角x坐标
		x1:右下角x坐标
		y0:左上角y坐标
		y1:右下角y坐标
	Output:

	Return:

	Gloable:	
		Number_X_Pixel:字符的X方向上的像素
		Number_Y_Pixel:字符在Y方向上的像素
		special:特殊处理,这是一个设计的局限性,需要在下一个版本中改进
		DisBuffer[]:图形缓冲
	Calls:
		

	Called By:
		
	Others:

	Modify Record:
	
*********************************************************************/
void GUI_InvertRect(UINT8 x0,UINT8 x1,UINT8 y0,UINT8 y1)
{
	UINT8 i,j,Location_Bit;
	UINT16 Location_Byte;

	//for(i=x0;i<=x1-5;i++)// 不怎么严谨
	for(i=x0;i<=x1;i++)
		for(j=y0;j<=y1;j++)
		{
			Location_Byte=(j/8)*X_PIXEL+i;
			Location_Bit=j%8;
			if((DisBuffer[Location_Byte]>>Location_Bit)&0x01)
				DisBuffer[Location_Byte]&=(~(0x01<<Location_Bit));
			else
				DisBuffer[Location_Byte]|=(0x01<<Location_Bit);
		}
}



/*********************************************************************
	Description:清除区域
	
	Input:
		x0:左上角x坐标
		x1:右下角x坐标
		y0:左上角y坐标
		y1:右下角y坐标
	Output:

	Return:

	Gloable:	
		
	Calls:
		GUI_DrawHLine_();画线,反色

	Called By:
		
	Others:

	Modify Record:
	
*********************************************************************/
void GUI_ClearRect(UINT8 x0,UINT8 x1,UINT8 y0,UINT8 y1)
{
	UINT8 i;
	for(i=y0;i<=y1;i++)
	{
		GUI_DrawHLine_(x0, x1,i);
//		Display();
	}
}



/*********************************************************************
	Description:像素值转成字节表示(0x00,0x01),这样编程简单,不过此方式需要改变。
	
	Input:
		row:字模行数
		col:字模列数
		zk:字模指针
	Output:
		p_Bitmap:转换结果存放区域指针
	Return:

	Gloable:	
		
	Calls:

	Called By:
		
	Others:

	Modify Record:
	
*********************************************************************/
void ZK_To_Bitmap(UINT8 code* zk,UINT8 row,UINT8 col,UINT8* p_Bitmap)
{
	UINT8 i,j,Byte_ZK,Bit_Byte;
	for(j=0;j<col;j++)
		for(i=0;i<row;i++)
		{
			Byte_ZK=j*(row/8+1)+i/8;//(i*((col-1)/8+1)+j/8);
			Bit_Byte=i%8;
//			if((zk[(i*((col-1)/8+1)+j/8)]<<(j%8))==0x80)
			if(((zk[Byte_ZK]>>Bit_Byte)&0x01))
				*p_Bitmap++=1;
			else
				*p_Bitmap++=0;
		}
}
/*
//汉字的基准在左下角
void HZInsertInDis(UINT8 *p_HZ,UINT8 Pixel_X,UINT8 Pixel_Y,UINT8 x,UINT8 y)
{
	UINT8 temp[144],i;
	for(i=0;i<144;i++)
		if()
}*/



/*********************************************************************
	Description:显示信息插入显示缓冲。
	
	Input:
		rect:区域位置,和内容相对应
		p_Content:显示内容,横排,字节标识像素值(0x00,0x01)
	Output:
		p_Bitmap:转换结果存放区域指针
	Return:

	Gloable:	
		DisBuffer[]:显示缓冲
	Calls:

	Called By:
		
	Others:

	Modify Record:
	
*********************************************************************/
void RegionInsertInDisBuffer(struct GUI_RECT* rect,UINT8* p_Content)
{
	UINT8 i,j;
	UINT16 Byte_Buffer,Bit_Byte;
	for(j=rect->x0;j<=rect->x1;j++)
	{	for(i =rect->y0;i<=rect->y1;i++)
		{
			Byte_Buffer=(i/8)*X_PIXEL+j;//(i-1)*16+(j-1)/8;
			Bit_Byte=(i%8);//(j-1)%8;
			if((*p_Content++)==1)
				DisBuffer[Byte_Buffer]|=(0x01<<Bit_Byte);
			else
				DisBuffer[Byte_Buffer]&=(~(0x01<<Bit_Byte));			
		}
	}
}






/*********************************************************************
	Description:获取汉字内码,汉字有两个字节表示
	
	Input:
		p:单个汉字指针
		
	Output:
		
	Return:
		两字节的汉字内码
	Gloable:	
	
	Calls:

	Called By:
		
	Others:

	Modify Record:
	
*********************************************************************/
unsigned int get_hz_const(UINT8 *p)
{
 	unsigned int const_;
 	const_=*p++;
 	const_<<=8;
 	const_|=*p++;
 	return const_;
}



/*********************************************************************
	Description:获取汉字串的字模表示
	
	Input:
		p:汉字串
		
	Output:
		HZ_Group:指向字模指针的指针,即存放汉字串中所有汉字字模指针的数组
	Return:
		两字节的汉字内码
	Gloable:	
	
	Calls:
		get_hz_const();获取汉字内码。
	Called By:
		
	Others:
		考虑到效率的问题,此函数当中的查找判断需要做优化,方法是做成顺序表。
	Modify Record:
	
*********************************************************************/
UINT8 Generate_HZ_Group(UINT8 *p,UINT8 code **HZ_Group)
{
	UINT8 n_HZ=0;
	UINT8 *q;
	UINT8 i;
	unsigned int const_mid=0;//mid;

	q=p;
	while((*q++)!=0x00)
 		n_HZ++;
	n_HZ>>=1;
	for(i=0;i<n_HZ;i++)
	{	
		const_mid=*p++;
		const_mid<<=8;
		const_mid|=*p++;
		

		if(const_mid==get_hz_const("等"))
			*HZ_Group++=hz_deng;
		else
		if(const_mid==get_hz_const("待"))
			*HZ_Group++=hz_dai;
		else
		if(const_mid==get_hz_const("完"))
			*HZ_Group++=hz_wan;
		else
		if(const_mid==get_hz_const("成"))
			*HZ_Group++=hz_cheng_gong;
		else
		if(const_mid==get_hz_const("测"))
			*HZ_Group++=hz_ce;
		else
		if(const_mid==get_hz_const("量"))
			*HZ_Group++=hz_liang;
		else
		if(const_mid==get_hz_const("设"))
			*HZ_Group++=hz_she;
		else
		if(const_mid==get_hz_const("置"))
			*HZ_Group++=hz_zhi;
		else
		if(const_mid==get_hz_const("存"))
			*HZ_Group++=hz_cun;
		else
		if(const_mid==get_hz_const("储"))
			*HZ_Group++=hz_chu_cun;
		else
		if(const_mid==get_hz_const("时"))
			*HZ_Group++=hz_shi;
		else
		if(const_mid==get_hz_const("间"))
			*HZ_Group++=hz_jian_xie;
		else
		if(const_mid==get_hz_const("通"))
			*HZ_Group++=hz_tong;
		else
		if(const_mid==get_hz_const("信"))
			*HZ_Group++=hz_xin;
		else
		if(const_mid==get_hz_const("仪"))
			*HZ_Group++=hz_yi;
		else
		if(const_mid==get_hz_const("表"))
			*HZ_Group++=hz_biao;
		else
		if(const_mid==get_hz_const("校"))
			*HZ_Group++=hz_jiao;
		else
		if(const_mid==get_hz_const("正"))
			*HZ_Group++=hz_zheng;
		else
		if(const_mid==get_hz_const("试"))
			*HZ_Group++=hz_shi_juan;
		else
		if(const_mid==get_hz_const("件"))
			*HZ_Group++=hz_jian;
		else
		if(const_mid==get_hz_const("模"))
			*HZ_Group++=hz_mo;
		else
		if(const_mid==get_hz_const("式"))
			*HZ_Group++=hz_shi_yang;
		else
		if(const_mid==get_hz_const("峰"))
			*HZ_Group++=hz_feng;
		else
		if(const_mid==get_hz_const("值"))
			*HZ_Group++=hz_zhi_ri;
		else
		if(const_mid==get_hz_const("停"))
			*HZ_Group++=hz_ting;
		else
		if(const_mid==get_hz_const("留"))
			*HZ_Group++=hz_liu;
		else
		if(const_mid==get_hz_const("阈"))
			*HZ_Group++=hz_yu;
		else
		if(const_mid==get_hz_const("报"))
			*HZ_Group++=hz_bao;
		else
		if(const_mid==get_hz_const("警"))
			*HZ_Group++=hz_jing;
		else
		if(const_mid==get_hz_const("截"))
			*HZ_Group++=hz_jie;
		else
		if(const_mid==get_hz_const("面"))
			*HZ_Group++=hz_mian;
		else
		if(const_mid==get_hz_const("打"))
			*HZ_Group++=hz_da;
		else
		if(const_mid==get_hz_const("印"))
			*HZ_Group++=hz_yin;
		else
		if(const_mid==get_hz_const("方"))
			*HZ_Group++=hz_fang;
		else
		if(const_mid==get_hz_const("数"))
			*HZ_Group++=hz_shu;
		else
		if(const_mid==get_hz_const("据"))
			*HZ_Group++=hz_ju;
		else
		if(const_mid==get_hz_const("查"))
			*HZ_Group++=hz_cha;
		else
		if(const_mid==get_hz_const("询"))
			*HZ_Group++=hz_xun;
		else
		if(const_mid==get_hz_const("清"))
			*HZ_Group++=hz_qing;
		else
		if(const_mid==get_hz_const("除"))
			*HZ_Group++=hz_chu;
		else
		if(const_mid==get_hz_const("分"))
			*HZ_Group++=hz_fen;
		else
		if(const_mid==get_hz_const("秒"))
			*HZ_Group++=hz_miao;
		else
		if(const_mid==get_hz_const("年"))
			*HZ_Group++=hz_nian;
		else
		if(const_mid==get_hz_const("月"))
			*HZ_Group++=hz_yue;
		else
		if(const_mid==get_hz_const("日"))
			*HZ_Group++=hz_ri;
		else
		if(const_mid==get_hz_const("波"))
			*HZ_Group++=hz_bo;
		else
		if(const_mid==get_hz_const("特"))
			*HZ_Group++=hz_te;
		else
		if(const_mid==get_hz_const("率"))
			*HZ_Group++=hz_lv;
		else
		if(const_mid==get_hz_const("地"))
			*HZ_Group++=hz_di;
		else
		if(const_mid==get_hz_const("址"))
			*HZ_Group++=hz_zhi_di;
		else
		if(const_mid==get_hz_const("/u"))
			*HZ_Group++=symbol_u;
		else
		if(const_mid==get_hz_const("/d"))
			*HZ_Group++=symbol_d;
		else
//new added

		if(const_mid==get_hz_const("三"))
			*HZ_Group++=hz_san;
				else
		if(const_mid==get_hz_const("思"))
			*HZ_Group++=hz_si;
				else
		if(const_mid==get_hz_const("行"))
			*HZ_Group++=hz_xing;
				else
		if(const_mid==get_hz_const("控"))
			*HZ_Group++=hz_kong;
				else
		if(const_mid==get_hz_const("联"))
			*HZ_Group++=hz_lian;
				else
		if(const_mid==get_hz_const("系"))
			*HZ_Group++=hz_xi;
				else
		if(const_mid==get_hz_const("电"))
			*HZ_Group++=hz_dian;
				else
		if(const_mid==get_hz_const("话"))
			*HZ_Group++=hz_hua;
				else
		if(const_mid==get_hz_const("实"))
			*HZ_Group++=hz_shi_ji;
				else
		if(const_mid==get_hz_const("速"))
			*HZ_Group++=hz_su_lv;
				else
		if(const_mid==get_hz_const("压"))
			*HZ_Group++=hz_ya;
				else
		if(const_mid==get_hz_const("力"))
			*HZ_Group++=hz_li;
				else
		if(const_mid==get_hz_const("机"))
			*HZ_Group++=hz_ji_qi;
				else
		if(const_mid==get_hz_const("欢"))
			*HZ_Group++=hz_huan;
				else
		if(const_mid==get_hz_const("迎"))
			*HZ_Group++=hz_ying;
				else
		if(const_mid==get_hz_const("使"))
			*HZ_Group++=hz_shi_yong;
				else
		if(const_mid==get_hz_const("用"))
			*HZ_Group++=hz_yong;
				else
		if(const_mid==get_hz_const("是"))
			*HZ_Group++=hz_shi_fou;
				else
		if(const_mid==get_hz_const("否"))
			*HZ_Group++=hz_fou;
				else
		if(const_mid==get_hz_const("请"))
			*HZ_Group++=hz_qing_shi;
				else
		if(const_mid==get_hz_const("输"))
			*HZ_Group++=hz_shu_ru;
				else
		if(const_mid==get_hz_const("入"))
			*HZ_Group++=hz_ru;
				else
		if(const_mid==get_hz_const("自"))
			*HZ_Group++=hz_zi;
				else
		if(const_mid==get_hz_const("动"))
			*HZ_Group++=hz_dong;
		else
		if(const_mid==get_hz_const("全"))
			*HZ_Group++=hz_quan;
		else
		if(const_mid==get_hz_const("部"))
			*HZ_Group++=hz_bu;

		else
		if(const_mid==get_hz_const("密"))
			*HZ_Group++=hz_mi;
		else
		if(const_mid==get_hz_const("码"))
			*HZ_Group++=hz_ma;
		else
		if(const_mid==get_hz_const("两"))
			*HZ_Group++=hz_liang_dian;
		else
		if(const_mid==get_hz_const("多"))
			*HZ_Group++=hz_duo;
		else
		if(const_mid==get_hz_const("点"))
			*HZ_Group++=hz_dian_di;
		else
		if(const_mid==get_hz_const("修"))
			*HZ_Group++=hz_xiu;
		else
		if(const_mid==get_hz_const("改"))
			*HZ_Group++=hz_gai;
		else
		if(const_mid==get_hz_const("新"))
			*HZ_Group++=hz_xin_niang;
		else
		if(const_mid==get_hz_const("隔"))
			*HZ_Group++=hz_ge;
		else
		if(const_mid==get_hz_const("统"))
			*HZ_Group++=hz_tong_ji;
		else
		if(const_mid==get_hz_const("复"))
			*HZ_Group++=hz_fu;
		else
		if(const_mid==get_hz_const("位"))
			*HZ_Group++=hz_wei;

		else
		if(const_mid==get_hz_const("重"))
			*HZ_Group++=hz_chong;
		else
		if(const_mid==get_hz_const("上"))
			*HZ_Group++=hz_shang;
		else
		if(const_mid==get_hz_const("电"))
			*HZ_Group++=hz_dian_yuan;
		else
		if(const_mid==get_hz_const("零"))
			*HZ_Group++=hz_ling;
		else
		if(const_mid==get_hz_const("满"))
			*HZ_Group++=hz_man;
		else
		if(const_mid==get_hz_const("程"))
			*HZ_Group++=hz_cheng;
		else
		if(const_mid==get_hz_const("编"))
			*HZ_Group++=hz_bian;
		else
		if(const_mid==get_hz_const("号"))
			*HZ_Group++=hz_hao;
		else
		if(const_mid==get_hz_const("无"))
			*HZ_Group++=hz_wu;
		else
		if(const_mid==get_hz_const("效"))
			*HZ_Group++=hz_xiao;
		else

		if(const_mid==get_hz_const("低"))
			*HZ_Group++=hz_di_wa;
		else
		if(const_mid==get_hz_const("砌"))
			*HZ_Group++=hz_qi;
		else
		if(const_mid==get_hz_const("体"))
			*HZ_Group++=hz_ti;
		else
		if(const_mid==get_hz_const("原"))
			*HZ_Group++=hz_yuan;
		else
		if(const_mid==get_hz_const("小"))
			*HZ_Group++=hz_xiao_shu;
		else
		if(const_mid==get_hz_const("型"))
			*HZ_Group++=hz_xing_hao;
		else
		if(const_mid==get_hz_const("数"))
			*HZ_Group++=hz_shu_ju;
		else
		if(const_mid==get_hz_const("显"))
			*HZ_Group++=hz_xian;
		else
		if(const_mid==get_hz_const("抗"))
			*HZ_Group++=hz_kang;
		else
		if(const_mid==get_hz_const("折"))
			*HZ_Group++=hz_zhe;
		else
		if(const_mid==get_hz_const("管"))

⌨️ 快捷键说明

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