基于Simple GUI实现的滚动显示汉字
原理
字符串循环左移https://www.cnblogs.com/summerkiki/p/5424818.html
二级标题
void String_Scroll(SGUI_CHAR *str,const SGUI_FONT_RES* pstFontRes,SGUI_CHAR str_size)//字符串后面记得加空格
{
SGUI_CHAR buff[20];
SGUI_CHAR Full_flag;
if(str_size > 20)
{
return;
}
Full_flag = pstFontRes->fnIsFullWidth(*str);
Full_flag++;
memcpy(buff,&str[Full_flag],(str_size - Full_flag));
memcpy(&buff[str_size - Full_flag],&str[0],Full_flag);
memcpy(str,buff,str_size);
}
HMI_ENGINE_RESULT HMI_Info_RefreshScreen(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters)
{
/*----------------------------------*/
/* Variable Declaration */
/*----------------------------------*/
SGUI_RECT stDisplayArea;
SGUI_POINT stInnerPos;
/*----------------------------------*/
/* Initialize */
/*----------------------------------*/
stInnerPos.iX = 0;
stInnerPos.iY = 0;
stDisplayArea.iX = 0;
stDisplayArea.iY = 0;
for(SGUI_INT8 i = 0; i < 9; i++)
{
SGUI_CHAR str_len = strlen(buff[i]);
if(str_len > 11)//如果字符串长度大于屏幕的宽度
{
String_Scroll(buff[i],&SGUI_DEFAULT_FONT_16,str_len);//字符串移动
}
stDisplayArea.iY += SGUI_DEFAULT_FONT_16.iHeight;
stDisplayArea.iWidth = pstDeviceIF->stSize.iWidth;
stDisplayArea.iHeight = SGUI_DEFAULT_FONT_16.iHeight;
SGUI_Text_DrawText(pstDeviceIF, ch_buff[i], &SGUI_DEFAULT_FONT_16, &stDisplayArea, &stInnerPos, SGUI_DRAW_NORMAL);
}
return HMI_RET_NORMAL;
}