📄 gui.c
字号:
Others:
Modify Record:
*********************************************************************/
void OnPre_YMD(UINT8 flag)
{
struct StpLabelBlk_YMD*p;
p=(struct StpLabelBlk_YMD*)p_S_L_B;
if(flag)//yy mm dd
{
switch(p->Location_Cur_Crt)
{
case 0:
{
(p->Time_Temp.year)++;
p->Time_Temp.year%=100;
}
break;
case 1:
{
if((++p->Time_Temp.mon)==13)
p->Time_Temp.mon=1;
}
break;
case 2:
{
if(++(p->Time_Temp.date)==32)
p->Time_Temp.date=1;
}
break;
default:;
}
}
else
{
switch(p->Location_Cur_Crt)
{
case 0:
{
(p->Time_Temp.hour)++;
p->Time_Temp.hour%=24;
}
break;
case 1:
{
(p->Time_Temp.min)++;
p->Time_Temp.min%=60;
}
break;
case 2:
{
(p->Time_Temp.sec)++;
p->Time_Temp.sec%=60;
}
break;
default:;
}
}
Refresh_YMD(p, flag);
}
/*********************************************************************
Description://shift
响应YYMMDDHHMMSS设置页移位键
Input:
flag: 1 YYMMDD 0 HHMMSS
Output:
Return:
Gloable:
p_S_L_B: 全局无类型指针
StpLabelBlk_YMD:YYMMDDHHMMSS设置页结构
Calls:
Refresh_YMD():
Called By:
Others:
Modify Record:
*********************************************************************/
void OnNxt_YMD(UINT8 flag)
{
struct StpLabelBlk_YMD *p;
p=(struct StpLabelBlk_YMD *)p_S_L_B;
p->Location_Cur_Crt++;
p->Location_Cur_Crt%=3;
Refresh_YMD(p, flag);
}
/*********************************************************************
Description:
响应YYMMDDHHMMSS设置页退出键
Input:
Output:
Return:
Gloable:
Calls:
Called By:
Others:
Modify Record:
*********************************************************************/
void OnCancle_YMD(UINT8 flag)
{
struct StpLabelBlk_YMD *p;
flag=flag;
p=(struct StpLabelBlk_YMD *)p_S_L_B;
}
/*********************************************************************
Description:创建一个年月日时分秒设置页,YYMMDDHHMMSS
Input:
p_HZ_Str:标签
p_Int:整形变量指针
x_HZ:汉字标签X坐标
y_HZ:汉字标签Y坐标
x_Dat:整数值值X坐标
y_Dat:整数值Y坐标
n_Int:显示位数
Output:
Return:
Gloable:
struct StpLabelBlk_Int:整形数标签页设置数据结构
p_S_L_B: 无类型指针
heap:自定义堆内存
Calls:
GUI_ClearAll();
GUI_DispLine_();
GUI_InvertRect();
Gui_CharacterStyle_Set12_6();
BCD2INT_TIME();
Refresh_YMD();
Called By:
Others:
光标位置基于0
Modify Record:
*********************************************************************/
void CreateStpLabel_Int(UINT8 *p_HZ_Str,UINT8 x_HZ,UINT8 y_HZ,unsigned int *p_Int, UINT8 x_Dat,UINT8 y_Dat,UINT8 n_Int)
{
struct StpLabelBlk_Int *p;
// Gui_CharacterStyle_Set12_6();
// GUI_ClearAll();
GUI_DispLine_(p_HZ_Str, x_HZ, y_HZ);
FormatStringTable[2]=n_Int+'0';
GUI_DisIntData(*p_Int, x_Dat, y_Dat, FormatStringTable);
GUI_InvertRect(x_Dat, x_Dat+Number_X_Pixel-1, y_Dat-Number_Y_Pixel+1, y_Dat);
p_S_L_B=heap;
p=(struct StpLabelBlk_Int *)p_S_L_B;
p->p_Dat=p_Int;
p->Dat_Temp=*(p->p_Dat);
p->Location_Cur_Crt=0;
p->n_Bit=n_Int;
p->x=x_Dat;
p->y=y_Dat;
// return p;
}
/*********************************************************************
Description://add
响应整数设置页确定键
Input:
Output:
Return:
Gloable:
p_S_L_B: 全局无类型指针
Number_X_Pixel:
Number_X_Pixel:
StpLabelBlk_Int:整形数据设置页结构
Calls:
ParaWrToEEPROM():
Called By:
Others:
Modify Record:
*********************************************************************/
void OnOk_Int(void)
{
struct StpLabelBlk_Int *p;
p=(struct StpLabelBlk_Int *)p_S_L_B;
*(p->p_Dat)=p->Dat_Temp;
}
/*********************************************************************
Description://add
响应整数设置页增加键
Input:
Output:
Return:
Gloable:
p_S_L_B: 全局无类型指针
Number_X_Pixel:
Number_X_Pixel:
StpLabelBlk_Int:整形数据设置页结构
Calls:
GUI_DisIntData():
GUI_InvertRect():
pow_10():
GetBCD_At():
Called By:
Others:
Modify Record:
*********************************************************************/
void OnPre_Int(void)
{
struct StpLabelBlk_Int *p;
p=(struct StpLabelBlk_Int *)p_S_L_B;
p->Dat_Temp+=pow_10(p->n_Bit-p->Location_Cur_Crt-1)*(GetBCD_At(p->Dat_Temp, p->n_Bit, p->Location_Cur_Crt));
FormatStringTable[2]=p->n_Bit+'0';
GUI_DisIntData(p->Dat_Temp, p->x, p->y, FormatStringTable);
GUI_InvertRect(p->x+Number_X_Pixel*(p->Location_Cur_Crt), p->x+Number_X_Pixel*(p->Location_Cur_Crt)+Number_X_Pixel-1, p->y-Number_Y_Pixel+1, p->y);//
Display();
}
/*********************************************************************
Description://shift
响应整数设置页移位键
Input:
Output:
Return:
Gloable:
p_S_L_B: 全局无类型指针
Number_X_Pixel:
Number_X_Pixel:
StpLabelBlk_Int:整形数据设置页结构
Calls:
GUI_DisIntData():
GUI_InvertRect():
Called By:
Others:
Modify Record:
*********************************************************************/
void OnNxt_Int(void)
{
struct StpLabelBlk_Int *p;
UINT8 mid;
p=(struct StpLabelBlk_Int *)p_S_L_B;
//p->Location_Cur_Crt=(p->Location_Cur_Crt++)%(p->n_Bit);
p->Location_Cur_Crt++;
mid=(p->Location_Cur_Crt)%(p->n_Bit);
p->Location_Cur_Crt=mid;
FormatStringTable[2]=p->n_Bit+'0';
GUI_DisIntData(p->Dat_Temp, p->x, p->y, FormatStringTable);
//GUI_InvertRect(p->x+(X_PIXEL_NUMBER+1)*(p->Location_Cur_Crt), p->x+(X_PIXEL_NUMBER+1)*(p->Location_Cur_Crt)+X_PIXEL_NUMBER, p->y-Y_PIXEL_NUMBER, p->y+1);
// GUI_InvertRect(p->x+(X_PIXEL_NUMBER+2)*(p->Location_Cur_Crt)-1, p->x+(X_PIXEL_NUMBER+2)*(p->Location_Cur_Crt)+X_PIXEL_NUMBER, p->y-Y_PIXEL_NUMBER, p->y+1);
GUI_InvertRect(p->x+Number_X_Pixel*(p->Location_Cur_Crt), p->x+Number_X_Pixel*(p->Location_Cur_Crt)+Number_X_Pixel-1, p->y-Number_Y_Pixel+1, p->y);
Display();
}
/*********************************************************************
Description:
响应整数设置页退出键
Input:
Output:
Return:
Gloable:
Calls:
Called By:
Others:
Modify Record:
*********************************************************************/
void OnCancle_Int(void)
{
// free(p_S_L_B);
}
/*********************************************************************
Description:创建一个逻辑设置页,即二值设置页
Input:
p_HZ_Str:标签
p_Logic:待设置逻辑变量指针
x_HZ:汉字标签X坐标
y_HZ:汉字标签Y坐标
x_dat:逻辑值(是否)X坐标
y_Dat:逻辑值(是否)Y坐标 坐标基点在左下角
Output:
Return:
Gloable:
struct StpLabelBlk_Logic:逻辑标签页设置数据结构
p_S_L_B: 无类型指针
heap:自定义堆内存
Calls:
GUI_ClearAll();
GUI_DispLine_();
GUI_InvertRect();
Called By:
Others:
Modify Record:
*********************************************************************/
void CreateStpLable_Logic(UINT8 *p_HZ_Str,UINT8 *p_Logic,UINT8 x_HZ,UINT8 y_HZ,UINT8 x_dat,UINT8 y_Dat)
{
struct StpLabelBlk_Logic *p;
//GUI_ClearAll();
GUI_DispLine_(p_HZ_Str, x_HZ, y_HZ);
//p_S_L_B=malloc(sizeof(struct StpLabelBlk_Logic));
p_S_L_B=heap;
p=(struct StpLabelBlk_Logic*)p_S_L_B;
p->p_Dat=p_Logic;
p->Location_Cur_Crt=*p_Logic;
p->Dat_Temp=*(p->p_Dat);
p->x=x_dat;
p->y=y_Dat;
GUI_DispLine_("是", x_dat, y_Dat);
// GUI_DispLine_("否", x_dat+15, y_Dat);
GUI_DispLine_("否", x_dat+35, y_Dat);
//GUI_InvertRect(x_dat-1, x_dat+12-1, y_Dat-12, y_Dat+1);
GUI_InvertRect(p->x+p->Location_Cur_Crt*35-1,p->x+p->Location_Cur_Crt*35-1+12 , p->y-12,p->y+1);
}
/*********************************************************************
Description:
响应逻辑设置页确定键
Input:
Output:
Return:
Gloable:
p_S_L_B:全局无类型指针
StpLabelBlk_Logic:逻辑设置页结构
Calls:
ParaWrToEEPROM():
Called By:
Others:
Modify Record:
*********************************************************************/
void OnOK_Logic(void)
{
struct StpLabelBlk_Logic *p;
p=(struct StpLabelBlk_Logic*)p_S_L_B;
*(p->p_Dat)=p->Dat_Temp;
}
/*********************************************************************
Description:
响应逻辑设置页移位键
Input:
Output:
Return:
Gloable:
p_S_L_B:全局无类型指针
StpLabelBlk_Logic:逻辑设置页结构
Calls:
GUI_InvertRect
Called By:
Others:
Modify Record:
*********************************************************************/
void OnPre_Logic(void)
{
struct StpLabelBlk_Logic *p;
p=(struct StpLabelBlk_Logic*)p_S_L_B;
if(p->Location_Cur_Crt)
{
p->Location_Cur_Crt=0;
p->Dat_Temp=0;
}
else
{
p->Location_Cur_Crt=1;
p->Dat_Temp=1;
}
// GUI_DispLine_("是", p->x, p->y);
// GUI_DispLine_("否", x_dat+15, y_Dat);
// GUI_DispLine_("是", p->x+15, p->y);
if(p->Location_Cur_Crt)
GUI_InvertRect(p->x+0-1,p->x+0-1+12 , p->y-12,p->y+1);
else
GUI_InvertRect(p->x+1*35-1,p->x+1*35-1+12 , p->y-12,p->y+1);
GUI_InvertRect(p->x+p->Location_Cur_Crt*35-1,p->x+p->Location_Cur_Crt*35-1+12 , p->y-12,p->y+1);
Display();
}
/*********************************************************************
Description:
响应逻辑设置页移位键
Input:
Output:
Return:
Gloable:
p_S_L_B:全局无类型指针
StpLabelBlk_Logic:逻辑设置页结构
Calls:
GUI_InvertRect
Called By:
Others:
Modify Record:
*********************************************************************/
void OnNxt_Logic(void)
{
struct StpLabelBlk_Logic *p;
p=(struct StpLabelBlk_Logic*)p_S_L_B;
if(p->Location_Cur_Crt)
{
p->Location_Cur_Crt=0;
p->Dat_Temp=0;
}
else
{
p->Location_Cur_Crt=1;
p->Dat_Temp=1;
}
// GUI_DispLine_("是", p->x, p->y);
// GUI_DispLine_("否", x_dat+15, y_Dat);
// GUI_DispLine_("是", p->x+15, p->y);
if(p->Location_Cur_Crt)
GUI_InvertRect(p->x+0-1,p->x+0-1+12 , p->y-12,p->y+1);
else
GUI_InvertRect(p->x+1*35-1,p->x+1*35-1+12 , p->y-12,p->y+1);
GUI_InvertRect(p->x+p->Location_Cur_Crt*35-1,p->x+p->Location_Cur_Crt*35-1+12 , p->y-12,p->y+1);
Display();
}
/*********************************************************************
Description:
响应逻辑设置页退出键
Input:
Output:
Return:
Gloable:
Calls:
Called By:
Others:
Modify Record:
*********************************************************************/
void OnCancle_Logic(void)
{
// free(p_S_L_B);
}
/*********************************************************************
Description://add
获取确定位置的BCD码,用于数字循环增加
34567 n_bit=5 location_bit=0----4
bit0---------------bit4
Input:
n_bit :总的位数
location_bit: 需要提取的BCD码所在的位置
dat:当前数据
Output:
Return:
BCD码
Gloable:
Calls:
pow_10():
Called By:
Others:
Modify Record:
*********************************************************************/
signed char GetBCD_At(unsigned int dat,UINT8 n_Bit,UINT8 Location_Bit)
{
UINT8 xdata bcd[16],i;
for(i=0;i<n_Bit;i++)
{
bcd[i]=dat/pow_10(n_Bit-(i+1));
dat=dat-pow_10(n_Bit-(i+1))*bcd[i];
}
//return bcd[Location_Bit];
if(bcd[Location_Bit]==9)
return -9;
else
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -