2017-10-11:重写HMI引擎,分离逻辑处理与数据;新增动态曲线接口,可以显示曲线图表。

This commit is contained in:
Polarix 2017-10-11 18:59:56 +08:00
parent c0db2b3b31
commit 208886c3b0
27 changed files with 831 additions and 3321 deletions

View File

@ -5,6 +5,7 @@
//=======================================================================// //=======================================================================//
#include "SGUI_Typedef.h" #include "SGUI_Typedef.h"
#include "HMI_Engine.h" #include "HMI_Engine.h"
#include <stdio.h>
//=======================================================================// //=======================================================================//
//= Data type definition. =// //= Data type definition. =//
@ -31,7 +32,9 @@ typedef struct
#define HMI_SCREEN_ID_DEMO_SCROLLING_TEXT (1001) #define HMI_SCREEN_ID_DEMO_SCROLLING_TEXT (1001)
#define HMI_SCREEN_ID_DEMO_LIST (1002) #define HMI_SCREEN_ID_DEMO_LIST (1002)
#define HMI_SCREEN_ID_DEMO_TEXT_NOTICE (1003) #define HMI_SCREEN_ID_DEMO_TEXT_NOTICE (1003)
#define HMI_SCREEN_ID_DEMO_VARIABLE_BOX (1004) #define HMI_SCREEN_ID_DEMO_RTC_NOTICE (1004)
#define HMI_SCREEN_ID_DEMO_VARIABLE_BOX (1005)
#define HMI_SCREEN_ID_DEMO_REAL_TIME_GRAPH (1006)
//=======================================================================// //=======================================================================//
//= Public variable declaration. =// //= Public variable declaration. =//
@ -40,7 +43,9 @@ extern HMI_ENGINE_OBJECT g_stDemoEngine;
extern HMI_SCREEN_OBJECT g_stHMIDemo_ScrollingText; extern HMI_SCREEN_OBJECT g_stHMIDemo_ScrollingText;
extern HMI_SCREEN_OBJECT g_stHMIDemo_List; extern HMI_SCREEN_OBJECT g_stHMIDemo_List;
extern HMI_SCREEN_OBJECT g_stHMIDemo_TextNotice; extern HMI_SCREEN_OBJECT g_stHMIDemo_TextNotice;
extern HMI_SCREEN_OBJECT g_stHMIDemo_VariableBox ; extern HMI_SCREEN_OBJECT g_stHMIDemo_RTCNotice;
extern HMI_SCREEN_OBJECT g_stHMIDemo_VariableBox;
extern HMI_SCREEN_OBJECT g_stHMI_DemoRealtimeGraph;
//=======================================================================// //=======================================================================//
//= Function declare. =// //= Function declare. =//
//=======================================================================// //=======================================================================//

View File

@ -84,9 +84,17 @@ HMI_ENGINE_RESULT InitializeEngine(HMI_ENGINE_OBJECT* pstHMIEngineObject)
eProcessResult = HMI_AddScreen(pstHMIEngineObject, &g_stHMIDemo_TextNotice, SGUI_TRUE); eProcessResult = HMI_AddScreen(pstHMIEngineObject, &g_stHMIDemo_TextNotice, SGUI_TRUE);
} }
if(HMI_PROCESS_SUCCESSFUL(eProcessResult)) if(HMI_PROCESS_SUCCESSFUL(eProcessResult))
{
eProcessResult = HMI_AddScreen(pstHMIEngineObject, &g_stHMIDemo_RTCNotice, SGUI_TRUE);
}
if(HMI_PROCESS_SUCCESSFUL(eProcessResult))
{ {
eProcessResult = HMI_AddScreen(pstHMIEngineObject, &g_stHMIDemo_VariableBox, SGUI_TRUE); eProcessResult = HMI_AddScreen(pstHMIEngineObject, &g_stHMIDemo_VariableBox, SGUI_TRUE);
} }
if(HMI_PROCESS_SUCCESSFUL(eProcessResult))
{
eProcessResult = HMI_AddScreen(pstHMIEngineObject, &g_stHMI_DemoRealtimeGraph, SGUI_TRUE);
}
if(HMI_PROCESS_SUCCESSFUL(eProcessResult)) if(HMI_PROCESS_SUCCESSFUL(eProcessResult))
{ {

View File

@ -1,6 +1,6 @@
/*************************************************************************/ /*************************************************************************/
/** Copyright. **/ /** Copyright. **/
/** FileName: HMI_Demo02_List.c **/ /** FileName: List.c **/
/** Author: Polarix **/ /** Author: Polarix **/
/** Version: 1.0.0.0 **/ /** Version: 1.0.0.0 **/
/** Description: HMI demo for list control interface. **/ /** Description: HMI demo for list control interface. **/
@ -12,7 +12,6 @@
#include "DemoProc.h" #include "DemoProc.h"
#include "SGUI_List.h" #include "SGUI_List.h"
#include "HMI_Engine.h" #include "HMI_Engine.h"
#include <stdio.h>
//=======================================================================// //=======================================================================//
//= User Macro definition. =// //= User Macro definition. =//
@ -31,41 +30,41 @@ static HMI_ENGINE_RESULT HMI_DemoList_PostProcess(SGUI_INT iActionResult);
//=======================================================================// //=======================================================================//
//= Static variable declaration. =// //= Static variable declaration. =//
//=======================================================================// //=======================================================================//
static SGUI_PCSZSTR szListTitle = "测试列表"; static SGUI_PCSZSTR s_szListTitle = "测试列表";
static SGUI_PCSZSTR arrszNoticeType[] = { "文字消息", "系统时间"}; static SGUI_PCSZSTR s_arrszNoticeType[] = { "文字消息", "系统时间"};
static SGUI_LIST_ITEM arrstTestListItems[] = { {0, "简单列表项", LIST_ITEM_NORMAL, {0}, {0, 0, 0}, NULL}, static SGUI_LIST_ITEM s_arrstTestListItems[] = { { 0, "简单列表项", LIST_ITEM_NORMAL, {0}, {0, 0, 0}, NULL},
{1, "枚举类型列表项", LIST_ITEM_ENUM, {0, 0, 1}, {0, 0, 0}, arrszNoticeType}, { 1, "枚举类型列表项", LIST_ITEM_ENUM, {0, 0, 1}, {0, 0, 0}, s_arrszNoticeType},
{2, "数字列表项", LIST_ITEM_DIGIT, {0, -50, 50}, {0, 0, 3}, NULL}, { 2, "数字列表项", LIST_ITEM_DIGIT, {0, -50, 50}, {0, 0, 3}, NULL},
{3, "带小数的数字列表项", LIST_ITEM_DIGIT, {1, -50, 50}, {2, 0, 5}, NULL}, { 3, "带小数的数字列表项", LIST_ITEM_DIGIT, {1, -50, 50}, {2, 0, 5}, NULL},
{4, "超长文字的简单列表项", LIST_ITEM_NORMAL, {0, 0, 0}, {0, 0, 0}, NULL}, { 4, "超长文字的简单列表项", LIST_ITEM_NORMAL, {0, 0, 0}, {0, 0, 0}, NULL},
{5, "列表项", LIST_ITEM_NORMAL, {0, 0, 0}, {0, 0, 0}, NULL}, { 5, "编辑框", LIST_ITEM_NORMAL, {0, 0, 0}, {0, 0, 0}, NULL},
{6, "曲线图", LIST_ITEM_NORMAL, {0, 0, 0}, {0, 0, 0}, NULL}, { 6, "实时曲线", LIST_ITEM_NORMAL, {0, 0, 0}, {0, 0, 0}, NULL},
{7, "编辑框", LIST_ITEM_NORMAL, {0, 0, 0}, {0, 0, 0}, NULL}, };
};
#if (_SIMPLE_GUI_ENABLE_DYNAMIC_MEMORY_ > 0) #if (_SIMPLE_GUI_ENABLE_DYNAMIC_MEMORY_ > 0)
static SGUI_LIST_ITEM arrstAppendListItems[] = { {8, "添加项1", LIST_ITEM_NORMAL, {0}, {0, 0, 0}, NULL}, static SGUI_LIST_ITEM s_arrstAppendListItems[] = { { 8, "添加项1", LIST_ITEM_NORMAL, {0}, {0, 0, 0}, NULL},
{9, "添加项2", LIST_ITEM_ENUM, {0, 0, 1}, {0, 0, 0}, arrszNoticeType}, { 9, "添加项2", LIST_ITEM_ENUM, {0, 0, 1}, {0, 0, 0}, s_arrszNoticeType},
{10, "添加项3", LIST_ITEM_DIGIT, {0, -50, 50}, {0, 0, 3}, NULL}, {10, "添加项3", LIST_ITEM_DIGIT, {0, -50, 50}, {0, 0, 3}, NULL}
}; };
#endif #endif
static SGUI_LIST_STRUCT stTestList; HMI_SCREEN_ACTION s_stDemoListActions = { HMI_DemoList_Initialize,
HMI_DemoList_Prepare,
HMI_DemoList_RefreshScreen,
HMI_DemoList_ProcessEvent,
HMI_DemoList_PostProcess
};
static char szNoticeTextBuffer[NOTICE_TEXT_BUFFER_SIZE] = {0x00}; static SGUI_LIST_STRUCT s_stDemoListObject;
static char s_szNoticeTextBuffer[NOTICE_TEXT_BUFFER_SIZE] = {0x00};
//=======================================================================// //=======================================================================//
//= Global variable declaration. =// //= Global variable declaration. =//
//=======================================================================// //=======================================================================//
HMI_SCREEN_ACTION stHMI_DemoListActions = { HMI_DemoList_Initialize, HMI_SCREEN_OBJECT g_stHMIDemo_List = { HMI_SCREEN_ID_DEMO_LIST,
HMI_DemoList_Prepare, &s_stDemoListActions
HMI_DemoList_RefreshScreen, };
HMI_DemoList_ProcessEvent,
HMI_DemoList_PostProcess
};
HMI_SCREEN_OBJECT g_stHMIDemo_List = { HMI_SCREEN_ID_DEMO_LIST,
&stHMI_DemoListActions
};
//=======================================================================// //=======================================================================//
//= Function implementation. =// //= Function implementation. =//
@ -83,25 +82,23 @@ HMI_ENGINE_RESULT HMI_DemoList_Initialize(void)
/* Process */ /* Process */
/*----------------------------------*/ /*----------------------------------*/
// Initialize list data. // Initialize list data.
SGUI_Common_MemorySet(&stTestList, 0x00, sizeof(SGUI_LIST_STRUCT)); SGUI_Common_MemorySet(&s_stDemoListObject, 0x00, sizeof(SGUI_LIST_STRUCT));
stTestList.Data.Title = szListTitle; // Title and font size must set before initialize list object.
stTestList.FontSize = SGUI_FONT_SIZE_H12; s_stDemoListObject.Data.Title = s_szListTitle;
#if (_SIMPLE_GUI_ENABLE_DYNAMIC_MEMORY_ > 0) s_stDemoListObject.FontSize = SGUI_FONT_SIZE_H12;
stTestList.Data.Items = NULL; //Initialize list object.
stTestList.Data.Count = 0; SGUI_LIST_InitializeListData(&s_stDemoListObject);
#else
stTestList.Data.Items = arrstTestListItems;
stTestList.Data.Count = sizeof(arrstTestListItems)/sizeof(SGUI_LIST_ITEM);
#endif
// Initialize logical.
SGUI_LIST_InitializeListData(&stTestList);
#if (_SIMPLE_GUI_ENABLE_DYNAMIC_MEMORY_ > 0) #if (_SIMPLE_GUI_ENABLE_DYNAMIC_MEMORY_ > 0)
s_stDemoListObject.Data.Items = NULL;
s_stDemoListObject.Data.Count = 0;
// Insert list item. // Insert list item.
for(i=0; i<(sizeof(arrstTestListItems)/sizeof(SGUI_LIST_ITEM)); i++) for(i=0; i<(sizeof(s_arrstTestListItems)/sizeof(SGUI_LIST_ITEM)); i++)
{ {
SGUI_LIST_InsertItem(&stTestList, &arrstTestListItems[i], stTestList.Data.Count); SGUI_LIST_InsertItem(&s_stDemoListObject, &s_arrstTestListItems[i], s_stDemoListObject.Data.Count);
} }
#else
s_stDemoListObject.Data.Items = s_arrstTestListItems;
s_stDemoListObject.Data.Count = sizeof(s_arrstTestListItems)/sizeof(SGUI_LIST_ITEM);
#endif #endif
return HMI_RET_NORMAL; return HMI_RET_NORMAL;
} }
@ -111,13 +108,16 @@ HMI_ENGINE_RESULT HMI_DemoList_Prepare (const void* pstParameters)
/*----------------------------------*/ /*----------------------------------*/
/* Process */ /* Process */
/*----------------------------------*/ /*----------------------------------*/
SGUI_LIST_RefreshList(&stTestList); SGUI_LIST_RefreshList(&s_stDemoListObject);
return HMI_RET_NORMAL; return HMI_RET_NORMAL;
} }
HMI_ENGINE_RESULT HMI_DemoList_RefreshScreen(const void* pstParameters) HMI_ENGINE_RESULT HMI_DemoList_RefreshScreen(const void* pstParameters)
{ {
SGUI_LIST_RefreshList(&stTestList); /*----------------------------------*/
/* Process */
/*----------------------------------*/
SGUI_LIST_RefreshList(&s_stDemoListObject);
return HMI_RET_NORMAL; return HMI_RET_NORMAL;
} }
@ -158,23 +158,23 @@ HMI_ENGINE_RESULT HMI_DemoList_ProcessEvent(HMI_EVENT_TYPE eEvent, const HMI_EVE
} }
case KEY_VALUE_UP: case KEY_VALUE_UP:
{ {
SGUI_LIST_SelectUpItem(&stTestList); SGUI_LIST_SelectUpItem(&s_stDemoListObject);
break; break;
} }
case KEY_VALUE_DOWN: case KEY_VALUE_DOWN:
{ {
SGUI_LIST_SelectDownItem(&stTestList); SGUI_LIST_SelectDownItem(&s_stDemoListObject);
break; break;
} }
case KEY_VALUE_RIGHT: case KEY_VALUE_RIGHT:
{ {
if((*(parrKeyValue+0) & KEY_OPTION_SHIFT) != 0) if((*(parrKeyValue+0) & KEY_OPTION_SHIFT) != 0)
{ {
SGUI_LIST_SetListItemValue(&stTestList, stTestList.ControlVariable.SelectIndex, SGUI_LIST_GetListItemPtr(&stTestList, stTestList.ControlVariable.SelectIndex)->Valid.Value, SGUI_LIST_GetListItemPtr(&stTestList, stTestList.ControlVariable.SelectIndex)->Decimal.Value-1); SGUI_LIST_SetListItemValue(&s_stDemoListObject, s_stDemoListObject.ControlVariable.SelectIndex, SGUI_LIST_GetListItemPtr(&s_stDemoListObject, s_stDemoListObject.ControlVariable.SelectIndex)->Valid.Value, SGUI_LIST_GetListItemPtr(&s_stDemoListObject, s_stDemoListObject.ControlVariable.SelectIndex)->Decimal.Value-1);
} }
else else
{ {
SGUI_LIST_SetListItemValue(&stTestList, stTestList.ControlVariable.SelectIndex, SGUI_LIST_GetListItemPtr(&stTestList, stTestList.ControlVariable.SelectIndex)->Valid.Value+1, SGUI_LIST_GetListItemPtr(&stTestList, stTestList.ControlVariable.SelectIndex)->Decimal.Value); SGUI_LIST_SetListItemValue(&s_stDemoListObject, s_stDemoListObject.ControlVariable.SelectIndex, SGUI_LIST_GetListItemPtr(&s_stDemoListObject, s_stDemoListObject.ControlVariable.SelectIndex)->Valid.Value+1, SGUI_LIST_GetListItemPtr(&s_stDemoListObject, s_stDemoListObject.ControlVariable.SelectIndex)->Decimal.Value);
} }
break; break;
} }
@ -182,37 +182,37 @@ HMI_ENGINE_RESULT HMI_DemoList_ProcessEvent(HMI_EVENT_TYPE eEvent, const HMI_EVE
{ {
if((*(parrKeyValue+0) & KEY_OPTION_SHIFT) != 0) if((*(parrKeyValue+0) & KEY_OPTION_SHIFT) != 0)
{ {
SGUI_LIST_SetListItemValue(&stTestList, stTestList.ControlVariable.SelectIndex, SGUI_LIST_GetListItemPtr(&stTestList, stTestList.ControlVariable.SelectIndex)->Valid.Value, SGUI_LIST_GetListItemPtr(&stTestList, stTestList.ControlVariable.SelectIndex)->Decimal.Value+1); SGUI_LIST_SetListItemValue(&s_stDemoListObject, s_stDemoListObject.ControlVariable.SelectIndex, SGUI_LIST_GetListItemPtr(&s_stDemoListObject, s_stDemoListObject.ControlVariable.SelectIndex)->Valid.Value, SGUI_LIST_GetListItemPtr(&s_stDemoListObject, s_stDemoListObject.ControlVariable.SelectIndex)->Decimal.Value+1);
} }
else else
{ {
SGUI_LIST_SetListItemValue(&stTestList, stTestList.ControlVariable.SelectIndex, SGUI_LIST_GetListItemPtr(&stTestList, stTestList.ControlVariable.SelectIndex)->Valid.Value-1, SGUI_LIST_GetListItemPtr(&stTestList, stTestList.ControlVariable.SelectIndex)->Decimal.Value); SGUI_LIST_SetListItemValue(&s_stDemoListObject, s_stDemoListObject.ControlVariable.SelectIndex, SGUI_LIST_GetListItemPtr(&s_stDemoListObject, s_stDemoListObject.ControlVariable.SelectIndex)->Valid.Value-1, SGUI_LIST_GetListItemPtr(&s_stDemoListObject, s_stDemoListObject.ControlVariable.SelectIndex)->Decimal.Value);
} }
break; break;
} }
#if (_SIMPLE_GUI_ENABLE_DYNAMIC_MEMORY_ > 0) #if (_SIMPLE_GUI_ENABLE_DYNAMIC_MEMORY_ > 0)
case KEY_VALUE_F8: case KEY_VALUE_F8:
{ {
SGUI_LIST_RemoveItem(&stTestList, stTestList.ControlVariable.SelectIndex); SGUI_LIST_RemoveItem(&s_stDemoListObject, s_stDemoListObject.ControlVariable.SelectIndex);
SGUI_LIST_RefreshList(&stTestList); SGUI_LIST_RefreshList(&s_stDemoListObject);
break; break;
} }
case KEY_VALUE_F9: // Insert to head. case KEY_VALUE_F9: // Insert to head.
{ {
SGUI_LIST_InsertItem(&stTestList, &arrstAppendListItems[0], 0); SGUI_LIST_InsertItem(&s_stDemoListObject, &s_arrstAppendListItems[0], 0);
SGUI_LIST_RefreshList(&stTestList); SGUI_LIST_RefreshList(&s_stDemoListObject);
break; break;
} }
case KEY_VALUE_F10: // Insert to intermediate. case KEY_VALUE_F10: // Insert to intermediate.
{ {
SGUI_LIST_InsertItem(&stTestList, &arrstAppendListItems[1], 5); SGUI_LIST_InsertItem(&s_stDemoListObject, &s_arrstAppendListItems[1], 5);
SGUI_LIST_RefreshList(&stTestList); SGUI_LIST_RefreshList(&s_stDemoListObject);
break; break;
} }
case KEY_VALUE_F11: // Insert to end. case KEY_VALUE_F11: // Insert to end.
{ {
SGUI_LIST_InsertItem(&stTestList, &arrstAppendListItems[2], stTestList.Data.Count); SGUI_LIST_InsertItem(&s_stDemoListObject, &s_arrstAppendListItems[2], s_stDemoListObject.Data.Count);
SGUI_LIST_RefreshList(&stTestList); SGUI_LIST_RefreshList(&s_stDemoListObject);
break; break;
} }
#endif #endif
@ -235,41 +235,39 @@ HMI_ENGINE_RESULT HMI_DemoList_PostProcess(SGUI_INT iActionResult)
if(HMI_RET_CONFIRM == iActionResult) if(HMI_RET_CONFIRM == iActionResult)
{ {
uiSelectListIndex = stTestList.ControlVariable.SelectIndex; uiSelectListIndex = s_stDemoListObject.ControlVariable.SelectIndex;
switch(SGUI_LIST_GetListItemPtr(&stTestList, uiSelectListIndex)->Sign) switch(SGUI_LIST_GetListItemPtr(&s_stDemoListObject, uiSelectListIndex)->Sign)
{ {
/*
case 1: case 1:
{ {
// Show notice. // Show notice.
pstSelectedItem = SGUI_LIST_GetListItemPtr(&stTestList, uiSelectListIndex); pstSelectedItem = SGUI_LIST_GetListItemPtr(&s_stDemoListObject, uiSelectListIndex);
iListItemParameterValue = pstSelectedItem->Valid.Value; iListItemParameterValue = pstSelectedItem->Valid.Value;
if(0 == iListItemParameterValue) if(0 == iListItemParameterValue)
{ {
sprintf(szNoticeTextBuffer, "选择列表项%u.", uiSelectListIndex); sprintf(s_szNoticeTextBuffer, "选择列表项%u.", uiSelectListIndex);
HMI_Action_Goto(3, szNoticeTextBuffer); HMI_Goto(HMI_SCREEN_ID_DEMO_TEXT_NOTICE, s_szNoticeTextBuffer);
} }
else else
{ {
HMI_Action_Goto(2, NULL); HMI_Goto(HMI_SCREEN_ID_DEMO_RTC_NOTICE, NULL);
} }
break; break;
} }
*/ case 5:
case 6:
{
//HMI_Action_Goto(4, NULL);
break;
}
case 7:
{ {
HMI_Goto(HMI_SCREEN_ID_DEMO_VARIABLE_BOX, NULL); HMI_Goto(HMI_SCREEN_ID_DEMO_VARIABLE_BOX, NULL);
break; break;
} }
case 6:
{
HMI_Goto(HMI_SCREEN_ID_DEMO_REAL_TIME_GRAPH, NULL);
break;
}
default: default:
{ {
sprintf(szNoticeTextBuffer, "选择列表项%u.", uiSelectListIndex); sprintf(s_szNoticeTextBuffer, "选择列表项%u.", uiSelectListIndex);
HMI_Goto(HMI_SCREEN_ID_DEMO_TEXT_NOTICE, szNoticeTextBuffer); HMI_Goto(HMI_SCREEN_ID_DEMO_TEXT_NOTICE, s_szNoticeTextBuffer);
break; break;
} }
} }

View File

@ -1,6 +1,6 @@
/*************************************************************************/ /*************************************************************************/
/** Copyright. **/ /** Copyright. **/
/** FileName: HMI_Demo03_Notice1.c **/ /** FileName: RTCNotice.c **/
/** Author: Polarix **/ /** Author: Polarix **/
/** Version: 1.0.0.0 **/ /** Version: 1.0.0.0 **/
/** Description: HMI demo for notice box interface and refresh screen. **/ /** Description: HMI demo for notice box interface and refresh screen. **/
@ -12,52 +12,54 @@
#include "HMI_Engine.h" #include "HMI_Engine.h"
#include "SGUI_Notice.h" #include "SGUI_Notice.h"
#include "SGUI_Common.h" #include "SGUI_Common.h"
#include <stdio.h>
//=======================================================================//
//= User Macro definition. =//
//=======================================================================//
#define NOTICE_RTC_BUFFER_SIZE (64)
//=======================================================================// //=======================================================================//
//= Static function declaration. =// //= Static function declaration. =//
//=======================================================================// //=======================================================================//
static SGUI_INT HMI_DemoNotice_Initialize(void); static HMI_ENGINE_RESULT HMI_DemoRTCNotice_Initialize(void);
static SGUI_INT HMI_DemoNotice_PreProcess(const void* pstParameters); static HMI_ENGINE_RESULT HMI_DemoRTCNotice_Prepare(const void* pstParameters);
static SGUI_INT HMI_DemoNotice_RefreshScreen(void); static HMI_ENGINE_RESULT HMI_DemoRTCNotice_RefreshScreen(const void* pstParameters);
static SGUI_INT HMI_DemoNotice_OnInternalEvent(SGUI_INT uiScreenID, const void* pstParameters); static HMI_ENGINE_RESULT HMI_DemoRTCNotice_ProcessEvent(HMI_EVENT_TYPE eEventType, const HMI_EVENT* pstEvent);
static SGUI_INT HMI_DemoNotice_OnExternalEvent(SGUI_INT uiScreenID, const void* pstParameters); static HMI_ENGINE_RESULT HMI_DemoRTCNotice_PostProcess(SGUI_INT iActionResult);
static SGUI_INT HMI_DemoNotice_PostProcess(SGUI_INT iActionResult);
//=======================================================================// //=======================================================================//
//= Static variable declaration. =// //= Static variable declaration. =//
//=======================================================================// //=======================================================================//
static char szRTCNoticeText[64] = {0x00}; static char s_szRTCNoticeText[NOTICE_RTC_BUFFER_SIZE+1] = {0x00};
HMI_SCREEN_ACTION s_stDemoRTCNoticeActions = { HMI_DemoRTCNotice_Initialize,
HMI_DemoRTCNotice_Prepare,
HMI_DemoRTCNotice_RefreshScreen,
HMI_DemoRTCNotice_ProcessEvent,
HMI_DemoRTCNotice_PostProcess
};
//=======================================================================// //=======================================================================//
//= Global variable declaration. =// //= Global variable declaration. =//
//=======================================================================// //=======================================================================//
HMI_SCREEN_ACTION stHMI_DemoRTCNoticeActions = { HMI_DemoNotice_Initialize, HMI_SCREEN_OBJECT g_stHMIDemo_RTCNotice = { HMI_SCREEN_ID_DEMO_RTC_NOTICE,
HMI_DemoNotice_PreProcess, &s_stDemoRTCNoticeActions
HMI_DemoNotice_RefreshScreen,
HMI_DemoNotice_OnInternalEvent,
HMI_DemoNotice_OnExternalEvent,
HMI_DemoNotice_PostProcess,
};
HMI_SCREEN_OBJECT g_stHMI_DemoRTCNotice = { HMI_SCREEN_ID_ANY,
&stHMI_DemoRTCNoticeActions
}; };
//=======================================================================// //=======================================================================//
//= Function implementation. =// //= Function implementation. =//
//=======================================================================// //=======================================================================//
HMI_ENGINE_RESULT HMI_DemoRTCNotice_Initialize(void)
SGUI_INT HMI_DemoNotice_Initialize(void)
{ {
SGUI_Common_MemorySet(s_szRTCNoticeText, 0x00, sizeof(SGUI_CHAR)*(NOTICE_RTC_BUFFER_SIZE+1));
return HMI_RET_NORMAL; return HMI_RET_NORMAL;
} }
SGUI_INT HMI_DemoNotice_PreProcess(const void* pstParameters) HMI_ENGINE_RESULT HMI_DemoRTCNotice_Prepare(const void* pstParameters)
{ {
HMI_DemoRTCNotice_RefreshScreen(NULL);
return HMI_RET_NORMAL; return HMI_RET_NORMAL;
} }
SGUI_INT HMI_DemoNotice_RefreshScreen(void) HMI_ENGINE_RESULT HMI_DemoRTCNotice_RefreshScreen(const void* pstParameters)
{ {
/*----------------------------------*/ /*----------------------------------*/
/* Variable Declaration */ /* Variable Declaration */
@ -68,76 +70,78 @@ SGUI_INT HMI_DemoNotice_RefreshScreen(void)
/* Process */ /* Process */
/*----------------------------------*/ /*----------------------------------*/
SGUI_Common_GetNowTime(&stRTCTime); SGUI_Common_GetNowTime(&stRTCTime);
sprintf(szRTCNoticeText, "系统时间\n%04u-%02u-%02u\n%02u:%02u:%02u", sprintf(s_szRTCNoticeText, "系统时间\n%04u-%02u-%02u\n%02u:%02u:%02u",
stRTCTime.Year, stRTCTime.Month, stRTCTime.Day, stRTCTime.Year, stRTCTime.Month, stRTCTime.Day,
stRTCTime.Hour, stRTCTime.Minute, stRTCTime.Second); stRTCTime.Hour, stRTCTime.Minute, stRTCTime.Second);
SGUI_Notice_RefreshNotice(szRTCNoticeText, 0, SGUI_ICON_INFORMATION); SGUI_Notice_RefreshNotice(s_szRTCNoticeText, 0, SGUI_ICON_INFORMATION);
return HMI_RET_NORMAL; return HMI_RET_NORMAL;
} }
SGUI_INT HMI_DemoNotice_OnInternalEvent(SGUI_INT uiScreenID, const void* pstParameters) HMI_ENGINE_RESULT HMI_DemoRTCNotice_ProcessEvent(HMI_EVENT_TYPE eEventType, const HMI_EVENT* pstEvent)
{ {
/*----------------------------------*/ /*----------------------------------*/
/* Variable Declaration */ /* Variable Declaration */
/*----------------------------------*/ /*----------------------------------*/
SGUI_INT iProcessResult; HMI_ENGINE_RESULT eProcessResult;
SGUI_TIME* pstRTCTime; SGUI_UINT16* parrKeyValue;
SGUI_TIME* pstRTCTime;
/*----------------------------------*/
/* Process */
/*----------------------------------*/
pstRTCTime = (SGUI_TIME*)pstParameters;
if(NULL != pstRTCTime)
{
sprintf(szRTCNoticeText, "系统时间\n%04u-%02u-%02u\n%02u:%02u:%02u",
pstRTCTime->Year, pstRTCTime->Month+1, pstRTCTime->Day,
pstRTCTime->Hour, pstRTCTime->Minute, pstRTCTime->Second);
SGUI_Notice_RefreshNotice(szRTCNoticeText, 0, SGUI_ICON_INFORMATION);
iProcessResult = HMI_RET_NORMAL;
}
else
{
iProcessResult = HMI_RET_NOACTION;
}
return iProcessResult;
}
SGUI_INT HMI_DemoNotice_OnExternalEvent(SGUI_INT uiScreenID, const void* pstParameters)
{
/*----------------------------------*/
/* Variable Declaration */
/*----------------------------------*/
SGUI_INT iProcessResult;
USER_ACT_KEYPRESS* pstUserEvent;
/*----------------------------------*/ /*----------------------------------*/
/* Initialize */ /* Initialize */
/*----------------------------------*/ /*----------------------------------*/
iProcessResult = HMI_RET_NORMAL; eProcessResult = HMI_RET_NORMAL;
pstUserEvent = (USER_ACT_KEYPRESS*)pstParameters;
/*----------------------------------*/ /*----------------------------------*/
/* Process */ /* Process */
/*----------------------------------*/ /*----------------------------------*/
if(KEY_VALUE_ENTER == pstUserEvent->KeyValue[0]) if(NULL != pstEvent)
{ {
iProcessResult = HMI_RET_CANCEL; if(eEventType == HMI_ENGINE_EVENT_ACTION)
{
parrKeyValue = (SGUI_UINT16*)pstEvent->Data;
if(NULL != parrKeyValue)
{
switch(*(parrKeyValue+1))
{
case KEY_VALUE_ENTER:
case KEY_VALUE_ESC:
{
eProcessResult = HMI_RET_CANCEL;
break;
}
}
}
}
else if(eEventType == HMI_ENGINE_EVENT_DATA)
{
if(HMI_ENGINE_ACTION_ON_TIMER_RTC == pstEvent->Action)
{
pstRTCTime = (SGUI_TIME*)pstEvent->Data;
if(NULL != pstRTCTime)
{
sprintf(s_szRTCNoticeText, "系统时间\n%04u-%02u-%02u\n%02u:%02u:%02u",
pstRTCTime->Year, pstRTCTime->Month+1, pstRTCTime->Day,
pstRTCTime->Hour, pstRTCTime->Minute, pstRTCTime->Second);
SGUI_Notice_RefreshNotice(s_szRTCNoticeText, 0, SGUI_ICON_INFORMATION);
eProcessResult = HMI_RET_NOACTION;
}
}
}
} }
else else
{ {
iProcessResult = HMI_RET_NORMAL; eProcessResult = HMI_RET_NOACTION;
} }
return iProcessResult;
return eProcessResult;
} }
SGUI_INT HMI_DemoNotice_PostProcess(SGUI_INT iActionResult) HMI_ENGINE_RESULT HMI_DemoRTCNotice_PostProcess(SGUI_INT iActionResult)
{ {
if(HMI_RET_CANCEL == iActionResult) if(HMI_RET_CANCEL == iActionResult)
{ {
HMI_Action_GoBack(); HMI_GoBack(NULL);
} }
return HMI_RET_NORMAL; return HMI_RET_NORMAL;
} }

138
Demo/src/RealtimeGraph.c Normal file
View File

@ -0,0 +1,138 @@
/*************************************************************************/
/** Copyright. **/
/** FileName: HMI_Demo04_Graph.c **/
/** Author: Polarix **/
/** Version: 1.0.0.0 **/
/** Description: HMI demo for graph interface. **/
/*************************************************************************/
//=======================================================================//
//= Include files. =//
//=======================================================================//
#include "DemoProc.h"
#include "SGUI_RealtimeGraph.h"
//=======================================================================//
//= Static function declaration. =//
//=======================================================================//
static HMI_ENGINE_RESULT HMI_DemoRealGraph_Initialize(void);
static HMI_ENGINE_RESULT HMI_DemoRealGraph_Prepare(const void* pstParameters);
static HMI_ENGINE_RESULT HMI_DemoRealGraph_RefreshScreen(const void* pstParameters);
static HMI_ENGINE_RESULT HMI_DemoRealGraph_ProcessEvent(HMI_EVENT_TYPE eEventType, const HMI_EVENT* pstEvent);
static HMI_ENGINE_RESULT HMI_DemoRealGraph_PostProcess(SGUI_INT iActionResult);
//=======================================================================//
//= Static variable declaration. =//
//=======================================================================//
SGUI_RTGRAPH_CONTROL s_stRealtimeGraphControl = {50, -50, SGUI_TRUE, 3, 0};
SGUI_RTGRAPH_DATA s_stRealtimeGraphData = {{0}, {0}, {0}, 0, 0};
SGUI_RTGRAPH s_stRealtimeGraph = {&s_stRealtimeGraphData, &s_stRealtimeGraphControl};
//=======================================================================//
//= Global variable declaration. =//
//=======================================================================//
HMI_SCREEN_ACTION s_stDemoRealtimeGraphActions = { HMI_DemoRealGraph_Initialize,
HMI_DemoRealGraph_Prepare,
HMI_DemoRealGraph_RefreshScreen,
HMI_DemoRealGraph_ProcessEvent,
HMI_DemoRealGraph_PostProcess,
};
HMI_SCREEN_OBJECT g_stHMI_DemoRealtimeGraph = { HMI_SCREEN_ID_DEMO_REAL_TIME_GRAPH,
&s_stDemoRealtimeGraphActions
};
//=======================================================================//
//= Function implementation. =//
//=======================================================================//
HMI_ENGINE_RESULT HMI_DemoRealGraph_Initialize(void)
{
//SGUI_RealtimeGraph_Initialize(&s_stRealtimeGraph);
return HMI_RET_NORMAL;
}
HMI_ENGINE_RESULT HMI_DemoRealGraph_Prepare(const void* pstParameters)
{
SGUI_RealtimeGraph_Initialize(&s_stRealtimeGraph);
return HMI_RET_NORMAL;
}
HMI_ENGINE_RESULT HMI_DemoRealGraph_RefreshScreen(const void* pstParameters)
{
SGUI_CHAR szTextBuffer[16];
SGUI_Common_IntegerToString(s_stRealtimeGraph.Data->ValueArray[s_stRealtimeGraph.Data->ValueCount-1], szTextBuffer, 10, -15, ' ');
SGUI_RealtimeGraph_Refresh(&s_stRealtimeGraph, szTextBuffer, "Real-time graph.");
return HMI_RET_NORMAL;
}
HMI_ENGINE_RESULT HMI_DemoRealGraph_ProcessEvent(HMI_EVENT_TYPE eEventType, const HMI_EVENT* pstEvent)
{
/*----------------------------------*/
/* Variable Declaration */
/*----------------------------------*/
HMI_ENGINE_RESULT eProcessResult;
SGUI_INT iNewValue;
SGUI_UINT16* parrKeyValue;
static SGUI_UINT uiTimer = 3;
/*----------------------------------*/
/* Initialize */
/*----------------------------------*/
eProcessResult = HMI_RET_NORMAL;
/*----------------------------------*/
/* Process */
/*----------------------------------*/
if(HMI_ENGINE_EVENT_ACTION == eEventType)
{
if(NULL != pstEvent)
{
switch(pstEvent->Action)
{
case HMI_ENGINE_ACTION_KEY_PRESS:
{
parrKeyValue = (SGUI_UINT16*)pstEvent->Data;
if(KEY_VALUE_ESC == *(parrKeyValue+1))
{
eProcessResult = HMI_RET_CANCEL;
}
else
{
eProcessResult = HMI_RET_NOACTION;
}
break;
}
case HMI_ENGINE_ACTION_ON_TIMER:
{
if(uiTimer > 0)
{
uiTimer--;
}
else
{
uiTimer = 10;
iNewValue = *((SGUI_INT*)pstEvent->Data);
SGUI_RealtimeGraph_AppendValue(&s_stRealtimeGraph, iNewValue);
HMI_DemoRealGraph_RefreshScreen(NULL);
}
break;
}
default:
{
eProcessResult = HMI_RET_NOACTION;
break;
}
}
}
}
return eProcessResult;
}
HMI_ENGINE_RESULT HMI_DemoRealGraph_PostProcess(SGUI_INT iActionResult)
{
/*----------------------------------*/
/* Process */
/*----------------------------------*/
if(HMI_RET_CANCEL == iActionResult)
{
HMI_GoBack(NULL);
}
return HMI_RET_NORMAL;
}

View File

@ -1,9 +1,9 @@
/*************************************************************************/ /*************************************************************************/
/** Copyright. **/ /** Copyright. **/
/** FileName: HMI_Demo01_Text.c **/ /** FileName: ScrollingText.c **/
/** Author: Polarix **/ /** Author: Polarix **/
/** Version: 1.0.0.0 **/ /** Version: 1.0.0.0 **/
/** Description: HMI demo for list control interface. **/ /** Description: HMI demo for text draw interface. **/
/*************************************************************************/ /*************************************************************************/
//=======================================================================// //=======================================================================//
@ -13,7 +13,6 @@
#include "SGUI_Text.h" #include "SGUI_Text.h"
#include "SGUI_Frame.h" #include "SGUI_Frame.h"
#include "HMI_Engine.h" #include "HMI_Engine.h"
#include <stdio.h>
//=======================================================================// //=======================================================================//
//= User Macro definition. =// //= User Macro definition. =//
@ -42,7 +41,7 @@ static HMI_ENGINE_RESULT HMI_DemoScrollingText_PostProcess(SGUI_INT iActionRe
//= Static variable declaration. =// //= Static variable declaration. =//
//=======================================================================// //=======================================================================//
// Demo text. // Demo text.
static char szDemoText[] = static char s_szDemoText[] =
{ {
" 欢迎来到SimpleGUI演示工程本工程用于演示SimpleGUI各API的显示效果、\ " 欢迎来到SimpleGUI演示工程本工程用于演示SimpleGUI各API的显示效果、\
使SimpleGUI演示工\ 使SimpleGUI演示工\
@ -50,24 +49,27 @@ static char szDemoText[] =
" "
}; };
static int32_t m_iTextOffset; static int32_t s_iTextOffset;
static SGUI_INT m_iTextHeight; static SGUI_INT s_iTextHeight;
static SGUI_RECT_AREA m_stTextDisplayArea; static SGUI_RECT_AREA s_stTextDisplayArea;
static SGUI_BOX_FRAME_STRUCT stTextFrame = {{HMI_TEXT_DEMO_FRAME_EDGE_LAYERS, SGUI_FONT_SIZE_H12}, {NULL}}; static SGUI_BOX_FRAME_STRUCT s_stTextFrame = { {HMI_TEXT_DEMO_FRAME_EDGE_LAYERS, SGUI_FONT_SIZE_H12},
HMI_SCREEN_ACTION m_stHMIDemo_ScrollingTextActions = { {NULL}
HMI_DemoScrollingText_Initialize, };
HMI_DemoScrollingText_Prepare, static HMI_SCREEN_ACTION s_stDemoScrollingTextActions = {
HMI_DemoScrollingText_RefreshScreen, HMI_DemoScrollingText_Initialize,
HMI_DemoScrollingText_ProcessEvent, HMI_DemoScrollingText_Prepare,
HMI_DemoScrollingText_PostProcess,}; HMI_DemoScrollingText_RefreshScreen,
HMI_DemoScrollingText_ProcessEvent,
HMI_DemoScrollingText_PostProcess
};
//=======================================================================// //=======================================================================//
//= Global variable declaration. =// //= Global variable declaration. =//
//=======================================================================// //=======================================================================//
HMI_SCREEN_OBJECT g_stHMIDemo_ScrollingText = { HMI_SCREEN_OBJECT g_stHMIDemo_ScrollingText = {
HMI_SCREEN_ID_DEMO_SCROLLING_TEXT, HMI_SCREEN_ID_DEMO_SCROLLING_TEXT,
&m_stHMIDemo_ScrollingTextActions}; &s_stDemoScrollingTextActions};
//=======================================================================// //=======================================================================//
//= Function implementation. =// //= Function implementation. =//
@ -82,12 +84,12 @@ HMI_SCREEN_OBJECT g_stHMIDemo_ScrollingText = {
/*****************************************************************************/ /*****************************************************************************/
HMI_ENGINE_RESULT HMI_DemoScrollingText_Initialize(void) HMI_ENGINE_RESULT HMI_DemoScrollingText_Initialize(void)
{ {
m_iTextOffset = HMI_TEXT_DEMO_FRAME_TEXT_HEIGHT; s_iTextOffset = HMI_TEXT_DEMO_FRAME_TEXT_HEIGHT;
m_iTextHeight = SGUI_Text_GetMultiLineTextLines(szDemoText, (HMI_TEXT_DEMO_FRAME_TEXT_WIDTH/g_stFontSize[SGUI_FONT_SIZE_H12].Width))*g_stFontSize[SGUI_FONT_SIZE_H12].Height; s_iTextHeight = SGUI_Text_GetMultiLineTextLines(s_szDemoText, (HMI_TEXT_DEMO_FRAME_TEXT_WIDTH/g_stFontSize[SGUI_FONT_SIZE_H12].Width))*g_stFontSize[SGUI_FONT_SIZE_H12].Height;
m_stTextDisplayArea.PosX = HMI_TEXT_DEMO_FRAME_TEXT_POSX; s_stTextDisplayArea.PosX = HMI_TEXT_DEMO_FRAME_TEXT_POSX;
m_stTextDisplayArea.PosY = HMI_TEXT_DEMO_FRAME_TEXT_POSY; s_stTextDisplayArea.PosY = HMI_TEXT_DEMO_FRAME_TEXT_POSY;
m_stTextDisplayArea.Width = HMI_TEXT_DEMO_FRAME_TEXT_WIDTH; s_stTextDisplayArea.Width = HMI_TEXT_DEMO_FRAME_TEXT_WIDTH;
m_stTextDisplayArea.Height = HMI_TEXT_DEMO_FRAME_TEXT_HEIGHT; s_stTextDisplayArea.Height = HMI_TEXT_DEMO_FRAME_TEXT_HEIGHT;
return HMI_RET_NORMAL; return HMI_RET_NORMAL;
} }
@ -101,7 +103,7 @@ HMI_ENGINE_RESULT HMI_DemoScrollingText_Initialize(void)
/*****************************************************************************/ /*****************************************************************************/
HMI_ENGINE_RESULT HMI_DemoScrollingText_Prepare(const void* pstParameters) HMI_ENGINE_RESULT HMI_DemoScrollingText_Prepare(const void* pstParameters)
{ {
SGUI_Frame_DrawFullScreenFrame(&stTextFrame); SGUI_Frame_DrawFullScreenFrame(&s_stTextFrame);
return HMI_RET_NORMAL; return HMI_RET_NORMAL;
} }
@ -115,8 +117,8 @@ HMI_ENGINE_RESULT HMI_DemoScrollingText_Prepare(const void* pstParameters)
/*****************************************************************************/ /*****************************************************************************/
HMI_ENGINE_RESULT HMI_DemoScrollingText_RefreshScreen(const void* pstParameters) HMI_ENGINE_RESULT HMI_DemoScrollingText_RefreshScreen(const void* pstParameters)
{ {
SGUI_Frame_DrawFullScreenFrame(&stTextFrame); SGUI_Frame_DrawFullScreenFrame(&s_stTextFrame);
SGUI_Text_DrawMultipleLinesText(szDemoText, SGUI_FONT_SIZE_H12, &m_stTextDisplayArea, m_iTextOffset, GUI_DRAW_NORMAL); SGUI_Text_DrawMultipleLinesText(s_szDemoText, SGUI_FONT_SIZE_H12, &s_stTextDisplayArea, s_iTextOffset, SGUI_DRAW_NORMAL);
return HMI_RET_NORMAL; return HMI_RET_NORMAL;
} }
@ -175,16 +177,16 @@ HMI_ENGINE_RESULT HMI_DemoScrollingText_ProcessEvent(HMI_EVENT_TYPE eEventType,
} }
else else
{ {
SGUI_Text_DrawMultipleLinesText(szDemoText, SGUI_FONT_SIZE_H12, &m_stTextDisplayArea, m_iTextOffset, GUI_DRAW_NORMAL); SGUI_Text_DrawMultipleLinesText(s_szDemoText, SGUI_FONT_SIZE_H12, &s_stTextDisplayArea, s_iTextOffset, SGUI_DRAW_NORMAL);
if(m_iTextOffset + m_iTextHeight == 0) if(s_iTextOffset + s_iTextHeight == 0)
{ {
m_iTextOffset = HMI_TEXT_DEMO_FRAME_TEXT_HEIGHT; s_iTextOffset = HMI_TEXT_DEMO_FRAME_TEXT_HEIGHT;
} }
else else
{ {
m_iTextOffset--; s_iTextOffset--;
} }
uiTimer = 3; uiTimer = 2;
} }
eProcessResult = HMI_RET_NOACTION; eProcessResult = HMI_RET_NOACTION;
break; break;

View File

@ -20,64 +20,65 @@
//=======================================================================// //=======================================================================//
//= Static function declaration. =// //= Static function declaration. =//
//=======================================================================// //=======================================================================//
static HMI_ENGINE_RESULT HMI_DemoNotice_Initialize(void); static HMI_ENGINE_RESULT HMI_DemoTextNotice_Initialize(void);
static HMI_ENGINE_RESULT HMI_DemoNotice_Prepare(const void* pstParameters); static HMI_ENGINE_RESULT HMI_DemoTextNotice_Prepare(const void* pstParameters);
static HMI_ENGINE_RESULT HMI_DemoNotice_RefreshScreen(const void* pstParameters); static HMI_ENGINE_RESULT HMI_DemoTextNotice_RefreshScreen(const void* pstParameters);
static HMI_ENGINE_RESULT HMI_DemoNotice_ProcessEvent(HMI_EVENT_TYPE eEvent, const HMI_EVENT* pstEvent); static HMI_ENGINE_RESULT HMI_DemoTextNotice_ProcessEvent(HMI_EVENT_TYPE eEventType, const HMI_EVENT* pstEvent);
static HMI_ENGINE_RESULT HMI_DemoNotice_PostProcess(SGUI_INT iActionResult); static HMI_ENGINE_RESULT HMI_DemoTextNotice_PostProcess(SGUI_INT iActionResult);
//=======================================================================// //=======================================================================//
//= Static variable declaration. =// //= Static variable declaration. =//
//=======================================================================// //=======================================================================//
static SGUI_CHAR m_szDemoNoticeText[NOTICE_TEXT_BUFFER_SIZE+1] = {0x00}; static SGUI_CHAR s_szDemoNoticeText[NOTICE_TEXT_BUFFER_SIZE+1] = {0x00};
HMI_SCREEN_ACTION s_stDemoTextNoticeActions = { HMI_DemoTextNotice_Initialize,
HMI_DemoTextNotice_Prepare,
HMI_DemoTextNotice_RefreshScreen,
HMI_DemoTextNotice_ProcessEvent,
HMI_DemoTextNotice_PostProcess,
};
//=======================================================================// //=======================================================================//
//= Global variable declaration. =// //= Global variable declaration. =//
//=======================================================================// //=======================================================================//
HMI_SCREEN_ACTION stHMI_DemoTextNoticeActions = { HMI_DemoNotice_Initialize,
HMI_DemoNotice_Prepare,
HMI_DemoNotice_RefreshScreen,
HMI_DemoNotice_ProcessEvent,
HMI_DemoNotice_PostProcess,
};
HMI_SCREEN_OBJECT g_stHMIDemo_TextNotice = { HMI_SCREEN_ID_DEMO_TEXT_NOTICE, HMI_SCREEN_OBJECT g_stHMIDemo_TextNotice = { HMI_SCREEN_ID_DEMO_TEXT_NOTICE,
&stHMI_DemoTextNoticeActions &s_stDemoTextNoticeActions
}; };
//=======================================================================// //=======================================================================//
//= Function implementation. =// //= Function implementation. =//
//=======================================================================// //=======================================================================//
HMI_ENGINE_RESULT HMI_DemoNotice_Initialize(void) HMI_ENGINE_RESULT HMI_DemoTextNotice_Initialize(void)
{ {
SGUI_Common_MemorySet(m_szDemoNoticeText, 0x00, sizeof(SGUI_CHAR)*(NOTICE_TEXT_BUFFER_SIZE+1)); SGUI_Common_MemorySet(s_szDemoNoticeText, 0x00, sizeof(SGUI_CHAR)*(NOTICE_TEXT_BUFFER_SIZE+1));
return HMI_RET_NORMAL; return HMI_RET_NORMAL;
} }
HMI_ENGINE_RESULT HMI_DemoNotice_Prepare(const void* pstParameters) HMI_ENGINE_RESULT HMI_DemoTextNotice_Prepare(const void* pstParameters)
{ {
/*----------------------------------*/ /*----------------------------------*/
/* Process */ /* Process */
/*----------------------------------*/ /*----------------------------------*/
if(NULL == pstParameters) if(NULL == pstParameters)
{ {
SGUI_Common_StringLengthCopy(m_szDemoNoticeText, "无参数。", NOTICE_TEXT_BUFFER_SIZE); SGUI_Common_StringLengthCopy(s_szDemoNoticeText, "无参数。", NOTICE_TEXT_BUFFER_SIZE);
} }
else else
{ {
SGUI_Common_StringLengthCopy(m_szDemoNoticeText, (SGUI_PSZSTR)pstParameters, NOTICE_TEXT_BUFFER_SIZE); SGUI_Common_StringLengthCopy(s_szDemoNoticeText, (SGUI_PSZSTR)pstParameters, NOTICE_TEXT_BUFFER_SIZE);
m_szDemoNoticeText[NOTICE_TEXT_BUFFER_SIZE] = '\0'; s_szDemoNoticeText[NOTICE_TEXT_BUFFER_SIZE] = '\0';
} }
SGUI_Notice_RefreshNotice(m_szDemoNoticeText, 0, SGUI_ICON_INFORMATION); SGUI_Notice_RefreshNotice(s_szDemoNoticeText, 0, SGUI_ICON_INFORMATION);
return HMI_RET_NORMAL; return HMI_RET_NORMAL;
} }
HMI_ENGINE_RESULT HMI_DemoNotice_RefreshScreen(const void* pstParameters) HMI_ENGINE_RESULT HMI_DemoTextNotice_RefreshScreen(const void* pstParameters)
{ {
SGUI_Notice_RefreshNotice(m_szDemoNoticeText, 0, SGUI_ICON_INFORMATION); SGUI_Notice_RefreshNotice(s_szDemoNoticeText, 0, SGUI_ICON_INFORMATION);
return HMI_RET_NORMAL; return HMI_RET_NORMAL;
} }
HMI_ENGINE_RESULT HMI_DemoNotice_ProcessEvent(HMI_EVENT_TYPE eEventType, const HMI_EVENT* pstEvent) HMI_ENGINE_RESULT HMI_DemoTextNotice_ProcessEvent(HMI_EVENT_TYPE eEventType, const HMI_EVENT* pstEvent)
{ {
/*----------------------------------*/ /*----------------------------------*/
/* Variable Declaration */ /* Variable Declaration */
@ -105,7 +106,7 @@ HMI_ENGINE_RESULT HMI_DemoNotice_ProcessEvent(HMI_EVENT_TYPE eEventType, const H
case KEY_VALUE_ENTER: case KEY_VALUE_ENTER:
case KEY_VALUE_ESC: case KEY_VALUE_ESC:
{ {
eProcessResult = HMI_RET_CONFIRM; eProcessResult = HMI_RET_CANCEL;
break; break;
} }
} }
@ -116,12 +117,12 @@ HMI_ENGINE_RESULT HMI_DemoNotice_ProcessEvent(HMI_EVENT_TYPE eEventType, const H
return eProcessResult; return eProcessResult;
} }
HMI_ENGINE_RESULT HMI_DemoNotice_PostProcess(SGUI_INT iActionResult) HMI_ENGINE_RESULT HMI_DemoTextNotice_PostProcess(SGUI_INT iActionResult)
{ {
/*----------------------------------*/ /*----------------------------------*/
/* Process */ /* Process */
/*----------------------------------*/ /*----------------------------------*/
if(HMI_RET_CONFIRM == iActionResult) if(HMI_RET_CANCEL == iActionResult)
{ {
HMI_GoBack(NULL); HMI_GoBack(NULL);
} }

View File

@ -16,8 +16,6 @@
//=======================================================================// //=======================================================================//
//= User Macro definition. =// //= User Macro definition. =//
//=======================================================================// //=======================================================================//
#define VARIABLE_DEMO_FONT_SIZE (SGUI_FONT_SIZE_H12)
#define FRAME_TITLE_HEIGHT (g_stFontSize[SGUI_FONT_SIZE_H12].Height+2)
#define TEXT_VARIABLE_LENGTH (20) #define TEXT_VARIABLE_LENGTH (20)
#define VARIABLE_BOX_WIDTH (100) #define VARIABLE_BOX_WIDTH (100)
@ -37,34 +35,49 @@ static void HMI_DemoVariableBox_DrawFrame(SGUI_PSZSTR szTitle);
//=======================================================================// //=======================================================================//
//= Static variable declaration. =// //= Static variable declaration. =//
//=======================================================================// //=======================================================================//
static SGUI_INT_VARBOX_STRUCT stNumberVariableBox = {VARIABLE_BOX_POSX+2, VARIABLE_BOX_NUMBER_POSY+2, VARIABLE_BOX_WIDTH, SGUI_FONT_SIZE_H12, -50, 100, 0}; static SGUI_INT_VARBOX_STRUCT s_stNumberVariableBox = { VARIABLE_BOX_POSX+2,
static char arrTextVariable[TEXT_VARIABLE_LENGTH+1] = {"ABCDEFG"}; VARIABLE_BOX_NUMBER_POSY+2,
static SGUI_TEXT_VARBOX_STRUCT stTextVariableBox = {VARIABLE_BOX_POSX+2, VARIABLE_BOX_TEXT_POSY+2, VARIABLE_BOX_WIDTH, SGUI_FONT_SIZE_H16, 0, TEXT_VARIABLE_LENGTH, arrTextVariable}; VARIABLE_BOX_WIDTH,
static const char stFrameTitleDefault[] = {"数值/文本编辑演示"}; SGUI_FONT_SIZE_H12,
static const char* szFrameTitle = stFrameTitleDefault; -50,
static uint16_t uiFocusedFlag; 100,
static const char szHelpNoticeText[] = {"TAB键切换焦点编辑框。\n上下箭头调整数值。\n左右箭头调整焦点字符。\n按空格键继续。"}; 0
static uint16_t uiNeedHelp = 5; };
static SGUI_CHAR s_szTextVariableBuffer[TEXT_VARIABLE_LENGTH+1] = {"ABCDEFG"};
static SGUI_TEXT_VARBOX_STRUCT s_stTextVariableBox = { VARIABLE_BOX_POSX+2,
VARIABLE_BOX_TEXT_POSY+2,
VARIABLE_BOX_WIDTH,
SGUI_FONT_SIZE_H16,
0,
TEXT_VARIABLE_LENGTH,
s_szTextVariableBuffer,
};
static SGUI_CHAR s_szDefaultFrameTitle[] = "数值/文本编辑演示";
static SGUI_PSZSTR s_szFrameTitle = s_szDefaultFrameTitle;
static SGUI_INT s_uiFocusedFlag;
static SGUI_PCSZSTR s_szHelpNoticeText = "TAB键切换焦点编辑框。\n上下箭头调整数值。\n左右箭头调整焦点字符。\n按空格键继续。";
static SGUI_INT s_uiAutoConfirmTimer = 5;
HMI_SCREEN_ACTION s_stDemoVariableBoxActions = {
HMI_DemoVariableBox_Initialize,
HMI_DemoVariableBox_Prepare,
HMI_DemoVariableBox_RefreshScreen,
HMI_DemoVariableBox_ProcessEvent,
HMI_DemoVariableBox_PostProcess,
};
//=======================================================================// //=======================================================================//
//= Global variable declaration. =// //= Global variable declaration. =//
//=======================================================================// //=======================================================================//
HMI_SCREEN_ACTION stHMI_DemoVariableBoxActions = {HMI_DemoVariableBox_Initialize, HMI_SCREEN_OBJECT g_stHMIDemo_VariableBox = { HMI_SCREEN_ID_DEMO_VARIABLE_BOX,
HMI_DemoVariableBox_Prepare, &s_stDemoVariableBoxActions
HMI_DemoVariableBox_RefreshScreen, };
HMI_DemoVariableBox_ProcessEvent,
HMI_DemoVariableBox_PostProcess,
};
HMI_SCREEN_OBJECT g_stHMIDemo_VariableBox = { HMI_SCREEN_ID_DEMO_VARIABLE_BOX,
&stHMI_DemoVariableBoxActions
};
//=======================================================================// //=======================================================================//
//= Function implementation. =// //= Function implementation. =//
//=======================================================================// //=======================================================================//
HMI_ENGINE_RESULT HMI_DemoVariableBox_Initialize(void) HMI_ENGINE_RESULT HMI_DemoVariableBox_Initialize(void)
{ {
uiFocusedFlag = 0; s_uiFocusedFlag = 0;
return HMI_RET_NORMAL; return HMI_RET_NORMAL;
} }
@ -74,9 +87,10 @@ HMI_ENGINE_RESULT HMI_DemoVariableBox_Prepare(const void* pstParameters)
/* Process */ /* Process */
/*----------------------------------*/ /*----------------------------------*/
// Draw frame // Draw frame
HMI_DemoVariableBox_DrawFrame((SGUI_PSZSTR)szFrameTitle); s_szFrameTitle = s_szDefaultFrameTitle;
HMI_DemoVariableBox_DrawFrame((SGUI_PSZSTR)s_szFrameTitle);
// Show notice // Show notice
SGUI_Notice_RefreshNotice(szHelpNoticeText, 0, SGUI_ICON_INFORMATION); SGUI_Notice_RefreshNotice(s_szHelpNoticeText, 0, SGUI_ICON_INFORMATION);
return HMI_RET_NORMAL; return HMI_RET_NORMAL;
} }
@ -86,13 +100,13 @@ HMI_ENGINE_RESULT HMI_DemoVariableBox_RefreshScreen(const void* pstParameters)
/* Process */ /* Process */
/*----------------------------------*/ /*----------------------------------*/
// Draw frame // Draw frame
HMI_DemoVariableBox_DrawFrame((SGUI_PSZSTR)szFrameTitle); HMI_DemoVariableBox_DrawFrame((SGUI_PSZSTR)s_szFrameTitle);
// Draw number box // Draw number box
SGUI_Basic_DrawRectangle(VARIABLE_BOX_POSX, VARIABLE_BOX_NUMBER_POSY, VARIABLE_BOX_WIDTH+4, g_stFontSize[stNumberVariableBox.FontSize].Height+6, GUI_COLOR_FRGCLR, GUI_COLOR_BKGCLR); SGUI_Basic_DrawRectangle(VARIABLE_BOX_POSX, VARIABLE_BOX_NUMBER_POSY, VARIABLE_BOX_WIDTH+4, g_stFontSize[s_stNumberVariableBox.FontSize].Height+6, SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR);
SGUI_IntegerVariableBox_Refresh(&stNumberVariableBox, SGUI_CENTER, (0 == uiFocusedFlag)?GUI_DRAW_REVERSE:GUI_DRAW_NORMAL); SGUI_IntegerVariableBox_Refresh(&s_stNumberVariableBox, SGUI_CENTER, (0 == s_uiFocusedFlag)?SGUI_DRAW_REVERSE:SGUI_DRAW_NORMAL);
// Draw text box // Draw text box
SGUI_Basic_DrawRectangle(VARIABLE_BOX_POSX, VARIABLE_BOX_TEXT_POSY, VARIABLE_BOX_WIDTH+4, g_stFontSize[stTextVariableBox.FontSize].Height+6, GUI_COLOR_FRGCLR, GUI_COLOR_BKGCLR); SGUI_Basic_DrawRectangle(VARIABLE_BOX_POSX, VARIABLE_BOX_TEXT_POSY, VARIABLE_BOX_WIDTH+4, g_stFontSize[s_stTextVariableBox.FontSize].Height+6, SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR);
SGUI_TextVariableBox_Refresh(&stTextVariableBox, (0 == uiFocusedFlag)?GUI_DRAW_NORMAL:GUI_DRAW_REVERSE); SGUI_TextVariableBox_Refresh(&s_stTextVariableBox, (0 == s_uiFocusedFlag)?SGUI_DRAW_NORMAL:SGUI_DRAW_REVERSE);
return HMI_RET_NORMAL; return HMI_RET_NORMAL;
} }
@ -113,7 +127,7 @@ HMI_ENGINE_RESULT HMI_DemoVariableBox_ProcessEvent(HMI_EVENT_TYPE eEventType, co
/*----------------------------------*/ /*----------------------------------*/
/* Process */ /* Process */
/*----------------------------------*/ /*----------------------------------*/
if(uiNeedHelp > 0) if(s_uiAutoConfirmTimer > 0)
{ {
if(NULL != pstEvent) if(NULL != pstEvent)
{ {
@ -128,7 +142,7 @@ HMI_ENGINE_RESULT HMI_DemoVariableBox_ProcessEvent(HMI_EVENT_TYPE eEventType, co
if(KEY_VALUE_SPACE == *(parrKeyValue+1)) if(KEY_VALUE_SPACE == *(parrKeyValue+1))
{ {
// Stop count down when press space. // Stop count down when press space.
uiNeedHelp = 0; s_uiAutoConfirmTimer = 0;
} }
} }
} }
@ -138,13 +152,13 @@ HMI_ENGINE_RESULT HMI_DemoVariableBox_ProcessEvent(HMI_EVENT_TYPE eEventType, co
if(HMI_ENGINE_ACTION_ON_TIMER_RTC == pstEvent->Action) if(HMI_ENGINE_ACTION_ON_TIMER_RTC == pstEvent->Action)
{ {
//Count down five seconds //Count down five seconds
uiNeedHelp--; s_uiAutoConfirmTimer--;
} }
} }
} }
// Redraw screen if time out. // Redraw screen if time out.
if(0 == uiNeedHelp) if(0 == s_uiAutoConfirmTimer)
{ {
eProcessResult = HMI_DemoVariableBox_RefreshScreen(NULL); eProcessResult = HMI_DemoVariableBox_RefreshScreen(NULL);
} }
@ -162,16 +176,16 @@ HMI_ENGINE_RESULT HMI_DemoVariableBox_ProcessEvent(HMI_EVENT_TYPE eEventType, co
{ {
case KEY_VALUE_TAB: case KEY_VALUE_TAB:
{ {
uiFocusedFlag = ((uiFocusedFlag+1)%2); s_uiFocusedFlag = ((s_uiFocusedFlag+1)%2);
if(0 == uiFocusedFlag) if(0 == s_uiFocusedFlag)
{ {
SGUI_IntegerVariableBox_Refresh(&stNumberVariableBox, SGUI_CENTER, GUI_DRAW_REVERSE); SGUI_IntegerVariableBox_Refresh(&s_stNumberVariableBox, SGUI_CENTER, SGUI_DRAW_REVERSE);
SGUI_TextVariableBox_Refresh(&stTextVariableBox, GUI_DRAW_NORMAL); SGUI_TextVariableBox_Refresh(&s_stTextVariableBox, SGUI_DRAW_NORMAL);
} }
else else
{ {
SGUI_IntegerVariableBox_Refresh(&stNumberVariableBox, SGUI_CENTER, GUI_DRAW_NORMAL); SGUI_IntegerVariableBox_Refresh(&s_stNumberVariableBox, SGUI_CENTER, SGUI_DRAW_NORMAL);
SGUI_TextVariableBox_Refresh(&stTextVariableBox, GUI_DRAW_REVERSE); SGUI_TextVariableBox_Refresh(&s_stTextVariableBox, SGUI_DRAW_REVERSE);
} }
eProcessResult = HMI_RET_NOACTION; eProcessResult = HMI_RET_NOACTION;
break; break;
@ -183,12 +197,12 @@ HMI_ENGINE_RESULT HMI_DemoVariableBox_ProcessEvent(HMI_EVENT_TYPE eEventType, co
} }
case KEY_VALUE_LEFT: case KEY_VALUE_LEFT:
{ {
if(1 == uiFocusedFlag) if(1 == s_uiFocusedFlag)
{ {
if(stTextVariableBox.FocusIndex > 0) if(s_stTextVariableBox.FocusIndex > 0)
{ {
stTextVariableBox.FocusIndex--; s_stTextVariableBox.FocusIndex--;
SGUI_TextVariableBox_ChangeCharacter(&stTextVariableBox, GUI_DRAW_REVERSE, GUI_TEXT_ASCII, SGUI_TXT_VARBOX_OPT_NONE); SGUI_TextVariableBox_ChangeCharacter(&s_stTextVariableBox, SGUI_DRAW_REVERSE, GUI_TEXT_ASCII, SGUI_TXT_VARBOX_OPT_NONE);
} }
} }
eProcessResult = HMI_RET_NOACTION; eProcessResult = HMI_RET_NOACTION;
@ -196,26 +210,26 @@ HMI_ENGINE_RESULT HMI_DemoVariableBox_ProcessEvent(HMI_EVENT_TYPE eEventType, co
} }
case KEY_VALUE_UP: case KEY_VALUE_UP:
{ {
if(1 == uiFocusedFlag) if(1 == s_uiFocusedFlag)
{ {
SGUI_TextVariableBox_ChangeCharacter(&stTextVariableBox, GUI_DRAW_REVERSE, GUI_TEXT_ASCII, SGUI_TXT_VARBOX_OPT_PREV); SGUI_TextVariableBox_ChangeCharacter(&s_stTextVariableBox, SGUI_DRAW_REVERSE, GUI_TEXT_ASCII, SGUI_TXT_VARBOX_OPT_PREV);
} }
else else
{ {
stNumberVariableBox.Value++; s_stNumberVariableBox.Value++;
SGUI_IntegerVariableBox_Refresh(&stNumberVariableBox, SGUI_CENTER, GUI_DRAW_REVERSE); SGUI_IntegerVariableBox_Refresh(&s_stNumberVariableBox, SGUI_CENTER, SGUI_DRAW_REVERSE);
} }
eProcessResult = HMI_RET_NOACTION; eProcessResult = HMI_RET_NOACTION;
break; break;
} }
case KEY_VALUE_RIGHT: case KEY_VALUE_RIGHT:
{ {
if(1 == uiFocusedFlag) if(1 == s_uiFocusedFlag)
{ {
if(stTextVariableBox.FocusIndex < (stTextVariableBox.MaxTextLength-1)) if(s_stTextVariableBox.FocusIndex < (s_stTextVariableBox.MaxTextLength-1))
{ {
stTextVariableBox.FocusIndex++; s_stTextVariableBox.FocusIndex++;
SGUI_TextVariableBox_ChangeCharacter(&stTextVariableBox, GUI_DRAW_REVERSE, GUI_TEXT_ASCII, SGUI_TXT_VARBOX_OPT_NONE); SGUI_TextVariableBox_ChangeCharacter(&s_stTextVariableBox, SGUI_DRAW_REVERSE, GUI_TEXT_ASCII, SGUI_TXT_VARBOX_OPT_NONE);
} }
} }
eProcessResult = HMI_RET_NOACTION; eProcessResult = HMI_RET_NOACTION;
@ -223,30 +237,30 @@ HMI_ENGINE_RESULT HMI_DemoVariableBox_ProcessEvent(HMI_EVENT_TYPE eEventType, co
} }
case KEY_VALUE_DOWN: case KEY_VALUE_DOWN:
{ {
if(1 == uiFocusedFlag) if(1 == s_uiFocusedFlag)
{ {
SGUI_TextVariableBox_ChangeCharacter(&stTextVariableBox, GUI_DRAW_REVERSE, GUI_TEXT_ASCII, SGUI_TXT_VARBOX_OPT_NEXT); SGUI_TextVariableBox_ChangeCharacter(&s_stTextVariableBox, SGUI_DRAW_REVERSE, GUI_TEXT_ASCII, SGUI_TXT_VARBOX_OPT_NEXT);
} }
else else
{ {
stNumberVariableBox.Value--; s_stNumberVariableBox.Value--;
SGUI_IntegerVariableBox_Refresh(&stNumberVariableBox, SGUI_CENTER, GUI_DRAW_REVERSE); SGUI_IntegerVariableBox_Refresh(&s_stNumberVariableBox, SGUI_CENTER, SGUI_DRAW_REVERSE);
} }
eProcessResult = HMI_RET_NOACTION; eProcessResult = HMI_RET_NOACTION;
break; break;
} }
case KEY_VALUE_ENTER: case KEY_VALUE_ENTER:
{ {
if(1 == uiFocusedFlag) if(1 == s_uiFocusedFlag)
{ {
szFrameTitle = stTextVariableBox.Value; s_szFrameTitle = s_stTextVariableBox.Value;
HMI_DemoVariableBox_DrawFrame((SGUI_PSZSTR)szFrameTitle); HMI_DemoVariableBox_DrawFrame((SGUI_PSZSTR)s_szFrameTitle);
// Draw number box // Draw number box
SGUI_Basic_DrawRectangle(VARIABLE_BOX_POSX, VARIABLE_BOX_NUMBER_POSY, VARIABLE_BOX_WIDTH+4, g_stFontSize[stNumberVariableBox.FontSize].Height+6, GUI_COLOR_FRGCLR, GUI_COLOR_BKGCLR); SGUI_Basic_DrawRectangle(VARIABLE_BOX_POSX, VARIABLE_BOX_NUMBER_POSY, VARIABLE_BOX_WIDTH+4, g_stFontSize[s_stNumberVariableBox.FontSize].Height+6, SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR);
SGUI_IntegerVariableBox_Refresh(&stNumberVariableBox, SGUI_CENTER, GUI_DRAW_NORMAL); SGUI_IntegerVariableBox_Refresh(&s_stNumberVariableBox, SGUI_CENTER, SGUI_DRAW_NORMAL);
// Draw text box // Draw text box
SGUI_Basic_DrawRectangle(VARIABLE_BOX_POSX, VARIABLE_BOX_TEXT_POSY, VARIABLE_BOX_WIDTH+4, g_stFontSize[stTextVariableBox.FontSize].Height+6, GUI_COLOR_FRGCLR, GUI_COLOR_BKGCLR); SGUI_Basic_DrawRectangle(VARIABLE_BOX_POSX, VARIABLE_BOX_TEXT_POSY, VARIABLE_BOX_WIDTH+4, g_stFontSize[s_stTextVariableBox.FontSize].Height+6, SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR);
SGUI_TextVariableBox_Refresh(&stTextVariableBox, GUI_DRAW_REVERSE); SGUI_TextVariableBox_Refresh(&s_stTextVariableBox, SGUI_DRAW_REVERSE);
} }
break; break;
} }
@ -267,7 +281,7 @@ SGUI_INT HMI_DemoVariableBox_PostProcess(SGUI_INT iActionResult)
{ {
if(HMI_RET_CANCEL == iActionResult) if(HMI_RET_CANCEL == iActionResult)
{ {
uiNeedHelp = 5; s_uiAutoConfirmTimer = 5;
HMI_GoBack(NULL); HMI_GoBack(NULL);
} }
return HMI_RET_NORMAL; return HMI_RET_NORMAL;

View File

@ -6,7 +6,7 @@
#define LCD_DISPLAY_EDGE (2) #define LCD_DISPLAY_EDGE (2)
#define LCD_PIXSIZE (2) #define LCD_PIXSIZE (2)
#define LCD_SIZE_WIDTH (128) #define LCD_SIZE_WIDTH (192)
#define LCD_SIZE_HEIGHT (64) #define LCD_SIZE_HEIGHT (64)
#define LCD_COLOR_OBJ_PIX (wxColor(88,120,20)) #define LCD_COLOR_OBJ_PIX (wxColor(88,120,20))
#define LCD_COLOR_OBJ_BKG (wxColor(202,246,22)) #define LCD_COLOR_OBJ_BKG (wxColor(202,246,22))

View File

@ -11,15 +11,15 @@
//=======================================================================// //=======================================================================//
typedef enum typedef enum
{ {
GUI_COLOR_BKGCLR = 0, SGUI_COLOR_BKGCLR = 0,
GUI_COLOR_FRGCLR = 1, SGUI_COLOR_FRGCLR = 1,
GUI_COLOR_TRANS = 2, SGUI_COLOR_TRANS = 2,
}SGUI_COLOR; }SGUI_COLOR;
typedef enum typedef enum
{ {
GUI_DRAW_NORMAL = 0, SGUI_DRAW_NORMAL = 0,
GUI_DRAW_REVERSE = 1, SGUI_DRAW_REVERSE = 1,
}SGUI_DRAW_MODE; }SGUI_DRAW_MODE;
//=======================================================================// //=======================================================================//

View File

@ -20,6 +20,7 @@
#define SGUI_ISHEXDIGIT(C) ((((C>='A')&&(C<='F'))||((C>='a')&&(C<='f'))||((C>='0')&&(C<='9')))?true:false) #define SGUI_ISHEXDIGIT(C) ((((C>='A')&&(C<='F'))||((C>='a')&&(C<='f'))||((C>='0')&&(C<='9')))?true:false)
#define SGUI_ISUPPER(C) (((C>='A')&&(C<='Z'))?true:false) #define SGUI_ISUPPER(C) (((C>='A')&&(C<='Z'))?true:false)
#define SGUI_TOUPPER(C) (SGUI_ISUPPER(C)?(C):(C-32)) #define SGUI_TOUPPER(C) (SGUI_ISUPPER(C)?(C):(C-32))
#define SGUI_SWAP(A, B) {A=A^B; B=A^B; A=A^B;}
//=======================================================================// //=======================================================================//
//= Public variable declaration. =// //= Public variable declaration. =//

View File

@ -0,0 +1,43 @@
#ifndef __INCLUDE_GUI_REAL_GRAPH_H__
#define __INCLUDE_GUI_REAL_GRAPH_H__
//=======================================================================//
//= Include files. =//
//=======================================================================//
#include "SGUI_Config.h"
#include "SGUI_Common.h"
#include "SGUI_Basic.h"
//=======================================================================//
//= Data type definition. =//
//=======================================================================//
typedef struct
{
SGUI_INT yAxisMax;
SGUI_INT yAxisMin;
SGUI_BOOL EnableBaseline;
SGUI_INT xAxisStepPixel;
SGUI_INT ValueArea;
}SGUI_RTGRAPH_CONTROL;
typedef struct
{
SGUI_INT ValueArray[LCD_SIZE_WIDTH];
SGUI_INT LimitedValueArray[LCD_SIZE_WIDTH];
SGUI_INT PointYCoordinateArray[LCD_SIZE_WIDTH];
SGUI_INT ZeroPointValue;
SGUI_INT ValueCount;
}SGUI_RTGRAPH_DATA;
typedef struct
{
SGUI_RTGRAPH_DATA* Data;
SGUI_RTGRAPH_CONTROL* Control;
}SGUI_RTGRAPH;
//=======================================================================//
//= Public function declaration. =//
//=======================================================================//
void SGUI_RealtimeGraph_Initialize(SGUI_RTGRAPH* pstRTGraph);
void SGUI_RealtimeGraph_Refresh(SGUI_RTGRAPH* pstRTGraph, SGUI_PCSZSTR szTopText, SGUI_PCSZSTR szBottomText);
void SGUI_RealtimeGraph_AppendValue(SGUI_RTGRAPH* pstRTGraph, SGUI_INT iNewValue);
#endif // __INCLUDE_GUI_REAL_GRAPH_H__

View File

@ -160,7 +160,7 @@ void SGUI_Basic_DrawPoint(SGUI_UINT uiCoordinateX, SGUI_UINT uiCoordinateY, SGUI
/*----------------------------------*/ /*----------------------------------*/
if((uiCoordinateX < LCD_SIZE_WIDTH) && (uiCoordinateY < LCD_SIZE_HEIGHT)) if((uiCoordinateX < LCD_SIZE_WIDTH) && (uiCoordinateY < LCD_SIZE_HEIGHT))
{ {
if(GUI_COLOR_FRGCLR == eColor) if(SGUI_COLOR_FRGCLR == eColor)
{ {
#if (_SIMPLE_GUI_VIRTUAL_ENVIRONMENT_SIMULATOR_ > 0) #if (_SIMPLE_GUI_VIRTUAL_ENVIRONMENT_SIMULATOR_ > 0)
VTIF_SetPoint(uiCoordinateX, uiCoordinateY, 1); VTIF_SetPoint(uiCoordinateX, uiCoordinateY, 1);
@ -168,7 +168,7 @@ void SGUI_Basic_DrawPoint(SGUI_UINT uiCoordinateX, SGUI_UINT uiCoordinateY, SGUI
// Call draw pix interface here. // Call draw pix interface here.
#endif //_SIMPLE_GUI_ENABLE_SIMULATOR_ #endif //_SIMPLE_GUI_ENABLE_SIMULATOR_
} }
else if(GUI_COLOR_BKGCLR == eColor) else if(SGUI_COLOR_BKGCLR == eColor)
{ {
#if (_SIMPLE_GUI_VIRTUAL_ENVIRONMENT_SIMULATOR_ > 0) #if (_SIMPLE_GUI_VIRTUAL_ENVIRONMENT_SIMULATOR_ > 0)
VTIF_SetPoint(uiCoordinateX, uiCoordinateY, 0); VTIF_SetPoint(uiCoordinateX, uiCoordinateY, 0);
@ -199,7 +199,7 @@ SGUI_COLOR SGUI_Basic_GetPoint(SGUI_UINT uiCoordinateX, SGUI_UINT uiCoordinateY)
/*----------------------------------*/ /*----------------------------------*/
/* Initialize */ /* Initialize */
/*----------------------------------*/ /*----------------------------------*/
eColor = GUI_COLOR_BKGCLR; eColor = SGUI_COLOR_BKGCLR;
uiPixValue = 0; uiPixValue = 0;
/*----------------------------------*/ /*----------------------------------*/
@ -214,11 +214,11 @@ SGUI_COLOR SGUI_Basic_GetPoint(SGUI_UINT uiCoordinateX, SGUI_UINT uiCoordinateY)
#endif //_SIMPLE_GUI_ENABLE_SIMULATOR_ #endif //_SIMPLE_GUI_ENABLE_SIMULATOR_
if(0 == uiPixValue) if(0 == uiPixValue)
{ {
eColor = GUI_COLOR_BKGCLR; eColor = SGUI_COLOR_BKGCLR;
} }
else else
{ {
eColor = GUI_COLOR_FRGCLR; eColor = SGUI_COLOR_FRGCLR;
} }
} }
@ -387,7 +387,7 @@ void SGUI_Basic_DrawRectangle(SGUI_UINT uiStartX, SGUI_UINT uiStartY, SGUI_UINT
SGUI_Basic_DrawLine(uiStartX, uiStartY, uiStartX+uiWidth-1, uiStartY, eEdgeColor); SGUI_Basic_DrawLine(uiStartX, uiStartY, uiStartX+uiWidth-1, uiStartY, eEdgeColor);
SGUI_Basic_DrawLine(uiStartX, uiStartY+uiHeight-1, uiStartX+uiWidth-1, uiStartY+uiHeight-1, eEdgeColor); SGUI_Basic_DrawLine(uiStartX, uiStartY+uiHeight-1, uiStartX+uiWidth-1, uiStartY+uiHeight-1, eEdgeColor);
// Fill area. // Fill area.
if((eFillColor != GUI_COLOR_TRANS) && (uiWidth > 2) && (uiHeight > 2)) if((eFillColor != SGUI_COLOR_TRANS) && (uiWidth > 2) && (uiHeight > 2))
{ {
for(uiColumnIndex=(uiStartX+1); uiColumnIndex<(uiStartX+uiWidth-1); uiColumnIndex++) for(uiColumnIndex=(uiStartX+1); uiColumnIndex<(uiStartX+uiWidth-1); uiColumnIndex++)
{ {
@ -444,7 +444,7 @@ void SGUI_Basic_DrawCircle(SGUI_UINT uiCx, SGUI_UINT uiCy, SGUI_UINT uiRadius, S
if((uiPosXOffset_Old != uiPosXOffset) || (uiPosYOffset_Old != uiPosYOffset) ) if((uiPosXOffset_Old != uiPosXOffset) || (uiPosYOffset_Old != uiPosYOffset) )
{ {
// Fill the circle // Fill the circle
if((uiRadius > 1) && (eFillColor != GUI_COLOR_TRANS) && (uiPosXOffset_Old != uiPosXOffset)) if((uiRadius > 1) && (eFillColor != SGUI_COLOR_TRANS) && (uiPosXOffset_Old != uiPosXOffset))
{ {
SGUI_Basic_DrawLine(uiCx-uiPosXOffset, uiCy-uiPosYOffset+1, uiCx-uiPosXOffset, uiCy+uiPosYOffset-1, eFillColor); SGUI_Basic_DrawLine(uiCx-uiPosXOffset, uiCy-uiPosYOffset+1, uiCx-uiPosXOffset, uiCy+uiPosYOffset-1, eFillColor);
@ -503,13 +503,13 @@ void SGUI_Basic_ReverseBlockColor(SGUI_UINT uiStartX, SGUI_UINT uiStartY, SGUI_U
{ {
for(i_H=0; i_H<uiHeight; i_H++) for(i_H=0; i_H<uiHeight; i_H++)
{ {
if(SGUI_Basic_GetPoint(uiStartX+i_W, uiStartY+i_H) == GUI_COLOR_FRGCLR) if(SGUI_Basic_GetPoint(uiStartX+i_W, uiStartY+i_H) == SGUI_COLOR_FRGCLR)
{ {
SGUI_Basic_DrawPoint(uiStartX+i_W, uiStartY+i_H, GUI_COLOR_BKGCLR); SGUI_Basic_DrawPoint(uiStartX+i_W, uiStartY+i_H, SGUI_COLOR_BKGCLR);
} }
else else
{ {
SGUI_Basic_DrawPoint(uiStartX+i_W, uiStartY+i_H, GUI_COLOR_FRGCLR); SGUI_Basic_DrawPoint(uiStartX+i_W, uiStartY+i_H, SGUI_COLOR_FRGCLR);
} }
} }
} }
@ -607,11 +607,11 @@ void SGUI_Basic_DrawBitMap(SGUI_RECT_AREA* pstDisplayArea, SGUI_RECT_AREA* pstDa
} }
if(GET_BIT(*pData, uiPixIndex) != eDrawMode) if(GET_BIT(*pData, uiPixIndex) != eDrawMode)
{ {
SGUI_Basic_DrawPoint(iDrawPixX, iDrawPixY, GUI_COLOR_FRGCLR); SGUI_Basic_DrawPoint(iDrawPixX, iDrawPixY, SGUI_COLOR_FRGCLR);
} }
else else
{ {
SGUI_Basic_DrawPoint(iDrawPixX, iDrawPixY, GUI_COLOR_BKGCLR); SGUI_Basic_DrawPoint(iDrawPixX, iDrawPixY, SGUI_COLOR_BKGCLR);
} }
uiDrawnHeightIndex ++; uiDrawnHeightIndex ++;
uiPixIndex ++; uiPixIndex ++;

View File

@ -56,7 +56,7 @@ void SGUI_Frame_DrawFullScreenFrame(SGUI_BOX_FRAME_STRUCT* pstFrameData)
{ {
SGUI_Basic_DrawRectangle( uiEdgeRectanglePosX, uiEdgeRectanglePosY, SGUI_Basic_DrawRectangle( uiEdgeRectanglePosX, uiEdgeRectanglePosY,
uiEdgeRectangleWidth, uiEdgeRectangleHeight, uiEdgeRectangleWidth, uiEdgeRectangleHeight,
GUI_COLOR_FRGCLR, GUI_COLOR_BKGCLR); SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR);
uiEdgeRectanglePosX += 2; uiEdgeRectanglePosX += 2;
uiEdgeRectanglePosY += 2; uiEdgeRectanglePosY += 2;
uiEdgeRectangleWidth -= 4; uiEdgeRectangleWidth -= 4;
@ -70,7 +70,7 @@ void SGUI_Frame_DrawFullScreenFrame(SGUI_BOX_FRAME_STRUCT* pstFrameData)
{ {
SGUI_Basic_DrawLine((pstFrameData->Parameter.EdgeLayers*2-1), (pstFrameData->Parameter.EdgeLayers*2-1+uiTitleLineWidth), SGUI_Basic_DrawLine((pstFrameData->Parameter.EdgeLayers*2-1), (pstFrameData->Parameter.EdgeLayers*2-1+uiTitleLineWidth),
LCD_SIZE_WIDTH-pstFrameData->Parameter.EdgeLayers*2, (pstFrameData->Parameter.EdgeLayers*2-1+uiTitleLineWidth), LCD_SIZE_WIDTH-pstFrameData->Parameter.EdgeLayers*2, (pstFrameData->Parameter.EdgeLayers*2-1+uiTitleLineWidth),
GUI_COLOR_FRGCLR); SGUI_COLOR_FRGCLR);
stTitleTextDisplayArea.PosX = pstFrameData->Parameter.EdgeLayers*2; stTitleTextDisplayArea.PosX = pstFrameData->Parameter.EdgeLayers*2;
stTitleTextDisplayArea.PosY = pstFrameData->Parameter.EdgeLayers*2; stTitleTextDisplayArea.PosY = pstFrameData->Parameter.EdgeLayers*2;
stTitleTextDisplayArea.Width = LCD_SIZE_WIDTH-pstFrameData->Parameter.EdgeLayers*4; stTitleTextDisplayArea.Width = LCD_SIZE_WIDTH-pstFrameData->Parameter.EdgeLayers*4;
@ -80,14 +80,14 @@ void SGUI_Frame_DrawFullScreenFrame(SGUI_BOX_FRAME_STRUCT* pstFrameData)
{ {
SGUI_Basic_DrawLine( 0, (pstFrameData->Parameter.EdgeLayers*2+uiTitleLineWidth), SGUI_Basic_DrawLine( 0, (pstFrameData->Parameter.EdgeLayers*2+uiTitleLineWidth),
LCD_SIZE_WIDTH-1, (pstFrameData->Parameter.EdgeLayers*2+uiTitleLineWidth), LCD_SIZE_WIDTH-1, (pstFrameData->Parameter.EdgeLayers*2+uiTitleLineWidth),
GUI_COLOR_FRGCLR); SGUI_COLOR_FRGCLR);
stTitleTextDisplayArea.PosX = 1; stTitleTextDisplayArea.PosX = 1;
stTitleTextDisplayArea.PosY = 1; stTitleTextDisplayArea.PosY = 1;
stTitleTextDisplayArea.Width = LCD_SIZE_WIDTH-2; stTitleTextDisplayArea.Width = LCD_SIZE_WIDTH-2;
stTitleTextDisplayArea.Height = g_stFontSize[pstFrameData->Parameter.FontSize].Height; stTitleTextDisplayArea.Height = g_stFontSize[pstFrameData->Parameter.FontSize].Height;
} }
SGUI_Text_DrawSingleLineText( pstFrameData->Data.Title, pstFrameData->Parameter.FontSize, SGUI_Text_DrawSingleLineText( pstFrameData->Data.Title, pstFrameData->Parameter.FontSize,
&stTitleTextDisplayArea, &stTitleTextDataArea, GUI_DRAW_NORMAL); &stTitleTextDisplayArea, &stTitleTextDataArea, SGUI_DRAW_NORMAL);
} }
} }
} }

View File

@ -70,14 +70,12 @@ void SGUI_LIST_InitializeListData(SGUI_LIST_STRUCT* pstList)
/*----------------------------------*/ /*----------------------------------*/
if(NULL != pstList) if(NULL != pstList)
{ {
// Initialize member object pointer.
pstListControl = &(pstList->ControlVariable); pstListControl = &(pstList->ControlVariable);
pstListData = &(pstList->Data); pstListData = &(pstList->Data);
pstSubElement = &(pstList->SubElement); pstSubElement = &(pstList->SubElement);
#if (_SIMPLE_GUI_ENABLE_DYNAMIC_MEMORY_ > 0) // Initialize visible area control parameter.
pstListData->Count = 0; pstListControl->ListTitleHeight = LIST_TITLE_HEIGHT(pstList->FontSize); // List title height, Include border.
pstListData->Items = NULL;
#endif
pstListControl->ListTitleHeight = LIST_TITLE_HEIGHT(pstList->FontSize);
pstListControl->PageStartIndex = 0; pstListControl->PageStartIndex = 0;
pstListControl->SelectIndex = 0; pstListControl->SelectIndex = 0;
pstListControl->ItemPosYOffSet = 0; pstListControl->ItemPosYOffSet = 0;
@ -96,6 +94,7 @@ void SGUI_LIST_InitializeListData(SGUI_LIST_STRUCT* pstList)
} }
pstListControl->VisibleItemsNum = (pstListControl->VisibleItemsAreaHeight-1)/pstListControl->ListItemHeight+1; pstListControl->VisibleItemsNum = (pstListControl->VisibleItemsAreaHeight-1)/pstListControl->ListItemHeight+1;
// Initialize scroll bar.
pstSubElement->ScrollBar.Parameter.eDirection = SGUI_SCROLLBAR_VERTICAL; pstSubElement->ScrollBar.Parameter.eDirection = SGUI_SCROLLBAR_VERTICAL;
pstSubElement->ScrollBar.Parameter.PosX = LIST_SCROLLBAR_POSX; pstSubElement->ScrollBar.Parameter.PosX = LIST_SCROLLBAR_POSX;
pstSubElement->ScrollBar.Parameter.PosY = pstListControl->FirstVisibleItemPosY; pstSubElement->ScrollBar.Parameter.PosY = pstListControl->FirstVisibleItemPosY;
@ -153,7 +152,7 @@ void SGUI_LIST_RefreshListItems(SGUI_LIST_STRUCT* pstList)
pstSubElement->ScrollBar.Parameter.MaxIndex = (pstListData->Count>pstListControl->VisibleIntegralItemsNum)?(pstListData->Count-pstListControl->VisibleIntegralItemsNum-1):0; pstSubElement->ScrollBar.Parameter.MaxIndex = (pstListData->Count>pstListControl->VisibleIntegralItemsNum)?(pstListData->Count-pstListControl->VisibleIntegralItemsNum-1):0;
#endif #endif
// Clear list item display area. // Clear list item display area.
SGUI_Basic_DrawRectangle(LIST_ITEM_RECT_POSX, pstListControl->FirstVisibleItemPosY, LIST_ITEM_RECT_WIDTH, pstListControl->VisibleItemsAreaHeight, GUI_COLOR_BKGCLR, GUI_COLOR_BKGCLR); SGUI_Basic_DrawRectangle(LIST_ITEM_RECT_POSX, pstListControl->FirstVisibleItemPosY, LIST_ITEM_RECT_WIDTH, pstListControl->VisibleItemsAreaHeight, SGUI_COLOR_BKGCLR, SGUI_COLOR_BKGCLR);
// Refresh scroll bar // Refresh scroll bar
pstSubElement->ScrollBar.Data.Index = pstListControl->PageStartIndex; pstSubElement->ScrollBar.Data.Index = pstListControl->PageStartIndex;
SGUI_ScrollBar_RefreshScrollBar(&(pstSubElement->ScrollBar)); SGUI_ScrollBar_RefreshScrollBar(&(pstSubElement->ScrollBar));
@ -392,7 +391,7 @@ void SGUI_LIST_DrawItem(SGUI_LIST_STRUCT* pstList, SGUI_SIZE uiIndex)
// Draw list item text. // Draw list item text.
SGUI_Text_DrawSingleLineText( pstListItemPointer->Text, pstList->FontSize, SGUI_Text_DrawSingleLineText( pstListItemPointer->Text, pstList->FontSize,
&stItemTextDisplayArea, &stItemTextDataArea, GUI_DRAW_NORMAL); &stItemTextDisplayArea, &stItemTextDataArea, SGUI_DRAW_NORMAL);
// Prepare draw parameter text. // Prepare draw parameter text.
stItemTextDataArea.PosX = LIST_ITEM_PARAMETER_SPLIT_WIDTH+1; stItemTextDataArea.PosX = LIST_ITEM_PARAMETER_SPLIT_WIDTH+1;
@ -447,7 +446,7 @@ void SGUI_LIST_DrawItem(SGUI_LIST_STRUCT* pstList, SGUI_SIZE uiIndex)
} }
} }
// Draw parameter text. // Draw parameter text.
SGUI_Text_DrawSingleLineText(szParameterStringBuffer, pstList->FontSize, &stItemTextDisplayArea, &stItemTextDataArea, GUI_DRAW_NORMAL); SGUI_Text_DrawSingleLineText(szParameterStringBuffer, pstList->FontSize, &stItemTextDisplayArea, &stItemTextDataArea, SGUI_DRAW_NORMAL);
} }
} }
} }
@ -528,7 +527,7 @@ void SGUI_LIST_SetListItemValue(SGUI_LIST_STRUCT* pstList, SGUI_INDEX iItemIndex
} }
// Clear list item area. // Clear list item area.
SGUI_Basic_DrawRectangle(LIST_ITEM_RECT_POSX, pstListControl->FirstVisibleItemPosY+(pstListControl->SelectIndex-pstListControl->PageStartIndex)*pstListControl->ListItemHeight-pstListControl->ItemPosYOffSet, SGUI_Basic_DrawRectangle(LIST_ITEM_RECT_POSX, pstListControl->FirstVisibleItemPosY+(pstListControl->SelectIndex-pstListControl->PageStartIndex)*pstListControl->ListItemHeight-pstListControl->ItemPosYOffSet,
LIST_ITEM_RECT_WIDTH, pstListControl->ListItemHeight, GUI_COLOR_BKGCLR, GUI_COLOR_BKGCLR); LIST_ITEM_RECT_WIDTH, pstListControl->ListItemHeight, SGUI_COLOR_BKGCLR, SGUI_COLOR_BKGCLR);
// refresh list item // refresh list item
SGUI_LIST_DrawItem(pstList, iItemIndex); SGUI_LIST_DrawItem(pstList, iItemIndex);
// High light selected item. // High light selected item.

View File

@ -119,7 +119,7 @@ SGUI_SIZE SGUI_Notice_RefreshNotice(SGUI_PCSZSTR szNoticeText, SGUI_INT uiTextOf
SGUI_SIZE uiLineCount; SGUI_SIZE uiLineCount;
SGUI_SIZE uiNoticeBoxHeight; SGUI_SIZE uiNoticeBoxHeight;
SGUI_SIZE uiTextLines; SGUI_SIZE uiTextLines;
SGUI_RECT_AREA m_stTextDisplayArea; SGUI_RECT_AREA stTextDisplayArea;
SGUI_RECT_AREA stIconDisplayArea, stIconDataArea; SGUI_RECT_AREA stIconDisplayArea, stIconDataArea;
SGUI_PCSZSTR pszNoticeTextPtr; SGUI_PCSZSTR pszNoticeTextPtr;
@ -147,7 +147,7 @@ SGUI_SIZE SGUI_Notice_RefreshNotice(SGUI_PCSZSTR szNoticeText, SGUI_INT uiTextOf
uiNoticeBoxHeight = NOTICE_BOX_HEIGHT_MAX; uiNoticeBoxHeight = NOTICE_BOX_HEIGHT_MAX;
} }
// Draw edge // Draw edge
SGUI_Basic_DrawRectangle(NOTICE_BOX_POSX, NOTICE_BOX_POSY(uiNoticeBoxHeight), NOTICE_BOX_WIDTH, uiNoticeBoxHeight, GUI_COLOR_FRGCLR, GUI_COLOR_BKGCLR); SGUI_Basic_DrawRectangle(NOTICE_BOX_POSX, NOTICE_BOX_POSY(uiNoticeBoxHeight), NOTICE_BOX_WIDTH, uiNoticeBoxHeight, SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR);
// Draw icon if exists. // Draw icon if exists.
if(SGUI_ICON_NONE != eIcon) if(SGUI_ICON_NONE != eIcon)
{ {
@ -159,27 +159,27 @@ SGUI_SIZE SGUI_Notice_RefreshNotice(SGUI_PCSZSTR szNoticeText, SGUI_INT uiTextOf
stIconDataArea.PosY = 0; stIconDataArea.PosY = 0;
stIconDataArea.Width = NOTICE_ICON_SIZE; stIconDataArea.Width = NOTICE_ICON_SIZE;
stIconDataArea.Height = NOTICE_ICON_SIZE; stIconDataArea.Height = NOTICE_ICON_SIZE;
SGUI_Basic_DrawBitMap(&stIconDisplayArea, &stIconDataArea, (SGUI_BYTE*)g_arrNoticeIcon[eIcon], GUI_DRAW_NORMAL); SGUI_Basic_DrawBitMap(&stIconDisplayArea, &stIconDataArea, (SGUI_BYTE*)g_arrNoticeIcon[eIcon], SGUI_DRAW_NORMAL);
} }
// Draw text; // Draw text;
if(SGUI_ICON_NONE != eIcon) if(SGUI_ICON_NONE != eIcon)
{ {
m_stTextDisplayArea.PosX = NOTICE_TEXT_POSX; stTextDisplayArea.PosX = NOTICE_TEXT_POSX;
m_stTextDisplayArea.Width = NOTICE_TEXT_AREA_WIDTH; stTextDisplayArea.Width = NOTICE_TEXT_AREA_WIDTH;
} }
else else
{ {
m_stTextDisplayArea.PosX = NOTICE_TEXT_POSX_NOICON; stTextDisplayArea.PosX = NOTICE_TEXT_POSX_NOICON;
m_stTextDisplayArea.Width = NOTICE_TEXT_AREA_WIDTH_NOICON;; stTextDisplayArea.Width = NOTICE_TEXT_AREA_WIDTH_NOICON;;
} }
m_stTextDisplayArea.PosY = NOTICE_TEXT_POSY(uiNoticeBoxHeight); stTextDisplayArea.PosY = NOTICE_TEXT_POSY(uiNoticeBoxHeight);
m_stTextDisplayArea.Height = NOTICE_TEXT_AREA_HEIGHT(uiLineCount); stTextDisplayArea.Height = NOTICE_TEXT_AREA_HEIGHT(uiLineCount);
if(m_stTextDisplayArea.Height > NOTICE_TEXT_AREA_HEIGHT_MAX) if(stTextDisplayArea.Height > NOTICE_TEXT_AREA_HEIGHT_MAX)
{ {
m_stTextDisplayArea.Height = NOTICE_TEXT_AREA_HEIGHT_MAX; stTextDisplayArea.Height = NOTICE_TEXT_AREA_HEIGHT_MAX;
} }
uiTextLines = SGUI_Text_DrawMultipleLinesText(pszNoticeTextPtr, NOTICE_FONT_SIZE, &m_stTextDisplayArea, uiTextOffset, GUI_DRAW_NORMAL); uiTextLines = SGUI_Text_DrawMultipleLinesText(pszNoticeTextPtr, NOTICE_FONT_SIZE, &stTextDisplayArea, uiTextOffset, SGUI_DRAW_NORMAL);
return uiTextLines; return uiTextLines;
} }

View File

@ -54,8 +54,8 @@ void SGUI_RefreshProcessBar(SGUI_PROCBAR_STRUCT *pstProcessBarData)
uiProcessBlockStartY = pstProcessBarData->Parameter.PosY + 1; uiProcessBlockStartY = pstProcessBarData->Parameter.PosY + 1;
uiProcessBlockWidth = pstProcessBarData->Parameter.Width - 2; uiProcessBlockWidth = pstProcessBarData->Parameter.Width - 2;
uiProcessBlockHeight = (pstProcessBarData->Parameter.Height - 2) * (pstProcessBarData->Data.Value) / pstProcessBarData->Parameter.MaxValue; uiProcessBlockHeight = (pstProcessBarData->Parameter.Height - 2) * (pstProcessBarData->Data.Value) / pstProcessBarData->Parameter.MaxValue;
eBackColor = GUI_COLOR_BKGCLR; eBackColor = SGUI_COLOR_BKGCLR;
eFillColor = GUI_COLOR_FRGCLR; eFillColor = SGUI_COLOR_FRGCLR;
break; break;
} }
case SGUI_PROCBAR_LEFT: // Process from right to left. case SGUI_PROCBAR_LEFT: // Process from right to left.
@ -64,8 +64,8 @@ void SGUI_RefreshProcessBar(SGUI_PROCBAR_STRUCT *pstProcessBarData)
uiProcessBlockStartY = pstProcessBarData->Parameter.PosY + 1; uiProcessBlockStartY = pstProcessBarData->Parameter.PosY + 1;
uiProcessBlockWidth = (pstProcessBarData->Parameter.Width - 2) * (pstProcessBarData->Parameter.MaxValue - pstProcessBarData->Data.Value) / pstProcessBarData->Parameter.MaxValue; uiProcessBlockWidth = (pstProcessBarData->Parameter.Width - 2) * (pstProcessBarData->Parameter.MaxValue - pstProcessBarData->Data.Value) / pstProcessBarData->Parameter.MaxValue;
uiProcessBlockHeight = pstProcessBarData->Parameter.Height - 2; uiProcessBlockHeight = pstProcessBarData->Parameter.Height - 2;
eBackColor = GUI_COLOR_FRGCLR; eBackColor = SGUI_COLOR_FRGCLR;
eFillColor = GUI_COLOR_BKGCLR; eFillColor = SGUI_COLOR_BKGCLR;
break; break;
} }
case SGUI_PROCBAR_RIGHT: // Process from left to right. case SGUI_PROCBAR_RIGHT: // Process from left to right.
@ -74,8 +74,8 @@ void SGUI_RefreshProcessBar(SGUI_PROCBAR_STRUCT *pstProcessBarData)
uiProcessBlockStartY = pstProcessBarData->Parameter.PosY + 1; uiProcessBlockStartY = pstProcessBarData->Parameter.PosY + 1;
uiProcessBlockWidth = (pstProcessBarData->Parameter.Width - 2) * (pstProcessBarData->Data.Value) / pstProcessBarData->Parameter.MaxValue; uiProcessBlockWidth = (pstProcessBarData->Parameter.Width - 2) * (pstProcessBarData->Data.Value) / pstProcessBarData->Parameter.MaxValue;
uiProcessBlockHeight = pstProcessBarData->Parameter.Height - 2; uiProcessBlockHeight = pstProcessBarData->Parameter.Height - 2;
eBackColor = GUI_COLOR_BKGCLR; eBackColor = SGUI_COLOR_BKGCLR;
eFillColor = GUI_COLOR_FRGCLR; eFillColor = SGUI_COLOR_FRGCLR;
break; break;
} }
case SGUI_PROCBAR_UP: // Process from down to up. case SGUI_PROCBAR_UP: // Process from down to up.
@ -85,12 +85,12 @@ void SGUI_RefreshProcessBar(SGUI_PROCBAR_STRUCT *pstProcessBarData)
uiProcessBlockStartY = pstProcessBarData->Parameter.PosY + 1; uiProcessBlockStartY = pstProcessBarData->Parameter.PosY + 1;
uiProcessBlockWidth = pstProcessBarData->Parameter.Width - 2; uiProcessBlockWidth = pstProcessBarData->Parameter.Width - 2;
uiProcessBlockHeight = (pstProcessBarData->Parameter.Height - 2) * (pstProcessBarData->Parameter.MaxValue - pstProcessBarData->Data.Value) / pstProcessBarData->Parameter.MaxValue; uiProcessBlockHeight = (pstProcessBarData->Parameter.Height - 2) * (pstProcessBarData->Parameter.MaxValue - pstProcessBarData->Data.Value) / pstProcessBarData->Parameter.MaxValue;
eBackColor = GUI_COLOR_FRGCLR; eBackColor = SGUI_COLOR_FRGCLR;
eFillColor = GUI_COLOR_BKGCLR; eFillColor = SGUI_COLOR_BKGCLR;
} }
} }
// Redraw edge and clean up area. // Redraw edge and clean up area.
SGUI_Basic_DrawRectangle(pstProcessBarData->Parameter.PosX, pstProcessBarData->Parameter.PosY, pstProcessBarData->Parameter.Width, pstProcessBarData->Parameter.Height, GUI_COLOR_FRGCLR, eBackColor); SGUI_Basic_DrawRectangle(pstProcessBarData->Parameter.PosX, pstProcessBarData->Parameter.PosY, pstProcessBarData->Parameter.Width, pstProcessBarData->Parameter.Height, SGUI_COLOR_FRGCLR, eBackColor);
// Draw process block. // Draw process block.
SGUI_Basic_DrawRectangle(uiProcessBlockStartX, uiProcessBlockStartY, uiProcessBlockWidth, uiProcessBlockHeight, eFillColor, eFillColor); SGUI_Basic_DrawRectangle(uiProcessBlockStartX, uiProcessBlockStartY, uiProcessBlockWidth, uiProcessBlockHeight, eFillColor, eFillColor);
} }

View File

@ -0,0 +1,262 @@
/*************************************************************************/
/** Copyright. **/
/** FileName: SGUI_Graph.c **/
/** Author: Polarix **/
/** Version: 1.0.0.0 **/
/** Description: Graph adjustment UI interface. **/
/*************************************************************************/
//=======================================================================//
//= Include files. =//
//=======================================================================//
#include "SGUI_Common.h"
#include "SGUI_Text.h"
#include "SGUI_RealtimeGraph.h"
//=======================================================================//
//= User Macro definition. =//
//=======================================================================//
#define GUI_GRAPH_SCROLLBAR_WIDTH (3)
#define GUI_GRAPH_GRAPH_AREA_WIDTH (LCD_SIZE_WIDTH-GUI_GRAPH_SCROLLBAR_WIDTH-1)
#define GUI_GRAPH_GRAPH_AREA_HEIGHT (LCD_SIZE_HEIGHT- GUI_GRAPH_SCROLLBAR_WIDTH-1)
//=======================================================================//
//= Static function declaration. =//
//=======================================================================//
static SGUI_INT SGUI_RealtimeGraph_GetValuePointYCoordinate(SGUI_RTGRAPH* pstRTGraph, SGUI_INT iValue);
//=======================================================================//
//= Function implementation. =//
//=======================================================================//
/*************************************************************************/
/** Function Name: SGUI_RealtimeGraph_Initialize **/
/** Purpose: Initialize a graph control data. **/
/** Params: **/
/** @pstRTGraph[in]: Graph map data. **/
/** Return: None. **/
/** Notice: None. **/
/*************************************************************************/
void SGUI_RealtimeGraph_Initialize(SGUI_RTGRAPH* pstRTGraph)
{
/*----------------------------------*/
/* Variable Declaration */
/*----------------------------------*/
SGUI_RTGRAPH_DATA* pstData;
SGUI_RTGRAPH_CONTROL* pstControl;
SGUI_INT iValueIndex;
/*----------------------------------*/
/* Process */
/*----------------------------------*/
if(NULL != pstRTGraph)
{
pstData = pstRTGraph->Data;
pstControl = pstRTGraph->Control;
// Initialize graph controller.
if((NULL != pstControl) && (NULL != pstData))
{
// yAxisMax must be greater then yAxisMin;
if(pstControl->yAxisMax < pstControl->yAxisMin)
{
SGUI_SWAP(pstControl->yAxisMax, pstControl->yAxisMin);
}
// X-axis step in pixel must be greater then 2.
if(pstControl->xAxisStepPixel < 2)
{
pstControl->xAxisStepPixel = 2;
}
pstControl->ValueArea = pstControl->yAxisMax - pstControl->yAxisMin;
// Initialize graph data.
//SGUI_Common_MemorySet(pstData, 0x00, sizeof(SGUI_RTGRAPH_DATA));
// Zero point value must NOT greater then yAxisMax and NOT less then yAxisMin.
if(pstData->ZeroPointValue > pstControl->yAxisMax)
{
pstData->ZeroPointValue = pstControl->yAxisMax;
}
if(pstData->ZeroPointValue < pstControl->yAxisMin)
{
pstData->ZeroPointValue = pstControl->yAxisMin;
}
// Calculate the number of value points that can be used.
pstData->ValueCount = (LCD_SIZE_WIDTH-2)/pstControl->xAxisStepPixel;
for(iValueIndex=0; iValueIndex<pstData->ValueCount; iValueIndex++)
{
pstData->ValueArray[iValueIndex] = pstData->ZeroPointValue;
pstData->LimitedValueArray[iValueIndex] = pstData->ZeroPointValue;
pstData->PointYCoordinateArray[iValueIndex] = SGUI_RealtimeGraph_GetValuePointYCoordinate(pstRTGraph, pstData->LimitedValueArray[iValueIndex]);
}
}
}
}
/*************************************************************************/
/** Function Name: SGUI_Graph_Refresh **/
/** Purpose: Refresh graph map display. **/
/** Resources: Graph data. **/
/** Params: **/
/** @pstRTGraph[in]: Graph map data used refreshed. **/
/** Return: None. **/
/** Notice: None. **/
/*************************************************************************/
void SGUI_RealtimeGraph_Refresh(SGUI_RTGRAPH* pstRTGraph, SGUI_PCSZSTR szTopText, SGUI_PCSZSTR szBottomText)
{
/*----------------------------------*/
/* Variable Declaration */
/*----------------------------------*/
SGUI_RTGRAPH_DATA* pstData;
SGUI_RTGRAPH_CONTROL* pstControl;
SGUI_INT iValueIndex;
SGUI_INT iPixelCoordinateStartX, iPixelCoordinateEndX;
SGUI_INT iBaseLineCoordinateY;
SGUI_RECT_AREA stTextDataArea, stTextDispArea;
/*----------------------------------*/
/* Process */
/*----------------------------------*/
// Draw frame
SGUI_Basic_DrawRectangle(0, 0, LCD_SIZE_WIDTH, LCD_SIZE_HEIGHT, SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR);
SGUI_Basic_DrawLine(1, 9, LCD_SIZE_WIDTH-2, 9, SGUI_COLOR_FRGCLR);
SGUI_Basic_DrawLine(1, LCD_SIZE_HEIGHT-9, LCD_SIZE_WIDTH-2, LCD_SIZE_HEIGHT-9, SGUI_COLOR_FRGCLR);
if(NULL != pstRTGraph)
{
pstData = pstRTGraph->Data;
pstControl = pstRTGraph->Control;
if((NULL != pstControl) && (NULL != pstData))
{
if(SGUI_TRUE == pstControl->EnableBaseline)
{
iBaseLineCoordinateY = SGUI_RealtimeGraph_GetValuePointYCoordinate(pstRTGraph, pstData->ZeroPointValue);
SGUI_Basic_DrawLine(1, iBaseLineCoordinateY, LCD_SIZE_WIDTH-2, iBaseLineCoordinateY, SGUI_COLOR_FRGCLR);
}
if(pstData->ValueCount > 1)
{
for(iValueIndex=1; iValueIndex<pstData->ValueCount; iValueIndex++)
{
iPixelCoordinateStartX = 1 + (iValueIndex-1) * pstControl->xAxisStepPixel;
iPixelCoordinateEndX = 1 + iValueIndex * pstControl->xAxisStepPixel;
SGUI_Basic_DrawLine(iPixelCoordinateStartX, pstData->PointYCoordinateArray[iValueIndex-1],
iPixelCoordinateEndX, pstData->PointYCoordinateArray[iValueIndex], SGUI_COLOR_FRGCLR);
}
}
//SGUI_Common_IntegerToString(pstData->ValueArray[pstData->ValueCount-1], szValueBuffer, 10, 10, ' ');
stTextDataArea.PosX = 0; stTextDataArea.PosY = 0;
stTextDispArea.PosX = 1; stTextDispArea.PosY = 1;
stTextDispArea.Width = LCD_SIZE_WIDTH-2, stTextDispArea.Height = 7;
SGUI_Text_DrawSingleLineText(szTopText, SGUI_FONT_SIZE_H8, &stTextDispArea, &stTextDataArea, SGUI_DRAW_NORMAL);
stTextDispArea.PosY = LCD_SIZE_HEIGHT-8;
SGUI_Text_DrawSingleLineText(szBottomText, SGUI_FONT_SIZE_H8, &stTextDispArea, &stTextDataArea, SGUI_DRAW_NORMAL);
}
}
}
/*************************************************************************/
/** Function Name: SGUI_RealtimeGraph_AppendValue **/
/** Purpose: Append a new value to graph. **/
/** Params: **/
/** @pstRTGraph[in]: Real-time graph object pointer. **/
/** @iNewValue[in]: New value will be appended. **/
/** Return: None. **/
/** Notice: None. **/
/*************************************************************************/
void SGUI_RealtimeGraph_AppendValue(SGUI_RTGRAPH* pstRTGraph, SGUI_INT iNewValue)
{
/*----------------------------------*/
/* Variable Declaration */
/*----------------------------------*/
SGUI_RTGRAPH_DATA* pstData;
SGUI_RTGRAPH_CONTROL* pstControl;
SGUI_INT iValueIndex;
SGUI_INT iLimitedValue;
/*----------------------------------*/
/* Process */
/*----------------------------------*/
if(NULL != pstRTGraph)
{
pstData = pstRTGraph->Data;
pstControl = pstRTGraph->Control;
if((NULL != pstControl) && (NULL != pstData))
{
// Push value.
for(iValueIndex=0; iValueIndex<pstData->ValueCount-1; iValueIndex++)
{
pstData->ValueArray[iValueIndex] = pstData->ValueArray[iValueIndex+1];
pstData->LimitedValueArray[iValueIndex] = pstData->LimitedValueArray[iValueIndex+1];
pstData->PointYCoordinateArray[iValueIndex] = pstData->PointYCoordinateArray[iValueIndex+1];
}
// Append new value.
iValueIndex = pstData->ValueCount-1;
pstData->ValueArray[iValueIndex] = iNewValue;
iLimitedValue = iNewValue;
if(iLimitedValue > pstControl->yAxisMax)
{
iLimitedValue = pstControl->yAxisMax;
}
if(iLimitedValue < pstControl->yAxisMin)
{
iLimitedValue = pstControl->yAxisMin;
}
pstData->LimitedValueArray[iValueIndex] = iLimitedValue;
pstData->PointYCoordinateArray[iValueIndex] = SGUI_RealtimeGraph_GetValuePointYCoordinate(pstRTGraph, iLimitedValue);
}
}
}
/*************************************************************************/
/** Function Name: SGUI_RealtimeGraph_GetValuePointYCoordinate **/
/** Purpose: Convert data point to a drawing point in visible **/
/** graph area. **/
/** Params: **/
/** @pstRTGraph[in]: Real-time graph object pointer. **/
/** @iValue[in]: Real value. **/
/** Return: None. **/
/** Notice: None. **/
/*************************************************************************/
SGUI_INT SGUI_RealtimeGraph_GetValuePointYCoordinate(SGUI_RTGRAPH* pstRTGraph, SGUI_INT iValue)
{
/*----------------------------------*/
/* Variable Declaration */
/*----------------------------------*/
SGUI_RTGRAPH_DATA* pstData;
SGUI_RTGRAPH_CONTROL* pstControl;
SGUI_INT iDisplayValuePointAreaHeight;
SGUI_INT iAbsoluteValue;
SGUI_INT iValuePointCoordinate;
/*----------------------------------*/
/* Initialize */
/*----------------------------------*/
iDisplayValuePointAreaHeight = LCD_SIZE_HEIGHT-9*2;
/*----------------------------------*/
/* Process */
/*----------------------------------*/
if(NULL != pstRTGraph)
{
pstData = pstRTGraph->Data;
pstControl = pstRTGraph->Control;
if((NULL != pstControl) && (NULL != pstData))
{
if(iValue > pstControl->yAxisMax)
{
iValue = pstControl->yAxisMax;
}
if(iValue < pstControl->yAxisMin)
{
iValue = pstControl->yAxisMin;
}
iAbsoluteValue = iValue - pstControl->yAxisMin;
iValuePointCoordinate = iAbsoluteValue*iDisplayValuePointAreaHeight/pstControl->ValueArea;
iValuePointCoordinate = iDisplayValuePointAreaHeight-iValuePointCoordinate;
iValuePointCoordinate = iValuePointCoordinate +9;
}
}
return iValuePointCoordinate;
}

View File

@ -60,19 +60,19 @@ void SGUI_ScrollBar_RefreshScrollBar(SGUI_SCROLLBAR_STRUCT* pstScrollBar)
// Draw scroll bar edge. // Draw scroll bar edge.
SGUI_Basic_DrawRectangle(pstScrollBar->Parameter.PosX, pstScrollBar->Parameter.PosY, SGUI_Basic_DrawRectangle(pstScrollBar->Parameter.PosX, pstScrollBar->Parameter.PosY,
pstScrollBar->Parameter.Width, pstScrollBar->Parameter.Height, pstScrollBar->Parameter.Width, pstScrollBar->Parameter.Height,
GUI_COLOR_FRGCLR, GUI_COLOR_BKGCLR); SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR);
// Value lower limit is 0, scroll blocks must be greater then 0. // Value lower limit is 0, scroll blocks must be greater then 0.
if(pstScrollBar->Parameter.MaxIndex > 0) if(pstScrollBar->Parameter.MaxIndex > 0)
{ {
uiScrollBlockPos = pstScrollBar->Parameter.PosY+1+((pstScrollBar->Parameter.Height-uiScrollBlockSize-2)*pstScrollBar->Data.Index/pstScrollBar->Parameter.MaxIndex); uiScrollBlockPos = pstScrollBar->Parameter.PosY+1+((pstScrollBar->Parameter.Height-uiScrollBlockSize-2)*pstScrollBar->Data.Index/pstScrollBar->Parameter.MaxIndex);
// Redraw process block // Redraw process block
SGUI_Basic_DrawRectangle(pstScrollBar->Parameter.PosX+1, uiScrollBlockPos, SGUI_Basic_DrawRectangle(pstScrollBar->Parameter.PosX+1, uiScrollBlockPos,
uiScrollBlockSize, uiScrollBlockSize, GUI_COLOR_FRGCLR, GUI_COLOR_FRGCLR); uiScrollBlockSize, uiScrollBlockSize, SGUI_COLOR_FRGCLR, SGUI_COLOR_FRGCLR);
} }
else else
{ {
SGUI_Basic_DrawRectangle(pstScrollBar->Parameter.PosX+1, pstScrollBar->Parameter.PosY+1, SGUI_Basic_DrawRectangle(pstScrollBar->Parameter.PosX+1, pstScrollBar->Parameter.PosY+1,
uiScrollBlockSize, uiScrollBlockSize, GUI_COLOR_FRGCLR, GUI_COLOR_FRGCLR); uiScrollBlockSize, uiScrollBlockSize, SGUI_COLOR_FRGCLR, SGUI_COLOR_FRGCLR);
} }
} }
else // Horizontal else // Horizontal
@ -80,19 +80,19 @@ void SGUI_ScrollBar_RefreshScrollBar(SGUI_SCROLLBAR_STRUCT* pstScrollBar)
// Draw scroll bar edge. // Draw scroll bar edge.
SGUI_Basic_DrawRectangle(pstScrollBar->Parameter.PosX, pstScrollBar->Parameter.PosY, SGUI_Basic_DrawRectangle(pstScrollBar->Parameter.PosX, pstScrollBar->Parameter.PosY,
pstScrollBar->Parameter.Width, pstScrollBar->Parameter.Height, pstScrollBar->Parameter.Width, pstScrollBar->Parameter.Height,
GUI_COLOR_FRGCLR, GUI_COLOR_BKGCLR); SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR);
// Value lower limit is 0, scroll blocks must be greater then 0. // Value lower limit is 0, scroll blocks must be greater then 0.
if(pstScrollBar->Parameter.MaxIndex > 0) if(pstScrollBar->Parameter.MaxIndex > 0)
{ {
uiScrollBlockPos = pstScrollBar->Parameter.PosX+1+((pstScrollBar->Parameter.Width-uiScrollBlockSize-2)*pstScrollBar->Data.Index/pstScrollBar->Parameter.MaxIndex); uiScrollBlockPos = pstScrollBar->Parameter.PosX+1+((pstScrollBar->Parameter.Width-uiScrollBlockSize-2)*pstScrollBar->Data.Index/pstScrollBar->Parameter.MaxIndex);
// Redraw process block // Redraw process block
SGUI_Basic_DrawRectangle(uiScrollBlockPos, pstScrollBar->Parameter.PosY+1, SGUI_Basic_DrawRectangle(uiScrollBlockPos, pstScrollBar->Parameter.PosY+1,
uiScrollBlockSize, uiScrollBlockSize, GUI_COLOR_FRGCLR, GUI_COLOR_FRGCLR); uiScrollBlockSize, uiScrollBlockSize, SGUI_COLOR_FRGCLR, SGUI_COLOR_FRGCLR);
} }
else else
{ {
SGUI_Basic_DrawRectangle(pstScrollBar->Parameter.PosX+1, pstScrollBar->Parameter.PosY+1, SGUI_Basic_DrawRectangle(pstScrollBar->Parameter.PosX+1, pstScrollBar->Parameter.PosY+1,
uiScrollBlockSize, uiScrollBlockSize, GUI_COLOR_FRGCLR, GUI_COLOR_FRGCLR); uiScrollBlockSize, uiScrollBlockSize, SGUI_COLOR_FRGCLR, SGUI_COLOR_FRGCLR);
} }
} }
} }

View File

@ -67,7 +67,7 @@ void SGUI_Text_DrawSingleLineText(SGUI_PCSZSTR szText, SGUI_FONT_SIZE eFontSize,
// Initialize variable. // Initialize variable.
pcTextPointer = ENCODE(szText); pcTextPointer = ENCODE(szText);
uiCharacterCode = 0x0000; uiCharacterCode = 0x0000;
eBackColor = (eFontMode == GUI_DRAW_NORMAL)?GUI_COLOR_BKGCLR:GUI_COLOR_FRGCLR; eBackColor = (eFontMode == SGUI_DRAW_NORMAL)?SGUI_COLOR_BKGCLR:SGUI_COLOR_FRGCLR;
// Get font graphics size. // Get font graphics size.
uiFontWidth = g_stFontSize[eFontSize].Width; uiFontWidth = g_stFontSize[eFontSize].Width;
uiFontHeight = g_stFontSize[eFontSize].Height; uiFontHeight = g_stFontSize[eFontSize].Height;
@ -171,7 +171,7 @@ SGUI_SIZE SGUI_Text_DrawMultipleLinesText(SGUI_PCSZSTR szText, SGUI_FONT_SIZE eF
pcTextPointer = ENCODE(szText); pcTextPointer = ENCODE(szText);
uiCharacterCode = 0x0000; uiCharacterCode = 0x0000;
uiLines = 0; uiLines = 0;
eBackColor = (eFontMode == GUI_DRAW_NORMAL)?GUI_COLOR_BKGCLR:GUI_COLOR_FRGCLR; eBackColor = (eFontMode == SGUI_DRAW_NORMAL)?SGUI_COLOR_BKGCLR:SGUI_COLOR_FRGCLR;
// Get font graphics size. // Get font graphics size.
uiFontWidth = g_stFontSize[eFontSize].Width; uiFontWidth = g_stFontSize[eFontSize].Width;
uiFontHeight = g_stFontSize[eFontSize].Height; uiFontHeight = g_stFontSize[eFontSize].Height;

View File

@ -43,7 +43,7 @@ void SGUI_IntegerVariableBox_Refresh(SGUI_INT_VARBOX_STRUCT* pstValue, SGUI_VARB
/*----------------------------------*/ /*----------------------------------*/
/* Variable Declaration */ /* Variable Declaration */
/*----------------------------------*/ /*----------------------------------*/
SGUI_RECT_AREA m_stTextDisplayArea; SGUI_RECT_AREA stTextDisplayArea;
SGUI_RECT_AREA stTextDataArea; SGUI_RECT_AREA stTextDataArea;
SGUI_SIZE uiTextLength; SGUI_SIZE uiTextLength;
SGUI_SIZE uiTextWidth; SGUI_SIZE uiTextWidth;
@ -52,7 +52,7 @@ void SGUI_IntegerVariableBox_Refresh(SGUI_INT_VARBOX_STRUCT* pstValue, SGUI_VARB
/*----------------------------------*/ /*----------------------------------*/
/* Initialize */ /* Initialize */
/*----------------------------------*/ /*----------------------------------*/
eBackColor = ((eMode==GUI_DRAW_NORMAL)?GUI_COLOR_BKGCLR:GUI_COLOR_FRGCLR); eBackColor = ((eMode==SGUI_DRAW_NORMAL)?SGUI_COLOR_BKGCLR:SGUI_COLOR_FRGCLR);
// Draw edge // Draw edge
SGUI_Basic_DrawRectangle(pstValue->PosX, pstValue->PosY, pstValue->Width, VARBOX_HEIGHT(pstValue->FontSize), eBackColor, eBackColor); SGUI_Basic_DrawRectangle(pstValue->PosX, pstValue->PosY, pstValue->Width, VARBOX_HEIGHT(pstValue->FontSize), eBackColor, eBackColor);
@ -74,20 +74,20 @@ void SGUI_IntegerVariableBox_Refresh(SGUI_INT_VARBOX_STRUCT* pstValue, SGUI_VARB
// Convert number to string // Convert number to string
uiTextLength = SGUI_Common_IntegerToString(pstValue->Value, arrTextBuffer, 10, -1, ' '); uiTextLength = SGUI_Common_IntegerToString(pstValue->Value, arrTextBuffer, 10, -1, ' ');
uiTextWidth = VARBOX_TEXT_WIDTH(pstValue->FontSize, uiTextLength); uiTextWidth = VARBOX_TEXT_WIDTH(pstValue->FontSize, uiTextLength);
m_stTextDisplayArea.PosX = pstValue->PosX+1; stTextDisplayArea.PosX = pstValue->PosX+1;
m_stTextDisplayArea.PosY = pstValue->PosY+1; stTextDisplayArea.PosY = pstValue->PosY+1;
m_stTextDisplayArea.Width = VARBOX_TEXT_AREA_WIDTH(pstValue->Width); stTextDisplayArea.Width = VARBOX_TEXT_AREA_WIDTH(pstValue->Width);
m_stTextDisplayArea.Height = g_stFontSize[pstValue->FontSize].Height; stTextDisplayArea.Height = g_stFontSize[pstValue->FontSize].Height;
switch(eAlignment) switch(eAlignment)
{ {
case SGUI_RIGHT: case SGUI_RIGHT:
{ {
stTextDataArea.PosX = m_stTextDisplayArea.Width - uiTextWidth; stTextDataArea.PosX = stTextDisplayArea.Width - uiTextWidth;
break; break;
} }
case SGUI_CENTER: case SGUI_CENTER:
{ {
stTextDataArea.PosX = (m_stTextDisplayArea.Width - uiTextWidth) / 2; stTextDataArea.PosX = (stTextDisplayArea.Width - uiTextWidth) / 2;
break; break;
} }
default: default:
@ -96,7 +96,7 @@ void SGUI_IntegerVariableBox_Refresh(SGUI_INT_VARBOX_STRUCT* pstValue, SGUI_VARB
} }
} }
stTextDataArea.PosY = 0; stTextDataArea.PosY = 0;
SGUI_Text_DrawSingleLineText(arrTextBuffer, pstValue->FontSize, &m_stTextDisplayArea, &stTextDataArea, eMode); SGUI_Text_DrawSingleLineText(arrTextBuffer, pstValue->FontSize, &stTextDisplayArea, &stTextDataArea, eMode);
} }
} }
@ -116,7 +116,7 @@ void SGUI_TextVariableBox_UpdateCharacter(SGUI_TEXT_VARBOX_STRUCT* pstTextValue,
/* Variable Declaration */ /* Variable Declaration */
/*----------------------------------*/ /*----------------------------------*/
SGUI_COLOR eBackColor; SGUI_COLOR eBackColor;
SGUI_RECT_AREA m_stTextDisplayArea, stTextDataArea; SGUI_RECT_AREA stTextDisplayArea, stTextDataArea;
SGUI_RECT_AREA stFocusArea; SGUI_RECT_AREA stFocusArea;
SGUI_UINT16 uiFontWidth, uiFontHeight; SGUI_UINT16 uiFontWidth, uiFontHeight;
SGUI_SIZE uiTextLength, uiFocusIndexMax; SGUI_SIZE uiTextLength, uiFocusIndexMax;
@ -125,7 +125,7 @@ void SGUI_TextVariableBox_UpdateCharacter(SGUI_TEXT_VARBOX_STRUCT* pstTextValue,
/*----------------------------------*/ /*----------------------------------*/
/* Initialize */ /* Initialize */
/*----------------------------------*/ /*----------------------------------*/
eBackColor = ((eMode==GUI_DRAW_NORMAL)?GUI_COLOR_BKGCLR:GUI_COLOR_FRGCLR); eBackColor = ((eMode==SGUI_DRAW_NORMAL)?SGUI_COLOR_BKGCLR:SGUI_COLOR_FRGCLR);
// Clear background. // Clear background.
if(NULL != pstTextValue->Value) if(NULL != pstTextValue->Value)
{ {
@ -179,25 +179,25 @@ void SGUI_TextVariableBox_UpdateCharacter(SGUI_TEXT_VARBOX_STRUCT* pstTextValue,
} }
} }
// Set text display area. // Set text display area.
m_stTextDisplayArea.PosX = pstTextValue->PosX+1; stTextDisplayArea.PosX = pstTextValue->PosX+1;
m_stTextDisplayArea.PosY = pstTextValue->PosY+1; stTextDisplayArea.PosY = pstTextValue->PosY+1;
m_stTextDisplayArea.Width = VARBOX_TEXT_AREA_WIDTH(pstTextValue->Width); stTextDisplayArea.Width = VARBOX_TEXT_AREA_WIDTH(pstTextValue->Width);
m_stTextDisplayArea.Height = uiFontHeight; stTextDisplayArea.Height = uiFontHeight;
stTextDataArea.PosX = 0; stTextDataArea.PosX = 0;
stTextDataArea.PosY = 0; stTextDataArea.PosY = 0;
// Set focus character area. // Set focus character area.
stFocusArea.PosX = m_stTextDisplayArea.PosX+pstTextValue->FocusIndex*uiFontWidth; stFocusArea.PosX = stTextDisplayArea.PosX+pstTextValue->FocusIndex*uiFontWidth;
stFocusArea.PosY = m_stTextDisplayArea.PosY; stFocusArea.PosY = stTextDisplayArea.PosY;
stFocusArea.Width = uiFontWidth; stFocusArea.Width = uiFontWidth;
stFocusArea.Height = uiFontHeight; stFocusArea.Height = uiFontHeight;
if(RECTANGLE_X_END(stFocusArea) > RECTANGLE_X_END(m_stTextDisplayArea)) if(RECTANGLE_X_END(stFocusArea) > RECTANGLE_X_END(stTextDisplayArea))
{ {
stTextDataArea.PosX = RECTANGLE_X_END(m_stTextDisplayArea) - RECTANGLE_X_END(stFocusArea); stTextDataArea.PosX = RECTANGLE_X_END(stTextDisplayArea) - RECTANGLE_X_END(stFocusArea);
stFocusArea.PosX = stFocusArea.PosX + stTextDataArea.PosX; stFocusArea.PosX = stFocusArea.PosX + stTextDataArea.PosX;
} }
// Display text. // Display text.
SGUI_Text_DrawSingleLineText(pstTextValue->Value, pstTextValue->FontSize, &m_stTextDisplayArea, &stTextDataArea, eMode); SGUI_Text_DrawSingleLineText(pstTextValue->Value, pstTextValue->FontSize, &stTextDisplayArea, &stTextDataArea, eMode);
// Focus first character. // Focus first character.
SGUI_Basic_ReverseBlockColor(stFocusArea.PosX, stFocusArea.PosY, stFocusArea.Width, stFocusArea.Height); SGUI_Basic_ReverseBlockColor(stFocusArea.PosX, stFocusArea.PosY, stFocusArea.Width, stFocusArea.Height);
} }

View File

@ -75,6 +75,12 @@
<Unit filename="../../Demo/src/List.c"> <Unit filename="../../Demo/src/List.c">
<Option compilerVar="CC" /> <Option compilerVar="CC" />
</Unit> </Unit>
<Unit filename="../../Demo/src/RTCNotice.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../../Demo/src/RealtimeGraph.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../../Demo/src/ScrollingText.c"> <Unit filename="../../Demo/src/ScrollingText.c">
<Option compilerVar="CC" /> <Option compilerVar="CC" />
</Unit> </Unit>
@ -99,12 +105,12 @@
<Unit filename="../../GUI/inc/SGUI_Frame.h"> <Unit filename="../../GUI/inc/SGUI_Frame.h">
<Option target="&lt;{~None~}&gt;" /> <Option target="&lt;{~None~}&gt;" />
</Unit> </Unit>
<Unit filename="../../GUI/inc/SGUI_Graph.h">
<Option target="&lt;{~None~}&gt;" />
</Unit>
<Unit filename="../../GUI/inc/SGUI_List.h" /> <Unit filename="../../GUI/inc/SGUI_List.h" />
<Unit filename="../../GUI/inc/SGUI_Notice.h" /> <Unit filename="../../GUI/inc/SGUI_Notice.h" />
<Unit filename="../../GUI/inc/SGUI_ProcessBar.h" /> <Unit filename="../../GUI/inc/SGUI_ProcessBar.h" />
<Unit filename="../../GUI/inc/SGUI_RealtimeGraph.h">
<Option target="&lt;{~None~}&gt;" />
</Unit>
<Unit filename="../../GUI/inc/SGUI_ScrollBar.h" /> <Unit filename="../../GUI/inc/SGUI_ScrollBar.h" />
<Unit filename="../../GUI/inc/SGUI_Text.h" /> <Unit filename="../../GUI/inc/SGUI_Text.h" />
<Unit filename="../../GUI/inc/SGUI_Typedef.h" /> <Unit filename="../../GUI/inc/SGUI_Typedef.h" />
@ -121,9 +127,6 @@
<Unit filename="../../GUI/src/SGUI_Frame.c"> <Unit filename="../../GUI/src/SGUI_Frame.c">
<Option compilerVar="CC" /> <Option compilerVar="CC" />
</Unit> </Unit>
<Unit filename="../../GUI/src/SGUI_Graph.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../../GUI/src/SGUI_List.c"> <Unit filename="../../GUI/src/SGUI_List.c">
<Option compilerVar="CC" /> <Option compilerVar="CC" />
</Unit> </Unit>
@ -133,6 +136,9 @@
<Unit filename="../../GUI/src/SGUI_ProcessBar.c"> <Unit filename="../../GUI/src/SGUI_ProcessBar.c">
<Option compilerVar="CC" /> <Option compilerVar="CC" />
</Unit> </Unit>
<Unit filename="../../GUI/src/SGUI_RealtimeGraph.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../../GUI/src/SGUI_ScrollBar.c"> <Unit filename="../../GUI/src/SGUI_ScrollBar.c">
<Option compilerVar="CC" /> <Option compilerVar="CC" />
</Unit> </Unit>

File diff suppressed because it is too large Load Diff

View File

@ -1,45 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Debug" />
<File name="..\..\Demo\src\DemoProc.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3779" topLine="72" />
</Cursor>
</File>
<File name="..\..\Demo\src\List.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="9616" topLine="244" />
</Cursor>
</File>
<File name="..\..\HMI\inc\HMI_Engine.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1902" topLine="40" />
</Cursor>
</File>
<File name="..\..\Demo\inc\DemoProc.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1161" topLine="15" />
</Cursor>
</File>
<File name="..\..\Demo\src\TextNotice.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="4269" topLine="80" />
</Cursor>
</File>
<File name="..\..\HMI\src\HMI_Engine.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="10156" topLine="0" />
</Cursor>
</File>
<File name="..\..\Demo\src\VariableBox.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="6816" topLine="261" />
</Cursor>
</File>
<File name="..\..\User\src\VirtualDeviceInterface.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="5118" topLine="104" />
</Cursor>
</File>
</CodeBlocks_layout_file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 KiB

View File

@ -3,6 +3,7 @@
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdlib.h>
//=======================================================================// //=======================================================================//
//= User definition. =// //= User definition. =//

View File

@ -94,6 +94,7 @@ void USR_ACT_OnTimerEventProcess(void)
/* Variable Declaration */ /* Variable Declaration */
/*----------------------------------*/ /*----------------------------------*/
HMI_EVENT stEvent; HMI_EVENT stEvent;
SGUI_INT iRandomNumber;
/*----------------------------------*/ /*----------------------------------*/
/* Initialize */ /* Initialize */
@ -104,6 +105,10 @@ void USR_ACT_OnTimerEventProcess(void)
/*----------------------------------*/ /*----------------------------------*/
/* Process */ /* Process */
/*----------------------------------*/ /*----------------------------------*/
iRandomNumber = rand();
iRandomNumber = (iRandomNumber % 200)-100;
stEvent.Data = (void*)(&iRandomNumber);
// Post timer event. // Post timer event.
HMI_ProcessEvent(HMI_ENGINE_EVENT_ACTION, &stEvent); HMI_ProcessEvent(HMI_ENGINE_EVENT_ACTION, &stEvent);
} }