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

📄 gui.c

📁 EVD测试仪开发源码含测试图片及部分GUI开发源码
💻 C
📖 第 1 页 / 共 4 页
字号:
			*HZ_Group++=hz_guan;
		else
		if(const_mid==get_hz_const("理"))
			*HZ_Group++=hz_li_lun;
		else
		if(const_mid==get_hz_const("所"))
			*HZ_Group++=hz_suo;
		else
		if(const_mid==get_hz_const("选"))
			*HZ_Group++=hz_xuan;
		else
		if(const_mid==get_hz_const("项"))
			*HZ_Group++=hz_xiang;
		else
		if(const_mid==get_hz_const("查"))
			*HZ_Group++=hz_cha_kan;
		else
		if(const_mid==get_hz_const("看"))
			*HZ_Group++=hz_kan;
		else
		if(const_mid==get_hz_const("恢"))
			*HZ_Group++=hz_hui;
		else
		if(const_mid==get_hz_const("出"))
			*HZ_Group++=hz_chu_chang;
		else
		if(const_mid==get_hz_const("厂"))
			*HZ_Group++=hz_chang;
		else
		if(const_mid==get_hz_const("索"))
			*HZ_Group++=hz_suo_yin;
		else
		if(const_mid==get_hz_const("引"))
			*HZ_Group++=hz_yin_hao;
		else
		if(const_mid==get_hz_const("确"))
			*HZ_Group++=hz_que;
		else
		if(const_mid==get_hz_const("认"))
			*HZ_Group++=hz_ren;
		else
		if(const_mid==get_hz_const("息"))
			*HZ_Group++=hz_xi_nu;
		else
		if(const_mid==get_hz_const("定"))
			*HZ_Group++=hz_ding;
		else
		if(const_mid==get_hz_const("退"))
			*HZ_Group++=hz_tui;
		else
		if(const_mid==get_hz_const("出"))
			*HZ_Group++=hz_chu_ru;
		else
		if(const_mid==get_hz_const("向"))
			*HZ_Group++=hz_xiang_xia;
		else
		if(const_mid==get_hz_const("下"))
			*HZ_Group++=hz_xia;
		else
		if(const_mid==get_hz_const("左"))
			*HZ_Group++=hz_zuo;
		else
		if(const_mid==get_hz_const("右"))
			*HZ_Group++=hz_you;
		else
		if(const_mid==get_hz_const("增"))
			*HZ_Group++=hz_zeng;
		else
		if(const_mid==get_hz_const("加"))
			*HZ_Group++=hz_jia;
		else
		if(const_mid==get_hz_const("移"))
			*HZ_Group++=hz_yi_wei;
		else
		if(const_mid==get_hz_const("空"))
			*HZ_Group++=hz_kong_kong;
		else
		if(const_mid==get_hz_const("终"))
			*HZ_Group++=hz_zhong;
		else
		if(const_mid==get_hz_const("止"))
			*HZ_Group++=hz_zhi_bu;
		else
		if(const_mid==get_hz_const("功"))
			*HZ_Group++=hz_gong;

	}
	return n_HZ;
}



/*********************************************************************
	Description:显示汉字串
	
	Input:
		p_HZ_Str:汉字串指针
		x:汉字串x坐标
		y:汉字串y坐标
	Output:
		
	Return:
		两字节的汉字内码
	Gloable:	
	
	Calls:
		Generate_HZ_Group();获取汉字串的字模表示
		ZK_To_Bitmap();字库到位图标识
		RegionInsertInDisBuffer();显示数据插入到显存
		GUI_ClearRect();清除区域
		
	Called By:
		
	Others:

	Modify Record:
	
*********************************************************************/
UINT8 GUI_DispLine_(UINT8 *p_HZ_Str,UINT8 x,UINT8 y)
{
	UINT8 xdata mid[144];
//	const UINT8 *p_hz[10];
	UINT8 code* p_hz[10];
	UINT8 n_hz,i;
	struct GUI_RECT rect;
	
	n_hz=Generate_HZ_Group(p_HZ_Str, p_hz);
	GUI_ClearRect(x, x+12*n_hz-1,y-11,y );
	for(i=0;i<n_hz;i++)
	{
		ZK_To_Bitmap(*(p_hz+i), 12, 12, mid);
		rect.x0=x+i*12;
		rect.x1=rect.x0+11;
		rect.y0=y-11;
		rect.y1=y;
		RegionInsertInDisBuffer(&rect,mid);
	}
	return n_hz;
}



/*********************************************************************
	Description:画上三角和下三角
	
	Input:
		up_down:0x01up  0x00down
	Output:
		
	Return:
		
	Gloable:	
	
	Calls:
		
	Called By:
		
	Others:

	Modify Record:
	
*********************************************************************/
void GUI_DrawArrow(UINT8 up_down)
{
	if(up_down==0x01)
		GUI_DispLine_("/u", 110, 15);
	else
		GUI_DispLine_("/d", 110, 30);
}



/*********************************************************************
	Description:清缓冲
	
	Input:

	Output:
		
	Return:
	
	Gloable:	
	
	Calls:
	
	Called By:
		
	Others:

	Modify Record:
	
*********************************************************************/
void GUI_ClearAll(void)
{
	UINT16 i;
	for(i=0;i<128*8;i++)
		DisBuffer[i]=0;
}




/*********************************************************************
	Description:设置数字字体12*6,
		设置全局变量:字体字模基址,偏移,X,Y方向像素个数
	
	Input:
	
	Output:
		
	Return:
		
	Gloable:	
		Number_X_Pixel:x方向像素
		Number_Y_Pixel:y方向上的像素
		CharacterStyle:字体类型
		Addr_Base:字体字模基址
		Addr_Deviate:字体字模偏移
		hz_1_:数字1
		hz_0_:数字0
	Calls:

	Called By:
		
	Others:

	Modify Record:
	
*********************************************************************/
void Gui_CharacterStyle_Set7_4(void)
{
	Number_X_Pixel=4;
	Number_Y_Pixel=7;
	CharacterStyle=0;
	Addr_Base=hz_0;
	Addr_Deviate=hz_1-hz_0;
	Number_Dot_Pixel=2;
	Number_Dot_Pixel_Y=1;
}



/*********************************************************************
	Description:设置数字字体12*6,
		设置全局变量:字体字模基址,偏移,X,Y方向像素个数
	
	Input:
	
	Output:
		
	Return:
		
	Gloable:	
		Number_X_Pixel:x方向像素
		Number_Y_Pixel:y方向上的像素
		CharacterStyle:字体类型
		Addr_Base:字体字模基址
		Addr_Deviate:字体字模偏移
		hz_1_:数字1
		hz_0_:数字0
	Calls:

	Called By:
		
	Others:

	Modify Record:
	
*********************************************************************/
void Gui_CharacterStyle_Set12_6(void)
{
	Number_X_Pixel=6;
	Number_Y_Pixel=12;
	CharacterStyle=1;
	Addr_Base=hz_0_;
	Addr_Deviate=hz_1_-hz_0_;
	Number_Dot_Pixel=2;
	Number_Dot_Pixel_Y=2;
}


/*********************************************************************
	Description:
		绘制按钮
	
	Input:
		p_btn:按钮指针
		p_HZ_Str:按钮文字
		x:按钮位置X坐标
		y:按钮位置Y坐标
		dx:按钮宽度
		dy:按钮高度
	
	Output:
		
	Return:
		
	Gloable:	

	Calls:

	Called By:
		
	Others:

	Modify Record:
	
*********************************************************************/
void GUI_DrawButton(struct GUI_BUTTON *p_btn, UINT8 *p_HZ_Str,UINT8 x,UINT8 y,UINT8 dx,UINT8 dy)
{
	struct GUI_RECT rect;

	p_btn->x = x;
	p_btn->y = y;
	p_btn->dx = dx;
	p_btn->dy = dy;
	p_btn->p_HZ_STR = p_HZ_Str;
	
	rect.x0 = x;
	rect.x1 = x + dx - 1;
	rect.y0 = y - dy + 1;
	rect.y1 = y;	

	GUI_ClearRect(rect.x0, rect.x1 + 1, rect.y0, rect.y1 + 1);
	GUI_DrawRect(rect.x0, rect.x1, rect.y0, rect.y1);
	GUI_ClearPixel(rect.x0, rect.y0);
	GUI_ClearPixel(rect.x1, rect.y0);
	GUI_DrawHLine(rect.x0 + 2, rect.x1 + 1, rect.y1 + 1);
	GUI_DrawVLine(rect.y0 + 2, rect.y1, rect.x1 + 1);
	GUI_DispLine_(p_HZ_Str, rect.x0 + 2, rect.y1 - 1);
}


/*********************************************************************
	Description:
		绘制按钮按下的效果
	
	Input:
		p_btn:按钮指针
	
	Output:
		
	Return:
		
	Gloable:	

	Calls:

	Called By:
		
	Others:

	Modify Record:
	
*********************************************************************/
void GUI_ButtonClick(struct GUI_BUTTON *p_btn)
{
	struct GUI_RECT rect;
	
	rect.x0 = p_btn->x;
	rect.x1 = p_btn->x + p_btn->dx - 1;
	rect.y0 = p_btn->y - p_btn->dy + 1;
	rect.y1 = p_btn->y;
	
	GUI_ClearRect(rect.x0, rect.x1 + 1, rect.y0, rect.y1 + 1);
	GUI_DrawRect(rect.x0 + 1, rect.x1 + 1, rect.y0 + 1, rect.y1 + 1);
	GUI_ClearPixel(rect.x0 + 1, rect.y0 + 1);
	GUI_ClearPixel(rect.x1 + 1, rect.y0 + 1);
	GUI_DispLine_(p_btn->p_HZ_STR, rect.x0 + 3, rect.y1);
	
	Display();
}


/*********************************************************************
	Description:
		绘制按钮释放的效果
	
	Input:
		p_btn:按钮指针
	
	Output:
		
	Return:
		
	Gloable:	

	Calls:

	Called By:
		
	Others:

	Modify Record:
	
*********************************************************************/
void GUI_ButtonRelease(struct GUI_BUTTON *p_btn)
{
	struct GUI_RECT rect;
	
	rect.x0 = p_btn->x;
	rect.x1 = p_btn->x + p_btn->dx - 1;
	rect.y0 = p_btn->y - p_btn->dy + 1;
	rect.y1 = p_btn->y;
	
	GUI_ClearRect(rect.x0, rect.x1 + 1, rect.y0, rect.y1 + 1);
	GUI_DrawRect(rect.x0, rect.x1, rect.y0, rect.y1);
	GUI_ClearPixel(rect.x0, rect.y0);
	GUI_ClearPixel(rect.x1, rect.y0);
	GUI_DrawHLine(rect.x0 + 2, rect.x1 + 1, rect.y1 + 1);
	GUI_DrawVLine(rect.y0 + 2, rect.y1, rect.x1 + 1);
	GUI_DispLine_(p_btn->p_HZ_STR, rect.x0 + 2, rect.y1 - 1);
	Display();
}


/*********************************************************************
	Description:
		清除一个点
	
	Input:
		x:X坐标
		y:Y坐标
	
	Output:
		
	Return:
		
	Gloable:	

	Calls:

	Called By:
		
	Others:

	Modify Record:
	
*********************************************************************/
void GUI_ClearPixel(UINT8 x,UINT8 y)
{
	UINT16 Location_Byte;
	UINT8 Location_Bit;

	Location_Byte = (y / 8) * 128 + x;
	Location_Bit = y % 8;
	DisBuffer[Location_Byte] &= (~(0x01 << Location_Bit));
}




/*********************************************************************
	Description:创建一个年月日时分秒设置页,YYMMDDHHMMSS
	
	Input:
		p_HZ_Str:标签
		p_T:时间结构体变量指针
		x_HZ:汉字标签X坐标
		y_HZ:汉字标签Y坐标
		x_T:时间值X坐标
		y_T:时间值Y坐标
		flag: 0x01YYMMDD 0x00HHMMSS
	Output:
		
	Return:
		
	Gloable:	
		struct StpLabelBlk_YMD:年月日时分秒标签页设置数据结构
		p_S_L_B: 无类型指针
		heap:自定义堆内存
	Calls:
		GUI_ClearAll();
		GUI_DispLine_();
		GUI_InvertRect();
		Gui_CharacterStyle_Set12_6();
		BCD2INT_TIME();
		Refresh_YMD();
	Called By:
		
	Others:

	Modify Record:
	
*********************************************************************/
void CreateStpLabel_YMD(UINT8 *p_HZ_Str,UINT8 x_HZ,UINT8 y_HZ,struct Time *p_T, UINT8 x_T,UINT8 y_T,UINT8 flag)
{
	struct StpLabelBlk_YMD* p;
	struct Time mid;
	
	GUI_ClearRect(2,	 124, 1, 40);
	Gui_CharacterStyle_Set12_6();
	GUI_DispLine_(p_HZ_Str, x_HZ, y_HZ);
	
//	p_S_L_B=malloc(sizeof(struct StpLabelBlk_YMD));
	p_S_L_B=heap;
	p=(struct StpLabelBlk_YMD*)p_S_L_B;
	
	p->Location_Cur_Crt=0;
	p->p_Time=p_T;
	p->x=x_T;
	p->y=y_T;
//	BCD2INT_TIME(p->p_Time, &mid);
	mid.year=7;
	mid.mon=1;
	mid.date=1;
	mid.hour=0;
	mid.min=0;
	mid.sec=0;
	if(flag)//year mon date
	{
		p->Time_Temp.year=mid.year;
		p->Time_Temp.mon=mid.mon;
		p->Time_Temp.date=mid.date;
	}
	else
	{
		p->Time_Temp.hour=mid.hour;
		p->Time_Temp.min=mid.min;
		p->Time_Temp.sec=mid.sec;
	}
	Refresh_YMD(p,flag);
//	GUI_InvertRect(x_T-1,x_T+(X_PIXEL_NUMBER+1)*2, y_T-Y_PIXEL_NUMBER, y_T+1);	
}



/*********************************************************************
	Description://shift
		响应YYMMDDHHMMSS设置页确定键
		
	Input:
		flag:1 YYMMDD 0 HHMMSS
	Output:
		
	Return:
		
	Gloable:	
		p_S_L_B:	全局无类型指针	
		StpLabelBlk_YMD:YYMMDDHHMMSS设置页结构
	Calls:
		DS1302_Init():
	Called By:
		
	Others:

	Modify Record:
	
*********************************************************************/
void OnOK_YMD(UINT8 flag)
{
	struct StpLabelBlk_YMD*p;
	UINT8 mid1,mid2;
	p=(struct StpLabelBlk_YMD*)p_S_L_B;
	if(flag)//YY MM DD
	{
		mid1=(p->Time_Temp.year/10)*16;
		mid2=p->Time_Temp.year%10;
		p->p_Time->year=mid1+mid2;
		mid1=(p->Time_Temp.mon/10)*16;
		mid2=p->Time_Temp.mon%10;
		p->p_Time->mon=mid1+mid2;
		mid1=(p->Time_Temp.date/10)*16;
		mid2=p->Time_Temp.date%10;
		p->p_Time->date=mid1+mid2;
	}
	else
	{
		mid1=(p->Time_Temp.hour/10)*16;
		mid2=p->Time_Temp.hour%10;
		p->p_Time->hour=mid1+mid2;
		mid1=(p->Time_Temp.min/10)*16;
		mid2=p->Time_Temp.min%10;
		p->p_Time->min=mid1+mid2;
		mid1=(p->Time_Temp.sec/10)*16;
		mid2=p->Time_Temp.sec%10;
		p->p_Time->sec=mid1+mid2;
	}
	DS1302_Init();
}



/*********************************************************************
	Description://shift
		响应YYMMDDHHMMSS设置页增加键
		
	Input:
		flag:1 YYMMDD 0 HHMMSS
	Output:
		
	Return:
		
	Gloable:	
		p_S_L_B:	全局无类型指针	
		StpLabelBlk_YMD:YYMMDDHHMMSS设置页结构
	Calls:
		Refresh_YMD():
	Called By:

⌨️ 快捷键说明

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