diff --git a/DemoProc/inc/DemoActions.h b/DemoProc/inc/DemoActions.h index a4fe9941e982b1269a74a449d41e95f7f5be0dea..1d9b81ed0b3918e25c765e0a44c36d5a47ebaa1f 100644 --- a/DemoProc/inc/DemoActions.h +++ b/DemoProc/inc/DemoActions.h @@ -1,43 +1,43 @@ #ifndef __INCLUDE_DEMO_ACTION_DEFINE_H__ #define __INCLUDE_DEMO_ACTION_DEFINE_H__ //=======================================================================// -//= User definition. =// +//= User definition. =// //=======================================================================// // Key value definition. -#define KEY_VALUE_NONE (0x0000) -#define KEY_VALUE_BACKSPACE (0x0008) -#define KEY_VALUE_TAB (0x0009) -#define KEY_VALUE_ENTER (0x000D) -#define KEY_VALUE_ESC (0x001B) -#define KEY_VALUE_SPACE (0x0020) -#define KEY_VALUE_DEL (0x007F) -#define KEY_VALUE_HOME (0x0139) -#define KEY_VALUE_END (0x0138) -#define KEY_VALUE_LEFT (0x013A) -#define KEY_VALUE_UP (0x013B) -#define KEY_VALUE_RIGHT (0x013C) -#define KEY_VALUE_DOWN (0x013D) -#define KEY_VALUE_INSERT (0x0142) -#define KEY_VALUE_F1 (0x0154) -#define KEY_VALUE_F2 (0x0155) -#define KEY_VALUE_F3 (0x0156) -#define KEY_VALUE_F4 (0x0157) -#define KEY_VALUE_F5 (0x0158) -#define KEY_VALUE_F6 (0x0159) -#define KEY_VALUE_F7 (0x015A) -#define KEY_VALUE_F8 (0x015B) -#define KEY_VALUE_F9 (0x015C) -#define KEY_VALUE_F10 (0x015D) -#define KEY_VALUE_F11 (0x015E) -#define KEY_VALUE_F12 (0x015F) -#define KEY_VALUE_ENTER_PAD (0x0172) -#define KEY_VALUE_PLUS_PAD (0x0184) -#define KEY_VALUE_SUB_PAD (0x0186) +#define KEY_VALUE_NONE (0x0000) +#define KEY_VALUE_BACKSPACE (0x0008) +#define KEY_VALUE_TAB (0x0009) +#define KEY_VALUE_ENTER (0x000D) +#define KEY_VALUE_ESC (0x001B) +#define KEY_VALUE_SPACE (0x0020) +#define KEY_VALUE_DEL (0x007F) +#define KEY_VALUE_HOME (0x0139) +#define KEY_VALUE_END (0x0138) +#define KEY_VALUE_LEFT (0x013A) +#define KEY_VALUE_UP (0x013B) +#define KEY_VALUE_RIGHT (0x013C) +#define KEY_VALUE_DOWN (0x013D) +#define KEY_VALUE_INSERT (0x0142) +#define KEY_VALUE_F1 (0x0154) +#define KEY_VALUE_F2 (0x0155) +#define KEY_VALUE_F3 (0x0156) +#define KEY_VALUE_F4 (0x0157) +#define KEY_VALUE_F5 (0x0158) +#define KEY_VALUE_F6 (0x0159) +#define KEY_VALUE_F7 (0x015A) +#define KEY_VALUE_F8 (0x015B) +#define KEY_VALUE_F9 (0x015C) +#define KEY_VALUE_F10 (0x015D) +#define KEY_VALUE_F11 (0x015E) +#define KEY_VALUE_F12 (0x015F) +#define KEY_VALUE_ENTER_PAD (0x0172) +#define KEY_VALUE_PLUS_PAD (0x0184) +#define KEY_VALUE_SUB_PAD (0x0186) // User option flag value define -#define KEY_OPTION_CTRL (0x1000) -#define KEY_OPTION_ALT (0x2000) -#define KEY_OPTION_SHIFT (0x4000) +#define KEY_OPTION_CTRL (0x1000) +#define KEY_OPTION_ALT (0x2000) +#define KEY_OPTION_SHIFT (0x4000) -#define KEY_CODE_VALUE(CODE) (CODE & 0x0FFF) -#define KEY_CODE_OPT(CODE) (CODE & 0xF000) +#define KEY_CODE_VALUE(CODE) (CODE & 0x0FFF) +#define KEY_CODE_OPT(CODE) (CODE & 0xF000) #endif // __INCLUDE_DEMO_ACTION_DEFINE_H__ diff --git a/DemoProc/inc/DemoProc.h b/DemoProc/inc/DemoProc.h index 7bde8ac64005c03f8e96f1d99616ee36247907e2..5c5c78f026251612b47413e801c43511ff7a9b03 100644 --- a/DemoProc/inc/DemoProc.h +++ b/DemoProc/inc/DemoProc.h @@ -1,7 +1,7 @@ #ifndef __INCLUDE_DEMO_PROC_H__ #define __INCLUDE_DEMO_PROC_H__ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include #include @@ -15,96 +15,96 @@ #endif //=======================================================================// -//= Data type definition. =// +//= Data type definition. =// //=======================================================================// // HMI action type typedef enum { - EVENT_ID_UNKNOW = 0, - // User defined action type. - EVENT_ID_KEY_PRESS, - EVENT_ID_TIMER, - EVENT_ID_RTC, - // User defined action above. - EVENT_ID_MAX + EVENT_ID_UNKNOW = 0, + // User defined action type. + EVENT_ID_KEY_PRESS, + EVENT_ID_TIMER, + EVENT_ID_RTC, + // User defined action above. + EVENT_ID_MAX }EVENT_ID; // HMI event type. typedef enum { - EVENT_TYPE_ANY = 0, + EVENT_TYPE_ANY = 0, EVENT_TYPE_ACTION, EVENT_TYPE_DATA, }EVENT_TYPE; enum DEMO_PROC_ACTION_ID { - HMI_DEMO_PROC_NO_ACT = 0, - HMI_DEMO_PROC_CONFIRM = 1, - HMI_DEMO_PROC_CANCEL = 2, + HMI_DEMO_PROC_NO_ACT = 0, + HMI_DEMO_PROC_CONFIRM = 1, + HMI_DEMO_PROC_CANCEL = 2, }; typedef struct { - SGUI_UINT16 uiKeyValue; + SGUI_UINT16 uiKeyValue; }KEY_EVENT_DATA; typedef struct { - SGUI_INT iValue; + SGUI_INT iValue; }DUMMY_DATA_EVENT_DATA; HMI_EVENT_TYPE_DECLARE(KEY_PRESS_EVENT, KEY_EVENT_DATA) HMI_EVENT_TYPE_DECLARE(DATA_EVENT, DUMMY_DATA_EVENT_DATA); //=======================================================================// -//= User Macro definition. =// +//= User Macro definition. =// //=======================================================================// -#define HMI_SCREEN_ID_DEMO_SCROLLING_TEXT (1001) -#define HMI_SCREEN_ID_DEMO_PAINT_TEXT (1002) -#define HMI_SCREEN_ID_DEMO_LIST (1003) -#define HMI_SCREEN_ID_DEMO_TEXT_NOTICE (1004) -#define HMI_SCREEN_ID_DEMO_BASIC_PAINT (1005) -#define HMI_SCREEN_ID_DEMO_VARIABLE_BOX (1006) -#define HMI_SCREEN_ID_DEMO_REAL_TIME_GRAPH (1007) -#define HMI_SCREEN_ID_DEMO_MENU (1008) -#define HMI_SCREEN_ID_DEMO_CURVE (1009) +#define HMI_SCREEN_ID_DEMO_SCROLLING_TEXT (1001) +#define HMI_SCREEN_ID_DEMO_PAINT_TEXT (1002) +#define HMI_SCREEN_ID_DEMO_LIST (1003) +#define HMI_SCREEN_ID_DEMO_TEXT_NOTICE (1004) +#define HMI_SCREEN_ID_DEMO_BASIC_PAINT (1005) +#define HMI_SCREEN_ID_DEMO_VARIABLE_BOX (1006) +#define HMI_SCREEN_ID_DEMO_REAL_TIME_GRAPH (1007) +#define HMI_SCREEN_ID_DEMO_MENU (1008) +#define HMI_SCREEN_ID_DEMO_CURVE (1009) -#define DEMO_HEART_BEAT_INTERVAL_MS (20) +#define DEMO_HEART_BEAT_INTERVAL_MS (20) //=======================================================================// -//= Public variable declaration. =// +//= Public variable declaration. =// //=======================================================================// /* HMI engine object. */ extern HMI_ENGINE_OBJECT g_stDemoEngine; /* Screen display objects. */ extern HMI_SCREEN_OBJECT g_stHMIDemo_ScrollingText; -extern HMI_SCREEN_OBJECT g_stHMIDemo_List; -extern HMI_SCREEN_OBJECT g_stHMIDemo_Notice; -extern HMI_SCREEN_OBJECT g_stHMIDemo_RTCNotice; +extern HMI_SCREEN_OBJECT g_stHMIDemo_List; +extern HMI_SCREEN_OBJECT g_stHMIDemo_Notice; +extern HMI_SCREEN_OBJECT g_stHMIDemo_RTCNotice; extern HMI_SCREEN_OBJECT g_stHMIDemo_VariableBox; -extern HMI_SCREEN_OBJECT g_stHMIDemo_RealtimeGraph; -extern HMI_SCREEN_OBJECT g_stHMIDemo_Menu; -extern HMI_SCREEN_OBJECT g_stHMIDemo_BasicPaint; -extern HMI_SCREEN_OBJECT g_stHMIDemo_TextPaint; -extern HMI_SCREEN_OBJECT g_stHMIDemo_Curve; +extern HMI_SCREEN_OBJECT g_stHMIDemo_RealtimeGraph; +extern HMI_SCREEN_OBJECT g_stHMIDemo_Menu; +extern HMI_SCREEN_OBJECT g_stHMIDemo_BasicPaint; +extern HMI_SCREEN_OBJECT g_stHMIDemo_TextPaint; +extern HMI_SCREEN_OBJECT g_stHMIDemo_Curve; //=======================================================================// -//= Function declare. =// +//= Function declare. =// //=======================================================================// #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ -HMI_ENGINE_RESULT InitializeHMIEngineObj(void); -void DemoMainProcess(void); +HMI_ENGINE_RESULT InitializeHMIEngineObj(void); +void DemoMainProcess(void); -bool SysTickTimerTriggered(void); -bool RTCTimerTriggered(void); -bool UserEventTriggered(void); +bool SysTickTimerTriggered(void); +bool RTCTimerTriggered(void); +bool UserEventTriggered(void); -void SysTickTimerEnable(bool bEnable); -void RTCTimerEnable(bool bEnable); +void SysTickTimerEnable(bool bEnable); +void RTCTimerEnable(bool bEnable); #ifdef __cplusplus } diff --git a/DemoProc/inc/DemoResource_ASCII.h b/DemoProc/inc/DemoResource_ASCII.h index 1eb9d0bee516bdab0a68176fb38d4246b7041547..7fdaf21c0080045a4c0c42a220fddee53ba91fd2 100644 --- a/DemoProc/inc/DemoResource_ASCII.h +++ b/DemoProc/inc/DemoResource_ASCII.h @@ -1,57 +1,58 @@ -#ifndef _INCLUDE_DEMO_RESOURCE_UTF8_H_ +#ifndef _INCLUDE_DEMO_RESOURCE_UTF8_H_ #define _INCLUDE_DEMO_RESOURCE_UTF8_H_ /* Screen 1: List Components. */ /* Start screen with list. */ -#define SCR1_TITLE ("List Components") -#define SCR1_LIST_ITEM1 ("Basic Paint") -#define SCR1_LIST_ITEM2 ("Text") -#define SCR1_LIST_ITEM3 ("Variable box") -#define SCR1_LIST_ITEM4 ("Realtime graph") -#define SCR1_LIST_ITEM5 ("Menu") -#define SCR1_LIST_ITEM6 ("Notice box") -#define SCR1_LIST_ITEM7 ("Tuning curve") - -#define SCR1_LIST_APPEND1 ("Add item 1") -#define SCR1_LIST_APPEND2 ("Add item 2") -#define SCR1_LIST_APPEND3 ("Add item 3") -#define SCR1_LIST_APPEND4 ("Add item 4") -#define SCR1_LIST_APPEND5 ("Add item 5") -#define SCR1_LIST_APPEND6 ("Add item 6") +#define SCR1_TITLE ("List Components") +#define SCR1_LIST_ITEM1 ("Basic Paint") +#define SCR1_LIST_ITEM2 ("Text") +#define SCR1_LIST_ITEM3 ("Variable box") +#define SCR1_LIST_ITEM4 ("Realtime graph") +#define SCR1_LIST_ITEM5 ("Menu") +#define SCR1_LIST_ITEM6 ("Notice box") +#define SCR1_LIST_ITEM7 ("Tuning curve") + +#define SCR1_LIST_APPEND1 ("Add item 1") +#define SCR1_LIST_APPEND2 ("Add item 2") +#define SCR1_LIST_APPEND3 ("Add item 3") +#define SCR1_LIST_APPEND4 ("Add item 4") +#define SCR1_LIST_APPEND5 ("Add item 5") +#define SCR1_LIST_APPEND6 ("Add item 6") /* Screen 2: Basic Paint*/ /* No text used. */ /* Screen 3: Text demo*/ /* For internal font resources. */ -#define SCR3_TEXT_MIN_NUM ("1+2+8/4*5=13") -#define SCR3_TEXT_INNER_8 ("Hello Simple GUI.") -#define SCR3_TEXT_INNER_12 ("Welcome!") -#define SCR3_TEXT_EXTEN_12 ("I don't like this.") -#define SCR3_TEXT_MULTILINE_12 ("Multiline demo text with 12-pixel font.") +#define SCR3_TEXT_MIN_NUM ("1+2+8/4*5=13") +#define SCR3_TEXT_INNER_8 ("Hello Simple GUI.") +#define SCR3_TEXT_INNER_12 ("Welcome!") +#define SCR3_TEXT_EXTEN_12 ("I don't like this.") +#define SCR3_TEXT_MULTILINE_12 ("Multiline demo text with 12-pixel font.") /* Screen 4: Variable box. */ -#define SCR4_VAR_BOX_TITLE ("Variable box") -#define SCR4_HELP_NOTICE ("Press TAB to switch focus.\nUp&Down to change value.\nSend \"SPACE\" to continue.") +#define SCR4_VAR_BOX_TITLE ("Variable box") +#define SCR4_HELP_NOTICE ("Press TAB to switch focus.\nUp&Down to change value.\nSend \"SPACE\" to continue.") /* Screen 5: Realtime graph. */ -#define SCR5_RT_GRAPH_TITLE ("Realtime graph") +#define SCR5_RT_GRAPH_TITLE ("Realtime graph") /* Screen 6: Variable box. */ -#define SCR6_MENU_ITEM1 ("Item 1") -#define SCR6_MENU_ITEM2 ("Item 2") -#define SCR6_MENU_ITEM3 ("Item 3") -#define SCR6_MENU_ITEM4 ("Item 4") -#define SCR6_MENU_ITEM5 ("Item 5") -#define SCR6_MENU_ITEM6 ("Item 6") -#define SCR6_MENU_ITEM7 ("Item 7") -#define SCR6_MENU_ITEM8 ("Item 8") -#define SCR6_SUB_MENU_ITEM1 ("Sub 1") -#define SCR6_SUB_MENU_ITEM2 ("Sub 2") -#define SCR6_SUB_MENU_ITEM3 ("Sub 3") -#define SCR6_SUB_MENU_ITEM4 ("Sub 4") +#define SCR6_MENU_ITEM1 ("Item 1") +#define SCR6_MENU_ITEM2 ("Item 2") +#define SCR6_MENU_ITEM3 ("Item 3") +#define SCR6_MENU_ITEM4 ("Item 4") +#define SCR6_MENU_ITEM5 ("Item 5") +#define SCR6_MENU_ITEM6 ("Item 6") +#define SCR6_MENU_ITEM7 ("Item 7") +#define SCR6_MENU_ITEM8 ("Item 8") +#define SCR6_SUB_MENU_ITEM1 ("Sub 1") +#define SCR6_SUB_MENU_ITEM2 ("Sub 2") +#define SCR6_SUB_MENU_ITEM3 ("Sub 3") +#define SCR6_SUB_MENU_ITEM4 ("Sub 4") /* Screen 7: Notice box. */ -#define SCR7_NOTICE_TEXT ("This is a test notice.") +#define SCR7_NOTICE_TEXT ("This is a test notice.") #endif // _INCLUDE_DEMO_RESOURCE_UTF8_H_ +_ diff --git a/DemoProc/inc/DemoResource_GB2312.h b/DemoProc/inc/DemoResource_GB2312.h index 510e57c899e4aba8806a03e76e004d00c423aae8..d824c7971d6b076ac40b3fac54ad8719dffb7802 100644 --- a/DemoProc/inc/DemoResource_GB2312.h +++ b/DemoProc/inc/DemoResource_GB2312.h @@ -3,55 +3,55 @@ /* Screen 1: List Components. */ /* Start screen with list. */ -#define SCR1_TITLE ("б") -#define SCR1_LIST_ITEM1 ("ͼӿ") -#define SCR1_LIST_ITEM2 ("ı") -#define SCR1_LIST_ITEM3 ("") -#define SCR1_LIST_ITEM4 ("ʵʱ") -#define SCR1_LIST_ITEM5 ("˵") -#define SCR1_LIST_ITEM6 ("Ϣ") -#define SCR1_LIST_ITEM7 ("") - -#define SCR1_LIST_APPEND1 ("Ӳ1") -#define SCR1_LIST_APPEND2 ("Ӳ2") -#define SCR1_LIST_APPEND3 ("Ӳ3") -#define SCR1_LIST_APPEND4 ("Ӳ4") -#define SCR1_LIST_APPEND5 ("Ӳ5") -#define SCR1_LIST_APPEND6 ("Ӳ6") +#define SCR1_TITLE ("列表组件") +#define SCR1_LIST_ITEM1 ("基础绘图接口") +#define SCR1_LIST_ITEM2 ("文本") +#define SCR1_LIST_ITEM3 ("输入框") +#define SCR1_LIST_ITEM4 ("实时曲线") +#define SCR1_LIST_ITEM5 ("菜单") +#define SCR1_LIST_ITEM6 ("消息框") +#define SCR1_LIST_ITEM7 ("调整曲线") + +#define SCR1_LIST_APPEND1 ("附加测试项1") +#define SCR1_LIST_APPEND2 ("附加测试项2") +#define SCR1_LIST_APPEND3 ("附加测试项3") +#define SCR1_LIST_APPEND4 ("附加测试项4") +#define SCR1_LIST_APPEND5 ("附加测试项5") +#define SCR1_LIST_APPEND6 ("附加测试项6") /* Screen 2: Basic Paint*/ /* No text used. */ /* Screen 3: Text demo*/ /* For internal font resources. */ -#define SCR3_TEXT_MIN_NUM ("1+2+8/4*5=13") -#define SCR3_TEXT_INNER_8 ("Hello Simple GUI.") -#define SCR3_TEXT_INNER_12 ("Welcome!") -#define SCR3_TEXT_EXTEN_12 ("Ҳϲ") -#define SCR3_TEXT_MULTILINE_12 ("12صĶıʾ") +#define SCR3_TEXT_MIN_NUM ("1+2+8/4*5=13") +#define SCR3_TEXT_INNER_8 ("Hello Simple GUI.") +#define SCR3_TEXT_INNER_12 ("Welcome!") +#define SCR3_TEXT_EXTEN_12 ("我不喜欢这个。") +#define SCR3_TEXT_MULTILINE_12 ("这里是12像素的多行文本演示。") /* Screen 4: Variable box. */ -#define SCR4_VAR_BOX_TITLE ("") -#define SCR4_HELP_NOTICE ("Press TAB to switch focus.\nUp&Down to change value.\nSend \"SPACE\" to continue.") +#define SCR4_VAR_BOX_TITLE ("输入框") +#define SCR4_HELP_NOTICE ("Press TAB to switch focus.\nUp&Down to change value.\nSend \"SPACE\" to continue.") /* Screen 5: Realtime graph. */ -#define SCR5_RT_GRAPH_TITLE ("Realtime graph") +#define SCR5_RT_GRAPH_TITLE ("Realtime graph") /* Screen 6: Variable box. */ -#define SCR6_MENU_ITEM1 ("Item 1") -#define SCR6_MENU_ITEM2 ("Item 2") -#define SCR6_MENU_ITEM3 ("Item 3") -#define SCR6_MENU_ITEM4 ("Item 4") -#define SCR6_MENU_ITEM5 ("Item 5") -#define SCR6_MENU_ITEM6 ("Item 6") -#define SCR6_MENU_ITEM7 ("Item 7") -#define SCR6_MENU_ITEM8 ("Item 8") -#define SCR6_SUB_MENU_ITEM1 ("Sub 1") -#define SCR6_SUB_MENU_ITEM2 ("Sub 2") -#define SCR6_SUB_MENU_ITEM3 ("Sub 3") -#define SCR6_SUB_MENU_ITEM4 ("Sub 4") +#define SCR6_MENU_ITEM1 ("Item 1") +#define SCR6_MENU_ITEM2 ("Item 2") +#define SCR6_MENU_ITEM3 ("Item 3") +#define SCR6_MENU_ITEM4 ("Item 4") +#define SCR6_MENU_ITEM5 ("Item 5") +#define SCR6_MENU_ITEM6 ("Item 6") +#define SCR6_MENU_ITEM7 ("Item 7") +#define SCR6_MENU_ITEM8 ("Item 8") +#define SCR6_SUB_MENU_ITEM1 ("Sub 1") +#define SCR6_SUB_MENU_ITEM2 ("Sub 2") +#define SCR6_SUB_MENU_ITEM3 ("Sub 3") +#define SCR6_SUB_MENU_ITEM4 ("Sub 4") /* Screen 7: Notice box. */ -#define SCR7_NOTICE_TEXT ("ӭʹSimpleGUI") +#define SCR7_NOTICE_TEXT ("欢迎使用SimpleGUI!") #endif // _INCLUDE_DEMO_RESOURCE_UTF8_H_ diff --git a/DemoProc/inc/DemoResource_UTF8.h b/DemoProc/inc/DemoResource_UTF8.h index 83afd5becf1efbbea44e4edbfc552f53cbf279f9..303fecca2cd03df341d76c63f389314f7d9e0029 100644 --- a/DemoProc/inc/DemoResource_UTF8.h +++ b/DemoProc/inc/DemoResource_UTF8.h @@ -1,57 +1,58 @@ -#ifndef _INCLUDE_DEMO_RESOURCE_UTF8_H_ +#ifndef _INCLUDE_DEMO_RESOURCE_UTF8_H_ #define _INCLUDE_DEMO_RESOURCE_UTF8_H_ /* Screen 1: List Components. */ /* Start screen with list. */ -#define SCR1_TITLE ("列表组件") -#define SCR1_LIST_ITEM1 ("基础绘图") -#define SCR1_LIST_ITEM2 ("文本") -#define SCR1_LIST_ITEM3 ("输入框") -#define SCR1_LIST_ITEM4 ("实时曲线") -#define SCR1_LIST_ITEM5 ("菜单") -#define SCR1_LIST_ITEM6 ("消息框") -#define SCR1_LIST_ITEM7 ("调整曲线") - -#define SCR1_LIST_APPEND1 ("附加测试项1") -#define SCR1_LIST_APPEND2 ("附加测试项2") -#define SCR1_LIST_APPEND3 ("附加测试项3") -#define SCR1_LIST_APPEND4 ("附加测试项4") -#define SCR1_LIST_APPEND5 ("附加测试项5") -#define SCR1_LIST_APPEND6 ("附加测试项6") +#define SCR1_TITLE ("列表组件") +#define SCR1_LIST_ITEM1 ("基础绘图") +#define SCR1_LIST_ITEM2 ("文本") +#define SCR1_LIST_ITEM3 ("输入框") +#define SCR1_LIST_ITEM4 ("实时曲线") +#define SCR1_LIST_ITEM5 ("菜单") +#define SCR1_LIST_ITEM6 ("消息框") +#define SCR1_LIST_ITEM7 ("调整曲线") + +#define SCR1_LIST_APPEND1 ("附加测试项1") +#define SCR1_LIST_APPEND2 ("附加测试项2") +#define SCR1_LIST_APPEND3 ("附加测试项3") +#define SCR1_LIST_APPEND4 ("附加测试项4") +#define SCR1_LIST_APPEND5 ("附加测试项5") +#define SCR1_LIST_APPEND6 ("附加测试项6") /* Screen 2: Basic Paint*/ /* No text used. */ /* Screen 3: Text demo*/ /* For internal font resources. */ -#define SCR3_TEXT_MIN_NUM ("1+2+8/4*5=13") -#define SCR3_TEXT_INNER_8 ("Hello Simple GUI.") -#define SCR3_TEXT_INNER_12 ("Welcome!") -#define SCR3_TEXT_EXTEN_12 ("我不喜欢这个。") -#define SCR3_TEXT_MULTILINE_12 ("这里是12像素的多行文本演示。") +#define SCR3_TEXT_MIN_NUM ("1+2+8/4*5=13") +#define SCR3_TEXT_INNER_8 ("Hello Simple GUI.") +#define SCR3_TEXT_INNER_12 ("Welcome!") +#define SCR3_TEXT_EXTEN_12 ("我不喜欢这个。") +#define SCR3_TEXT_MULTILINE_12 ("这里是12像素的多行文本演示。") /* Screen 4: Variable box. */ -#define SCR4_VAR_BOX_TITLE ("输入框") -#define SCR4_HELP_NOTICE ("Press TAB to switch focus.\nUp&Down to change value.\nSend \"SPACE\" to continue.") +#define SCR4_VAR_BOX_TITLE ("输入框") +#define SCR4_HELP_NOTICE ("Press TAB to switch focus.\nUp&Down to change value.\nSend \"SPACE\" to continue.") /* Screen 5: Realtime graph. */ -#define SCR5_RT_GRAPH_TITLE ("Realtime graph") +#define SCR5_RT_GRAPH_TITLE ("Realtime graph") /* Screen 6: Variable box. */ -#define SCR6_MENU_ITEM1 ("Item 1") -#define SCR6_MENU_ITEM2 ("Item 2") -#define SCR6_MENU_ITEM3 ("Item 3") -#define SCR6_MENU_ITEM4 ("Item 4") -#define SCR6_MENU_ITEM5 ("Item 5") -#define SCR6_MENU_ITEM6 ("Item 6") -#define SCR6_MENU_ITEM7 ("Item 7") -#define SCR6_MENU_ITEM8 ("Item 8") -#define SCR6_SUB_MENU_ITEM1 ("Sub 1") -#define SCR6_SUB_MENU_ITEM2 ("Sub 2") -#define SCR6_SUB_MENU_ITEM3 ("Sub 3") -#define SCR6_SUB_MENU_ITEM4 ("Sub 4") +#define SCR6_MENU_ITEM1 ("Item 1") +#define SCR6_MENU_ITEM2 ("Item 2") +#define SCR6_MENU_ITEM3 ("Item 3") +#define SCR6_MENU_ITEM4 ("Item 4") +#define SCR6_MENU_ITEM5 ("Item 5") +#define SCR6_MENU_ITEM6 ("Item 6") +#define SCR6_MENU_ITEM7 ("Item 7") +#define SCR6_MENU_ITEM8 ("Item 8") +#define SCR6_SUB_MENU_ITEM1 ("Sub 1") +#define SCR6_SUB_MENU_ITEM2 ("Sub 2") +#define SCR6_SUB_MENU_ITEM3 ("Sub 3") +#define SCR6_SUB_MENU_ITEM4 ("Sub 4") /* Screen 7: Notice box. */ -#define SCR7_NOTICE_TEXT ("欢迎使用SimpleGUI!") +#define SCR7_NOTICE_TEXT ("欢迎使用SimpleGUI!") #endif // _INCLUDE_DEMO_RESOURCE_UTF8_H_ +_ diff --git a/DemoProc/src/Basic.c b/DemoProc/src/Basic.c index ead047d3f35e7210816fa8d08c4e2c0e792265ba..d60a00fd8f1990050faca04e058959c320967b65 100644 --- a/DemoProc/src/Basic.c +++ b/DemoProc/src/Basic.c @@ -1,78 +1,78 @@ -/*************************************************************************/ -/** Copyright. **/ -/** FileName: RTCNotice.c **/ -/** Author: Polarix **/ -/** Version: 1.0.0.0 **/ -/** Description: HMI demo for notice box interface and refresh screen. **/ +/*************************************************************************/ +/** Copyright. **/ +/** FileName: RTCNotice.c **/ +/** Author: Polarix **/ +/** Version: 1.0.0.0 **/ +/** Description: HMI demo for notice box interface and refresh screen. **/ /*************************************************************************/ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "DemoProc.h" #include "HMI_Engine.h" #include "SGUI_Basic.h" //=======================================================================// -//= User Macro definition. =// +//= User Macro definition. =// //=======================================================================// //=======================================================================// -//= Static function declaration. =// +//= Static function declaration. =// //=======================================================================// -static HMI_ENGINE_RESULT HMI_DemoBasic_Prepare(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters); -static HMI_ENGINE_RESULT HMI_DemoBasic_RefreshScreen(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters); -static HMI_ENGINE_RESULT HMI_DemoBasic_ProcessEvent(SGUI_SCR_DEV* pstDeviceIF, const HMI_EVENT_BASE* pstEvent, SGUI_INT* piActionID); -static HMI_ENGINE_RESULT HMI_DemoBasic_PostProcess(SGUI_SCR_DEV* pstDeviceIF, HMI_ENGINE_RESULT eProcResult, SGUI_INT iActionID); +static HMI_ENGINE_RESULT HMI_DemoBasic_Prepare(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters); +static HMI_ENGINE_RESULT HMI_DemoBasic_RefreshScreen(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters); +static HMI_ENGINE_RESULT HMI_DemoBasic_ProcessEvent(SGUI_SCR_DEV* pstDeviceIF, const HMI_EVENT_BASE* pstEvent, SGUI_INT* piActionID); +static HMI_ENGINE_RESULT HMI_DemoBasic_PostProcess(SGUI_SCR_DEV* pstDeviceIF, HMI_ENGINE_RESULT eProcResult, SGUI_INT iActionID); //=======================================================================// -//= Static variable declaration. =// +//= Static variable declaration. =// //=======================================================================// -HMI_SCREEN_ACTION s_stDemoBasicPaintActions = { NULL, - HMI_DemoBasic_Prepare, - HMI_DemoBasic_RefreshScreen, - HMI_DemoBasic_ProcessEvent, - HMI_DemoBasic_PostProcess - }; +HMI_SCREEN_ACTION s_stDemoBasicPaintActions = { NULL, + HMI_DemoBasic_Prepare, + HMI_DemoBasic_RefreshScreen, + HMI_DemoBasic_ProcessEvent, + HMI_DemoBasic_PostProcess + }; //=======================================================================// -//= Global variable declaration. =// +//= Global variable declaration. =// //=======================================================================// -HMI_SCREEN_OBJECT g_stHMIDemo_BasicPaint = { HMI_SCREEN_ID_DEMO_BASIC_PAINT, - &s_stDemoBasicPaintActions - }; +HMI_SCREEN_OBJECT g_stHMIDemo_BasicPaint = { HMI_SCREEN_ID_DEMO_BASIC_PAINT, + &s_stDemoBasicPaintActions + }; //=======================================================================// -//= Function define. =// +//= Function define. =// //=======================================================================// HMI_ENGINE_RESULT HMI_DemoBasic_Prepare(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters) { - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if(NULL != pstDeviceIF->fnClear) - { - pstDeviceIF->fnClear(); - } - else - { - SGUI_Basic_DrawRectangle(pstDeviceIF, 0, 0, pstDeviceIF->stSize.iWidth, pstDeviceIF->stSize.iHeight, SGUI_COLOR_BKGCLR, SGUI_COLOR_BKGCLR); - } - HMI_DemoBasic_RefreshScreen(pstDeviceIF, pstParameters); - return HMI_RET_NORMAL; + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(NULL != pstDeviceIF->fnClear) + { + pstDeviceIF->fnClear(); + } + else + { + SGUI_Basic_DrawRectangle(pstDeviceIF, 0, 0, pstDeviceIF->stSize.iWidth, pstDeviceIF->stSize.iHeight, SGUI_COLOR_BKGCLR, SGUI_COLOR_BKGCLR); + } + HMI_DemoBasic_RefreshScreen(pstDeviceIF, pstParameters); + return HMI_RET_NORMAL; } HMI_ENGINE_RESULT HMI_DemoBasic_RefreshScreen(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters) { /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_INT iPaintBkgIdx; + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_INT iPaintBkgIdx; - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ - // Paint background. - for(iPaintBkgIdx=0; iPaintBkgIdxstSize.iHeight; iPaintBkgIdx+=5) + // Paint background. + for(iPaintBkgIdx=0; iPaintBkgIdxstSize.iHeight; iPaintBkgIdx+=5) { SGUI_Basic_DrawHorizontalLine(pstDeviceIF, 0, pstDeviceIF->stSize.iWidth-1, iPaintBkgIdx, SGUI_COLOR_FRGCLR); } @@ -86,9 +86,9 @@ HMI_ENGINE_RESULT HMI_DemoBasic_RefreshScreen(SGUI_SCR_DEV* pstDeviceIF, const v SGUI_Basic_DrawRectangle(pstDeviceIF, 37, 43, 5, 20, SGUI_COLOR_FRGCLR, SGUI_COLOR_FRGCLR); // Paint circle - SGUI_Basic_DrawCircle(pstDeviceIF, 55, 10, 9, SGUI_COLOR_FRGCLR, SGUI_COLOR_TRANS); - SGUI_Basic_DrawCircle(pstDeviceIF, 55, 31, 9, SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); - SGUI_Basic_DrawCircle(pstDeviceIF, 55, 52, 9, SGUI_COLOR_FRGCLR, SGUI_COLOR_FRGCLR); + SGUI_Basic_DrawCircle(pstDeviceIF, 55, 10, 9, SGUI_COLOR_FRGCLR, SGUI_COLOR_TRANS); + SGUI_Basic_DrawCircle(pstDeviceIF, 55, 31, 9, SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); + SGUI_Basic_DrawCircle(pstDeviceIF, 55, 52, 9, SGUI_COLOR_FRGCLR, SGUI_COLOR_FRGCLR); // Paint rounded rectangle SGUI_Basic_DrawRoundedRectangle(pstDeviceIF, 70, 1, 30, 20, 4, SGUI_COLOR_FRGCLR, SGUI_COLOR_TRANS); @@ -100,62 +100,64 @@ HMI_ENGINE_RESULT HMI_DemoBasic_RefreshScreen(SGUI_SCR_DEV* pstDeviceIF, const v SGUI_Basic_DrawRoundedRectangle(pstDeviceIF, 105, 22, 20, 20, 7, SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); SGUI_Basic_DrawRoundedRectangle(pstDeviceIF, 105, 43, 20, 20, 7, SGUI_COLOR_FRGCLR, SGUI_COLOR_FRGCLR); - return HMI_RET_NORMAL; + return HMI_RET_NORMAL; } HMI_ENGINE_RESULT HMI_DemoBasic_ProcessEvent(SGUI_SCR_DEV* pstDeviceIF, const HMI_EVENT_BASE* pstEvent, SGUI_INT* piActionID) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - HMI_ENGINE_RESULT eProcessResult; - SGUI_INT iProcessAction; - KEY_PRESS_EVENT* pstKeyEvent; - - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - eProcessResult = HMI_RET_NORMAL; - iProcessAction = HMI_DEMO_PROC_NO_ACT; - pstKeyEvent = (KEY_PRESS_EVENT*)pstEvent; - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if(pstEvent->iType == EVENT_TYPE_ACTION) - { - // Check event is valid. - if(SGUI_FALSE == HMI_EVENT_SIZE_CHK(*pstKeyEvent, KEY_PRESS_EVENT)) - { - // Event data is invalid. - eProcessResult = HMI_RET_INVALID_DATA; - } - else if(EVENT_ID_KEY_PRESS == pstEvent->iID) - { - iProcessAction = HMI_DEMO_PROC_CANCEL; - } - } - if(NULL != piActionID) - { - *piActionID = iProcessAction; - } - - return eProcessResult; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + HMI_ENGINE_RESULT eProcessResult; + SGUI_INT iProcessAction; + KEY_PRESS_EVENT* pstKeyEvent; + + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + eProcessResult = HMI_RET_NORMAL; + iProcessAction = HMI_DEMO_PROC_NO_ACT; + pstKeyEvent = (KEY_PRESS_EVENT*)pstEvent; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(pstEvent->iType == EVENT_TYPE_ACTION) + { + // Check event is valid. + if(SGUI_FALSE == HMI_EVENT_SIZE_CHK(*pstKeyEvent, KEY_PRESS_EVENT)) + { + // Event data is invalid. + eProcessResult = HMI_RET_INVALID_DATA; + } + else if(EVENT_ID_KEY_PRESS == pstEvent->iID) + { + iProcessAction = HMI_DEMO_PROC_CANCEL; + } + } + if(NULL != piActionID) + { + *piActionID = iProcessAction; + } + + return eProcessResult; } HMI_ENGINE_RESULT HMI_DemoBasic_PostProcess(SGUI_SCR_DEV* pstDeviceIF, HMI_ENGINE_RESULT eProcResult, SGUI_INT iActionID) { - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if(HMI_PROCESS_SUCCESSFUL(eProcResult)) - { - if(HMI_DEMO_PROC_CANCEL == iActionID) - { - HMI_GoBack(NULL); - } - } - - return HMI_RET_NORMAL; + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(HMI_PROCESS_SUCCESSFUL(eProcResult)) + { + if(HMI_DEMO_PROC_CANCEL == iActionID) + { + HMI_GoBack(NULL); + } + } + + return HMI_RET_NORMAL; } + + diff --git a/DemoProc/src/Curve.c b/DemoProc/src/Curve.c index 599c73df306536d81ee0bb0425b759188c09d1be..2d90af23c370f920a71fad3120c686061ecf5031 100644 --- a/DemoProc/src/Curve.c +++ b/DemoProc/src/Curve.c @@ -1,12 +1,12 @@ /*************************************************************************/ -/** Copyright. **/ -/** FileName: Curve.c **/ -/** Author: Polarix **/ -/** Version: 1.0.0.0 **/ -/** Description: HMI demo for graph interface. **/ +/** Copyright. **/ +/** FileName: Curve.c **/ +/** Author: Polarix **/ +/** Version: 1.0.0.0 **/ +/** Description: HMI demo for graph interface. **/ /*************************************************************************/ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "DemoProc.h" #include "Resource.h" @@ -16,367 +16,367 @@ #include "SGUI_FontResource.h" //=======================================================================// -//= User Macro definition. =// +//= User Macro definition. =// //=======================================================================// -#define CURVE_POINT_MUN_MAX (20) +#define CURVE_POINT_MUN_MAX (20) //=======================================================================// -//= Static function declaration. =// +//= Static function declaration. =// //=======================================================================// static HMI_ENGINE_RESULT HMI_DemoCurve_Initialize(SGUI_SCR_DEV* pstDeviceIF); -static HMI_ENGINE_RESULT HMI_DemoCurve_Prepare(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters); -static HMI_ENGINE_RESULT HMI_DemoCurve_RefreshScreen(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters); +static HMI_ENGINE_RESULT HMI_DemoCurve_Prepare(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters); +static HMI_ENGINE_RESULT HMI_DemoCurve_RefreshScreen(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters); static HMI_ENGINE_RESULT HMI_DemoCurve_ProcessEvent(SGUI_SCR_DEV* pstDeviceIF, const HMI_EVENT_BASE* pstEvent, SGUI_INT* piActionID); -static HMI_ENGINE_RESULT HMI_DemoCurve_PostProcess(SGUI_SCR_DEV* pstDeviceIF, HMI_ENGINE_RESULT eProcResult, SGUI_INT iActionID); -static SGUI_CURVE_POINT* HMI_DemoCurve_NewPoint(void); -static void HMI_DemoBasic_ReleasePoint(SGUI_CURVE_POINT* pcstPoint); -static void HMI_DemoCurve_RepaintText(SGUI_SCR_DEV* pstDeviceIF); +static HMI_ENGINE_RESULT HMI_DemoCurve_PostProcess(SGUI_SCR_DEV* pstDeviceIF, HMI_ENGINE_RESULT eProcResult, SGUI_INT iActionID); +static SGUI_CURVE_POINT* HMI_DemoCurve_NewPoint(void); +static void HMI_DemoBasic_ReleasePoint(SGUI_CURVE_POINT* pcstPoint); +static void HMI_DemoCurve_RepaintText(SGUI_SCR_DEV* pstDeviceIF); //=======================================================================// -//= Static variable declaration. =// +//= Static variable declaration. =// //=======================================================================// -static SGUI_CURVE_STRUCT s_stCurve = {0x00}; -static SGUI_BOOL s_arrbPointDataUsed[CURVE_POINT_MUN_MAX] = {0x00}; -static SGUI_CURVE_POINT s_arrstPointArray[CURVE_POINT_MUN_MAX] = {0x00}; -HMI_SCREEN_ACTION s_stDemoCurveActions = { - HMI_DemoCurve_Initialize, - HMI_DemoCurve_Prepare, - HMI_DemoCurve_RefreshScreen, - HMI_DemoCurve_ProcessEvent, - HMI_DemoCurve_PostProcess, - }; +static SGUI_CURVE_STRUCT s_stCurve = {0x00}; +static SGUI_BOOL s_arrbPointDataUsed[CURVE_POINT_MUN_MAX] = {0x00}; +static SGUI_CURVE_POINT s_arrstPointArray[CURVE_POINT_MUN_MAX] = {0x00}; +HMI_SCREEN_ACTION s_stDemoCurveActions = { + HMI_DemoCurve_Initialize, + HMI_DemoCurve_Prepare, + HMI_DemoCurve_RefreshScreen, + HMI_DemoCurve_ProcessEvent, + HMI_DemoCurve_PostProcess, + }; //=======================================================================// -//= Global variable declaration. =// +//= Global variable declaration. =// //=======================================================================// -HMI_SCREEN_OBJECT g_stHMIDemo_Curve = { HMI_SCREEN_ID_DEMO_CURVE, - &s_stDemoCurveActions - }; +HMI_SCREEN_OBJECT g_stHMIDemo_Curve = { HMI_SCREEN_ID_DEMO_CURVE, + &s_stDemoCurveActions + }; //=======================================================================// -//= Function define. =// +//= Function define. =// //=======================================================================// SGUI_CURVE_POINT* HMI_DemoCurve_NewPoint(void) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_INT iIndex; - SGUI_CURVE_POINT* pstNewPoint; - - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - pstNewPoint = NULL; - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - for(iIndex=0; iIndexValueArray[s_stRealtimeGraph.Data->ValueCount-1], szTextBuffer, 10, 4, ' '); - - stTextArea.iY = pstDeviceIF->stSize.iHeight-9; - stTextArea.iWidth = 48; - sTextLength = SGUI_Common_IntegerToString(s_stCurve.stData.pstFocused->stPoint.iX, szNumberTextBuffer, 10, -1, ' '); - SGUI_Text_DrawText(pstDeviceIF, szNumberTextBuffer, &SGUI_DEFAULT_FONT_8, &stTextArea, &stInnsrPos, SGUI_DRAW_NORMAL); - stTextArea.iX+=(SGUI_INT)(sTextLength*SGUI_DEFAULT_FONT_8.iHalfWidth); - SGUI_Text_DrawText(pstDeviceIF, ",", &SGUI_DEFAULT_FONT_8, &stTextArea, &stInnsrPos, SGUI_DRAW_NORMAL); - stTextArea.iX+=SGUI_DEFAULT_FONT_8.iHalfWidth; - sTextLength = SGUI_Common_IntegerToString(s_stCurve.stData.pstFocused->stPoint.iY, szNumberTextBuffer, 10, -1, ' '); - SGUI_Text_DrawText(pstDeviceIF, szNumberTextBuffer, &SGUI_DEFAULT_FONT_8, &stTextArea, &stInnsrPos, SGUI_DRAW_NORMAL); - } + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_RECT stTextArea; + SGUI_POINT stInnsrPos; + SGUI_CHAR szNumberTextBuffer[12]; + SGUI_SIZE sTextLength; + + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + SGUI_SystemIF_MemorySet(&stInnsrPos, 0x00, sizeof(SGUI_POINT)); + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + stTextArea.iX = 1; + stTextArea.iY = 1; + stTextArea.iWidth = 48; + stTextArea.iHeight = 8; + SGUI_Text_DrawText(pstDeviceIF, "Focused ", &SGUI_DEFAULT_FONT_8, &stTextArea, &stInnsrPos, SGUI_DRAW_NORMAL); + if(NULL != s_stCurve.stData.pstFocused) + { + //SGUI_Common_IntegerToString(s_stRealtimeGraph.Data->ValueArray[s_stRealtimeGraph.Data->ValueCount-1], szTextBuffer, 10, 4, ' '); + + stTextArea.iY = pstDeviceIF->stSize.iHeight-9; + stTextArea.iWidth = 48; + sTextLength = SGUI_Common_IntegerToString(s_stCurve.stData.pstFocused->stPoint.iX, szNumberTextBuffer, 10, -1, ' '); + SGUI_Text_DrawText(pstDeviceIF, szNumberTextBuffer, &SGUI_DEFAULT_FONT_8, &stTextArea, &stInnsrPos, SGUI_DRAW_NORMAL); + stTextArea.iX+=(SGUI_INT)(sTextLength*SGUI_DEFAULT_FONT_8.iHalfWidth); + SGUI_Text_DrawText(pstDeviceIF, ",", &SGUI_DEFAULT_FONT_8, &stTextArea, &stInnsrPos, SGUI_DRAW_NORMAL); + stTextArea.iX+=SGUI_DEFAULT_FONT_8.iHalfWidth; + sTextLength = SGUI_Common_IntegerToString(s_stCurve.stData.pstFocused->stPoint.iY, szNumberTextBuffer, 10, -1, ' '); + SGUI_Text_DrawText(pstDeviceIF, szNumberTextBuffer, &SGUI_DEFAULT_FONT_8, &stTextArea, &stInnsrPos, SGUI_DRAW_NORMAL); + } } HMI_ENGINE_RESULT HMI_DemoCurve_Initialize(SGUI_SCR_DEV* pstDeviceIF) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_CURVE_PARAM stCurveInitParam; - SGUI_CURVE_POINT* pstNewPoint; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_CURVE_PARAM stCurveInitParam; + SGUI_CURVE_POINT* pstNewPoint; - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - pstNewPoint = NULL; + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + pstNewPoint = NULL; - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - stCurveInitParam.stLayout.iX = 1; - stCurveInitParam.stLayout.iY = 10; - stCurveInitParam.stLayout.iWidth = pstDeviceIF->stSize.iWidth-2; - stCurveInitParam.stLayout.iHeight = pstDeviceIF->stSize.iHeight-20; + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + stCurveInitParam.stLayout.iX = 1; + stCurveInitParam.stLayout.iY = 10; + stCurveInitParam.stLayout.iWidth = pstDeviceIF->stSize.iWidth-2; + stCurveInitParam.stLayout.iHeight = pstDeviceIF->stSize.iHeight-20; - stCurveInitParam.stXRange.iMin = -100; - stCurveInitParam.stXRange.iMax = 100; - stCurveInitParam.stYRange.iMin = -100; - stCurveInitParam.stYRange.iMax = 100; + stCurveInitParam.stXRange.iMin = -100; + stCurveInitParam.stXRange.iMax = 100; + stCurveInitParam.stYRange.iMin = -100; + stCurveInitParam.stYRange.iMax = 100; - SGUI_Curve_Initialize(&s_stCurve, &stCurveInitParam); + SGUI_Curve_Initialize(&s_stCurve, &stCurveInitParam); - pstNewPoint = HMI_DemoCurve_NewPoint(); - SGUI_Curve_InitializePoint(pstNewPoint, -100, -100); - SGUI_Curve_AddPoint(&s_stCurve, pstNewPoint); + pstNewPoint = HMI_DemoCurve_NewPoint(); + SGUI_Curve_InitializePoint(pstNewPoint, -100, -100); + SGUI_Curve_AddPoint(&s_stCurve, pstNewPoint); - pstNewPoint = HMI_DemoCurve_NewPoint(); - SGUI_Curve_InitializePoint(pstNewPoint, 0, 0); - SGUI_Curve_AddPoint(&s_stCurve, pstNewPoint); + pstNewPoint = HMI_DemoCurve_NewPoint(); + SGUI_Curve_InitializePoint(pstNewPoint, 0, 0); + SGUI_Curve_AddPoint(&s_stCurve, pstNewPoint); - pstNewPoint = HMI_DemoCurve_NewPoint(); - SGUI_Curve_InitializePoint(pstNewPoint, 100, 75); - SGUI_Curve_AddPoint(&s_stCurve, pstNewPoint); + pstNewPoint = HMI_DemoCurve_NewPoint(); + SGUI_Curve_InitializePoint(pstNewPoint, 100, 75); + SGUI_Curve_AddPoint(&s_stCurve, pstNewPoint); - pstNewPoint = SGUI_Curve_FocusPoint(&s_stCurve, 1); + pstNewPoint = SGUI_Curve_FocusPoint(&s_stCurve, 1); - pstNewPoint = HMI_DemoCurve_NewPoint(); - SGUI_Curve_InitializePoint(pstNewPoint, -75, -100); - SGUI_Curve_InsertBeforePoint(&s_stCurve, pstNewPoint); + pstNewPoint = HMI_DemoCurve_NewPoint(); + SGUI_Curve_InitializePoint(pstNewPoint, -75, -100); + SGUI_Curve_InsertBeforePoint(&s_stCurve, pstNewPoint); - pstNewPoint = HMI_DemoCurve_NewPoint(); - SGUI_Curve_InitializePoint(pstNewPoint, 50, 25); - SGUI_Curve_InsertAfterPoint(&s_stCurve, pstNewPoint); + pstNewPoint = HMI_DemoCurve_NewPoint(); + SGUI_Curve_InitializePoint(pstNewPoint, 50, 25); + SGUI_Curve_InsertAfterPoint(&s_stCurve, pstNewPoint); - SGUI_Curve_FocusPoint(&s_stCurve, 0); + SGUI_Curve_FocusPoint(&s_stCurve, 0); - return HMI_RET_NORMAL; + return HMI_RET_NORMAL; } HMI_ENGINE_RESULT HMI_DemoCurve_Prepare(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - HMI_DemoCurve_RefreshScreen(pstDeviceIF, pstParameters); - SGUI_Curve_FocusPoint(&s_stCurve, 0); + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + HMI_DemoCurve_RefreshScreen(pstDeviceIF, pstParameters); + SGUI_Curve_FocusPoint(&s_stCurve, 0); - return HMI_RET_NORMAL; + return HMI_RET_NORMAL; } HMI_ENGINE_RESULT HMI_DemoCurve_RefreshScreen(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters) { /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - SGUI_Basic_DrawRectangle(pstDeviceIF, 0, 0, pstDeviceIF->stSize.iWidth, pstDeviceIF->stSize.iHeight, SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); - SGUI_Basic_DrawLine(pstDeviceIF, 1, 9, pstDeviceIF->stSize.iWidth-2, 9, SGUI_COLOR_FRGCLR); - SGUI_Basic_DrawLine(pstDeviceIF, 1, pstDeviceIF->stSize.iHeight-10, pstDeviceIF->stSize.iWidth-2, pstDeviceIF->stSize.iHeight-10, SGUI_COLOR_FRGCLR); - HMI_DemoCurve_RepaintText(pstDeviceIF); - SGUI_Curve_Repaint(pstDeviceIF, &s_stCurve); - SGUI_Curve_HighlightFocus(pstDeviceIF, &s_stCurve); - - return HMI_RET_NORMAL; + /* Process */ + /*----------------------------------*/ + SGUI_Basic_DrawRectangle(pstDeviceIF, 0, 0, pstDeviceIF->stSize.iWidth, pstDeviceIF->stSize.iHeight, SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); + SGUI_Basic_DrawLine(pstDeviceIF, 1, 9, pstDeviceIF->stSize.iWidth-2, 9, SGUI_COLOR_FRGCLR); + SGUI_Basic_DrawLine(pstDeviceIF, 1, pstDeviceIF->stSize.iHeight-10, pstDeviceIF->stSize.iWidth-2, pstDeviceIF->stSize.iHeight-10, SGUI_COLOR_FRGCLR); + HMI_DemoCurve_RepaintText(pstDeviceIF); + SGUI_Curve_Repaint(pstDeviceIF, &s_stCurve); + SGUI_Curve_HighlightFocus(pstDeviceIF, &s_stCurve); + + return HMI_RET_NORMAL; } HMI_ENGINE_RESULT HMI_DemoCurve_ProcessEvent(SGUI_SCR_DEV* pstDeviceIF, const HMI_EVENT_BASE* pstEvent, SGUI_INT* piActionID) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - HMI_ENGINE_RESULT eProcessResult; - KEY_PRESS_EVENT* pstKeyEvent; - SGUI_INT iProcessAction; - SGUI_CURVE_POINT* pstFocusedPoint; - SGUI_CURVE_POINT* pstPointObj; - - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - eProcessResult = HMI_RET_NORMAL; - iProcessAction = HMI_DEMO_PROC_NO_ACT; - pstFocusedPoint = s_stCurve.stData.pstFocused; - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if(EVENT_ID_KEY_PRESS == pstEvent->iID) - { - pstKeyEvent = (KEY_PRESS_EVENT*)pstEvent; - - switch(KEY_CODE_VALUE(pstKeyEvent->Data.uiKeyValue)) - { - case KEY_VALUE_ESC: - { - iProcessAction = HMI_DEMO_PROC_CANCEL; - break; - } - case KEY_VALUE_TAB: - { - if(NULL == s_stCurve.stData.pstFocused) - { - s_stCurve.stData.pstFocused = s_stCurve.stData.stPoints.pstHead; - } - else - { - if(SGUI_TRUE == SGUI_Curve_PointIsHighlight(pstDeviceIF, SGUI_Curve_FocusedPoint(&s_stCurve))) - { - SGUI_Curve_HighlightFocus(pstDeviceIF, &s_stCurve); - } - s_stCurve.stData.pstFocused = s_stCurve.stData.pstFocused->pstNext; - } - pstFocusedPoint = s_stCurve.stData.pstFocused; - HMI_DemoCurve_RefreshScreen(pstDeviceIF, NULL); - break; - } - case KEY_VALUE_UP: - { - if(NULL != pstFocusedPoint) - { - SGUI_Curve_UpdateFocusPoint(&s_stCurve, pstFocusedPoint->stPoint.iX, pstFocusedPoint->stPoint.iY+1); - HMI_DemoCurve_RefreshScreen(pstDeviceIF, NULL); - } - break; - } - case KEY_VALUE_DOWN: - { - if(NULL != pstFocusedPoint) - { - SGUI_Curve_UpdateFocusPoint(&s_stCurve, pstFocusedPoint->stPoint.iX, pstFocusedPoint->stPoint.iY-1); - HMI_DemoCurve_RefreshScreen(pstDeviceIF, NULL); - } - break; - } - case KEY_VALUE_LEFT: - { - if(NULL != pstFocusedPoint) - { - SGUI_Curve_UpdateFocusPoint(&s_stCurve, pstFocusedPoint->stPoint.iX-1, pstFocusedPoint->stPoint.iY); - HMI_DemoCurve_RefreshScreen(pstDeviceIF, NULL); - } - break; - } - case KEY_VALUE_RIGHT: - { - if(NULL != pstFocusedPoint) - { - SGUI_Curve_UpdateFocusPoint(&s_stCurve, pstFocusedPoint->stPoint.iX+1, pstFocusedPoint->stPoint.iY); - HMI_DemoCurve_RefreshScreen(pstDeviceIF, NULL); - } - break; - } - case KEY_VALUE_INSERT: - { - pstPointObj = HMI_DemoCurve_NewPoint(); - if(NULL != pstPointObj) - { - SGUI_Curve_InitializePoint(pstPointObj, 0, s_stCurve.stParam.stYRange.iMin); - if(KEY_OPTION_SHIFT == KEY_CODE_OPT(pstKeyEvent->Data.uiKeyValue)) - { - SGUI_Curve_InsertBeforePoint(&s_stCurve, pstPointObj); - } - else - { - SGUI_Curve_InsertAfterPoint(&s_stCurve, pstPointObj); - } - HMI_DemoCurve_RefreshScreen(pstDeviceIF, NULL); - } - break; - } - case KEY_VALUE_DEL: - { - pstPointObj = SGUI_Curve_FocusedPoint(&s_stCurve); - if(NULL != pstPointObj) - { - if(SGUI_TRUE == SGUI_Curve_RemovePoint(&s_stCurve, pstPointObj)) - { - HMI_DemoBasic_ReleasePoint(pstPointObj); - } - HMI_DemoCurve_RefreshScreen(pstDeviceIF, NULL); - } - - break; - } - default: - { - // do nothing. - break; - } - } - - } + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + HMI_ENGINE_RESULT eProcessResult; + KEY_PRESS_EVENT* pstKeyEvent; + SGUI_INT iProcessAction; + SGUI_CURVE_POINT* pstFocusedPoint; + SGUI_CURVE_POINT* pstPointObj; + + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + eProcessResult = HMI_RET_NORMAL; + iProcessAction = HMI_DEMO_PROC_NO_ACT; + pstFocusedPoint = s_stCurve.stData.pstFocused; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(EVENT_ID_KEY_PRESS == pstEvent->iID) + { + pstKeyEvent = (KEY_PRESS_EVENT*)pstEvent; + + switch(KEY_CODE_VALUE(pstKeyEvent->Data.uiKeyValue)) + { + case KEY_VALUE_ESC: + { + iProcessAction = HMI_DEMO_PROC_CANCEL; + break; + } + case KEY_VALUE_TAB: + { + if(NULL == s_stCurve.stData.pstFocused) + { + s_stCurve.stData.pstFocused = s_stCurve.stData.stPoints.pstHead; + } + else + { + if(SGUI_TRUE == SGUI_Curve_PointIsHighlight(pstDeviceIF, SGUI_Curve_FocusedPoint(&s_stCurve))) + { + SGUI_Curve_HighlightFocus(pstDeviceIF, &s_stCurve); + } + s_stCurve.stData.pstFocused = s_stCurve.stData.pstFocused->pstNext; + } + pstFocusedPoint = s_stCurve.stData.pstFocused; + HMI_DemoCurve_RefreshScreen(pstDeviceIF, NULL); + break; + } + case KEY_VALUE_UP: + { + if(NULL != pstFocusedPoint) + { + SGUI_Curve_UpdateFocusPoint(&s_stCurve, pstFocusedPoint->stPoint.iX, pstFocusedPoint->stPoint.iY+1); + HMI_DemoCurve_RefreshScreen(pstDeviceIF, NULL); + } + break; + } + case KEY_VALUE_DOWN: + { + if(NULL != pstFocusedPoint) + { + SGUI_Curve_UpdateFocusPoint(&s_stCurve, pstFocusedPoint->stPoint.iX, pstFocusedPoint->stPoint.iY-1); + HMI_DemoCurve_RefreshScreen(pstDeviceIF, NULL); + } + break; + } + case KEY_VALUE_LEFT: + { + if(NULL != pstFocusedPoint) + { + SGUI_Curve_UpdateFocusPoint(&s_stCurve, pstFocusedPoint->stPoint.iX-1, pstFocusedPoint->stPoint.iY); + HMI_DemoCurve_RefreshScreen(pstDeviceIF, NULL); + } + break; + } + case KEY_VALUE_RIGHT: + { + if(NULL != pstFocusedPoint) + { + SGUI_Curve_UpdateFocusPoint(&s_stCurve, pstFocusedPoint->stPoint.iX+1, pstFocusedPoint->stPoint.iY); + HMI_DemoCurve_RefreshScreen(pstDeviceIF, NULL); + } + break; + } + case KEY_VALUE_INSERT: + { + pstPointObj = HMI_DemoCurve_NewPoint(); + if(NULL != pstPointObj) + { + SGUI_Curve_InitializePoint(pstPointObj, 0, s_stCurve.stParam.stYRange.iMin); + if(KEY_OPTION_SHIFT == KEY_CODE_OPT(pstKeyEvent->Data.uiKeyValue)) + { + SGUI_Curve_InsertBeforePoint(&s_stCurve, pstPointObj); + } + else + { + SGUI_Curve_InsertAfterPoint(&s_stCurve, pstPointObj); + } + HMI_DemoCurve_RefreshScreen(pstDeviceIF, NULL); + } + break; + } + case KEY_VALUE_DEL: + { + pstPointObj = SGUI_Curve_FocusedPoint(&s_stCurve); + if(NULL != pstPointObj) + { + if(SGUI_TRUE == SGUI_Curve_RemovePoint(&s_stCurve, pstPointObj)) + { + HMI_DemoBasic_ReleasePoint(pstPointObj); + } + HMI_DemoCurve_RefreshScreen(pstDeviceIF, NULL); + } + + break; + } + default: + { + // do nothing. + break; + } + } + + } if(NULL != piActionID) - { - *piActionID = iProcessAction; - } + { + *piActionID = iProcessAction; + } - return eProcessResult; + return eProcessResult; } HMI_ENGINE_RESULT HMI_DemoCurve_PostProcess(SGUI_SCR_DEV* pstDeviceIF, HMI_ENGINE_RESULT eProcResult, SGUI_INT iActionID) { - if(HMI_PROCESS_SUCCESSFUL(eProcResult)) - { - if(HMI_DEMO_PROC_CANCEL == iActionID) - { - HMI_GoBack(NULL); - } - } - - return HMI_RET_NORMAL; + if(HMI_PROCESS_SUCCESSFUL(eProcResult)) + { + if(HMI_DEMO_PROC_CANCEL == iActionID) + { + HMI_GoBack(NULL); + } + } + + return HMI_RET_NORMAL; } diff --git a/DemoProc/src/DemoProc.c b/DemoProc/src/DemoProc.c index 4739738ce6a3feb66248f98da15f904a6247d8ae..66a0f72818208c7d7f0fe518cdc836e8880024d4 100644 --- a/DemoProc/src/DemoProc.c +++ b/DemoProc/src/DemoProc.c @@ -1,11 +1,11 @@ /*************************************************************************/ -/** Copyright. **/ -/** FileName: DemoProc.c **/ -/** Author: Polarix **/ -/** Description: User operation interface. **/ +/** Copyright. **/ +/** FileName: DemoProc.c **/ +/** Author: Polarix **/ +/** Description: User operation interface. **/ /*************************************************************************/ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "DemoProc.h" #include "SGUI_Basic.h" @@ -24,185 +24,185 @@ #endif //=======================================================================// -//= User Macro definition. =// +//= User Macro definition. =// //=======================================================================// -#define BMP_DATA_BUFFER_SIZE (512) +#define BMP_DATA_BUFFER_SIZE (512) //=======================================================================// -//= Static variable declaration. =// +//= Static variable declaration. =// //=======================================================================// -SGUI_SCR_DEV g_stDeviceInterface; -HMI_SCREEN_OBJECT* g_arrpstScreenObjs[] = - { - &g_stHMIDemo_List, - &g_stHMIDemo_TextPaint, - &g_stHMIDemo_VariableBox, - &g_stHMIDemo_RealtimeGraph, - &g_stHMIDemo_Menu, - &g_stHMIDemo_Notice, - &g_stHMIDemo_BasicPaint, - &g_stHMIDemo_Curve - }; -HMI_ENGINE_OBJECT g_stDemoEngine; - -SGUI_BYTE s_pBmpDataBuffer[BMP_DATA_BUFFER_SIZE]; +SGUI_SCR_DEV g_stDeviceInterface; +HMI_SCREEN_OBJECT* g_arrpstScreenObjs[] = + { + &g_stHMIDemo_List, + &g_stHMIDemo_TextPaint, + &g_stHMIDemo_VariableBox, + &g_stHMIDemo_RealtimeGraph, + &g_stHMIDemo_Menu, + &g_stHMIDemo_Notice, + &g_stHMIDemo_BasicPaint, + &g_stHMIDemo_Curve + }; +HMI_ENGINE_OBJECT g_stDemoEngine; + +SGUI_BYTE s_pBmpDataBuffer[BMP_DATA_BUFFER_SIZE]; //=======================================================================// -//= Static function declare. =// +//= Static function declare. =// //=======================================================================// -static void KeyPressEventProc(void); -static void RTCEventProc(void); -static void SysTickTimerEventProc(void); +static void KeyPressEventProc(void); +static void RTCEventProc(void); +static void SysTickTimerEventProc(void); #ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ -static bool CheckEventFlag(ENV_FLAG_INDEX eIndex); +static bool CheckEventFlag(ENV_FLAG_INDEX eIndex); #endif //_SIMPLE_GUI_IN_VIRTUAL_SDK_ //=======================================================================// -//= Function define. =// +//= Function define. =// //=======================================================================// /*****************************************************************************/ -/** Function Name: InitializeHMIEngineObj **/ -/** Purpose: Simple GUI HMI engine and interface demo process. **/ -/** Parameters: None. **/ -/** Return: HMI_ENGINE_RESULT. **/ -/** Notice: This function demonstrates how to use the interface and **/ +/** Function Name: InitializeHMIEngineObj **/ +/** Purpose: Simple GUI HMI engine and interface demo process. **/ +/** Parameters: None. **/ +/** Return: HMI_ENGINE_RESULT. **/ +/** Notice: This function demonstrates how to use the interface and **/ /** HMI engine of Simple GUI. **/ /*****************************************************************************/ HMI_ENGINE_RESULT InitializeHMIEngineObj(void) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - HMI_ENGINE_RESULT eProcessResult; - int iIndex; - - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - eProcessResult = HMI_RET_NORMAL; - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - /* Clear structure. */ - SGUI_SystemIF_MemorySet(&g_stDeviceInterface, 0x00, sizeof(SGUI_SCR_DEV)); - SGUI_SystemIF_MemorySet(&g_stDemoEngine, 0x00, sizeof(HMI_ENGINE_OBJECT)); + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + HMI_ENGINE_RESULT eProcessResult; + int iIndex; + + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + eProcessResult = HMI_RET_NORMAL; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + /* Clear structure. */ + SGUI_SystemIF_MemorySet(&g_stDeviceInterface, 0x00, sizeof(SGUI_SCR_DEV)); + SGUI_SystemIF_MemorySet(&g_stDemoEngine, 0x00, sizeof(HMI_ENGINE_OBJECT)); #ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ - /* Initialize display size. */ - g_stDeviceInterface.stSize.iWidth = 128; - g_stDeviceInterface.stSize.iHeight = 64; - /* Initialize interface object. */ - g_stDeviceInterface.fnSetPixel = SGUI_SDK_SetPixel; - g_stDeviceInterface.fnGetPixel = SGUI_SDK_GetPixel; - g_stDeviceInterface.fnClear = SGUI_SDK_ClearDisplay; - g_stDeviceInterface.fnSyncBuffer = SGUI_SDK_RefreshDisplay; + /* Initialize display size. */ + g_stDeviceInterface.stSize.iWidth = 128; + g_stDeviceInterface.stSize.iHeight = 64; + /* Initialize interface object. */ + g_stDeviceInterface.fnSetPixel = SGUI_SDK_SetPixel; + g_stDeviceInterface.fnGetPixel = SGUI_SDK_GetPixel; + g_stDeviceInterface.fnClear = SGUI_SDK_ClearDisplay; + g_stDeviceInterface.fnSyncBuffer = SGUI_SDK_RefreshDisplay; #else - #error Add screen device object initialize process here. + #error Add screen device object initialize process here. #endif - g_stDeviceInterface.stBuffer.pBuffer = s_pBmpDataBuffer; - g_stDeviceInterface.stBuffer.sSize = BMP_DATA_BUFFER_SIZE; - SGUI_Basic_ResetActiveArea(&g_stDeviceInterface, 0, 0, g_stDeviceInterface.stSize.iWidth, g_stDeviceInterface.stSize.iHeight); - do - { - /* Prepare HMI engine object. */ - g_stDemoEngine.ScreenCount = sizeof(g_arrpstScreenObjs)/sizeof(*g_arrpstScreenObjs); - g_stDemoEngine.ScreenObjPtr = g_arrpstScreenObjs; - g_stDemoEngine.Interface = &g_stDeviceInterface; - - /* Initialize all screen object. */ - if(NULL != g_stDemoEngine.ScreenObjPtr) - { - for(iIndex=0; iIndexpstActions) - && (NULL != g_stDemoEngine.ScreenObjPtr[iIndex]->pstActions->Initialize) - ) - { - g_stDemoEngine.ScreenObjPtr[iIndex]->pstActions->Initialize(&g_stDeviceInterface); - g_stDemoEngine.ScreenObjPtr[iIndex]->pstPrevious = NULL; - } - } - } - else - { - - } - /* Active engine object. */ - eProcessResult = HMI_ActiveEngine(&g_stDemoEngine, HMI_SCREEN_ID_DEMO_LIST); - if(HMI_PROCESS_FAILED(eProcessResult)) - { - /* Active engine failed. */ - break; - } - /* Start engine process. */ - eProcessResult = HMI_StartEngine(NULL); - if(HMI_PROCESS_FAILED(eProcessResult)) - { - /* Start engine failed. */ - break; - } - }while(0); - - return eProcessResult; + g_stDeviceInterface.stBuffer.pBuffer = s_pBmpDataBuffer; + g_stDeviceInterface.stBuffer.sSize = BMP_DATA_BUFFER_SIZE; + SGUI_Basic_ResetActiveArea(&g_stDeviceInterface, 0, 0, g_stDeviceInterface.stSize.iWidth, g_stDeviceInterface.stSize.iHeight); + do + { + /* Prepare HMI engine object. */ + g_stDemoEngine.ScreenCount = sizeof(g_arrpstScreenObjs)/sizeof(*g_arrpstScreenObjs); + g_stDemoEngine.ScreenObjPtr = g_arrpstScreenObjs; + g_stDemoEngine.Interface = &g_stDeviceInterface; + + /* Initialize all screen object. */ + if(NULL != g_stDemoEngine.ScreenObjPtr) + { + for(iIndex=0; iIndexpstActions) + && (NULL != g_stDemoEngine.ScreenObjPtr[iIndex]->pstActions->Initialize) + ) + { + g_stDemoEngine.ScreenObjPtr[iIndex]->pstActions->Initialize(&g_stDeviceInterface); + g_stDemoEngine.ScreenObjPtr[iIndex]->pstPrevious = NULL; + } + } + } + else + { + + } + /* Active engine object. */ + eProcessResult = HMI_ActiveEngine(&g_stDemoEngine, HMI_SCREEN_ID_DEMO_LIST); + if(HMI_PROCESS_FAILED(eProcessResult)) + { + /* Active engine failed. */ + break; + } + /* Start engine process. */ + eProcessResult = HMI_StartEngine(NULL); + if(HMI_PROCESS_FAILED(eProcessResult)) + { + /* Start engine failed. */ + break; + } + }while(0); + + return eProcessResult; } #ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ /*****************************************************************************/ -/** Function Name: CheckEventFlag **/ -/** Purpose: Check SimpleGUI virtual SDK event trigger flag and **/ -/** reset for next trigger and check. **/ -/** Parameters: **/ -/** @ eIndex[in]: Checked flag index. **/ -/** Return: true for event is trigger, false for not. **/ -/** Notice: This function only used in SimpleGUI virtual SDK **/ +/** Function Name: CheckEventFlag **/ +/** Purpose: Check SimpleGUI virtual SDK event trigger flag and **/ +/** reset for next trigger and check. **/ +/** Parameters: **/ +/** @ eIndex[in]: Checked flag index. **/ +/** Return: true for event is trigger, false for not. **/ +/** Notice: This function only used in SimpleGUI virtual SDK **/ /*****************************************************************************/ bool CheckEventFlag(ENV_FLAG_INDEX eIndex) { - /*----------------------------------*/ - /* Variable Declaration */ /*----------------------------------*/ - bool bReturn; + /* Variable Declaration */ + /*----------------------------------*/ + bool bReturn; - /*----------------------------------*/ - /* Process */ /*----------------------------------*/ - bReturn = SGUI_SDK_GetEventSyncFlag(eIndex); + /* Process */ + /*----------------------------------*/ + bReturn = SGUI_SDK_GetEventSyncFlag(eIndex); if(true == bReturn) - { - SGUI_SDK_SetEvnetSyncFlag(eIndex, false); - } + { + SGUI_SDK_SetEvnetSyncFlag(eIndex, false); + } - return bReturn; + return bReturn; } #endif // _SIMPLE_GUI_VIRTUAL_ENVIRONMENT_SIMULATOR_ /*****************************************************************************/ -/** Function Name: DemoMainProcess **/ -/** Purpose: It is a dummy main function for SimpleGUI Virtual SDK, **/ -/** or run demo process in demo process. **/ -/** Parameters: None. **/ -/** Return: Terminal code, seam as main function return code. **/ -/** Notice: None. **/ +/** Function Name: DemoMainProcess **/ +/** Purpose: It is a dummy main function for SimpleGUI Virtual SDK, **/ +/** or run demo process in demo process. **/ +/** Parameters: None. **/ +/** Return: Terminal code, seam as main function return code. **/ +/** Notice: None. **/ /*****************************************************************************/ void DemoMainProcess(void) { - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ // Initialize HMI Engine. InitializeHMIEngineObj(); /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ while(1) { // Check and process heart-beat timer event. if(true == SysTickTimerTriggered()) { - SysTickTimerEventProc(); + SysTickTimerEventProc(); } // Check and process key press event. if(true == UserEventTriggered()) @@ -218,37 +218,37 @@ void DemoMainProcess(void) } /*****************************************************************************/ -/** Function Name: KeyPressEventProc **/ -/** Purpose: Deal with user key process in demo process. **/ -/** Parameters: None. **/ -/** Return: None. **/ -/** Notice: The button is just abstract, and the message may come **/ -/** from a touch screen, a serial port, and so on. **/ +/** Function Name: KeyPressEventProc **/ +/** Purpose: Deal with user key process in demo process. **/ +/** Parameters: None. **/ +/** Return: None. **/ +/** Notice: The button is just abstract, and the message may come **/ +/** from a touch screen, a serial port, and so on. **/ /*****************************************************************************/ void KeyPressEventProc(void) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - KEY_PRESS_EVENT stEvent; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + KEY_PRESS_EVENT stEvent; #ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ const SDK_KB_EVENT* pstSDKEvent; #endif // _SIMPLE_GUI_IN_VIRTUAL_SDK_ - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - HMI_EVENT_INIT(stEvent); + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + HMI_EVENT_INIT(stEvent); - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - stEvent.Head.iType = EVENT_TYPE_ACTION; - stEvent.Head.iID = EVENT_ID_KEY_PRESS; + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + stEvent.Head.iType = EVENT_TYPE_ACTION; + stEvent.Head.iID = EVENT_ID_KEY_PRESS; #ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ pstSDKEvent = SGUI_SDK_GetKeyEventData(); - stEvent.Data.uiKeyValue = pstSDKEvent->iKeyCode; - if(pstSDKEvent->bShift) + stEvent.Data.uiKeyValue = pstSDKEvent->iKeyCode; + if(pstSDKEvent->bShift) { stEvent.Data.uiKeyValue |= KEY_OPTION_SHIFT; } @@ -261,163 +261,163 @@ void KeyPressEventProc(void) stEvent.Data.uiKeyValue |= KEY_OPTION_ALT; } #else - #error Add key event data prepare process here. + #error Add key event data prepare process here. #endif - // Post key press event. - HMI_ProcessEvent((HMI_EVENT_BASE*)(&stEvent)); + // Post key press event. + HMI_ProcessEvent((HMI_EVENT_BASE*)(&stEvent)); } /*****************************************************************************/ -/** Function Name: SysTickTimerEventProc **/ -/** Purpose: Deal with heartbeat timer event in demo process. **/ -/** Parameters: None. **/ -/** Return: None. **/ -/** Notice: It is usually used to simulate ADC or other sensors. **/ +/** Function Name: SysTickTimerEventProc **/ +/** Purpose: Deal with heartbeat timer event in demo process. **/ +/** Parameters: None. **/ +/** Return: None. **/ +/** Notice: It is usually used to simulate ADC or other sensors. **/ /*****************************************************************************/ void SysTickTimerEventProc(void) { /*----------------------------------*/ - /* Variable Declaration */ + /* Variable Declaration */ /*----------------------------------*/ - DATA_EVENT stEvent; + DATA_EVENT stEvent; /*----------------------------------*/ - /* Initialize */ + /* Initialize */ /*----------------------------------*/ HMI_EVENT_INIT(stEvent); /*----------------------------------*/ - /* Process */ + /* Process */ /*----------------------------------*/ - stEvent.Head.iType = EVENT_TYPE_DATA; - stEvent.Head.iID = EVENT_ID_TIMER; + stEvent.Head.iType = EVENT_TYPE_DATA; + stEvent.Head.iID = EVENT_ID_TIMER; stEvent.Data.iValue = (rand() % 200)-100; // Post timer event. HMI_ProcessEvent((HMI_EVENT_BASE*)&stEvent); } /*****************************************************************************/ -/** Function Name: RTCEventProc **/ -/** Purpose: Deal with RTC timer event in demo process. **/ -/** Parameters: None. **/ -/** Return: None. **/ -/** Notice: It is usually used to simulate ADC or other sensors. **/ +/** Function Name: RTCEventProc **/ +/** Purpose: Deal with RTC timer event in demo process. **/ +/** Parameters: None. **/ +/** Return: None. **/ +/** Notice: It is usually used to simulate ADC or other sensors. **/ /*****************************************************************************/ void RTCEventProc(void) { /*----------------------------------*/ - /* Variable Declaration */ + /* Variable Declaration */ /*----------------------------------*/ - HMI_GENERAL_EVENT stEvent; + HMI_GENERAL_EVENT stEvent; /*----------------------------------*/ - /* Initialize */ + /* Initialize */ /*----------------------------------*/ HMI_EVENT_INIT(stEvent); /*----------------------------------*/ - /* Process */ + /* Process */ /*----------------------------------*/ - stEvent.Head.iType = EVENT_TYPE_DATA; - stEvent.Head.iID = EVENT_ID_RTC; + stEvent.Head.iType = EVENT_TYPE_DATA; + stEvent.Head.iID = EVENT_ID_RTC; // Post RTC update message to a screen. HMI_ProcessEvent((HMI_EVENT_BASE*)&stEvent); } /*****************************************************************************/ -/** Function Name: SysTickTimerTriggered **/ -/** Purpose: Check sys-tick timer interrupt is triggered. **/ -/** Parameters: None. **/ -/** Return: None. **/ -/** Notice: None. **/ +/** Function Name: SysTickTimerTriggered **/ +/** Purpose: Check sys-tick timer interrupt is triggered. **/ +/** Parameters: None. **/ +/** Return: None. **/ +/** Notice: None. **/ /*****************************************************************************/ bool SysTickTimerTriggered(void) { - /*----------------------------------*/ - /* Process */ + /*----------------------------------*/ + /* Process */ /*----------------------------------*/ #ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ - return CheckEventFlag(ENV_FLAG_IDX_SDK_TIM_EVENT); + return CheckEventFlag(ENV_FLAG_IDX_SDK_TIM_EVENT); #else - #error Add sys-tick timer trigger process here. + #error Add sys-tick timer trigger process here. #endif } /*****************************************************************************/ -/** Function Name: RTCTimerTriggered **/ -/** Purpose: Check RTC timer interrupt is triggered. **/ -/** Parameters: None. **/ -/** Return: None. **/ -/** Notice: None. **/ +/** Function Name: RTCTimerTriggered **/ +/** Purpose: Check RTC timer interrupt is triggered. **/ +/** Parameters: None. **/ +/** Return: None. **/ +/** Notice: None. **/ /*****************************************************************************/ bool RTCTimerTriggered(void) { - /*----------------------------------*/ - /* Process */ + /*----------------------------------*/ + /* Process */ /*----------------------------------*/ #ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ - return CheckEventFlag(ENV_FLAG_IDX_SDK_SEC_EVENT); + return CheckEventFlag(ENV_FLAG_IDX_SDK_SEC_EVENT); #else // // Add Dummy RTC trigger process here. - return false; + return false; #endif } /*****************************************************************************/ -/** Function Name: UserEventTriggered **/ -/** Purpose: Check user event is triggered. **/ -/** Parameters: None. **/ -/** Return: None. **/ -/** Notice: None. **/ +/** Function Name: UserEventTriggered **/ +/** Purpose: Check user event is triggered. **/ +/** Parameters: None. **/ +/** Return: None. **/ +/** Notice: None. **/ /*****************************************************************************/ bool UserEventTriggered(void) { - /*----------------------------------*/ - /* Process */ + /*----------------------------------*/ + /* Process */ /*----------------------------------*/ #ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ - return CheckEventFlag(ENV_FLAG_IDX_SDK_KEY_EVENT); + return CheckEventFlag(ENV_FLAG_IDX_SDK_KEY_EVENT); #else - #error Add user event trigger process here. + #error Add user event trigger process here. #endif } /*****************************************************************************/ -/** Function Name: SysTickTimerEnable **/ -/** Purpose: Enable or disable sys-tick timer. **/ -/** Parameters: **/ -/** @ bEnable[in]: True for enable sys-tick timer, false for disable. **/ -/** Return: None. **/ -/** Notice: None. **/ +/** Function Name: SysTickTimerEnable **/ +/** Purpose: Enable or disable sys-tick timer. **/ +/** Parameters: **/ +/** @ bEnable[in]: True for enable sys-tick timer, false for disable. **/ +/** Return: None. **/ +/** Notice: None. **/ /*****************************************************************************/ void SysTickTimerEnable(bool bEnable) { - /*----------------------------------*/ - /* Process */ + /*----------------------------------*/ + /* Process */ /*----------------------------------*/ #ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ - (void)SGUI_SDK_ConfigGeneralTimer(bEnable?DEMO_HEART_BEAT_INTERVAL_MS:0); + (void)SGUI_SDK_ConfigGeneralTimer(bEnable?DEMO_HEART_BEAT_INTERVAL_MS:0); #else - #error Add sys-tick timer enable/disable process here. + #error Add sys-tick timer enable/disable process here. #endif } /*****************************************************************************/ -/** Function Name: RTCTimerEnable **/ -/** Purpose: Enable or disable RTC timer. **/ -/** Parameters: **/ -/** @ bEnable[in]: True for enable RTC timer, false for disable. **/ -/** Return: None. **/ -/** Notice: None. **/ +/** Function Name: RTCTimerEnable **/ +/** Purpose: Enable or disable RTC timer. **/ +/** Parameters: **/ +/** @ bEnable[in]: True for enable RTC timer, false for disable. **/ +/** Return: None. **/ +/** Notice: None. **/ /*****************************************************************************/ void RTCTimerEnable(bool bEnable) { - /*----------------------------------*/ - /* Process */ + /*----------------------------------*/ + /* Process */ /*----------------------------------*/ #ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ - (void)SGUI_SDK_EnableSecondInterrupt(bEnable); + (void)SGUI_SDK_EnableSecondInterrupt(bEnable); #endif } diff --git a/DemoProc/src/List.c b/DemoProc/src/List.c index cba01c1451697d8c694b2b86a42967842adbc14b..2837dfeb25404d11100d18cb487f53597cbff4a8 100644 --- a/DemoProc/src/List.c +++ b/DemoProc/src/List.c @@ -1,11 +1,11 @@ -/*************************************************************************/ -/** Copyright. **/ -/** FileName: List.c **/ -/** Author: Polarix **/ -/** Description: HMI demo for list control interface. **/ +/*************************************************************************/ +/** Copyright. **/ +/** FileName: List.c **/ +/** Author: Polarix **/ +/** Description: HMI demo for list control interface. **/ /*************************************************************************/ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "DemoProc.h" #include "SGUI_List.h" @@ -13,337 +13,339 @@ #include "Resource.h" //=======================================================================// -//= User Macro definition. =// +//= User Macro definition. =// //=======================================================================// -#define NOTICE_TEXT_BUFFER_SIZE (64) +#define NOTICE_TEXT_BUFFER_SIZE (64) //=======================================================================// -//= Static function declaration. =// +//= Static function declaration. =// //=======================================================================// -static HMI_ENGINE_RESULT HMI_DemoList_Initialize(SGUI_SCR_DEV* pstDeviceIF); -static HMI_ENGINE_RESULT HMI_DemoList_Prepare(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters); -static HMI_ENGINE_RESULT HMI_DemoList_RefreshScreen(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters); -static HMI_ENGINE_RESULT HMI_DemoList_ProcessEvent(SGUI_SCR_DEV* pstDeviceIF, const HMI_EVENT_BASE* pstEvent, SGUI_INT* piActionID); -static HMI_ENGINE_RESULT HMI_DemoList_PostProcess(SGUI_SCR_DEV* pstDeviceIF, HMI_ENGINE_RESULT eProcResult, SGUI_INT iActionID); +static HMI_ENGINE_RESULT HMI_DemoList_Initialize(SGUI_SCR_DEV* pstDeviceIF); +static HMI_ENGINE_RESULT HMI_DemoList_Prepare(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters); +static HMI_ENGINE_RESULT HMI_DemoList_RefreshScreen(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters); +static HMI_ENGINE_RESULT HMI_DemoList_ProcessEvent(SGUI_SCR_DEV* pstDeviceIF, const HMI_EVENT_BASE* pstEvent, SGUI_INT* piActionID); +static HMI_ENGINE_RESULT HMI_DemoList_PostProcess(SGUI_SCR_DEV* pstDeviceIF, HMI_ENGINE_RESULT eProcResult, SGUI_INT iActionID); //=======================================================================// -//= Static variable declaration. =// +//= Static variable declaration. =// //=======================================================================// -static const SGUI_RECT s_arrstLayouts[] = { {0, 0, 96, 48}, - {0, 0, 128, 64}, - {0, 0, 192, 128}, - {0, 0, 256, 160}, - }; -static SGUI_SIZE s_iLayoutIndex = 1; +static const SGUI_RECT s_arrstLayouts[] = { {0, 0, 96, 48}, + {0, 0, 128, 64}, + {0, 0, 192, 128}, + {0, 0, 256, 160}, + }; +static SGUI_SIZE s_iLayoutIndex = 1; -static SGUI_ITEMS_ITEM s_arrstListItems[] = { {SCR1_LIST_ITEM1, NULL}, - {SCR1_LIST_ITEM2, NULL}, - {SCR1_LIST_ITEM3, NULL}, - {SCR1_LIST_ITEM4, NULL}, - {SCR1_LIST_ITEM5, NULL}, - {SCR1_LIST_ITEM6, NULL}, - {SCR1_LIST_ITEM7, NULL} - }; +static SGUI_ITEMS_ITEM s_arrstListItems[] = { {SCR1_LIST_ITEM1, NULL}, + {SCR1_LIST_ITEM2, NULL}, + {SCR1_LIST_ITEM3, NULL}, + {SCR1_LIST_ITEM4, NULL}, + {SCR1_LIST_ITEM5, NULL}, + {SCR1_LIST_ITEM6, NULL}, + {SCR1_LIST_ITEM7, NULL} + }; typedef struct { - SGUI_ITEMS_ITEM stItem; - SGUI_BOOL bUsed; + SGUI_ITEMS_ITEM stItem; + SGUI_BOOL bUsed; }SGUI_TEST_ITEM; -static SGUI_TEST_ITEM s_arrstAppendListItems[] = { {{SCR1_LIST_APPEND1, NULL}, SGUI_FALSE}, - {{SCR1_LIST_APPEND2, NULL}, SGUI_FALSE}, - {{SCR1_LIST_APPEND3, NULL}, SGUI_FALSE}, - {{SCR1_LIST_APPEND4, NULL}, SGUI_FALSE}, - {{SCR1_LIST_APPEND5, NULL}, SGUI_FALSE}, - {{SCR1_LIST_APPEND6, NULL}, SGUI_FALSE} - }; +static SGUI_TEST_ITEM s_arrstAppendListItems[] = { {{SCR1_LIST_APPEND1, NULL}, SGUI_FALSE}, + {{SCR1_LIST_APPEND2, NULL}, SGUI_FALSE}, + {{SCR1_LIST_APPEND3, NULL}, SGUI_FALSE}, + {{SCR1_LIST_APPEND4, NULL}, SGUI_FALSE}, + {{SCR1_LIST_APPEND5, NULL}, SGUI_FALSE}, + {{SCR1_LIST_APPEND6, NULL}, SGUI_FALSE} + }; -static SGUI_LIST s_stDemoListObject = {0x00}; +static SGUI_LIST s_stDemoListObject = {0x00}; //=======================================================================// -//= Global variable declaration. =// +//= Global variable declaration. =// //=======================================================================// -HMI_SCREEN_ACTION s_stDemoListActions = { HMI_DemoList_Initialize, - HMI_DemoList_Prepare, - HMI_DemoList_RefreshScreen, - HMI_DemoList_ProcessEvent, - HMI_DemoList_PostProcess - }; -HMI_SCREEN_OBJECT g_stHMIDemo_List = { HMI_SCREEN_ID_DEMO_LIST, - &s_stDemoListActions - }; +HMI_SCREEN_ACTION s_stDemoListActions = { HMI_DemoList_Initialize, + HMI_DemoList_Prepare, + HMI_DemoList_RefreshScreen, + HMI_DemoList_ProcessEvent, + HMI_DemoList_PostProcess + }; +HMI_SCREEN_OBJECT g_stHMIDemo_List = { HMI_SCREEN_ID_DEMO_LIST, + &s_stDemoListActions + }; //=======================================================================// -//= Function define. =// +//= Function define. =// //=======================================================================// HMI_ENGINE_RESULT HMI_DemoList_Initialize(SGUI_SCR_DEV* pstDeviceIF) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_RECT stListLayout; - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_RECT stListLayout; + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ // Initialize list data. SGUI_SystemIF_MemorySet(&s_stDemoListObject, 0x00, sizeof(SGUI_LIST)); //Initialize list object. - stListLayout.iX = 0; - stListLayout.iY = 0; - stListLayout.iWidth = pstDeviceIF->stSize.iWidth; - stListLayout.iHeight = pstDeviceIF->stSize.iHeight; - SGUI_List_Initialize(&s_stDemoListObject, &stListLayout, &GB2312_FZXS12, SCR1_TITLE, s_arrstListItems, sizeof(s_arrstListItems)/sizeof(SGUI_ITEMS_ITEM)); - return HMI_RET_NORMAL; + stListLayout.iX = 0; + stListLayout.iY = 0; + stListLayout.iWidth = pstDeviceIF->stSize.iWidth; + stListLayout.iHeight = pstDeviceIF->stSize.iHeight; + SGUI_List_Initialize(&s_stDemoListObject, &stListLayout, &GB2312_FZXS12, SCR1_TITLE, s_arrstListItems, sizeof(s_arrstListItems)/sizeof(SGUI_ITEMS_ITEM)); + return HMI_RET_NORMAL; } HMI_ENGINE_RESULT HMI_DemoList_Prepare (SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters) { - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - SGUI_List_Repaint(pstDeviceIF, &s_stDemoListObject); - return HMI_RET_NORMAL; + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + SGUI_List_Repaint(pstDeviceIF, &s_stDemoListObject); + return HMI_RET_NORMAL; } HMI_ENGINE_RESULT HMI_DemoList_RefreshScreen(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters) { - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - SGUI_List_Repaint(pstDeviceIF, &s_stDemoListObject); - return HMI_RET_NORMAL; + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + SGUI_List_Repaint(pstDeviceIF, &s_stDemoListObject); + return HMI_RET_NORMAL; } HMI_ENGINE_RESULT HMI_DemoList_ProcessEvent(SGUI_SCR_DEV* pstDeviceIF, const HMI_EVENT_BASE* pstEvent, SGUI_INT* piActionID) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - HMI_ENGINE_RESULT eProcessResult; - SGUI_UINT16 uiKeyCode; - SGUI_UINT16 uiKeyValue; - KEY_PRESS_EVENT* pstKeyEvent; - SGUI_INT iProcessAction; - SGUI_SIZE sInsertDataIdx; - SGUI_ITEMS_ITEM* pstItemObj; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + HMI_ENGINE_RESULT eProcessResult; + SGUI_UINT16 uiKeyCode; + SGUI_UINT16 uiKeyValue; + KEY_PRESS_EVENT* pstKeyEvent; + SGUI_INT iProcessAction; + SGUI_SIZE sInsertDataIdx; + SGUI_ITEMS_ITEM* pstItemObj; - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - eProcessResult = HMI_RET_NORMAL; - pstKeyEvent = (KEY_PRESS_EVENT*)pstEvent; - iProcessAction = HMI_DEMO_PROC_NO_ACT; + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + eProcessResult = HMI_RET_NORMAL; + pstKeyEvent = (KEY_PRESS_EVENT*)pstEvent; + iProcessAction = HMI_DEMO_PROC_NO_ACT; - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if(pstEvent->iType == EVENT_TYPE_ACTION) - { - // Check event is valid. - if(SGUI_FALSE == HMI_EVENT_SIZE_CHK(*pstKeyEvent, KEY_PRESS_EVENT)) - { - // Event data is invalid. - eProcessResult = HMI_RET_INVALID_DATA; - } - else if(EVENT_ID_KEY_PRESS == pstEvent->iID) - { - uiKeyCode = pstKeyEvent->Data.uiKeyValue; - uiKeyValue = KEY_CODE_VALUE(uiKeyCode); - switch(uiKeyValue) - { - case KEY_VALUE_ENTER: - { - iProcessAction = HMI_DEMO_PROC_CONFIRM; - break; - } - case KEY_VALUE_ESC: - { - iProcessAction = HMI_DEMO_PROC_CANCEL; - break; - } - case KEY_VALUE_UP: - { - if(SGUI_List_GetSelection(&s_stDemoListObject)->iIndex > 0) - { - SGUI_List_Selecte(&s_stDemoListObject, SGUI_List_GetSelection(&s_stDemoListObject)->iIndex-1); - } - SGUI_List_Repaint(pstDeviceIF, &s_stDemoListObject); - break; - } - case KEY_VALUE_DOWN: - { - if(SGUI_List_GetSelection(&s_stDemoListObject)->iIndex < (s_stDemoListObject.stItems.iCount-1)) - { - SGUI_List_Selecte(&s_stDemoListObject, SGUI_List_GetSelection(&s_stDemoListObject)->iIndex+1); - } - SGUI_List_Repaint(pstDeviceIF, &s_stDemoListObject); - break; - } - case KEY_VALUE_PLUS_PAD: - { - // Erase old paint. - SGUI_Basic_DrawRectangle(pstDeviceIF, s_arrstLayouts[s_iLayoutIndex].iX, s_arrstLayouts[s_iLayoutIndex].iY, s_arrstLayouts[s_iLayoutIndex].iWidth, s_arrstLayouts[s_iLayoutIndex].iHeight, SGUI_COLOR_BKGCLR, SGUI_COLOR_BKGCLR); - // Select new layout. - s_iLayoutIndex++; - s_iLayoutIndex = s_iLayoutIndex%(sizeof(s_arrstLayouts)/sizeof(SGUI_RECT)); - // Resize and repaint. - SGUI_List_Resize(&s_stDemoListObject, &(s_arrstLayouts[s_iLayoutIndex])); - SGUI_List_Repaint(pstDeviceIF, &s_stDemoListObject); - break; - } - case KEY_VALUE_SUB_PAD: - { - // Erase old paint. - SGUI_Basic_DrawRectangle(pstDeviceIF, s_arrstLayouts[s_iLayoutIndex].iX, s_arrstLayouts[s_iLayoutIndex].iY, s_arrstLayouts[s_iLayoutIndex].iWidth, s_arrstLayouts[s_iLayoutIndex].iHeight, SGUI_COLOR_BKGCLR, SGUI_COLOR_BKGCLR); - // Select new layout. - s_iLayoutIndex--; - s_iLayoutIndex = s_iLayoutIndex%(sizeof(s_arrstLayouts)/sizeof(SGUI_RECT)); - // Resize and repaint. - SGUI_List_Resize(&s_stDemoListObject, &(s_arrstLayouts[s_iLayoutIndex])); - SGUI_List_Repaint(pstDeviceIF, &s_stDemoListObject); - break; - } - case KEY_VALUE_DEL: - { - sInsertDataIdx = 0; - pstItemObj = SGUI_List_RemoveItem(&s_stDemoListObject, SGUI_List_GetSelection(&s_stDemoListObject)->iIndex); - while(sInsertDataIdx < sizeof(s_arrstAppendListItems)/sizeof(SGUI_TEST_ITEM)) - { - if(pstItemObj == &(s_arrstAppendListItems[sInsertDataIdx].stItem)) - { - s_arrstAppendListItems[sInsertDataIdx].bUsed = SGUI_FALSE; - break; - } - else - { - sInsertDataIdx++; - } - } - SGUI_List_Repaint(pstDeviceIF, &s_stDemoListObject); - break; - } - case KEY_VALUE_INSERT: - { - sInsertDataIdx = 0; - while(sInsertDataIdx < sizeof(s_arrstAppendListItems)/sizeof(SGUI_TEST_ITEM)) - { - if(SGUI_FALSE == s_arrstAppendListItems[sInsertDataIdx].bUsed) - { - s_arrstAppendListItems[sInsertDataIdx].bUsed = (SGUI_List_InsertItem(&s_stDemoListObject, &(s_arrstAppendListItems[sInsertDataIdx].stItem), SGUI_List_GetSelection(&s_stDemoListObject)->iIndex))?SGUI_TRUE:SGUI_FALSE; - break; - } - else - { - sInsertDataIdx++; - } - } - SGUI_List_Repaint(pstDeviceIF, &s_stDemoListObject); - break; - } - case KEY_VALUE_HOME: - { - sInsertDataIdx = 0; - while(sInsertDataIdx < sizeof(s_arrstAppendListItems)/sizeof(SGUI_TEST_ITEM)) - { - if(SGUI_FALSE == s_arrstAppendListItems[sInsertDataIdx].bUsed) - { - s_arrstAppendListItems[sInsertDataIdx].bUsed = (SGUI_List_InsertItem(&s_stDemoListObject, &(s_arrstAppendListItems[sInsertDataIdx].stItem), 0)?SGUI_TRUE:SGUI_FALSE); - break; - } - else - { - sInsertDataIdx++; - } - } - SGUI_List_Repaint(pstDeviceIF, &s_stDemoListObject); - break; - } - case KEY_VALUE_END: - { - sInsertDataIdx = 0; - while(sInsertDataIdx < sizeof(s_arrstAppendListItems)/sizeof(SGUI_TEST_ITEM)) - { - if(SGUI_FALSE == s_arrstAppendListItems[sInsertDataIdx].bUsed) - { - s_arrstAppendListItems[sInsertDataIdx].bUsed = (SGUI_List_InsertItem(&s_stDemoListObject, &(s_arrstAppendListItems[sInsertDataIdx].stItem), SGUI_List_Count(&s_stDemoListObject))?SGUI_TRUE:SGUI_FALSE); - break; - } - else - { - sInsertDataIdx++; - } - } - SGUI_List_Repaint(pstDeviceIF, &s_stDemoListObject); - break; - } - default: - { - break; - } - } - } - } - if(NULL != piActionID) - { - *piActionID = iProcessAction; - } + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(pstEvent->iType == EVENT_TYPE_ACTION) + { + // Check event is valid. + if(SGUI_FALSE == HMI_EVENT_SIZE_CHK(*pstKeyEvent, KEY_PRESS_EVENT)) + { + // Event data is invalid. + eProcessResult = HMI_RET_INVALID_DATA; + } + else if(EVENT_ID_KEY_PRESS == pstEvent->iID) + { + uiKeyCode = pstKeyEvent->Data.uiKeyValue; + uiKeyValue = KEY_CODE_VALUE(uiKeyCode); + switch(uiKeyValue) + { + case KEY_VALUE_ENTER: + { + iProcessAction = HMI_DEMO_PROC_CONFIRM; + break; + } + case KEY_VALUE_ESC: + { + iProcessAction = HMI_DEMO_PROC_CANCEL; + break; + } + case KEY_VALUE_UP: + { + if(SGUI_List_GetSelection(&s_stDemoListObject)->iIndex > 0) + { + SGUI_List_Selecte(&s_stDemoListObject, SGUI_List_GetSelection(&s_stDemoListObject)->iIndex-1); + } + SGUI_List_Repaint(pstDeviceIF, &s_stDemoListObject); + break; + } + case KEY_VALUE_DOWN: + { + if(SGUI_List_GetSelection(&s_stDemoListObject)->iIndex < (s_stDemoListObject.stItems.iCount-1)) + { + SGUI_List_Selecte(&s_stDemoListObject, SGUI_List_GetSelection(&s_stDemoListObject)->iIndex+1); + } + SGUI_List_Repaint(pstDeviceIF, &s_stDemoListObject); + break; + } + case KEY_VALUE_PLUS_PAD: + { + // Erase old paint. + SGUI_Basic_DrawRectangle(pstDeviceIF, s_arrstLayouts[s_iLayoutIndex].iX, s_arrstLayouts[s_iLayoutIndex].iY, s_arrstLayouts[s_iLayoutIndex].iWidth, s_arrstLayouts[s_iLayoutIndex].iHeight, SGUI_COLOR_BKGCLR, SGUI_COLOR_BKGCLR); + // Select new layout. + s_iLayoutIndex++; + s_iLayoutIndex = s_iLayoutIndex%(sizeof(s_arrstLayouts)/sizeof(SGUI_RECT)); + // Resize and repaint. + SGUI_List_Resize(&s_stDemoListObject, &(s_arrstLayouts[s_iLayoutIndex])); + SGUI_List_Repaint(pstDeviceIF, &s_stDemoListObject); + break; + } + case KEY_VALUE_SUB_PAD: + { + // Erase old paint. + SGUI_Basic_DrawRectangle(pstDeviceIF, s_arrstLayouts[s_iLayoutIndex].iX, s_arrstLayouts[s_iLayoutIndex].iY, s_arrstLayouts[s_iLayoutIndex].iWidth, s_arrstLayouts[s_iLayoutIndex].iHeight, SGUI_COLOR_BKGCLR, SGUI_COLOR_BKGCLR); + // Select new layout. + s_iLayoutIndex--; + s_iLayoutIndex = s_iLayoutIndex%(sizeof(s_arrstLayouts)/sizeof(SGUI_RECT)); + // Resize and repaint. + SGUI_List_Resize(&s_stDemoListObject, &(s_arrstLayouts[s_iLayoutIndex])); + SGUI_List_Repaint(pstDeviceIF, &s_stDemoListObject); + break; + } + case KEY_VALUE_DEL: + { + sInsertDataIdx = 0; + pstItemObj = SGUI_List_RemoveItem(&s_stDemoListObject, SGUI_List_GetSelection(&s_stDemoListObject)->iIndex); + while(sInsertDataIdx < sizeof(s_arrstAppendListItems)/sizeof(SGUI_TEST_ITEM)) + { + if(pstItemObj == &(s_arrstAppendListItems[sInsertDataIdx].stItem)) + { + s_arrstAppendListItems[sInsertDataIdx].bUsed = SGUI_FALSE; + break; + } + else + { + sInsertDataIdx++; + } + } + SGUI_List_Repaint(pstDeviceIF, &s_stDemoListObject); + break; + } + case KEY_VALUE_INSERT: + { + sInsertDataIdx = 0; + while(sInsertDataIdx < sizeof(s_arrstAppendListItems)/sizeof(SGUI_TEST_ITEM)) + { + if(SGUI_FALSE == s_arrstAppendListItems[sInsertDataIdx].bUsed) + { + s_arrstAppendListItems[sInsertDataIdx].bUsed = (SGUI_List_InsertItem(&s_stDemoListObject, &(s_arrstAppendListItems[sInsertDataIdx].stItem), SGUI_List_GetSelection(&s_stDemoListObject)->iIndex))?SGUI_TRUE:SGUI_FALSE; + break; + } + else + { + sInsertDataIdx++; + } + } + SGUI_List_Repaint(pstDeviceIF, &s_stDemoListObject); + break; + } + case KEY_VALUE_HOME: + { + sInsertDataIdx = 0; + while(sInsertDataIdx < sizeof(s_arrstAppendListItems)/sizeof(SGUI_TEST_ITEM)) + { + if(SGUI_FALSE == s_arrstAppendListItems[sInsertDataIdx].bUsed) + { + s_arrstAppendListItems[sInsertDataIdx].bUsed = (SGUI_List_InsertItem(&s_stDemoListObject, &(s_arrstAppendListItems[sInsertDataIdx].stItem), 0)?SGUI_TRUE:SGUI_FALSE); + break; + } + else + { + sInsertDataIdx++; + } + } + SGUI_List_Repaint(pstDeviceIF, &s_stDemoListObject); + break; + } + case KEY_VALUE_END: + { + sInsertDataIdx = 0; + while(sInsertDataIdx < sizeof(s_arrstAppendListItems)/sizeof(SGUI_TEST_ITEM)) + { + if(SGUI_FALSE == s_arrstAppendListItems[sInsertDataIdx].bUsed) + { + s_arrstAppendListItems[sInsertDataIdx].bUsed = (SGUI_List_InsertItem(&s_stDemoListObject, &(s_arrstAppendListItems[sInsertDataIdx].stItem), SGUI_List_Count(&s_stDemoListObject))?SGUI_TRUE:SGUI_FALSE); + break; + } + else + { + sInsertDataIdx++; + } + } + SGUI_List_Repaint(pstDeviceIF, &s_stDemoListObject); + break; + } + default: + { + break; + } + } + } + } + if(NULL != piActionID) + { + *piActionID = iProcessAction; + } - return eProcessResult; + return eProcessResult; } HMI_ENGINE_RESULT HMI_DemoList_PostProcess(SGUI_SCR_DEV* pstDeviceIF, HMI_ENGINE_RESULT eProcResult, SGUI_INT iActionID) { - if(HMI_DEMO_PROC_CONFIRM == iActionID) - { + if(HMI_DEMO_PROC_CONFIRM == iActionID) + { switch(SGUI_List_GetSelection(&s_stDemoListObject)->iIndex) { - case 0: - { - HMI_SwitchScreen(HMI_SCREEN_ID_DEMO_BASIC_PAINT, NULL); - break; - } - case 1: - { - HMI_SwitchScreen(HMI_SCREEN_ID_DEMO_PAINT_TEXT, NULL); - break; - } - case 2: - { - HMI_SwitchScreen(HMI_SCREEN_ID_DEMO_VARIABLE_BOX, NULL); - break; - } - case 3: - { - HMI_SwitchScreen(HMI_SCREEN_ID_DEMO_REAL_TIME_GRAPH, NULL); - break; - } - case 4: - { - HMI_SwitchScreen(HMI_SCREEN_ID_DEMO_MENU, NULL); - break; - } - case 5: - { - HMI_SwitchScreen(HMI_SCREEN_ID_DEMO_TEXT_NOTICE, SCR7_NOTICE_TEXT); - break; - } - case 6: - { - HMI_SwitchScreen(HMI_SCREEN_ID_DEMO_CURVE, NULL); - break; - } - default: - { - /* do nothing. */ - } + case 0: + { + HMI_SwitchScreen(HMI_SCREEN_ID_DEMO_BASIC_PAINT, NULL); + break; + } + case 1: + { + HMI_SwitchScreen(HMI_SCREEN_ID_DEMO_PAINT_TEXT, NULL); + break; + } + case 2: + { + HMI_SwitchScreen(HMI_SCREEN_ID_DEMO_VARIABLE_BOX, NULL); + break; + } + case 3: + { + HMI_SwitchScreen(HMI_SCREEN_ID_DEMO_REAL_TIME_GRAPH, NULL); + break; + } + case 4: + { + HMI_SwitchScreen(HMI_SCREEN_ID_DEMO_MENU, NULL); + break; + } + case 5: + { + HMI_SwitchScreen(HMI_SCREEN_ID_DEMO_TEXT_NOTICE, SCR7_NOTICE_TEXT); + break; + } + case 6: + { + HMI_SwitchScreen(HMI_SCREEN_ID_DEMO_CURVE, NULL); + break; + } + default: + { + /* do nothing. */ + } } - } - else if(HMI_DEMO_PROC_CANCEL == iActionID) - { - HMI_GoBack(NULL); - } + } + else if(HMI_DEMO_PROC_CANCEL == iActionID) + { + HMI_GoBack(NULL); + } - return HMI_RET_NORMAL; + return HMI_RET_NORMAL; } + + diff --git a/DemoProc/src/Menu.c b/DemoProc/src/Menu.c index c716e74c88286bd568235e24331ca0c1b6b6c17c..ef5b64e46734b9e1fca6c7ad7352836d14664121 100644 --- a/DemoProc/src/Menu.c +++ b/DemoProc/src/Menu.c @@ -1,11 +1,11 @@ /*************************************************************************/ -/** Copyright. **/ -/** FileName: Menu.c **/ -/** Author: Polarix **/ -/** Description: HMI demo for menu control interface. **/ +/** Copyright. **/ +/** FileName: Menu.c **/ +/** Author: Polarix **/ +/** Description: HMI demo for menu control interface. **/ /*************************************************************************/ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "DemoProc.h" #include "SGUI_Menu.h" @@ -14,206 +14,206 @@ #include "Resource.h" //=======================================================================// -//= Static function declaration. =// +//= Static function declaration. =// //=======================================================================// -static HMI_ENGINE_RESULT HMI_DemoMenu_Initialize(SGUI_SCR_DEV* pstDeviceIF); -static HMI_ENGINE_RESULT HMI_DemoMenu_Prepare(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters); -static HMI_ENGINE_RESULT HMI_DemoMenu_RefreshScreen(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters); -static HMI_ENGINE_RESULT HMI_DemoMenu_ProcessEvent(SGUI_SCR_DEV* pstDeviceIF, const HMI_EVENT_BASE* pstEvent, SGUI_INT* piActionID); -static HMI_ENGINE_RESULT HMI_DemoMenu_PostProcess(SGUI_SCR_DEV* pstDeviceIF, HMI_ENGINE_RESULT eProcResult, SGUI_INT iActionID); +static HMI_ENGINE_RESULT HMI_DemoMenu_Initialize(SGUI_SCR_DEV* pstDeviceIF); +static HMI_ENGINE_RESULT HMI_DemoMenu_Prepare(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters); +static HMI_ENGINE_RESULT HMI_DemoMenu_RefreshScreen(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters); +static HMI_ENGINE_RESULT HMI_DemoMenu_ProcessEvent(SGUI_SCR_DEV* pstDeviceIF, const HMI_EVENT_BASE* pstEvent, SGUI_INT* piActionID); +static HMI_ENGINE_RESULT HMI_DemoMenu_PostProcess(SGUI_SCR_DEV* pstDeviceIF, HMI_ENGINE_RESULT eProcResult, SGUI_INT iActionID); //=======================================================================// -//= Static variable declaration. =// +//= Static variable declaration. =// //=======================================================================// -static SGUI_ITEMS_ITEM s_arrstMenuItems[] = { {SCR6_MENU_ITEM1, NULL}, - {SCR6_MENU_ITEM2, NULL}, - {SCR6_MENU_ITEM3, NULL}, - {SCR6_MENU_ITEM4, NULL}, - {SCR6_MENU_ITEM5, NULL}, - {SCR6_MENU_ITEM6, NULL}, - {SCR6_MENU_ITEM7, NULL}, - {SCR6_MENU_ITEM8, NULL}, - }; - -static SGUI_ITEMS_ITEM s_arrstSubMenuItems[] = { {SCR6_SUB_MENU_ITEM1, NULL}, - {SCR6_SUB_MENU_ITEM2, NULL}, - {SCR6_SUB_MENU_ITEM3, NULL}, - {SCR6_SUB_MENU_ITEM4, NULL} - }; - -static SGUI_MENU s_stDemoMenuObject = {0x00}; -static SGUI_MENU s_stDemoSubMenuObject = {0x00}; - -static SGUI_MENU* s_pstActivedMenu = &s_stDemoMenuObject; +static SGUI_ITEMS_ITEM s_arrstMenuItems[] = { {SCR6_MENU_ITEM1, NULL}, + {SCR6_MENU_ITEM2, NULL}, + {SCR6_MENU_ITEM3, NULL}, + {SCR6_MENU_ITEM4, NULL}, + {SCR6_MENU_ITEM5, NULL}, + {SCR6_MENU_ITEM6, NULL}, + {SCR6_MENU_ITEM7, NULL}, + {SCR6_MENU_ITEM8, NULL}, + }; + +static SGUI_ITEMS_ITEM s_arrstSubMenuItems[] = { {SCR6_SUB_MENU_ITEM1, NULL}, + {SCR6_SUB_MENU_ITEM2, NULL}, + {SCR6_SUB_MENU_ITEM3, NULL}, + {SCR6_SUB_MENU_ITEM4, NULL} + }; + +static SGUI_MENU s_stDemoMenuObject = {0x00}; +static SGUI_MENU s_stDemoSubMenuObject = {0x00}; + +static SGUI_MENU* s_pstActivedMenu = &s_stDemoMenuObject; //=======================================================================// -//= Global variable declaration. =// +//= Global variable declaration. =// //=======================================================================// -HMI_SCREEN_ACTION s_stDemoMenuActions = { HMI_DemoMenu_Initialize, - HMI_DemoMenu_Prepare, - HMI_DemoMenu_RefreshScreen, - HMI_DemoMenu_ProcessEvent, - HMI_DemoMenu_PostProcess - }; -HMI_SCREEN_OBJECT g_stHMIDemo_Menu = { HMI_SCREEN_ID_DEMO_MENU, - &s_stDemoMenuActions - }; +HMI_SCREEN_ACTION s_stDemoMenuActions = { HMI_DemoMenu_Initialize, + HMI_DemoMenu_Prepare, + HMI_DemoMenu_RefreshScreen, + HMI_DemoMenu_ProcessEvent, + HMI_DemoMenu_PostProcess + }; +HMI_SCREEN_OBJECT g_stHMIDemo_Menu = { HMI_SCREEN_ID_DEMO_MENU, + &s_stDemoMenuActions + }; //=======================================================================// -//= Function define. =// +//= Function define. =// //=======================================================================// HMI_ENGINE_RESULT HMI_DemoMenu_Initialize(SGUI_SCR_DEV* pstDeviceIF) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_RECT stLayout; - - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - stLayout.iX = 0; - stLayout.iY = 0; - stLayout.iWidth = 48; - stLayout.iHeight = 60; - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_RECT stLayout; + + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + stLayout.iX = 0; + stLayout.iY = 0; + stLayout.iWidth = 48; + stLayout.iHeight = 60; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ // Initialize list data. SGUI_SystemIF_MemorySet(&s_stDemoMenuObject, 0x00, sizeof(SGUI_MENU)); //Initialize list object. - SGUI_Menu_Initialize(&s_stDemoMenuObject, &stLayout, &SGUI_DEFAULT_FONT_8, s_arrstMenuItems, sizeof(s_arrstMenuItems)/sizeof(SGUI_ITEMS_ITEM)); - return HMI_RET_NORMAL; + SGUI_Menu_Initialize(&s_stDemoMenuObject, &stLayout, &SGUI_DEFAULT_FONT_8, s_arrstMenuItems, sizeof(s_arrstMenuItems)/sizeof(SGUI_ITEMS_ITEM)); + return HMI_RET_NORMAL; } HMI_ENGINE_RESULT HMI_DemoMenu_Prepare(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters) { - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - SGUI_Basic_DrawRectangle(pstDeviceIF, 0, 0, pstDeviceIF->stSize.iWidth, pstDeviceIF->stSize.iHeight, SGUI_COLOR_BKGCLR, SGUI_COLOR_BKGCLR); - SGUI_Menu_Repaint(pstDeviceIF, &s_stDemoMenuObject); - return HMI_RET_NORMAL; + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + SGUI_Basic_DrawRectangle(pstDeviceIF, 0, 0, pstDeviceIF->stSize.iWidth, pstDeviceIF->stSize.iHeight, SGUI_COLOR_BKGCLR, SGUI_COLOR_BKGCLR); + SGUI_Menu_Repaint(pstDeviceIF, &s_stDemoMenuObject); + return HMI_RET_NORMAL; } HMI_ENGINE_RESULT HMI_DemoMenu_RefreshScreen(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters) { - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - SGUI_Menu_Repaint(pstDeviceIF, s_pstActivedMenu); - return HMI_RET_NORMAL; + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + SGUI_Menu_Repaint(pstDeviceIF, s_pstActivedMenu); + return HMI_RET_NORMAL; } HMI_ENGINE_RESULT HMI_DemoMenu_ProcessEvent(SGUI_SCR_DEV* pstDeviceIF, const HMI_EVENT_BASE* pstEvent, SGUI_INT* piActionID) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - HMI_ENGINE_RESULT eProcessResult; - SGUI_UINT16 uiKeyCode; - SGUI_UINT16 uiKeyValue; - KEY_PRESS_EVENT* pstKeyEvent; - SGUI_INT iProcessAction; - SGUI_RECT stItemArea; - - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - eProcessResult = HMI_RET_NORMAL; - pstKeyEvent = (KEY_PRESS_EVENT*)pstEvent; - iProcessAction = HMI_DEMO_PROC_NO_ACT; - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if(pstEvent->iType == EVENT_TYPE_ACTION) - { - // Check event is valid. - if(SGUI_FALSE == HMI_EVENT_SIZE_CHK(*pstKeyEvent, KEY_PRESS_EVENT)) - { - // Event data is invalid. - eProcessResult = HMI_RET_INVALID_DATA; - } - else if(EVENT_ID_KEY_PRESS == pstEvent->iID) - { - uiKeyCode = pstKeyEvent->Data.uiKeyValue; - uiKeyValue = KEY_CODE_VALUE(uiKeyCode); - switch(uiKeyValue) - { - case KEY_VALUE_ENTER: - { - if(&s_stDemoMenuObject == s_pstActivedMenu) - { - SGUI_ItemsBase_GetItemExtent(&(s_pstActivedMenu->stItems), SGUI_Menu_GetSelection(s_pstActivedMenu)->iIndex, &stItemArea); - s_pstActivedMenu = &s_stDemoSubMenuObject; - SGUI_Menu_Initialize(&s_stDemoSubMenuObject, &stItemArea, &SGUI_DEFAULT_FONT_8, s_arrstSubMenuItems, sizeof(s_arrstSubMenuItems)/sizeof(SGUI_ITEMS_ITEM)); - SGUI_Menu_PopupSubMenu(pstDeviceIF, &s_stDemoSubMenuObject, &stItemArea); - SGUI_Menu_Repaint(pstDeviceIF, s_pstActivedMenu); - } - iProcessAction = HMI_DEMO_PROC_CONFIRM; - break; - } - case KEY_VALUE_ESC: - { - if(&s_stDemoMenuObject == s_pstActivedMenu) - { - iProcessAction = HMI_DEMO_PROC_CANCEL; - } - else - { - if(s_pstActivedMenu->stLayout.iWidth > 0) - { - /* Cleanup sub-menu display. */ - SGUI_Basic_DrawRectangle(pstDeviceIF, s_pstActivedMenu->stLayout.iX, s_pstActivedMenu->stLayout.iY, s_pstActivedMenu->stLayout.iWidth, s_pstActivedMenu->stLayout.iHeight, SGUI_COLOR_BKGCLR, SGUI_COLOR_BKGCLR); - s_pstActivedMenu->stLayout.iWidth = 0; - s_pstActivedMenu = &s_stDemoMenuObject; - } - SGUI_Menu_Repaint(pstDeviceIF, s_pstActivedMenu); - } - - break; - } - case KEY_VALUE_UP: - { - if(SGUI_Menu_GetSelection(s_pstActivedMenu)->iIndex > 0) - { - SGUI_Menu_Selecte(s_pstActivedMenu, SGUI_Menu_GetSelection(s_pstActivedMenu)->iIndex-1); - SGUI_Menu_Repaint(pstDeviceIF, s_pstActivedMenu); - } - break; - } - case KEY_VALUE_DOWN: - { - if(SGUI_Menu_GetSelection(s_pstActivedMenu)->iIndex < s_pstActivedMenu->stItems.iCount-1) - { - SGUI_Menu_Selecte(s_pstActivedMenu, SGUI_Menu_GetSelection(s_pstActivedMenu)->iIndex+1); - SGUI_Menu_Repaint(pstDeviceIF, s_pstActivedMenu); - } - break; - } - default: - { - break; - } - } - } - } - if(NULL != piActionID) - { - *piActionID = iProcessAction; - } - - return eProcessResult; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + HMI_ENGINE_RESULT eProcessResult; + SGUI_UINT16 uiKeyCode; + SGUI_UINT16 uiKeyValue; + KEY_PRESS_EVENT* pstKeyEvent; + SGUI_INT iProcessAction; + SGUI_RECT stItemArea; + + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + eProcessResult = HMI_RET_NORMAL; + pstKeyEvent = (KEY_PRESS_EVENT*)pstEvent; + iProcessAction = HMI_DEMO_PROC_NO_ACT; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(pstEvent->iType == EVENT_TYPE_ACTION) + { + // Check event is valid. + if(SGUI_FALSE == HMI_EVENT_SIZE_CHK(*pstKeyEvent, KEY_PRESS_EVENT)) + { + // Event data is invalid. + eProcessResult = HMI_RET_INVALID_DATA; + } + else if(EVENT_ID_KEY_PRESS == pstEvent->iID) + { + uiKeyCode = pstKeyEvent->Data.uiKeyValue; + uiKeyValue = KEY_CODE_VALUE(uiKeyCode); + switch(uiKeyValue) + { + case KEY_VALUE_ENTER: + { + if(&s_stDemoMenuObject == s_pstActivedMenu) + { + SGUI_ItemsBase_GetItemExtent(&(s_pstActivedMenu->stItems), SGUI_Menu_GetSelection(s_pstActivedMenu)->iIndex, &stItemArea); + s_pstActivedMenu = &s_stDemoSubMenuObject; + SGUI_Menu_Initialize(&s_stDemoSubMenuObject, &stItemArea, &SGUI_DEFAULT_FONT_8, s_arrstSubMenuItems, sizeof(s_arrstSubMenuItems)/sizeof(SGUI_ITEMS_ITEM)); + SGUI_Menu_PopupSubMenu(pstDeviceIF, &s_stDemoSubMenuObject, &stItemArea); + SGUI_Menu_Repaint(pstDeviceIF, s_pstActivedMenu); + } + iProcessAction = HMI_DEMO_PROC_CONFIRM; + break; + } + case KEY_VALUE_ESC: + { + if(&s_stDemoMenuObject == s_pstActivedMenu) + { + iProcessAction = HMI_DEMO_PROC_CANCEL; + } + else + { + if(s_pstActivedMenu->stLayout.iWidth > 0) + { + /* Cleanup sub-menu display. */ + SGUI_Basic_DrawRectangle(pstDeviceIF, s_pstActivedMenu->stLayout.iX, s_pstActivedMenu->stLayout.iY, s_pstActivedMenu->stLayout.iWidth, s_pstActivedMenu->stLayout.iHeight, SGUI_COLOR_BKGCLR, SGUI_COLOR_BKGCLR); + s_pstActivedMenu->stLayout.iWidth = 0; + s_pstActivedMenu = &s_stDemoMenuObject; + } + SGUI_Menu_Repaint(pstDeviceIF, s_pstActivedMenu); + } + + break; + } + case KEY_VALUE_UP: + { + if(SGUI_Menu_GetSelection(s_pstActivedMenu)->iIndex > 0) + { + SGUI_Menu_Selecte(s_pstActivedMenu, SGUI_Menu_GetSelection(s_pstActivedMenu)->iIndex-1); + SGUI_Menu_Repaint(pstDeviceIF, s_pstActivedMenu); + } + break; + } + case KEY_VALUE_DOWN: + { + if(SGUI_Menu_GetSelection(s_pstActivedMenu)->iIndex < s_pstActivedMenu->stItems.iCount-1) + { + SGUI_Menu_Selecte(s_pstActivedMenu, SGUI_Menu_GetSelection(s_pstActivedMenu)->iIndex+1); + SGUI_Menu_Repaint(pstDeviceIF, s_pstActivedMenu); + } + break; + } + default: + { + break; + } + } + } + } + if(NULL != piActionID) + { + *piActionID = iProcessAction; + } + + return eProcessResult; } HMI_ENGINE_RESULT HMI_DemoMenu_PostProcess(SGUI_SCR_DEV* pstDeviceIF, HMI_ENGINE_RESULT eProcResult, SGUI_INT iActionID) { - if(HMI_DEMO_PROC_CANCEL == iActionID) - { - HMI_GoBack(NULL); - } + if(HMI_DEMO_PROC_CANCEL == iActionID) + { + HMI_GoBack(NULL); + } - return HMI_RET_NORMAL; + return HMI_RET_NORMAL; } diff --git a/DemoProc/src/Notice.c b/DemoProc/src/Notice.c index 1e405bc7b3121d10f0502a8813fd9b966851e012..4a434da8090f16cc1b5d93af2ae5d4baf6344d9d 100644 --- a/DemoProc/src/Notice.c +++ b/DemoProc/src/Notice.c @@ -1,143 +1,143 @@ /*************************************************************************/ -/** Copyright. **/ -/** FileName: Notice.c **/ -/** Author: Polarix **/ -/** Description: HMI demo for notice box interface. **/ +/** Copyright. **/ +/** FileName: Notice.c **/ +/** Author: Polarix **/ +/** Description: HMI demo for notice box interface. **/ /*************************************************************************/ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "DemoProc.h" #include "SGUI_Notice.h" #include "SGUI_FontResource.h" //=======================================================================// -//= User Macro definition. =// +//= User Macro definition. =// //=======================================================================// -#define NOTICE_TEXT_BUFFER_SIZE (64) +#define NOTICE_TEXT_BUFFER_SIZE (64) //=======================================================================// -//= Static function declaration. =// +//= Static function declaration. =// //=======================================================================// -static HMI_ENGINE_RESULT HMI_DemoNotice_Initialize(SGUI_SCR_DEV* pstDeviceIF); -static HMI_ENGINE_RESULT HMI_DemoNotice_Prepare(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters); -static HMI_ENGINE_RESULT HMI_DemoNotice_RefreshScreen(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters); -static HMI_ENGINE_RESULT HMI_DemoNotice_ProcessEvent(SGUI_SCR_DEV* pstDeviceIF, const HMI_EVENT_BASE* pstEvent, SGUI_INT* piActionID); -static HMI_ENGINE_RESULT HMI_DemoNotice_PostProcess(SGUI_SCR_DEV* pstDeviceIF, HMI_ENGINE_RESULT eProcResult, SGUI_INT iActionID); +static HMI_ENGINE_RESULT HMI_DemoNotice_Initialize(SGUI_SCR_DEV* pstDeviceIF); +static HMI_ENGINE_RESULT HMI_DemoNotice_Prepare(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters); +static HMI_ENGINE_RESULT HMI_DemoNotice_RefreshScreen(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters); +static HMI_ENGINE_RESULT HMI_DemoNotice_ProcessEvent(SGUI_SCR_DEV* pstDeviceIF, const HMI_EVENT_BASE* pstEvent, SGUI_INT* piActionID); +static HMI_ENGINE_RESULT HMI_DemoNotice_PostProcess(SGUI_SCR_DEV* pstDeviceIF, HMI_ENGINE_RESULT eProcResult, SGUI_INT iActionID); //=======================================================================// -//= Static variable declaration. =// +//= Static variable declaration. =// //=======================================================================// -static SGUI_NOTICT_BOX s_stDemoNoticeBox = {0x00}; -static SGUI_CHAR s_szDemoNoticeText[NOTICE_TEXT_BUFFER_SIZE+1] = {0x00}; +static SGUI_NOTICT_BOX s_stDemoNoticeBox = {0x00}; +static SGUI_CHAR s_szDemoNoticeText[NOTICE_TEXT_BUFFER_SIZE+1] = {0x00}; -HMI_SCREEN_ACTION s_stDemoNoticeActions = { HMI_DemoNotice_Initialize, - HMI_DemoNotice_Prepare, - HMI_DemoNotice_RefreshScreen, - HMI_DemoNotice_ProcessEvent, - HMI_DemoNotice_PostProcess, - }; +HMI_SCREEN_ACTION s_stDemoNoticeActions = { HMI_DemoNotice_Initialize, + HMI_DemoNotice_Prepare, + HMI_DemoNotice_RefreshScreen, + HMI_DemoNotice_ProcessEvent, + HMI_DemoNotice_PostProcess, + }; //=======================================================================// -//= Global variable declaration. =// +//= Global variable declaration. =// //=======================================================================// -HMI_SCREEN_OBJECT g_stHMIDemo_Notice = { HMI_SCREEN_ID_DEMO_TEXT_NOTICE, - &s_stDemoNoticeActions - }; +HMI_SCREEN_OBJECT g_stHMIDemo_Notice = { HMI_SCREEN_ID_DEMO_TEXT_NOTICE, + &s_stDemoNoticeActions + }; //=======================================================================// -//= Function define. =// +//= Function define. =// //=======================================================================// HMI_ENGINE_RESULT HMI_DemoNotice_Initialize(SGUI_SCR_DEV* pstDeviceIF) { - SGUI_SystemIF_MemorySet(s_szDemoNoticeText, 0x00, sizeof(SGUI_CHAR)*(NOTICE_TEXT_BUFFER_SIZE+1)); - s_stDemoNoticeBox.cszNoticeText = s_szDemoNoticeText; - s_stDemoNoticeBox.pstIcon = NULL; - SGUI_Notice_FitArea(pstDeviceIF, &(s_stDemoNoticeBox.stLayout)); - return HMI_RET_NORMAL; + SGUI_SystemIF_MemorySet(s_szDemoNoticeText, 0x00, sizeof(SGUI_CHAR)*(NOTICE_TEXT_BUFFER_SIZE+1)); + s_stDemoNoticeBox.cszNoticeText = s_szDemoNoticeText; + s_stDemoNoticeBox.pstIcon = NULL; + SGUI_Notice_FitArea(pstDeviceIF, &(s_stDemoNoticeBox.stLayout)); + return HMI_RET_NORMAL; } HMI_ENGINE_RESULT HMI_DemoNotice_Prepare(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters) { - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if(NULL == pstParameters) - { - SGUI_SystemIF_StringLengthCopy(s_szDemoNoticeText, "No Parameter.", NOTICE_TEXT_BUFFER_SIZE); - } - else - { - SGUI_SystemIF_StringLengthCopy(s_szDemoNoticeText, (SGUI_SZSTR)pstParameters, NOTICE_TEXT_BUFFER_SIZE); - s_szDemoNoticeText[NOTICE_TEXT_BUFFER_SIZE] = '\0'; - } - SGUI_Notice_Repaint(pstDeviceIF, &s_stDemoNoticeBox, &GB2312_FZXS12, 0); - return HMI_RET_NORMAL; + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(NULL == pstParameters) + { + SGUI_SystemIF_StringLengthCopy(s_szDemoNoticeText, "No Parameter.", NOTICE_TEXT_BUFFER_SIZE); + } + else + { + SGUI_SystemIF_StringLengthCopy(s_szDemoNoticeText, (SGUI_SZSTR)pstParameters, NOTICE_TEXT_BUFFER_SIZE); + s_szDemoNoticeText[NOTICE_TEXT_BUFFER_SIZE] = '\0'; + } + SGUI_Notice_Repaint(pstDeviceIF, &s_stDemoNoticeBox, &GB2312_FZXS12, 0); + return HMI_RET_NORMAL; } HMI_ENGINE_RESULT HMI_DemoNotice_RefreshScreen(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters) { - SGUI_Notice_Repaint(pstDeviceIF, &s_stDemoNoticeBox, &GB2312_FZXS12, 0); - return HMI_RET_NORMAL; + SGUI_Notice_Repaint(pstDeviceIF, &s_stDemoNoticeBox, &GB2312_FZXS12, 0); + return HMI_RET_NORMAL; } HMI_ENGINE_RESULT HMI_DemoNotice_ProcessEvent(SGUI_SCR_DEV* pstDeviceIF, const HMI_EVENT_BASE* pstEvent, SGUI_INT* piActionID) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - HMI_ENGINE_RESULT eProcessResult; - SGUI_UINT16 uiKeyValue; - KEY_PRESS_EVENT* pstKeyEvent; - SGUI_INT iProcessAction; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + HMI_ENGINE_RESULT eProcessResult; + SGUI_UINT16 uiKeyValue; + KEY_PRESS_EVENT* pstKeyEvent; + SGUI_INT iProcessAction; - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - eProcessResult = HMI_RET_NORMAL; - iProcessAction = HMI_DEMO_PROC_NO_ACT; + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + eProcessResult = HMI_RET_NORMAL; + iProcessAction = HMI_DEMO_PROC_NO_ACT; - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if(EVENT_TYPE_ACTION == pstEvent->iType) - { - if(EVENT_ID_KEY_PRESS == pstEvent->iID) - { - pstKeyEvent = (KEY_PRESS_EVENT*)pstEvent; - uiKeyValue = KEY_CODE_VALUE(pstKeyEvent->Data.uiKeyValue); + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(EVENT_TYPE_ACTION == pstEvent->iType) + { + if(EVENT_ID_KEY_PRESS == pstEvent->iID) + { + pstKeyEvent = (KEY_PRESS_EVENT*)pstEvent; + uiKeyValue = KEY_CODE_VALUE(pstKeyEvent->Data.uiKeyValue); - switch(uiKeyValue) - { - case KEY_VALUE_ENTER: - case KEY_VALUE_ESC: - { - iProcessAction = HMI_DEMO_PROC_CANCEL; - break; - } - } - } - } - if(NULL != piActionID) - { - *piActionID = iProcessAction; - } + switch(uiKeyValue) + { + case KEY_VALUE_ENTER: + case KEY_VALUE_ESC: + { + iProcessAction = HMI_DEMO_PROC_CANCEL; + break; + } + } + } + } + if(NULL != piActionID) + { + *piActionID = iProcessAction; + } - return eProcessResult; + return eProcessResult; } HMI_ENGINE_RESULT HMI_DemoNotice_PostProcess(SGUI_SCR_DEV* pstDeviceIF, HMI_ENGINE_RESULT eProcResult, SGUI_INT iActionID) { - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if(HMI_PROCESS_SUCCESSFUL(eProcResult)) - { - if(HMI_DEMO_PROC_CANCEL == iActionID) - { - HMI_GoBack(NULL); - } - } - return HMI_RET_NORMAL; + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(HMI_PROCESS_SUCCESSFUL(eProcResult)) + { + if(HMI_DEMO_PROC_CANCEL == iActionID) + { + HMI_GoBack(NULL); + } + } + return HMI_RET_NORMAL; } diff --git a/DemoProc/src/RealtimeGraph.c b/DemoProc/src/RealtimeGraph.c index b09da4fae508d03415af6d28d74bf6a341ece0b6..3c2a956a471392ff6d18343311a6067b87c7702f 100644 --- a/DemoProc/src/RealtimeGraph.c +++ b/DemoProc/src/RealtimeGraph.c @@ -1,12 +1,12 @@ /*************************************************************************/ -/** Copyright. **/ -/** FileName: HMI_Demo04_Graph.c **/ -/** Author: Polarix **/ -/** Version: 1.0.0.0 **/ -/** Description: HMI demo for graph interface. **/ +/** Copyright. **/ +/** FileName: HMI_Demo04_Graph.c **/ +/** Author: Polarix **/ +/** Version: 1.0.0.0 **/ +/** Description: HMI demo for graph interface. **/ /*************************************************************************/ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "DemoProc.h" #include "SGUI_Text.h" @@ -14,179 +14,179 @@ #include "SGUI_FontResource.h" //=======================================================================// -//= Static function declaration. =// +//= Static function declaration. =// //=======================================================================// -static HMI_ENGINE_RESULT HMI_DemoRealGraph_Initialize(SGUI_SCR_DEV* pstDeviceIF); -static HMI_ENGINE_RESULT HMI_DemoRealGraph_Prepare(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters); -static HMI_ENGINE_RESULT HMI_DemoRealGraph_RefreshScreen(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters); -static HMI_ENGINE_RESULT HMI_DemoRealGraph_ProcessEvent(SGUI_SCR_DEV* pstDeviceIF, const HMI_EVENT_BASE* pstEvent, SGUI_INT* piActionID); -static HMI_ENGINE_RESULT HMI_DemoRealGraph_PostProcess(SGUI_SCR_DEV* pstDeviceIF, HMI_ENGINE_RESULT eProcResult, SGUI_INT iActionID); +static HMI_ENGINE_RESULT HMI_DemoRealGraph_Initialize(SGUI_SCR_DEV* pstDeviceIF); +static HMI_ENGINE_RESULT HMI_DemoRealGraph_Prepare(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters); +static HMI_ENGINE_RESULT HMI_DemoRealGraph_RefreshScreen(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters); +static HMI_ENGINE_RESULT HMI_DemoRealGraph_ProcessEvent(SGUI_SCR_DEV* pstDeviceIF, const HMI_EVENT_BASE* pstEvent, SGUI_INT* piActionID); +static HMI_ENGINE_RESULT HMI_DemoRealGraph_PostProcess(SGUI_SCR_DEV* pstDeviceIF, HMI_ENGINE_RESULT eProcResult, SGUI_INT iActionID); //=======================================================================// -//= Static variable declaration. =// +//= 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 = {{1, 9, 126, 49}, &s_stRealtimeGraphData, &s_stRealtimeGraphControl}; -static HMI_SCREEN_ACTION s_stDemoRealtimeGraphActions = { HMI_DemoRealGraph_Initialize, - HMI_DemoRealGraph_Prepare, - HMI_DemoRealGraph_RefreshScreen, - HMI_DemoRealGraph_ProcessEvent, - HMI_DemoRealGraph_PostProcess, - }; +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 = {{1, 9, 126, 49}, &s_stRealtimeGraphData, &s_stRealtimeGraphControl}; +static HMI_SCREEN_ACTION s_stDemoRealtimeGraphActions = { HMI_DemoRealGraph_Initialize, + HMI_DemoRealGraph_Prepare, + HMI_DemoRealGraph_RefreshScreen, + HMI_DemoRealGraph_ProcessEvent, + HMI_DemoRealGraph_PostProcess, + }; //=======================================================================// -//= Global variable declaration. =// +//= Global variable declaration. =// //=======================================================================// -HMI_SCREEN_OBJECT g_stHMIDemo_RealtimeGraph = {HMI_SCREEN_ID_DEMO_REAL_TIME_GRAPH, +HMI_SCREEN_OBJECT g_stHMIDemo_RealtimeGraph = {HMI_SCREEN_ID_DEMO_REAL_TIME_GRAPH, &s_stDemoRealtimeGraphActions - }; + }; //=======================================================================// -//= Function define. =// +//= Function define. =// //=======================================================================// HMI_ENGINE_RESULT HMI_DemoRealGraph_Initialize(SGUI_SCR_DEV* pstDeviceIF) { - //SGUI_RealtimeGraph_Initialize(&s_stRealtimeGraph); - s_stRealtimeGraph.stLayout.iWidth = pstDeviceIF->stSize.iWidth-2; - s_stRealtimeGraph.stLayout.iHeight = pstDeviceIF->stSize.iHeight-15; - return HMI_RET_NORMAL; + //SGUI_RealtimeGraph_Initialize(&s_stRealtimeGraph); + s_stRealtimeGraph.stLayout.iWidth = pstDeviceIF->stSize.iWidth-2; + s_stRealtimeGraph.stLayout.iHeight = pstDeviceIF->stSize.iHeight-15; + return HMI_RET_NORMAL; } HMI_ENGINE_RESULT HMI_DemoRealGraph_Prepare(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters) { - // Reinitialize data. - SGUI_RealtimeGraph_Initialize(&s_stRealtimeGraph); - // Paint frame. - SGUI_Basic_DrawRectangle(pstDeviceIF, 0, 0, RECT_WIDTH(pstDeviceIF->stSize), RECT_HEIGHT(pstDeviceIF->stSize), SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); - // Update screen display. - SGUI_RealtimeGraph_Repaint(pstDeviceIF, &s_stRealtimeGraph); - // Start dummy heart-beat timer. - SysTickTimerEnable(true); - - return HMI_RET_NORMAL; + // Reinitialize data. + SGUI_RealtimeGraph_Initialize(&s_stRealtimeGraph); + // Paint frame. + SGUI_Basic_DrawRectangle(pstDeviceIF, 0, 0, RECT_WIDTH(pstDeviceIF->stSize), RECT_HEIGHT(pstDeviceIF->stSize), SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); + // Update screen display. + SGUI_RealtimeGraph_Repaint(pstDeviceIF, &s_stRealtimeGraph); + // Start dummy heart-beat timer. + SysTickTimerEnable(true); + + return HMI_RET_NORMAL; } HMI_ENGINE_RESULT HMI_DemoRealGraph_RefreshScreen(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters) { - SGUI_CHAR szTextBuffer[16]; - SGUI_RECT stTextDisplayArea; - SGUI_POINT stInnerPos; - - // Paint frame. - SGUI_Basic_DrawRectangle(pstDeviceIF, 0, 0, RECT_WIDTH(pstDeviceIF->stSize), RECT_HEIGHT(pstDeviceIF->stSize), SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); - // Paint title - stTextDisplayArea.iX = 1; - stTextDisplayArea.iY = 1; - stTextDisplayArea.iWidth = RECT_WIDTH(pstDeviceIF->stSize)-2; - stTextDisplayArea.iHeight = 8; - stInnerPos.iX = 0; - stInnerPos.iY = 0; - SGUI_Text_DrawText(pstDeviceIF, SCR5_RT_GRAPH_TITLE, &SGUI_DEFAULT_FONT_8, &stTextDisplayArea, &stInnerPos, SGUI_DRAW_NORMAL); - // Paint value. - SGUI_Common_IntegerToString(s_stRealtimeGraph.Data->ValueArray[s_stRealtimeGraph.Data->ValueCount-1], szTextBuffer, 10, 4, ' '); - stTextDisplayArea.iX = 1; - stTextDisplayArea.iY = RECT_HEIGHT(pstDeviceIF->stSize)-6; - stTextDisplayArea.iWidth = RECT_WIDTH(pstDeviceIF->stSize)-2; - stTextDisplayArea.iHeight = 5; - stInnerPos.iX = 0; - stInnerPos.iY = 0; - SGUI_Text_DrawText(pstDeviceIF, szTextBuffer, &SGUI_DEFAULT_FONT_MiniNum, &stTextDisplayArea, &stInnerPos, SGUI_DRAW_NORMAL); - SGUI_RealtimeGraph_Repaint(pstDeviceIF, &s_stRealtimeGraph); - return HMI_RET_NORMAL; + SGUI_CHAR szTextBuffer[16]; + SGUI_RECT stTextDisplayArea; + SGUI_POINT stInnerPos; + + // Paint frame. + SGUI_Basic_DrawRectangle(pstDeviceIF, 0, 0, RECT_WIDTH(pstDeviceIF->stSize), RECT_HEIGHT(pstDeviceIF->stSize), SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); + // Paint title + stTextDisplayArea.iX = 1; + stTextDisplayArea.iY = 1; + stTextDisplayArea.iWidth = RECT_WIDTH(pstDeviceIF->stSize)-2; + stTextDisplayArea.iHeight = 8; + stInnerPos.iX = 0; + stInnerPos.iY = 0; + SGUI_Text_DrawText(pstDeviceIF, SCR5_RT_GRAPH_TITLE, &SGUI_DEFAULT_FONT_8, &stTextDisplayArea, &stInnerPos, SGUI_DRAW_NORMAL); + // Paint value. + SGUI_Common_IntegerToString(s_stRealtimeGraph.Data->ValueArray[s_stRealtimeGraph.Data->ValueCount-1], szTextBuffer, 10, 4, ' '); + stTextDisplayArea.iX = 1; + stTextDisplayArea.iY = RECT_HEIGHT(pstDeviceIF->stSize)-6; + stTextDisplayArea.iWidth = RECT_WIDTH(pstDeviceIF->stSize)-2; + stTextDisplayArea.iHeight = 5; + stInnerPos.iX = 0; + stInnerPos.iY = 0; + SGUI_Text_DrawText(pstDeviceIF, szTextBuffer, &SGUI_DEFAULT_FONT_MiniNum, &stTextDisplayArea, &stInnerPos, SGUI_DRAW_NORMAL); + SGUI_RealtimeGraph_Repaint(pstDeviceIF, &s_stRealtimeGraph); + return HMI_RET_NORMAL; } HMI_ENGINE_RESULT HMI_DemoRealGraph_ProcessEvent(SGUI_SCR_DEV* pstDeviceIF, const HMI_EVENT_BASE* pstEvent, SGUI_INT* piActionID) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - HMI_ENGINE_RESULT eProcessResult; - SGUI_INT iNewValue; - SGUI_UINT16 uiKeyCode; - SGUI_UINT16 uiKeyValue; - KEY_PRESS_EVENT* pstKeyEvent; - DATA_EVENT* pstDataEvent; - SGUI_INT iProcessAction; - - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - eProcessResult = HMI_RET_NORMAL; - iProcessAction = HMI_DEMO_PROC_NO_ACT; - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - switch(pstEvent->iID) - { - case EVENT_ID_KEY_PRESS: - { - pstKeyEvent = (KEY_PRESS_EVENT*)pstEvent; - if(SGUI_FALSE == HMI_EVENT_SIZE_CHK(*pstKeyEvent, KEY_PRESS_EVENT)) - { - // Event data is invalid. - eProcessResult = HMI_RET_INVALID_DATA; - } - else - { - uiKeyCode = pstKeyEvent->Data.uiKeyValue; - uiKeyValue = KEY_CODE_VALUE(uiKeyCode); - - if(KEY_VALUE_ESC == uiKeyValue) - { - iProcessAction = HMI_DEMO_PROC_CANCEL; - } - } - break; - } - case EVENT_ID_TIMER: - { - pstDataEvent = (DATA_EVENT*)pstEvent; - if(SGUI_FALSE == HMI_EVENT_SIZE_CHK(*pstDataEvent, DATA_EVENT)) - { - // Event data is invalid. - eProcessResult = HMI_RET_INVALID_DATA; - } - else - { - iNewValue = pstDataEvent->Data.iValue; - SGUI_RealtimeGraph_AppendValue(pstDeviceIF, &s_stRealtimeGraph, iNewValue); - HMI_DemoRealGraph_RefreshScreen(pstDeviceIF, NULL); - } - break; - } - default: - { - /* No process. */ - break; - } - } - - if(NULL != piActionID) - { - *piActionID = iProcessAction; - } - - return eProcessResult; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + HMI_ENGINE_RESULT eProcessResult; + SGUI_INT iNewValue; + SGUI_UINT16 uiKeyCode; + SGUI_UINT16 uiKeyValue; + KEY_PRESS_EVENT* pstKeyEvent; + DATA_EVENT* pstDataEvent; + SGUI_INT iProcessAction; + + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + eProcessResult = HMI_RET_NORMAL; + iProcessAction = HMI_DEMO_PROC_NO_ACT; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + switch(pstEvent->iID) + { + case EVENT_ID_KEY_PRESS: + { + pstKeyEvent = (KEY_PRESS_EVENT*)pstEvent; + if(SGUI_FALSE == HMI_EVENT_SIZE_CHK(*pstKeyEvent, KEY_PRESS_EVENT)) + { + // Event data is invalid. + eProcessResult = HMI_RET_INVALID_DATA; + } + else + { + uiKeyCode = pstKeyEvent->Data.uiKeyValue; + uiKeyValue = KEY_CODE_VALUE(uiKeyCode); + + if(KEY_VALUE_ESC == uiKeyValue) + { + iProcessAction = HMI_DEMO_PROC_CANCEL; + } + } + break; + } + case EVENT_ID_TIMER: + { + pstDataEvent = (DATA_EVENT*)pstEvent; + if(SGUI_FALSE == HMI_EVENT_SIZE_CHK(*pstDataEvent, DATA_EVENT)) + { + // Event data is invalid. + eProcessResult = HMI_RET_INVALID_DATA; + } + else + { + iNewValue = pstDataEvent->Data.iValue; + SGUI_RealtimeGraph_AppendValue(pstDeviceIF, &s_stRealtimeGraph, iNewValue); + HMI_DemoRealGraph_RefreshScreen(pstDeviceIF, NULL); + } + break; + } + default: + { + /* No process. */ + break; + } + } + + if(NULL != piActionID) + { + *piActionID = iProcessAction; + } + + return eProcessResult; } HMI_ENGINE_RESULT HMI_DemoRealGraph_PostProcess(SGUI_SCR_DEV* pstDeviceIF, HMI_ENGINE_RESULT eProcResult, SGUI_INT iActionID) { - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if(HMI_PROCESS_SUCCESSFUL(eProcResult)) - { - if(HMI_DEMO_PROC_CANCEL == iActionID) - { - // Stop heart-beat timer. - SysTickTimerEnable(false); - // Go back to last screen. - HMI_GoBack(NULL); - } - } - - return HMI_RET_NORMAL; + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(HMI_PROCESS_SUCCESSFUL(eProcResult)) + { + if(HMI_DEMO_PROC_CANCEL == iActionID) + { + // Stop heart-beat timer. + SysTickTimerEnable(false); + // Go back to last screen. + HMI_GoBack(NULL); + } + } + + return HMI_RET_NORMAL; } diff --git a/DemoProc/src/Resource.c b/DemoProc/src/Resource.c index 9e24c48990665bf0c8c3bc5221795623a13bb927..9168e216ac5cf70dfc9f2598f1e61e9bc636f99f 100644 --- a/DemoProc/src/Resource.c +++ b/DemoProc/src/Resource.c @@ -1,122 +1,122 @@ /*************************************************************************/ -/** Copyright. **/ -/** FileName: Resource.c **/ -/** Author: Polarix **/ -/** Version: 1.0.0.0 **/ -/** Description: GB2312 font resource data, used FZXS-12 font. **/ +/** Copyright. **/ +/** FileName: Resource.c **/ +/** Author: Polarix **/ +/** Version: 1.0.0.0 **/ +/** Description: GB2312 font resource data, used FZXS-12 font. **/ /*************************************************************************/ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "Resource.h" //=======================================================================// -//= Static function declaration. =// +//= Static function declaration. =// //=======================================================================// -static SGUI_INT GetCharIndex_GB2312(SGUI_UINT32 uiCode); -static SGUI_CSZSTR StepNext_GB2312(SGUI_CSZSTR cszSrc, SGUI_UINT32* puiCode); -static SGUI_SIZE GB2312_GetFontData(SGUI_SIZE sStartAddr, SGUI_BYTE* pDataBuffer, SGUI_SIZE sReadSize); -static SGUI_BOOL GB2312_IsFullWidth(SGUI_UINT32 uiCode); +static SGUI_INT GetCharIndex_GB2312(SGUI_UINT32 uiCode); +static SGUI_CSZSTR StepNext_GB2312(SGUI_CSZSTR cszSrc, SGUI_UINT32* puiCode); +static SGUI_SIZE GB2312_GetFontData(SGUI_SIZE sStartAddr, SGUI_BYTE* pDataBuffer, SGUI_SIZE sReadSize); +static SGUI_BOOL GB2312_IsFullWidth(SGUI_UINT32 uiCode); //=======================================================================// -//= Global variable declaration. =// +//= Global variable declaration. =// //=======================================================================// const SGUI_CBYTE GB2312_H12[] = { -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // space Index 0 -0x00, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, // ! -0x00, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // " -0x90, 0xD0, 0xBC, 0xD0, 0xBC, 0x90, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, // # -0x18, 0x24, 0xFE, 0x44, 0x88, 0x00, 0x01, 0x02, 0x07, 0x02, 0x01, 0x00, // $ -0x18, 0x24, 0xD8, 0xB0, 0x4C, 0x80, 0x00, 0x03, 0x00, 0x01, 0x02, 0x01, // % -0xC0, 0x38, 0xE4, 0x38, 0x80, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, // & -0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ' -0x00, 0x00, 0x00, 0xF0, 0x0C, 0x02, 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, // ( -0x02, 0x0C, 0xF0, 0x00, 0x00, 0x00, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, // ) -0x90, 0x60, 0xF8, 0x60, 0x90, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, // * -0x20, 0x20, 0xFC, 0x20, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, // + -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x06, 0x00, 0x00, 0x00, 0x00, // , -0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // - -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, // . -0x00, 0x80, 0x60, 0x18, 0x06, 0x00, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, // / -0xF8, 0x04, 0x04, 0x04, 0xF8, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // 0 -0x00, 0x08, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x02, 0x00, 0x00, // 1 -0x18, 0x84, 0x44, 0x24, 0x18, 0x00, 0x03, 0x02, 0x02, 0x02, 0x02, 0x00, // 2 -0x08, 0x04, 0x24, 0x24, 0xD8, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // 3 -0x40, 0xB0, 0x88, 0xFC, 0x80, 0x00, 0x00, 0x00, 0x02, 0x03, 0x02, 0x00, // 4 -0x3C, 0x24, 0x24, 0x24, 0xC4, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // 5 -0xF8, 0x24, 0x24, 0x24, 0xC8, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // 6 -0x0C, 0x04, 0xE4, 0x14, 0x0C, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, // 7 -0xD8, 0x24, 0x24, 0x24, 0xD8, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // 8 -0x38, 0x44, 0x44, 0x44, 0xF8, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // 9 -0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, // : -0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x04, 0x03, 0x00, 0x00, 0x00, // ; -0x00, 0x20, 0x50, 0x88, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, // < -0x90, 0x90, 0x90, 0x90, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // = -0x00, 0x02, 0x04, 0x88, 0x50, 0x20, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, // > -0x18, 0x04, 0xC4, 0x24, 0x18, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, // ? -0xF8, 0x04, 0xE4, 0x94, 0x78, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, // @ -0x00, 0xF0, 0x9C, 0x9C, 0xF0, 0x00, 0x02, 0x03, 0x00, 0x00, 0x03, 0x02, // A -0x04, 0xFC, 0x24, 0x24, 0xD8, 0x00, 0x02, 0x03, 0x02, 0x02, 0x01, 0x00, // B -0xF8, 0x04, 0x04, 0x04, 0x08, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // C -0x04, 0xFC, 0x04, 0x04, 0xF8, 0x00, 0x02, 0x03, 0x02, 0x02, 0x01, 0x00, // D -0x04, 0xFC, 0x24, 0x74, 0x0C, 0x00, 0x02, 0x03, 0x02, 0x02, 0x03, 0x00, // E -0x04, 0xFC, 0x24, 0x74, 0x0C, 0x00, 0x02, 0x03, 0x02, 0x00, 0x00, 0x00, // F -0xF8, 0x04, 0x04, 0x44, 0xCC, 0x40, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // G -0x04, 0xFC, 0x20, 0x20, 0xFC, 0x04, 0x02, 0x03, 0x00, 0x00, 0x03, 0x02, // H -0x04, 0x04, 0xFC, 0x04, 0x04, 0x00, 0x02, 0x02, 0x03, 0x02, 0x02, 0x00, // I -0x00, 0x04, 0x04, 0xFC, 0x04, 0x04, 0x02, 0x04, 0x04, 0x03, 0x00, 0x00, // J -0x04, 0xFC, 0x24, 0xD0, 0x0C, 0x04, 0x02, 0x03, 0x02, 0x00, 0x03, 0x02, // K -0x04, 0xFC, 0x04, 0x00, 0x00, 0x00, 0x02, 0x03, 0x02, 0x02, 0x02, 0x03, // L -0xFC, 0x3C, 0xC0, 0x3C, 0xFC, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, // M -0x04, 0xFC, 0x30, 0xC4, 0xFC, 0x04, 0x02, 0x03, 0x02, 0x00, 0x03, 0x02, // N -0xF8, 0x04, 0x04, 0x04, 0xF8, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // O -0x04, 0xFC, 0x24, 0x24, 0x18, 0x00, 0x02, 0x03, 0x02, 0x00, 0x00, 0x00, // P -0xF8, 0x84, 0x84, 0x04, 0xF8, 0x00, 0x01, 0x02, 0x02, 0x07, 0x04, 0x00, // Q -0x04, 0xFC, 0x24, 0x64, 0x98, 0x00, 0x02, 0x03, 0x02, 0x00, 0x03, 0x02, // R -0x18, 0x24, 0x24, 0x44, 0x88, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // S -0x0C, 0x04, 0xFC, 0x04, 0x0C, 0x00, 0x00, 0x02, 0x03, 0x02, 0x00, 0x00, // T -0x04, 0xFC, 0x00, 0x00, 0xFC, 0x04, 0x00, 0x01, 0x02, 0x02, 0x01, 0x00, // U -0x04, 0x7C, 0x80, 0x80, 0x7C, 0x04, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, // V -0x1C, 0xE0, 0x3C, 0xE0, 0x1C, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, // W -0x04, 0x9C, 0x60, 0x9C, 0x04, 0x00, 0x02, 0x03, 0x00, 0x03, 0x02, 0x00, // X -0x04, 0x1C, 0xE0, 0x1C, 0x04, 0x00, 0x00, 0x02, 0x03, 0x02, 0x00, 0x00, // Y -0x0C, 0x84, 0x64, 0x1C, 0x04, 0x00, 0x02, 0x03, 0x02, 0x02, 0x03, 0x00, // Z -0x00, 0x00, 0xFE, 0x02, 0x02, 0x00, 0x00, 0x00, 0x07, 0x04, 0x04, 0x00, // [ -0x00, 0x0E, 0x30, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, // '\' -0x00, 0x02, 0x02, 0xFE, 0x00, 0x00, 0x00, 0x04, 0x04, 0x07, 0x00, 0x00, // ] -0x00, 0x04, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ^ -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, // _ -0x00, 0x00, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ` -0x00, 0x40, 0xA0, 0xA0, 0xC0, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, // a -0x04, 0xFC, 0x20, 0x20, 0xC0, 0x00, 0x00, 0x03, 0x02, 0x02, 0x01, 0x00, // b -0x00, 0xC0, 0x20, 0x20, 0x60, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, // c -0x00, 0xC0, 0x20, 0x24, 0xFC, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, // d -0x00, 0xC0, 0xA0, 0xA0, 0xC0, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, // e -0x00, 0x20, 0xF8, 0x24, 0x24, 0x04, 0x00, 0x02, 0x03, 0x02, 0x02, 0x00, // f -0x00, 0x40, 0xA0, 0xA0, 0x60, 0x20, 0x00, 0x07, 0x0A, 0x0A, 0x0A, 0x04, // g -0x04, 0xFC, 0x20, 0x20, 0xC0, 0x00, 0x02, 0x03, 0x00, 0x00, 0x03, 0x02, // h -0x00, 0x20, 0xE4, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x02, 0x00, 0x00, // i -0x00, 0x00, 0x20, 0xE4, 0x00, 0x00, 0x08, 0x08, 0x08, 0x07, 0x00, 0x00, // j -0x04, 0xFC, 0x80, 0xA0, 0x60, 0x20, 0x02, 0x03, 0x02, 0x00, 0x03, 0x02, // k -0x04, 0x04, 0xFC, 0x00, 0x00, 0x00, 0x02, 0x02, 0x03, 0x02, 0x02, 0x00, // l -0xE0, 0x20, 0xE0, 0x20, 0xC0, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, // m -0x20, 0xE0, 0x20, 0x20, 0xC0, 0x00, 0x02, 0x03, 0x02, 0x00, 0x03, 0x02, // n -0x00, 0xC0, 0x20, 0x20, 0xC0, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x00, // o -0x20, 0xE0, 0x20, 0x20, 0xC0, 0x00, 0x08, 0x0F, 0x0A, 0x02, 0x01, 0x00, // p -0x00, 0xC0, 0x20, 0x20, 0xE0, 0x00, 0x00, 0x01, 0x02, 0x0A, 0x0F, 0x08, // q -0x20, 0xE0, 0x40, 0x20, 0x20, 0x00, 0x02, 0x03, 0x02, 0x00, 0x00, 0x00, // r -0x00, 0x40, 0xA0, 0xA0, 0x20, 0x00, 0x00, 0x02, 0x02, 0x02, 0x01, 0x00, // s -0x00, 0x20, 0xF8, 0x20, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, // t -0x20, 0xE0, 0x00, 0x20, 0xE0, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, // u -0x20, 0xE0, 0x00, 0x00, 0xE0, 0x20, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, // v -0x60, 0x80, 0xE0, 0x80, 0x60, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, // w -0x20, 0x60, 0x80, 0x60, 0x20, 0x00, 0x02, 0x03, 0x00, 0x03, 0x02, 0x00, // x -0x20, 0xE0, 0x20, 0x80, 0x60, 0x20, 0x08, 0x08, 0x07, 0x01, 0x00, 0x00, // y -0x00, 0x20, 0xA0, 0x60, 0x20, 0x00, 0x00, 0x02, 0x03, 0x02, 0x02, 0x00, // z -0x00, 0x00, 0x60, 0x9E, 0x02, 0x00, 0x00, 0x00, 0x00, 0x07, 0x04, 0x00, // { -0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, // | -0x00, 0x02, 0x9E, 0x60, 0x00, 0x00, 0x00, 0x04, 0x07, 0x00, 0x00, 0x00, // } -0x04, 0x02, 0x02, 0x04, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ~ Index 94 +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // space Index 0 +0x00, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, // ! +0x00, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // " +0x90, 0xD0, 0xBC, 0xD0, 0xBC, 0x90, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, // # +0x18, 0x24, 0xFE, 0x44, 0x88, 0x00, 0x01, 0x02, 0x07, 0x02, 0x01, 0x00, // $ +0x18, 0x24, 0xD8, 0xB0, 0x4C, 0x80, 0x00, 0x03, 0x00, 0x01, 0x02, 0x01, // % +0xC0, 0x38, 0xE4, 0x38, 0x80, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, // & +0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ' +0x00, 0x00, 0x00, 0xF0, 0x0C, 0x02, 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, // ( +0x02, 0x0C, 0xF0, 0x00, 0x00, 0x00, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, // ) +0x90, 0x60, 0xF8, 0x60, 0x90, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, // * +0x20, 0x20, 0xFC, 0x20, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, // + +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x06, 0x00, 0x00, 0x00, 0x00, // , +0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // - +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, // . +0x00, 0x80, 0x60, 0x18, 0x06, 0x00, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, // / +0xF8, 0x04, 0x04, 0x04, 0xF8, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // 0 +0x00, 0x08, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x02, 0x00, 0x00, // 1 +0x18, 0x84, 0x44, 0x24, 0x18, 0x00, 0x03, 0x02, 0x02, 0x02, 0x02, 0x00, // 2 +0x08, 0x04, 0x24, 0x24, 0xD8, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // 3 +0x40, 0xB0, 0x88, 0xFC, 0x80, 0x00, 0x00, 0x00, 0x02, 0x03, 0x02, 0x00, // 4 +0x3C, 0x24, 0x24, 0x24, 0xC4, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // 5 +0xF8, 0x24, 0x24, 0x24, 0xC8, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // 6 +0x0C, 0x04, 0xE4, 0x14, 0x0C, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, // 7 +0xD8, 0x24, 0x24, 0x24, 0xD8, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // 8 +0x38, 0x44, 0x44, 0x44, 0xF8, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // 9 +0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, // : +0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x04, 0x03, 0x00, 0x00, 0x00, // ; +0x00, 0x20, 0x50, 0x88, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, // < +0x90, 0x90, 0x90, 0x90, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // = +0x00, 0x02, 0x04, 0x88, 0x50, 0x20, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, // > +0x18, 0x04, 0xC4, 0x24, 0x18, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, // ? +0xF8, 0x04, 0xE4, 0x94, 0x78, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, // @ +0x00, 0xF0, 0x9C, 0x9C, 0xF0, 0x00, 0x02, 0x03, 0x00, 0x00, 0x03, 0x02, // A +0x04, 0xFC, 0x24, 0x24, 0xD8, 0x00, 0x02, 0x03, 0x02, 0x02, 0x01, 0x00, // B +0xF8, 0x04, 0x04, 0x04, 0x08, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // C +0x04, 0xFC, 0x04, 0x04, 0xF8, 0x00, 0x02, 0x03, 0x02, 0x02, 0x01, 0x00, // D +0x04, 0xFC, 0x24, 0x74, 0x0C, 0x00, 0x02, 0x03, 0x02, 0x02, 0x03, 0x00, // E +0x04, 0xFC, 0x24, 0x74, 0x0C, 0x00, 0x02, 0x03, 0x02, 0x00, 0x00, 0x00, // F +0xF8, 0x04, 0x04, 0x44, 0xCC, 0x40, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // G +0x04, 0xFC, 0x20, 0x20, 0xFC, 0x04, 0x02, 0x03, 0x00, 0x00, 0x03, 0x02, // H +0x04, 0x04, 0xFC, 0x04, 0x04, 0x00, 0x02, 0x02, 0x03, 0x02, 0x02, 0x00, // I +0x00, 0x04, 0x04, 0xFC, 0x04, 0x04, 0x02, 0x04, 0x04, 0x03, 0x00, 0x00, // J +0x04, 0xFC, 0x24, 0xD0, 0x0C, 0x04, 0x02, 0x03, 0x02, 0x00, 0x03, 0x02, // K +0x04, 0xFC, 0x04, 0x00, 0x00, 0x00, 0x02, 0x03, 0x02, 0x02, 0x02, 0x03, // L +0xFC, 0x3C, 0xC0, 0x3C, 0xFC, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, // M +0x04, 0xFC, 0x30, 0xC4, 0xFC, 0x04, 0x02, 0x03, 0x02, 0x00, 0x03, 0x02, // N +0xF8, 0x04, 0x04, 0x04, 0xF8, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // O +0x04, 0xFC, 0x24, 0x24, 0x18, 0x00, 0x02, 0x03, 0x02, 0x00, 0x00, 0x00, // P +0xF8, 0x84, 0x84, 0x04, 0xF8, 0x00, 0x01, 0x02, 0x02, 0x07, 0x04, 0x00, // Q +0x04, 0xFC, 0x24, 0x64, 0x98, 0x00, 0x02, 0x03, 0x02, 0x00, 0x03, 0x02, // R +0x18, 0x24, 0x24, 0x44, 0x88, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // S +0x0C, 0x04, 0xFC, 0x04, 0x0C, 0x00, 0x00, 0x02, 0x03, 0x02, 0x00, 0x00, // T +0x04, 0xFC, 0x00, 0x00, 0xFC, 0x04, 0x00, 0x01, 0x02, 0x02, 0x01, 0x00, // U +0x04, 0x7C, 0x80, 0x80, 0x7C, 0x04, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, // V +0x1C, 0xE0, 0x3C, 0xE0, 0x1C, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, // W +0x04, 0x9C, 0x60, 0x9C, 0x04, 0x00, 0x02, 0x03, 0x00, 0x03, 0x02, 0x00, // X +0x04, 0x1C, 0xE0, 0x1C, 0x04, 0x00, 0x00, 0x02, 0x03, 0x02, 0x00, 0x00, // Y +0x0C, 0x84, 0x64, 0x1C, 0x04, 0x00, 0x02, 0x03, 0x02, 0x02, 0x03, 0x00, // Z +0x00, 0x00, 0xFE, 0x02, 0x02, 0x00, 0x00, 0x00, 0x07, 0x04, 0x04, 0x00, // [ +0x00, 0x0E, 0x30, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, // '\' +0x00, 0x02, 0x02, 0xFE, 0x00, 0x00, 0x00, 0x04, 0x04, 0x07, 0x00, 0x00, // ] +0x00, 0x04, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ^ +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, // _ +0x00, 0x00, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ` +0x00, 0x40, 0xA0, 0xA0, 0xC0, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, // a +0x04, 0xFC, 0x20, 0x20, 0xC0, 0x00, 0x00, 0x03, 0x02, 0x02, 0x01, 0x00, // b +0x00, 0xC0, 0x20, 0x20, 0x60, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, // c +0x00, 0xC0, 0x20, 0x24, 0xFC, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, // d +0x00, 0xC0, 0xA0, 0xA0, 0xC0, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, // e +0x00, 0x20, 0xF8, 0x24, 0x24, 0x04, 0x00, 0x02, 0x03, 0x02, 0x02, 0x00, // f +0x00, 0x40, 0xA0, 0xA0, 0x60, 0x20, 0x00, 0x07, 0x0A, 0x0A, 0x0A, 0x04, // g +0x04, 0xFC, 0x20, 0x20, 0xC0, 0x00, 0x02, 0x03, 0x00, 0x00, 0x03, 0x02, // h +0x00, 0x20, 0xE4, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x02, 0x00, 0x00, // i +0x00, 0x00, 0x20, 0xE4, 0x00, 0x00, 0x08, 0x08, 0x08, 0x07, 0x00, 0x00, // j +0x04, 0xFC, 0x80, 0xA0, 0x60, 0x20, 0x02, 0x03, 0x02, 0x00, 0x03, 0x02, // k +0x04, 0x04, 0xFC, 0x00, 0x00, 0x00, 0x02, 0x02, 0x03, 0x02, 0x02, 0x00, // l +0xE0, 0x20, 0xE0, 0x20, 0xC0, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, // m +0x20, 0xE0, 0x20, 0x20, 0xC0, 0x00, 0x02, 0x03, 0x02, 0x00, 0x03, 0x02, // n +0x00, 0xC0, 0x20, 0x20, 0xC0, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x00, // o +0x20, 0xE0, 0x20, 0x20, 0xC0, 0x00, 0x08, 0x0F, 0x0A, 0x02, 0x01, 0x00, // p +0x00, 0xC0, 0x20, 0x20, 0xE0, 0x00, 0x00, 0x01, 0x02, 0x0A, 0x0F, 0x08, // q +0x20, 0xE0, 0x40, 0x20, 0x20, 0x00, 0x02, 0x03, 0x02, 0x00, 0x00, 0x00, // r +0x00, 0x40, 0xA0, 0xA0, 0x20, 0x00, 0x00, 0x02, 0x02, 0x02, 0x01, 0x00, // s +0x00, 0x20, 0xF8, 0x20, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, // t +0x20, 0xE0, 0x00, 0x20, 0xE0, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, // u +0x20, 0xE0, 0x00, 0x00, 0xE0, 0x20, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, // v +0x60, 0x80, 0xE0, 0x80, 0x60, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, // w +0x20, 0x60, 0x80, 0x60, 0x20, 0x00, 0x02, 0x03, 0x00, 0x03, 0x02, 0x00, // x +0x20, 0xE0, 0x20, 0x80, 0x60, 0x20, 0x08, 0x08, 0x07, 0x01, 0x00, 0x00, // y +0x00, 0x20, 0xA0, 0x60, 0x20, 0x00, 0x00, 0x02, 0x03, 0x02, 0x02, 0x00, // z +0x00, 0x00, 0x60, 0x9E, 0x02, 0x00, 0x00, 0x00, 0x00, 0x07, 0x04, 0x00, // { +0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, // | +0x00, 0x02, 0x9E, 0x60, 0x00, 0x00, 0x00, 0x04, 0x07, 0x00, 0x00, 0x00, // } +0x04, 0x02, 0x02, 0x04, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ~ Index 94 #ifdef _SIMPLE_GUI_DEMO_INNER_CHS_ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* [  ][0 ][0] */ 0x00, 0x00, 0x00, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* [、 ][1 ][2] */ @@ -7740,175 +7740,175 @@ const SGUI_FONT_RES GB2312_FZXS12 = /*SGUI_INT iHalfWidth*/ 6, /*SGUI_INT iFullWidth*/ 12, /*SGUI_INT iHeight*/ 12, - /*SGUI_FN_IF_GET_CHAR_INDEX fnGetIndex*/ GetCharIndex_GB2312, - /*SGUI_FN_IF_GET_DATA fnGetData*/ GB2312_GetFontData, - /*SGUI_FN_IF_STEP_NEXT fnStepNext*/ StepNext_GB2312, - /*SGUI_FN_IF_IS_FULL_WIDTH fnIsFullWidth*/ GB2312_IsFullWidth + /*SGUI_FN_IF_GET_CHAR_INDEX fnGetIndex*/ GetCharIndex_GB2312, + /*SGUI_FN_IF_GET_DATA fnGetData*/ GB2312_GetFontData, + /*SGUI_FN_IF_STEP_NEXT fnStepNext*/ StepNext_GB2312, + /*SGUI_FN_IF_IS_FULL_WIDTH fnIsFullWidth*/ GB2312_IsFullWidth }; //=======================================================================// -//= Function define. =// +//= Function define. =// //=======================================================================// /*************************************************************************/ -/** Function Name: GetCharIndex_GB2312 **/ -/** Purpose: Get character index in font library. **/ -/** Resources: None. **/ -/** Params: **/ -/** @ uiCode[in]: Character code. **/ -/** Return: Character index. **/ +/** Function Name: GetCharIndex_GB2312 **/ +/** Purpose: Get character index in font library. **/ +/** Resources: None. **/ +/** Params: **/ +/** @ uiCode[in]: Character code. **/ +/** Return: Character index. **/ /*************************************************************************/ SGUI_INT GetCharIndex_GB2312(SGUI_UINT32 uiCode) { /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_INT iIndex; - SGUI_UINT8 uiLowByte, uiHighByte; + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_INT iIndex; + SGUI_UINT8 uiLowByte, uiHighByte; - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - // Initialize variable. - iIndex = SGUI_INVALID_INDEX; + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + // Initialize variable. + iIndex = SGUI_INVALID_INDEX; - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - /* for ASCII characters. */ - if((uiCode > 0x19) && (uiCode < 0x7F)) - { - iIndex = uiCode - (0x20); - } - else - { - uiLowByte = (SGUI_UINT8)(uiCode&0xFF); - uiHighByte = (SGUI_UINT8)((uiCode>>8)&0xFF); - /* For symbol characters. */ - if((uiCode > 0xA1A0) && (uiCode < 0xA9FF)) - { - iIndex =(((uiHighByte-0xA1)*94 + (uiLowByte-0xA1))*2)+95; - } - else if((uiCode > 0xB0A0) && (uiCode < 0xF7FF)) - { - iIndex =(((uiHighByte-0xB0)*94 + (uiLowByte-0xA1))*2)+1787; - } - } - return iIndex; + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + /* for ASCII characters. */ + if((uiCode > 0x19) && (uiCode < 0x7F)) + { + iIndex = uiCode - (0x20); + } + else + { + uiLowByte = (SGUI_UINT8)(uiCode&0xFF); + uiHighByte = (SGUI_UINT8)((uiCode>>8)&0xFF); + /* For symbol characters. */ + if((uiCode > 0xA1A0) && (uiCode < 0xA9FF)) + { + iIndex =(((uiHighByte-0xA1)*94 + (uiLowByte-0xA1))*2)+95; + } + else if((uiCode > 0xB0A0) && (uiCode < 0xF7FF)) + { + iIndex =(((uiHighByte-0xB0)*94 + (uiLowByte-0xA1))*2)+1787; + } + } + return iIndex; } /*************************************************************************/ -/** Function Name: StepNext_GB2312 **/ -/** Purpose: Read current character code order by input pointer **/ -/** and step to next character start pointer. **/ -/** Resources: None. **/ -/** Params: **/ -/** @ cszSrc[in]: Current char pointer. **/ -/** @ puiCode[in]: Character code. **/ -/** Return: Next character start pointer. **/ +/** Function Name: StepNext_GB2312 **/ +/** Purpose: Read current character code order by input pointer **/ +/** and step to next character start pointer. **/ +/** Resources: None. **/ +/** Params: **/ +/** @ cszSrc[in]: Current char pointer. **/ +/** @ puiCode[in]: Character code. **/ +/** Return: Next character start pointer. **/ /*************************************************************************/ SGUI_CSZSTR StepNext_GB2312(SGUI_CSZSTR cszSrc, SGUI_UINT32* puiCode) { /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - const SGUI_CHAR* pcNextChar; - SGUI_UINT32 uiCode; + /* Variable Declaration */ + /*----------------------------------*/ + const SGUI_CHAR* pcNextChar; + SGUI_UINT32 uiCode; - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - pcNextChar = cszSrc; - uiCode = 0; + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + pcNextChar = cszSrc; + uiCode = 0; - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if(NULL != pcNextChar) + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(NULL != pcNextChar) { - do - { - uiCode = (SGUI_BYTE)(*pcNextChar++); - if(uiCode < 0x7F) - { - break; - } - uiCode = uiCode<<8; - uiCode |= (SGUI_BYTE)(*pcNextChar++); - }while(0); + do + { + uiCode = (SGUI_BYTE)(*pcNextChar++); + if(uiCode < 0x7F) + { + break; + } + uiCode = uiCode<<8; + uiCode |= (SGUI_BYTE)(*pcNextChar++); + }while(0); } - *puiCode = uiCode; + *puiCode = uiCode; return pcNextChar; } /*************************************************************************/ -/** Function Name: GB2312_GetFontData **/ -/** Purpose: Read character data form font data. **/ -/** Resources: None. **/ -/** Params: **/ -/** @ sStartAddr[in]: Read start address in memory. **/ -/** @ pDataBuffer[in]: Character data dump buffer pointer. **/ -/** @ sReadSize[in]: Size of data will be read, always mean the buffer **/ -/** size. **/ -/** Return: Data in process was be read. **/ +/** Function Name: GB2312_GetFontData **/ +/** Purpose: Read character data form font data. **/ +/** Resources: None. **/ +/** Params: **/ +/** @ sStartAddr[in]: Read start address in memory. **/ +/** @ pDataBuffer[in]: Character data dump buffer pointer. **/ +/** @ sReadSize[in]: Size of data will be read, always mean the buffer **/ +/** size. **/ +/** Return: Data in process was be read. **/ /*************************************************************************/ SGUI_SIZE GB2312_GetFontData(SGUI_SIZE sStartAddr, SGUI_BYTE* pDataBuffer, SGUI_SIZE sReadSize) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_SIZE sReadCount; - const SGUI_BYTE* pSrc = GB2312_H12+sStartAddr; - SGUI_BYTE* pDest = pDataBuffer; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_SIZE sReadCount; + const SGUI_BYTE* pSrc = GB2312_H12+sStartAddr; + SGUI_BYTE* pDest = pDataBuffer; - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - pSrc = GB2312_H12+sStartAddr; - pDest = pDataBuffer; + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + pSrc = GB2312_H12+sStartAddr; + pDest = pDataBuffer; - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if(NULL != pDataBuffer) - { - for(sReadCount=0; sReadCountfnClear) - { - pstDeviceIF->fnClear(); - } - else - { - SGUI_Basic_DrawRectangle(pstDeviceIF, 0, 0, pstDeviceIF->stSize.iWidth, pstDeviceIF->stSize.iHeight, SGUI_COLOR_BKGCLR, SGUI_COLOR_BKGCLR); - } - HMI_DemoText_RefreshScreen(pstDeviceIF, pstParameters); - return HMI_RET_NORMAL; + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(NULL != pstDeviceIF->fnClear) + { + pstDeviceIF->fnClear(); + } + else + { + SGUI_Basic_DrawRectangle(pstDeviceIF, 0, 0, pstDeviceIF->stSize.iWidth, pstDeviceIF->stSize.iHeight, SGUI_COLOR_BKGCLR, SGUI_COLOR_BKGCLR); + } + HMI_DemoText_RefreshScreen(pstDeviceIF, pstParameters); + return HMI_RET_NORMAL; } HMI_ENGINE_RESULT HMI_DemoText_RefreshScreen(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_RECT stDisplayArea; - SGUI_POINT stInnerPos; - - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - stInnerPos.iX = 0; - stInnerPos.iY = 0; - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - stDisplayArea.iX = 1; - stDisplayArea.iY = 1; - stDisplayArea.iWidth = 62; - stDisplayArea.iHeight = SGUI_DEFAULT_FONT_MiniNum.iHeight+1; - SGUI_Text_DrawText(pstDeviceIF, SCR3_TEXT_MIN_NUM, &SGUI_DEFAULT_FONT_MiniNum, &stDisplayArea, &stInnerPos, SGUI_DRAW_NORMAL); - - stDisplayArea.iY += stDisplayArea.iHeight; - stDisplayArea.iWidth = 62; - stDisplayArea.iHeight = SGUI_DEFAULT_FONT_8.iHeight+1; - SGUI_Text_DrawText(pstDeviceIF, SCR3_TEXT_INNER_8, &SGUI_DEFAULT_FONT_8, &stDisplayArea, &stInnerPos, SGUI_DRAW_NORMAL); - - stDisplayArea.iY += stDisplayArea.iHeight; - stDisplayArea.iWidth = 62; - stDisplayArea.iHeight = SGUI_DEFAULT_FONT_12.iHeight+1; - SGUI_Text_DrawText(pstDeviceIF, SCR3_TEXT_INNER_12, &SGUI_DEFAULT_FONT_12, &stDisplayArea, &stInnerPos, SGUI_DRAW_REVERSE); - - stDisplayArea.iY += stDisplayArea.iHeight; - stDisplayArea.iWidth = 62; - stDisplayArea.iHeight = SGUI_DEFAULT_FONT_12.iHeight+1; - SGUI_Text_DrawText(pstDeviceIF, SCR3_TEXT_EXTEN_12, &GB2312_FZXS12, &stDisplayArea, &stInnerPos, SGUI_DRAW_NORMAL); - - stDisplayArea.iX = 64; - stDisplayArea.iY = 1; - stDisplayArea.iWidth = 62; - stDisplayArea.iHeight = 62; - SGUI_Text_DrawMultipleLinesText(pstDeviceIF, SCR3_TEXT_MULTILINE_12, &GB2312_FZXS12, &stDisplayArea, 0, SGUI_DRAW_NORMAL); - return HMI_RET_NORMAL; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_RECT stDisplayArea; + SGUI_POINT stInnerPos; + + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + stInnerPos.iX = 0; + stInnerPos.iY = 0; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + stDisplayArea.iX = 1; + stDisplayArea.iY = 1; + stDisplayArea.iWidth = 62; + stDisplayArea.iHeight = SGUI_DEFAULT_FONT_MiniNum.iHeight+1; + SGUI_Text_DrawText(pstDeviceIF, SCR3_TEXT_MIN_NUM, &SGUI_DEFAULT_FONT_MiniNum, &stDisplayArea, &stInnerPos, SGUI_DRAW_NORMAL); + + stDisplayArea.iY += stDisplayArea.iHeight; + stDisplayArea.iWidth = 62; + stDisplayArea.iHeight = SGUI_DEFAULT_FONT_8.iHeight+1; + SGUI_Text_DrawText(pstDeviceIF, SCR3_TEXT_INNER_8, &SGUI_DEFAULT_FONT_8, &stDisplayArea, &stInnerPos, SGUI_DRAW_NORMAL); + + stDisplayArea.iY += stDisplayArea.iHeight; + stDisplayArea.iWidth = 62; + stDisplayArea.iHeight = SGUI_DEFAULT_FONT_12.iHeight+1; + SGUI_Text_DrawText(pstDeviceIF, SCR3_TEXT_INNER_12, &SGUI_DEFAULT_FONT_12, &stDisplayArea, &stInnerPos, SGUI_DRAW_REVERSE); + + stDisplayArea.iY += stDisplayArea.iHeight; + stDisplayArea.iWidth = 62; + stDisplayArea.iHeight = SGUI_DEFAULT_FONT_12.iHeight+1; + SGUI_Text_DrawText(pstDeviceIF, SCR3_TEXT_EXTEN_12, &GB2312_FZXS12, &stDisplayArea, &stInnerPos, SGUI_DRAW_NORMAL); + + stDisplayArea.iX = 64; + stDisplayArea.iY = 1; + stDisplayArea.iWidth = 62; + stDisplayArea.iHeight = 62; + SGUI_Text_DrawMultipleLinesText(pstDeviceIF, SCR3_TEXT_MULTILINE_12, &GB2312_FZXS12, &stDisplayArea, 0, SGUI_DRAW_NORMAL); + return HMI_RET_NORMAL; } HMI_ENGINE_RESULT HMI_DemoText_ProcessEvent(SGUI_SCR_DEV* pstDeviceIF, const HMI_EVENT_BASE* pstEvent, SGUI_INT* piActionID) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - HMI_ENGINE_RESULT eProcessResult; - SGUI_INT iProcessAction; - KEY_PRESS_EVENT* pstKeyEvent; - - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - eProcessResult = HMI_RET_NORMAL; - iProcessAction = HMI_DEMO_PROC_NO_ACT; - pstKeyEvent = (KEY_PRESS_EVENT*)pstEvent; - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if(pstEvent->iType == EVENT_TYPE_ACTION) - { - // Check event is valid. - if(SGUI_FALSE == HMI_EVENT_SIZE_CHK(*pstKeyEvent, KEY_PRESS_EVENT)) - { - // Event data is invalid. - eProcessResult = HMI_RET_INVALID_DATA; - } - else if(EVENT_ID_KEY_PRESS == pstEvent->iID) - { - iProcessAction = HMI_DEMO_PROC_CANCEL; - } - } - if(NULL != piActionID) - { - *piActionID = iProcessAction; - } - - return eProcessResult; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + HMI_ENGINE_RESULT eProcessResult; + SGUI_INT iProcessAction; + KEY_PRESS_EVENT* pstKeyEvent; + + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + eProcessResult = HMI_RET_NORMAL; + iProcessAction = HMI_DEMO_PROC_NO_ACT; + pstKeyEvent = (KEY_PRESS_EVENT*)pstEvent; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(pstEvent->iType == EVENT_TYPE_ACTION) + { + // Check event is valid. + if(SGUI_FALSE == HMI_EVENT_SIZE_CHK(*pstKeyEvent, KEY_PRESS_EVENT)) + { + // Event data is invalid. + eProcessResult = HMI_RET_INVALID_DATA; + } + else if(EVENT_ID_KEY_PRESS == pstEvent->iID) + { + iProcessAction = HMI_DEMO_PROC_CANCEL; + } + } + if(NULL != piActionID) + { + *piActionID = iProcessAction; + } + + return eProcessResult; } HMI_ENGINE_RESULT HMI_DemoText_PostProcess(SGUI_SCR_DEV* pstDeviceIF, HMI_ENGINE_RESULT eProcResult, SGUI_INT iActionID) { - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if(HMI_PROCESS_SUCCESSFUL(eProcResult)) - { - if(HMI_DEMO_PROC_CANCEL == iActionID) - { - HMI_GoBack(NULL); - } - } - - return HMI_RET_NORMAL; + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(HMI_PROCESS_SUCCESSFUL(eProcResult)) + { + if(HMI_DEMO_PROC_CANCEL == iActionID) + { + HMI_GoBack(NULL); + } + } + + return HMI_RET_NORMAL; } diff --git a/DemoProc/src/VariableBox.c b/DemoProc/src/VariableBox.c index a79af1428ce694838d52273983ee9b486cb399ee..3ce55eb6f94df216ea9f0045961e6d9955583ecb 100644 --- a/DemoProc/src/VariableBox.c +++ b/DemoProc/src/VariableBox.c @@ -1,12 +1,12 @@ /*************************************************************************/ -/** Copyright. **/ -/** FileName: HMI_Demo04_Graph.c **/ -/** Author: Polarix **/ -/** Version: 1.0.0.0 **/ -/** Description: HMI demo for graph interface. **/ +/** Copyright. **/ +/** FileName: HMI_Demo04_Graph.c **/ +/** Author: Polarix **/ +/** Version: 1.0.0.0 **/ +/** Description: HMI demo for graph interface. **/ /*************************************************************************/ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "DemoProc.h" #include "Resource.h" @@ -16,187 +16,187 @@ #include "SGUI_IconResource.h" //=======================================================================// -//= User Macro definition. =// +//= User Macro definition. =// //=======================================================================// -#define TEXT_VARIABLE_LENGTH (20) +#define TEXT_VARIABLE_LENGTH (20) -#define VARIABLE_BOX_WIDTH (100) -#define VARIABLE_NUMBER_BOX_HEIGHT (8) -#define VARIABLE_TEXT_BOX_HEIGHT (12) -#define VARIABLE_BOX_POSX (10) -#define VARIABLE_BOX_NUMBER_POSY (24) -#define VARIABLE_BOX_TEXT_POSY (40) +#define VARIABLE_BOX_WIDTH (100) +#define VARIABLE_NUMBER_BOX_HEIGHT (8) +#define VARIABLE_TEXT_BOX_HEIGHT (12) +#define VARIABLE_BOX_POSX (10) +#define VARIABLE_BOX_NUMBER_POSY (24) +#define VARIABLE_BOX_TEXT_POSY (40) //=======================================================================// -//= Static function declaration. =// +//= Static function declaration. =// //=======================================================================// static HMI_ENGINE_RESULT HMI_DemoVariableBox_Initialize(SGUI_SCR_DEV* pstDeviceIF); -static HMI_ENGINE_RESULT HMI_DemoVariableBox_Prepare(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters); -static HMI_ENGINE_RESULT HMI_DemoVariableBox_RefreshScreen(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters); +static HMI_ENGINE_RESULT HMI_DemoVariableBox_Prepare(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters); +static HMI_ENGINE_RESULT HMI_DemoVariableBox_RefreshScreen(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters); static HMI_ENGINE_RESULT HMI_DemoVariableBox_ProcessEvent(SGUI_SCR_DEV* pstDeviceIF, const HMI_EVENT_BASE* pstEvent, SGUI_INT* piActionID); -static HMI_ENGINE_RESULT HMI_DemoVariableBox_PostProcess(SGUI_SCR_DEV* pstDeviceIF, HMI_ENGINE_RESULT eProcResult, SGUI_INT iActionID); -static void HMI_DemoVariableBox_DrawFrame(SGUI_SCR_DEV* pstDeviceIF, SGUI_SZSTR szTitle); +static HMI_ENGINE_RESULT HMI_DemoVariableBox_PostProcess(SGUI_SCR_DEV* pstDeviceIF, HMI_ENGINE_RESULT eProcResult, SGUI_INT iActionID); +static void HMI_DemoVariableBox_DrawFrame(SGUI_SCR_DEV* pstDeviceIF, SGUI_SZSTR szTitle); //=======================================================================// -//= Static variable declaration. =// +//= Static variable declaration. =// //=======================================================================// -static SGUI_NUM_VARBOX_STRUCT s_stNumberVariableBox = {0x00}; -static SGUI_CHAR s_szTextVariableBuffer[TEXT_VARIABLE_LENGTH+1] = {"ABCDEFG1234567890"}; -static SGUI_TEXT_VARBOX_STRUCT s_stTextVariableBox = {0x00}; -static SGUI_CHAR s_szDefaultFrameTitle[] = SCR4_VAR_BOX_TITLE; -static SGUI_SZSTR s_szFrameTitle = s_szDefaultFrameTitle; -static SGUI_INT s_uiFocusedFlag; -static SGUI_CSZSTR s_szHelpNoticeText = SCR4_HELP_NOTICE; -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, - }; +static SGUI_NUM_VARBOX_STRUCT s_stNumberVariableBox = {0x00}; +static SGUI_CHAR s_szTextVariableBuffer[TEXT_VARIABLE_LENGTH+1] = {"ABCDEFG1234567890"}; +static SGUI_TEXT_VARBOX_STRUCT s_stTextVariableBox = {0x00}; +static SGUI_CHAR s_szDefaultFrameTitle[] = SCR4_VAR_BOX_TITLE; +static SGUI_SZSTR s_szFrameTitle = s_szDefaultFrameTitle; +static SGUI_INT s_uiFocusedFlag; +static SGUI_CSZSTR s_szHelpNoticeText = SCR4_HELP_NOTICE; +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_OBJECT g_stHMIDemo_VariableBox = { HMI_SCREEN_ID_DEMO_VARIABLE_BOX, - &s_stDemoVariableBoxActions - }; +HMI_SCREEN_OBJECT g_stHMIDemo_VariableBox = { HMI_SCREEN_ID_DEMO_VARIABLE_BOX, + &s_stDemoVariableBoxActions + }; //=======================================================================// -//= Function define. =// +//= Function define. =// //=======================================================================// HMI_ENGINE_RESULT HMI_DemoVariableBox_Initialize(SGUI_SCR_DEV* pstDeviceIF) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_NUM_VARBOX_PARAM stNumBoxInitParam; - SGUI_TEXT_VARBOX_PARAM stTextBoxInitParam; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_NUM_VARBOX_PARAM stNumBoxInitParam; + SGUI_TEXT_VARBOX_PARAM stTextBoxInitParam; - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - s_uiFocusedFlag = 0; + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + s_uiFocusedFlag = 0; - stNumBoxInitParam.eAlignment = SGUI_CENTER; - stNumBoxInitParam.iMin = -50; - stNumBoxInitParam.iMax = 100; - stNumBoxInitParam.pstFontRes = &SGUI_DEFAULT_FONT_8; - stNumBoxInitParam.stLayout.iX = VARIABLE_BOX_POSX+2; - stNumBoxInitParam.stLayout.iY = VARIABLE_BOX_NUMBER_POSY+2; - stNumBoxInitParam.stLayout.iWidth = pstDeviceIF->stSize.iWidth - (VARIABLE_BOX_POSX*2)-4; - stNumBoxInitParam.stLayout.iHeight = SGUI_DEFAULT_FONT_8.iHeight; + stNumBoxInitParam.eAlignment = SGUI_CENTER; + stNumBoxInitParam.iMin = -50; + stNumBoxInitParam.iMax = 100; + stNumBoxInitParam.pstFontRes = &SGUI_DEFAULT_FONT_8; + stNumBoxInitParam.stLayout.iX = VARIABLE_BOX_POSX+2; + stNumBoxInitParam.stLayout.iY = VARIABLE_BOX_NUMBER_POSY+2; + stNumBoxInitParam.stLayout.iWidth = pstDeviceIF->stSize.iWidth - (VARIABLE_BOX_POSX*2)-4; + stNumBoxInitParam.stLayout.iHeight = SGUI_DEFAULT_FONT_8.iHeight; - SGUI_NumberVariableBox_Initialize(&s_stNumberVariableBox, &stNumBoxInitParam); + SGUI_NumberVariableBox_Initialize(&s_stNumberVariableBox, &stNumBoxInitParam); - stTextBoxInitParam.pstFontRes = &SGUI_DEFAULT_FONT_12; - stTextBoxInitParam.stLayout.iX = VARIABLE_BOX_POSX+2; - stTextBoxInitParam.stLayout.iY = VARIABLE_BOX_TEXT_POSY+2; - stTextBoxInitParam.stLayout.iWidth = pstDeviceIF->stSize.iWidth-(VARIABLE_BOX_POSX*2)-4; - stTextBoxInitParam.stLayout.iHeight = SGUI_DEFAULT_FONT_12.iHeight; - stTextBoxInitParam.sTextLengthMax = TEXT_VARIABLE_LENGTH; + stTextBoxInitParam.pstFontRes = &SGUI_DEFAULT_FONT_12; + stTextBoxInitParam.stLayout.iX = VARIABLE_BOX_POSX+2; + stTextBoxInitParam.stLayout.iY = VARIABLE_BOX_TEXT_POSY+2; + stTextBoxInitParam.stLayout.iWidth = pstDeviceIF->stSize.iWidth-(VARIABLE_BOX_POSX*2)-4; + stTextBoxInitParam.stLayout.iHeight = SGUI_DEFAULT_FONT_12.iHeight; + stTextBoxInitParam.sTextLengthMax = TEXT_VARIABLE_LENGTH; - SGUI_TextVariableBox_Initialize(&s_stTextVariableBox, &stTextBoxInitParam, s_szTextVariableBuffer); + SGUI_TextVariableBox_Initialize(&s_stTextVariableBox, &stTextBoxInitParam, s_szTextVariableBuffer); - return HMI_RET_NORMAL; + return HMI_RET_NORMAL; } HMI_ENGINE_RESULT HMI_DemoVariableBox_Prepare(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_NOTICT_BOX stNoticeBox; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_NOTICT_BOX stNoticeBox; - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - stNoticeBox.pstIcon = &SGUI_RES_ICON_INFORMATION_16; - stNoticeBox.cszNoticeText = s_szHelpNoticeText; - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - // Draw frame - s_szFrameTitle = s_szDefaultFrameTitle; - HMI_DemoVariableBox_DrawFrame(pstDeviceIF, (SGUI_SZSTR)s_szFrameTitle); - // Show notice - SGUI_Notice_FitArea(pstDeviceIF, &(stNoticeBox.stLayout)); - SGUI_Notice_Repaint(pstDeviceIF, &stNoticeBox, &SGUI_DEFAULT_FONT_8, 0); - // Start RTC - RTCTimerEnable(true); - return HMI_RET_NORMAL; + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + stNoticeBox.pstIcon = &SGUI_RES_ICON_INFORMATION_16; + stNoticeBox.cszNoticeText = s_szHelpNoticeText; + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + // Draw frame + s_szFrameTitle = s_szDefaultFrameTitle; + HMI_DemoVariableBox_DrawFrame(pstDeviceIF, (SGUI_SZSTR)s_szFrameTitle); + // Show notice + SGUI_Notice_FitArea(pstDeviceIF, &(stNoticeBox.stLayout)); + SGUI_Notice_Repaint(pstDeviceIF, &stNoticeBox, &SGUI_DEFAULT_FONT_8, 0); + // Start RTC + RTCTimerEnable(true); + return HMI_RET_NORMAL; } HMI_ENGINE_RESULT HMI_DemoVariableBox_RefreshScreen(SGUI_SCR_DEV* pstDeviceIF, const void* pstParameters) { /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - // Draw frame + /* Process */ + /*----------------------------------*/ + // Draw frame HMI_DemoVariableBox_DrawFrame(pstDeviceIF, (SGUI_SZSTR)s_szFrameTitle); // Draw number box SGUI_Basic_DrawRectangle(pstDeviceIF, VARIABLE_BOX_POSX, VARIABLE_BOX_NUMBER_POSY, - s_stNumberVariableBox.stParam.stLayout.iWidth+4, s_stNumberVariableBox.stParam.stLayout.iHeight+4, - SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); + s_stNumberVariableBox.stParam.stLayout.iWidth+4, s_stNumberVariableBox.stParam.stLayout.iHeight+4, + SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); SGUI_NumberVariableBox_Repaint(pstDeviceIF, &s_stNumberVariableBox, (0 == s_uiFocusedFlag)?SGUI_DRAW_REVERSE:SGUI_DRAW_NORMAL); // Draw text box SGUI_Basic_DrawRectangle(pstDeviceIF, VARIABLE_BOX_POSX, VARIABLE_BOX_TEXT_POSY, - s_stTextVariableBox.stParam.stLayout.iWidth+4, s_stTextVariableBox.stParam.stLayout.iHeight+4, - SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); + s_stTextVariableBox.stParam.stLayout.iWidth+4, s_stTextVariableBox.stParam.stLayout.iHeight+4, + SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); SGUI_TextVariableBox_Repaint(pstDeviceIF, &s_stTextVariableBox, (0 == s_uiFocusedFlag)?SGUI_DRAW_NORMAL:SGUI_DRAW_REVERSE); - return HMI_RET_NORMAL; + return HMI_RET_NORMAL; } HMI_ENGINE_RESULT HMI_DemoVariableBox_ProcessEvent(SGUI_SCR_DEV* pstDeviceIF, const HMI_EVENT_BASE* pstEvent, SGUI_INT* piActionID) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - HMI_ENGINE_RESULT eProcessResult; - SGUI_UINT16 uiKeyValue; - KEY_PRESS_EVENT* pstKeyEvent; - SGUI_INT iProcessAction; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + HMI_ENGINE_RESULT eProcessResult; + SGUI_UINT16 uiKeyValue; + KEY_PRESS_EVENT* pstKeyEvent; + SGUI_INT iProcessAction; - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - eProcessResult = HMI_RET_NORMAL; - iProcessAction = HMI_DEMO_PROC_NO_ACT; + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + eProcessResult = HMI_RET_NORMAL; + iProcessAction = HMI_DEMO_PROC_NO_ACT; - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if(s_uiAutoConfirmTimer > 0) + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(s_uiAutoConfirmTimer > 0) { - if(EVENT_TYPE_ACTION == pstEvent->iType) - { - if(EVENT_ID_KEY_PRESS == pstEvent->iID) - { - pstKeyEvent = (KEY_PRESS_EVENT*)pstEvent; - uiKeyValue = KEY_CODE_VALUE(pstKeyEvent->Data.uiKeyValue); + if(EVENT_TYPE_ACTION == pstEvent->iType) + { + if(EVENT_ID_KEY_PRESS == pstEvent->iID) + { + pstKeyEvent = (KEY_PRESS_EVENT*)pstEvent; + uiKeyValue = KEY_CODE_VALUE(pstKeyEvent->Data.uiKeyValue); - if(KEY_VALUE_SPACE == uiKeyValue) - { - // Stop count down when press space. - s_uiAutoConfirmTimer = 0; - } - } - } - else if(EVENT_TYPE_DATA == pstEvent->iType) - { - if(EVENT_ID_RTC == pstEvent->iID) - { - //Count down five seconds - s_uiAutoConfirmTimer--; - } - } + if(KEY_VALUE_SPACE == uiKeyValue) + { + // Stop count down when press space. + s_uiAutoConfirmTimer = 0; + } + } + } + else if(EVENT_TYPE_DATA == pstEvent->iType) + { + if(EVENT_ID_RTC == pstEvent->iID) + { + //Count down five seconds + s_uiAutoConfirmTimer--; + } + } // Redraw screen if time out. if(0 == s_uiAutoConfirmTimer) @@ -209,149 +209,149 @@ HMI_ENGINE_RESULT HMI_DemoVariableBox_ProcessEvent(SGUI_SCR_DEV* pstDeviceIF, co { if(EVENT_ID_KEY_PRESS == pstEvent->iID) { - pstKeyEvent = (KEY_PRESS_EVENT*)pstEvent; - uiKeyValue = KEY_CODE_VALUE(pstKeyEvent->Data.uiKeyValue); + pstKeyEvent = (KEY_PRESS_EVENT*)pstEvent; + uiKeyValue = KEY_CODE_VALUE(pstKeyEvent->Data.uiKeyValue); - switch(uiKeyValue) - { - case KEY_VALUE_TAB: - { - s_uiFocusedFlag = ((s_uiFocusedFlag+1)%2); - if(0 == s_uiFocusedFlag) - { - SGUI_NumberVariableBox_Repaint(pstDeviceIF, &s_stNumberVariableBox, SGUI_DRAW_REVERSE); - SGUI_TextVariableBox_Repaint(pstDeviceIF, &s_stTextVariableBox, SGUI_DRAW_NORMAL); - } - else - { - SGUI_NumberVariableBox_Repaint(pstDeviceIF, &s_stNumberVariableBox, SGUI_DRAW_NORMAL); - SGUI_TextVariableBox_Repaint(pstDeviceIF, &s_stTextVariableBox, SGUI_DRAW_REVERSE); - } - break; - } - case KEY_VALUE_ESC: - { - iProcessAction = HMI_DEMO_PROC_CANCEL; - break; - } - case KEY_VALUE_LEFT: - { - if(1 == s_uiFocusedFlag) - { - SGUI_TextVariableBox_DecreaseIndex(&s_stTextVariableBox); - SGUI_TextVariableBox_Repaint(pstDeviceIF, &s_stTextVariableBox, SGUI_DRAW_REVERSE); - } - break; - } - case KEY_VALUE_UP: - { - if(1 == s_uiFocusedFlag) - { - SGUI_TextVariableBox_IncreaseChar(&s_stTextVariableBox); - SGUI_TextVariableBox_Repaint(pstDeviceIF, &s_stTextVariableBox, SGUI_DRAW_REVERSE); - } - else - { - SGUI_NumberVariableBox_SetValue(&s_stNumberVariableBox, SGUI_NumberVariableBox_GetValue(&s_stNumberVariableBox)+1); - SGUI_NumberVariableBox_Repaint(pstDeviceIF, &s_stNumberVariableBox, SGUI_DRAW_REVERSE); - } - break; - } - case KEY_VALUE_RIGHT: - { - if(1 == s_uiFocusedFlag) - { - SGUI_TextVariableBox_IncreaseIndex(&s_stTextVariableBox); - SGUI_TextVariableBox_Repaint(pstDeviceIF, &s_stTextVariableBox, SGUI_DRAW_REVERSE); - } - break; - } - case KEY_VALUE_DOWN: - { - if(1 == s_uiFocusedFlag) - { - SGUI_TextVariableBox_DecreaseChar(&s_stTextVariableBox); - SGUI_TextVariableBox_Repaint(pstDeviceIF, &s_stTextVariableBox, SGUI_DRAW_REVERSE); - } - else - { - SGUI_NumberVariableBox_SetValue(&s_stNumberVariableBox, SGUI_NumberVariableBox_GetValue(&s_stNumberVariableBox)-1); - SGUI_NumberVariableBox_Repaint(pstDeviceIF, &s_stNumberVariableBox, SGUI_DRAW_REVERSE); - } - break; - } - case KEY_VALUE_ENTER: - { - if(1 == s_uiFocusedFlag) - { - s_szFrameTitle = SGUI_TextVariableBox_GetText(&s_stTextVariableBox); - HMI_DemoVariableBox_DrawFrame(pstDeviceIF, (SGUI_SZSTR)s_szFrameTitle); - // Draw number box - SGUI_Basic_DrawRectangle(pstDeviceIF, VARIABLE_BOX_POSX, VARIABLE_BOX_NUMBER_POSY, VARIABLE_BOX_WIDTH+4, VARIABLE_NUMBER_BOX_HEIGHT+4, SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); - SGUI_NumberVariableBox_Repaint(pstDeviceIF, &s_stNumberVariableBox, SGUI_DRAW_NORMAL); - // Draw text box - SGUI_Basic_DrawRectangle(pstDeviceIF, VARIABLE_BOX_POSX, VARIABLE_BOX_TEXT_POSY, VARIABLE_BOX_WIDTH+4, VARIABLE_TEXT_BOX_HEIGHT+4, SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); - SGUI_TextVariableBox_Repaint(pstDeviceIF, &s_stTextVariableBox, SGUI_DRAW_REVERSE); - } - break; - } - default: - { - /* No process. */ - break; - } - } + switch(uiKeyValue) + { + case KEY_VALUE_TAB: + { + s_uiFocusedFlag = ((s_uiFocusedFlag+1)%2); + if(0 == s_uiFocusedFlag) + { + SGUI_NumberVariableBox_Repaint(pstDeviceIF, &s_stNumberVariableBox, SGUI_DRAW_REVERSE); + SGUI_TextVariableBox_Repaint(pstDeviceIF, &s_stTextVariableBox, SGUI_DRAW_NORMAL); + } + else + { + SGUI_NumberVariableBox_Repaint(pstDeviceIF, &s_stNumberVariableBox, SGUI_DRAW_NORMAL); + SGUI_TextVariableBox_Repaint(pstDeviceIF, &s_stTextVariableBox, SGUI_DRAW_REVERSE); + } + break; + } + case KEY_VALUE_ESC: + { + iProcessAction = HMI_DEMO_PROC_CANCEL; + break; + } + case KEY_VALUE_LEFT: + { + if(1 == s_uiFocusedFlag) + { + SGUI_TextVariableBox_DecreaseIndex(&s_stTextVariableBox); + SGUI_TextVariableBox_Repaint(pstDeviceIF, &s_stTextVariableBox, SGUI_DRAW_REVERSE); + } + break; + } + case KEY_VALUE_UP: + { + if(1 == s_uiFocusedFlag) + { + SGUI_TextVariableBox_IncreaseChar(&s_stTextVariableBox); + SGUI_TextVariableBox_Repaint(pstDeviceIF, &s_stTextVariableBox, SGUI_DRAW_REVERSE); + } + else + { + SGUI_NumberVariableBox_SetValue(&s_stNumberVariableBox, SGUI_NumberVariableBox_GetValue(&s_stNumberVariableBox)+1); + SGUI_NumberVariableBox_Repaint(pstDeviceIF, &s_stNumberVariableBox, SGUI_DRAW_REVERSE); + } + break; + } + case KEY_VALUE_RIGHT: + { + if(1 == s_uiFocusedFlag) + { + SGUI_TextVariableBox_IncreaseIndex(&s_stTextVariableBox); + SGUI_TextVariableBox_Repaint(pstDeviceIF, &s_stTextVariableBox, SGUI_DRAW_REVERSE); + } + break; + } + case KEY_VALUE_DOWN: + { + if(1 == s_uiFocusedFlag) + { + SGUI_TextVariableBox_DecreaseChar(&s_stTextVariableBox); + SGUI_TextVariableBox_Repaint(pstDeviceIF, &s_stTextVariableBox, SGUI_DRAW_REVERSE); + } + else + { + SGUI_NumberVariableBox_SetValue(&s_stNumberVariableBox, SGUI_NumberVariableBox_GetValue(&s_stNumberVariableBox)-1); + SGUI_NumberVariableBox_Repaint(pstDeviceIF, &s_stNumberVariableBox, SGUI_DRAW_REVERSE); + } + break; + } + case KEY_VALUE_ENTER: + { + if(1 == s_uiFocusedFlag) + { + s_szFrameTitle = SGUI_TextVariableBox_GetText(&s_stTextVariableBox); + HMI_DemoVariableBox_DrawFrame(pstDeviceIF, (SGUI_SZSTR)s_szFrameTitle); + // Draw number box + SGUI_Basic_DrawRectangle(pstDeviceIF, VARIABLE_BOX_POSX, VARIABLE_BOX_NUMBER_POSY, VARIABLE_BOX_WIDTH+4, VARIABLE_NUMBER_BOX_HEIGHT+4, SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); + SGUI_NumberVariableBox_Repaint(pstDeviceIF, &s_stNumberVariableBox, SGUI_DRAW_NORMAL); + // Draw text box + SGUI_Basic_DrawRectangle(pstDeviceIF, VARIABLE_BOX_POSX, VARIABLE_BOX_TEXT_POSY, VARIABLE_BOX_WIDTH+4, VARIABLE_TEXT_BOX_HEIGHT+4, SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); + SGUI_TextVariableBox_Repaint(pstDeviceIF, &s_stTextVariableBox, SGUI_DRAW_REVERSE); + } + break; + } + default: + { + /* No process. */ + break; + } + } } } if(NULL != piActionID) - { - *piActionID = iProcessAction; - } + { + *piActionID = iProcessAction; + } - return eProcessResult; + return eProcessResult; } HMI_ENGINE_RESULT HMI_DemoVariableBox_PostProcess(SGUI_SCR_DEV* pstDeviceIF, HMI_ENGINE_RESULT eProcResult, SGUI_INT iActionID) { - if(HMI_PROCESS_SUCCESSFUL(eProcResult)) - { - if(HMI_DEMO_PROC_CANCEL == iActionID) - { - s_uiAutoConfirmTimer = 5; - HMI_GoBack(NULL); - } - } + if(HMI_PROCESS_SUCCESSFUL(eProcResult)) + { + if(HMI_DEMO_PROC_CANCEL == iActionID) + { + s_uiAutoConfirmTimer = 5; + HMI_GoBack(NULL); + } + } - return HMI_RET_NORMAL; + return HMI_RET_NORMAL; } void HMI_DemoVariableBox_DrawFrame(SGUI_SCR_DEV* pstDeviceIF, SGUI_SZSTR szTitle) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_RECT stTextDisplayArea; - SGUI_POINT stInnerPos; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_RECT stTextDisplayArea; + SGUI_POINT stInnerPos; - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - stTextDisplayArea.iX = 4; - stTextDisplayArea.iY = 4; - stTextDisplayArea.iHeight = 12; - stInnerPos.iX = 0; - stInnerPos.iY = 0; + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + stTextDisplayArea.iX = 4; + stTextDisplayArea.iY = 4; + stTextDisplayArea.iHeight = 12; + stInnerPos.iX = 0; + stInnerPos.iY = 0; - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if(NULL != pstDeviceIF) - { - stTextDisplayArea.iWidth = pstDeviceIF->stSize.iWidth-8; - SGUI_Basic_DrawRectangle(pstDeviceIF, 0, 0, RECT_WIDTH(pstDeviceIF->stSize), RECT_HEIGHT(pstDeviceIF->stSize), SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); - SGUI_Basic_DrawRectangle(pstDeviceIF, 2, 2, RECT_WIDTH(pstDeviceIF->stSize)-4, RECT_HEIGHT(pstDeviceIF->stSize)-4, SGUI_COLOR_FRGCLR, SGUI_COLOR_TRANS); - SGUI_Basic_DrawLine(pstDeviceIF, 3, 17, 124, 17, SGUI_COLOR_FRGCLR); - SGUI_Text_DrawText(pstDeviceIF, szTitle, &GB2312_FZXS12, &stTextDisplayArea, &stInnerPos, SGUI_DRAW_NORMAL); - } + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(NULL != pstDeviceIF) + { + stTextDisplayArea.iWidth = pstDeviceIF->stSize.iWidth-8; + SGUI_Basic_DrawRectangle(pstDeviceIF, 0, 0, RECT_WIDTH(pstDeviceIF->stSize), RECT_HEIGHT(pstDeviceIF->stSize), SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); + SGUI_Basic_DrawRectangle(pstDeviceIF, 2, 2, RECT_WIDTH(pstDeviceIF->stSize)-4, RECT_HEIGHT(pstDeviceIF->stSize)-4, SGUI_COLOR_FRGCLR, SGUI_COLOR_TRANS); + SGUI_Basic_DrawLine(pstDeviceIF, 3, 17, 124, 17, SGUI_COLOR_FRGCLR); + SGUI_Text_DrawText(pstDeviceIF, szTitle, &GB2312_FZXS12, &stTextDisplayArea, &stInnerPos, SGUI_DRAW_NORMAL); + } } diff --git a/GUI/inc/SGUI_Basic.h b/GUI/inc/SGUI_Basic.h index d35f1651218af54f0a4a153e1ae85281944bbf2b..40fffaafa7c67470d3a95ac67675fcc3b151fca3 100644 --- a/GUI/inc/SGUI_Basic.h +++ b/GUI/inc/SGUI_Basic.h @@ -1,35 +1,35 @@ #ifndef __INCLUDE_GUI_BASIC__ #define __INCLUDE_GUI_BASIC__ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "SGUI_Common.h" //=======================================================================// -//= User Macro definition. =// +//= User Macro definition. =// //=======================================================================// #define SGUI_USED_BYTE(V) (((V-1)/8)+1) //Bitmap(include font) data bit operation -#define SGUI_SET_PAGE_BIT(PAGE, Bit) ((PAGE) = (PAGE) | (0x01 << (Bit))) -#define SGUI_CLR_PAGE_BIT(PAGE, Bit) ((PAGE) = (PAGE) & (~(0x01 << (Bit)))) -#define SGUI_GET_PAGE_BIT(PAGE, Bit) ((((PAGE) & (0x01 << (Bit)))>0)?1:0) +#define SGUI_SET_PAGE_BIT(PAGE, Bit) ((PAGE) = (PAGE) | (0x01 << (Bit))) +#define SGUI_CLR_PAGE_BIT(PAGE, Bit) ((PAGE) = (PAGE) & (~(0x01 << (Bit)))) +#define SGUI_GET_PAGE_BIT(PAGE, Bit) ((((PAGE) & (0x01 << (Bit)))>0)?1:0) //=======================================================================// -//= Public function declaration. =// +//= Public function declaration. =// //=======================================================================// -void SGUI_Basic_ClearScreen(SGUI_SCR_DEV* pstDeviceIF); -void SGUI_Basic_DrawPoint(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iPosX, SGUI_INT iPosY, SGUI_COLOR eColor); -void SGUI_Basic_DrawLine(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iStartX, SGUI_INT iStartY, SGUI_INT iEndX, SGUI_INT iEndY, SGUI_COLOR eColor); +void SGUI_Basic_ClearScreen(SGUI_SCR_DEV* pstDeviceIF); +void SGUI_Basic_DrawPoint(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iPosX, SGUI_INT iPosY, SGUI_COLOR eColor); +void SGUI_Basic_DrawLine(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iStartX, SGUI_INT iStartY, SGUI_INT iEndX, SGUI_INT iEndY, SGUI_COLOR eColor); void SGUI_Basic_DrawHorizontalLine(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iStartX, SGUI_INT iEndX, SGUI_INT iY, SGUI_COLOR eColor); void SGUI_Basic_DrawVerticalLine(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iX, SGUI_INT iStartY, SGUI_INT iEndY, SGUI_COLOR eColor); -void SGUI_Basic_DrawRectangle(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iStartX, SGUI_INT iStartY, SGUI_INT iWidth, SGUI_INT iHeight, SGUI_COLOR eEdgeColor, SGUI_COLOR eFillColor); +void SGUI_Basic_DrawRectangle(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iStartX, SGUI_INT iStartY, SGUI_INT iWidth, SGUI_INT iHeight, SGUI_COLOR eEdgeColor, SGUI_COLOR eFillColor); void SGUI_Basic_DrawRoundedRectangle(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iStartX, SGUI_INT iStartY, SGUI_INT iWidth, SGUI_INT iHeight, SGUI_INT iFillet, SGUI_COLOR eEdgeColor, SGUI_COLOR eFillColor); -void SGUI_Basic_DrawCircle(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iCx, SGUI_INT iCy, SGUI_INT iRadius, SGUI_COLOR eEdgeColor, SGUI_COLOR eFillColor); -void SGUI_Basic_ReverseBlockColor(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iStartX, SGUI_INT iStartY, SGUI_INT iWidth, SGUI_INT iHeight); -void SGUI_Basic_FillRectangleArea(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iStartX, SGUI_INT iStartY, SGUI_INT iWidth, SGUI_INT iHeight, SGUI_COLOR eFillColor); +void SGUI_Basic_DrawCircle(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iCx, SGUI_INT iCy, SGUI_INT iRadius, SGUI_COLOR eEdgeColor, SGUI_COLOR eFillColor); +void SGUI_Basic_ReverseBlockColor(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iStartX, SGUI_INT iStartY, SGUI_INT iWidth, SGUI_INT iHeight); +void SGUI_Basic_FillRectangleArea(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iStartX, SGUI_INT iStartY, SGUI_INT iWidth, SGUI_INT iHeight, SGUI_COLOR eFillColor); void SGUI_Basic_DrawBitMap(SGUI_SCR_DEV* pstDeviceIF, SGUI_RECT* pstDisplayArea, SGUI_POINT* pstInnerPos, const SGUI_BMP_RES* pstBitmapData, SGUI_DRAW_MODE eDrawMode); -SGUI_COLOR SGUI_Basic_GetPoint(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iPosX, SGUI_INT iPosY); -SGUI_BOOL SGUI_Basic_PointIsInArea(const SGUI_RECT* pstArea, SGUI_INT iPosX, SGUI_INT iPosY); -void SGUI_Basic_ResetActiveArea(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iStartX, SGUI_INT iStartY, SGUI_INT iWidth, SGUI_INT iHeight); +SGUI_COLOR SGUI_Basic_GetPoint(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iPosX, SGUI_INT iPosY); +SGUI_BOOL SGUI_Basic_PointIsInArea(const SGUI_RECT* pstArea, SGUI_INT iPosX, SGUI_INT iPosY); +void SGUI_Basic_ResetActiveArea(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iStartX, SGUI_INT iStartY, SGUI_INT iWidth, SGUI_INT iHeight); #endif diff --git a/GUI/inc/SGUI_Common.h b/GUI/inc/SGUI_Common.h index 08e4a19acb219fb049f54ff5dfe18e758067e830..13127e088b1b4e3a490c1fce182de51a45f21464 100644 --- a/GUI/inc/SGUI_Common.h +++ b/GUI/inc/SGUI_Common.h @@ -1,35 +1,35 @@ #ifndef __INCLUDE_GUI_COMMON_H__ #define __INCLUDE_GUI_COMMON_H__ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "SGUI_Config.h" #include "SGUI_Typedef.h" #include "SGUI_Interface.h" //=======================================================================// -//= User Macro definition. =// +//= User Macro definition. =// //=======================================================================// -#define NOTICE_ICON_SIZE (16) -#define SGUI_NUMBER_STR_LENGTH_MAX (12) -#define SGUI_ISDIGIT(C) (((C>='0')&&(C<='9'))?true:false) -#define SGUI_ISALPHA(C) ((((C>='A')&&(C<='Z'))||((C>='a')&&(C<='z')))?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_TOUPPER(C) (SGUI_ISUPPER(C)?(C):(C-32)) -#define SGUI_SWAP(A, B) {A=A^B; B=A^B; A=A^B;} +#define NOTICE_ICON_SIZE (16) +#define SGUI_NUMBER_STR_LENGTH_MAX (12) +#define SGUI_ISDIGIT(C) (((C>='0')&&(C<='9'))?true:false) +#define SGUI_ISALPHA(C) ((((C>='A')&&(C<='Z'))||((C>='a')&&(C<='z')))?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_TOUPPER(C) (SGUI_ISUPPER(C)?(C):(C-32)) +#define SGUI_SWAP(A, B) {A=A^B; B=A^B; A=A^B;} -#define LAYOUT(POBJ) ((POBJ)->stParam.stLayout) +#define LAYOUT(POBJ) ((POBJ)->stParam.stLayout) //=======================================================================// -//= Public function declaration. =// +//= Public function declaration. =// //=======================================================================// //=======================================================================// -//= Public function declaration. =// +//= Public function declaration. =// //=======================================================================// -void SGUI_Common_AdaptDisplayInfo(SGUI_RECT* pstDisplayArea, SGUI_POINT* pstInnerPos); -SGUI_INT SGUI_Common_IntegerToStringWithDecimalPoint(SGUI_INT iInteger, SGUI_INT iDecimalPlaces, SGUI_SZSTR pszStringBuffer, SGUI_INT iAlignment, SGUI_CHAR cFillCharacter); +void SGUI_Common_AdaptDisplayInfo(SGUI_RECT* pstDisplayArea, SGUI_POINT* pstInnerPos); +SGUI_INT SGUI_Common_IntegerToStringWithDecimalPoint(SGUI_INT iInteger, SGUI_INT iDecimalPlaces, SGUI_SZSTR pszStringBuffer, SGUI_INT iAlignment, SGUI_CHAR cFillCharacter); SGUI_SIZE SGUI_Common_IntegerToString(SGUI_INT iInteger, SGUI_SZSTR pszStringBuffer, SGUI_UINT uiBase, SGUI_INT iAlignment, SGUI_CHAR cFillCharacter); SGUI_UINT SGUI_Common_ConvertStringToUnsignedInteger(SGUI_SZSTR szString, SGUI_CHAR** ppcEndPointer, SGUI_UINT uiBase); SGUI_INT SGUI_Common_ConvertStringToInteger(SGUI_SZSTR szString, SGUI_CHAR** ppcEndPointer, SGUI_UINT uiBase); diff --git a/GUI/inc/SGUI_Config.h b/GUI/inc/SGUI_Config.h index fb67e8cd7ef3e268053f245e55659519c0a384ee..62c88251456e599855885de711a8f217f4e5d2e7 100644 --- a/GUI/inc/SGUI_Config.h +++ b/GUI/inc/SGUI_Config.h @@ -2,16 +2,16 @@ #define _INCLUDE_SIMPLE_GUI_CONFIG_H_ //=======================================================================// -//= Used for SimpleGUI virtual SDK. =// +//= Used for SimpleGUI virtual SDK. =// //=======================================================================// #ifdef _SIMPLE_GUI_ENCODE_TEXT_ - #define _SIMPLE_GUI_ENCODE_TEXT_SRC_ ("UTF-8") - #define _SIMPLE_GUI_ENCODE_TEXT_DEST_ ("GB2312") + #define _SIMPLE_GUI_ENCODE_TEXT_SRC_ ("UTF-8") + #define _SIMPLE_GUI_ENCODE_TEXT_DEST_ ("GB2312") #endif // _SIMPLE_GUI_ENCODE_TEXT_ #define _SIMPLE_GUI_IN_VIRTUAL_SDK_ //=======================================================================// -//= Used for SimpleGUI interface. =// +//= Used for SimpleGUI interface. =// //=======================================================================// //#define _SIMPLE_GUI_ENABLE_DYNAMIC_MEMORY_ diff --git a/GUI/inc/SGUI_Curve.h b/GUI/inc/SGUI_Curve.h index 239148407f910f0e1d7200337f402dae33dd7a10..851abec2a62e78f8b6041abdfb4e750144b530b4 100644 --- a/GUI/inc/SGUI_Curve.h +++ b/GUI/inc/SGUI_Curve.h @@ -1,74 +1,74 @@ #ifndef _INCLUDE_GUI_CURVE_H__ #define _INCLUDE_GUI_CURVE_H__ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "SGUI_Common.h" #include "SGUI_Basic.h" //=======================================================================// -//= User Macro definition. =// +//= User Macro definition. =// //=======================================================================// //=======================================================================// -//= Data type definition. =// +//= Data type definition. =// //=======================================================================// typedef struct { - SGUI_INT iA; - SGUI_INT iB; + SGUI_INT iA; + SGUI_INT iB; }SGUI_CURVE_COEFFICIENT; typedef struct _sgui_st_curve_point_ { - struct _sgui_st_curve_point_* pstPrev; - SGUI_POINT stPoint; - SGUI_POINT stPosition; - struct _sgui_st_curve_point_* pstNext; + struct _sgui_st_curve_point_* pstPrev; + SGUI_POINT stPoint; + SGUI_POINT stPosition; + struct _sgui_st_curve_point_* pstNext; }SGUI_CURVE_POINT; typedef struct { - SGUI_CURVE_POINT* pstHead; - SGUI_CURVE_POINT* pstEnd; - SGUI_SIZE sCount; + SGUI_CURVE_POINT* pstHead; + SGUI_CURVE_POINT* pstEnd; + SGUI_SIZE sCount; }SGUI_CURVE_POINT_LIST; typedef struct { - SGUI_RECT stLayout; - SGUI_RANGE stXRange; - SGUI_RANGE stYRange; + SGUI_RECT stLayout; + SGUI_RANGE stXRange; + SGUI_RANGE stYRange; }SGUI_CURVE_PARAM; typedef struct { - SGUI_CURVE_POINT_LIST stPoints; - SGUI_CURVE_POINT* pstFocused; + SGUI_CURVE_POINT_LIST stPoints; + SGUI_CURVE_POINT* pstFocused; }SGUI_CURVE_DATA; typedef struct { - SGUI_CURVE_PARAM stParam; - SGUI_CURVE_DATA stData; + SGUI_CURVE_PARAM stParam; + SGUI_CURVE_DATA stData; }SGUI_CURVE_STRUCT; //=======================================================================// -//= Public function declaration. =// +//= Public function declaration. =// //=======================================================================// -void SGUI_Curve_Initialize(SGUI_CURVE_STRUCT* pstObj, const SGUI_CURVE_PARAM* pcstInitParam); -void SGUI_Curve_Repaint(SGUI_SCR_DEV* pstDeviceIF, const SGUI_CURVE_STRUCT* pstObj); -void SGUI_Curve_InitializePoint(SGUI_CURVE_POINT* pstNewPoint, SGUI_INT iX, SGUI_INT iY); -void SGUI_Curve_CalculatePointPosition(SGUI_CURVE_STRUCT* pstObj, SGUI_CURVE_POINT* pstPoint); -void SGUI_Curve_AddPoint(SGUI_CURVE_STRUCT* pstObj, SGUI_CURVE_POINT* pstNewPoint); -SGUI_BOOL SGUI_Curve_InsertBeforePoint(SGUI_CURVE_STRUCT* pstObj, SGUI_CURVE_POINT* pstNewPoint); -SGUI_BOOL SGUI_Curve_InsertAfterPoint(SGUI_CURVE_STRUCT* pstObj, SGUI_CURVE_POINT* pstNewPoint); -SGUI_BOOL SGUI_Curve_RemovePoint(SGUI_CURVE_STRUCT* pstObj, SGUI_CURVE_POINT* pstPoint); -SGUI_CURVE_POINT* SGUI_Curve_FocusPoint(SGUI_CURVE_STRUCT* pstObj, SGUI_INT iIndex); -#define SGUI_Curve_FocusedPoint(OBJ) ((OBJ)->stData.pstFocused) -SGUI_BOOL SGUI_Curve_UpdateFocusPoint(SGUI_CURVE_STRUCT* pstObj, SGUI_INT iX, SGUI_INT iY); -void SGUI_Curve_HighlightFocus(SGUI_SCR_DEV* pstDeviceIF, SGUI_CURVE_STRUCT* pstObj); -SGUI_BOOL SGUI_Curve_PointIsHighlight(SGUI_SCR_DEV* pstDeviceIF, SGUI_CURVE_POINT* pstPoint); +void SGUI_Curve_Initialize(SGUI_CURVE_STRUCT* pstObj, const SGUI_CURVE_PARAM* pcstInitParam); +void SGUI_Curve_Repaint(SGUI_SCR_DEV* pstDeviceIF, const SGUI_CURVE_STRUCT* pstObj); +void SGUI_Curve_InitializePoint(SGUI_CURVE_POINT* pstNewPoint, SGUI_INT iX, SGUI_INT iY); +void SGUI_Curve_CalculatePointPosition(SGUI_CURVE_STRUCT* pstObj, SGUI_CURVE_POINT* pstPoint); +void SGUI_Curve_AddPoint(SGUI_CURVE_STRUCT* pstObj, SGUI_CURVE_POINT* pstNewPoint); +SGUI_BOOL SGUI_Curve_InsertBeforePoint(SGUI_CURVE_STRUCT* pstObj, SGUI_CURVE_POINT* pstNewPoint); +SGUI_BOOL SGUI_Curve_InsertAfterPoint(SGUI_CURVE_STRUCT* pstObj, SGUI_CURVE_POINT* pstNewPoint); +SGUI_BOOL SGUI_Curve_RemovePoint(SGUI_CURVE_STRUCT* pstObj, SGUI_CURVE_POINT* pstPoint); +SGUI_CURVE_POINT* SGUI_Curve_FocusPoint(SGUI_CURVE_STRUCT* pstObj, SGUI_INT iIndex); +#define SGUI_Curve_FocusedPoint(OBJ) ((OBJ)->stData.pstFocused) +SGUI_BOOL SGUI_Curve_UpdateFocusPoint(SGUI_CURVE_STRUCT* pstObj, SGUI_INT iX, SGUI_INT iY); +void SGUI_Curve_HighlightFocus(SGUI_SCR_DEV* pstDeviceIF, SGUI_CURVE_STRUCT* pstObj); +SGUI_BOOL SGUI_Curve_PointIsHighlight(SGUI_SCR_DEV* pstDeviceIF, SGUI_CURVE_POINT* pstPoint); #endif // __INCLUDE_GUI_REAL_GRAPH_H__ diff --git a/GUI/inc/SGUI_FontResource.h b/GUI/inc/SGUI_FontResource.h index 21c3375273e6ef561d146db6a45b8ea9e9a5d421..b1dcae6bb1b416350badc66d150a855d3a028393 100644 --- a/GUI/inc/SGUI_FontResource.h +++ b/GUI/inc/SGUI_FontResource.h @@ -1,16 +1,16 @@ #ifndef _INCLUDED_SGUI_FONT_SOURCE_H_ #define _INCLUDED_SGUI_FONT_SOURCE_H_ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "SGUI_Typedef.h" //=======================================================================// -//= Public variable declaration. =// +//= Public variable declaration. =// //=======================================================================// extern const SGUI_FONT_RES SGUI_DEFAULT_FONT_MiniNum; extern const SGUI_FONT_RES SGUI_DEFAULT_FONT_8; -extern const SGUI_FONT_RES SGUI_DEFAULT_FONT_12; -extern const SGUI_FONT_RES SGUI_DEFAULT_FONT_16; +extern const SGUI_FONT_RES SGUI_DEFAULT_FONT_12; +extern const SGUI_FONT_RES SGUI_DEFAULT_FONT_16; #endif // _INCLUDED_SGUI_FONT_SOURCE_H_ diff --git a/GUI/inc/SGUI_Graph.h b/GUI/inc/SGUI_Graph.h index ae2a9b5941f544d1c84e40f61966649c99346859..c36fa822bd91649c07f99b290c5c907947b56ba1 100644 --- a/GUI/inc/SGUI_Graph.h +++ b/GUI/inc/SGUI_Graph.h @@ -1,66 +1,66 @@ #ifndef __INCLUDE_SGUI_GRAPH_H__ #define __INCLUDE_SGUI_GRAPH_H__ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "SGUI_Common.h" #include "SGUI_Basic.h" #include "SGUI_ScrollBar.h" //=======================================================================// -//= Data type definition. =// +//= Data type definition. =// //=======================================================================// typedef struct { - SGUI_INT x; - SGUI_INT y; + SGUI_INT x; + SGUI_INT y; }SGUI_GRAPH_POINT; typedef struct { - SGUI_INT Min; - SGUI_INT Max; + SGUI_INT Min; + SGUI_INT Max; }SGUI_GRAPH_AXIS; typedef struct { - SGUI_GRAPH_POINT* Points; - SGUI_SIZE Count; + SGUI_GRAPH_POINT* Points; + SGUI_SIZE Count; }SGUI_GRAPH_DATA; typedef struct { - SGUI_GRAPH_AXIS xAxis; - SGUI_GRAPH_AXIS yAxis; - SGUI_SIZE FocusIndex; - SGUI_INT PointRangeX; - SGUI_INT PointRangeY; - SGUI_GRAPH_POINT LastDrawingPoint; + SGUI_GRAPH_AXIS xAxis; + SGUI_GRAPH_AXIS yAxis; + SGUI_SIZE FocusIndex; + SGUI_INT PointRangeX; + SGUI_INT PointRangeY; + SGUI_GRAPH_POINT LastDrawingPoint; }SGUI_GRAPH_CONTROL; typedef struct { - SGUI_SCROLLBAR_STRUCT xScrollBar; - SGUI_SCROLLBAR_STRUCT yScrollBar; + SGUI_SCROLLBAR_STRUCT xScrollBar; + SGUI_SCROLLBAR_STRUCT yScrollBar; }SGUI_GRAPH_SUBELEMENT; typedef struct { - SGUI_GRAPH_DATA* Data; - SGUI_GRAPH_CONTROL* Control; - SGUI_GRAPH_SUBELEMENT SubElement; + SGUI_GRAPH_DATA* Data; + SGUI_GRAPH_CONTROL* Control; + SGUI_GRAPH_SUBELEMENT SubElement; }SGUI_GRAPH; typedef struct { - SGUI_SIZE Count; - SGUI_SIZE FocusIndex; - SGUI_GRAPH_POINT* Points; + SGUI_SIZE Count; + SGUI_SIZE FocusIndex; + SGUI_GRAPH_POINT* Points; }SGUI_GRAPH_INIT_DATA; //=======================================================================// -//= Public function declaration. =// +//= Public function declaration. =// //=======================================================================// -void SGUI_Graph_InitializeGraphData(SGUI_SCR_DEV* pstIFObj, SGUI_GRAPH* pstGraph, SGUI_GRAPH_INIT_DATA* pstInitializeData); -void SGUI_Graph_Refresh(SGUI_SCR_DEV* pstIFObj, SGUI_GRAPH* pstGraph); +void SGUI_Graph_InitializeGraphData(SGUI_SCR_DEV* pstIFObj, SGUI_GRAPH* pstGraph, SGUI_GRAPH_INIT_DATA* pstInitializeData); +void SGUI_Graph_Refresh(SGUI_SCR_DEV* pstIFObj, SGUI_GRAPH* pstGraph); #endif // __INCLUDE_SGUI_GRAPH_H__ diff --git a/GUI/inc/SGUI_IconResource.h b/GUI/inc/SGUI_IconResource.h index f6fa1940898d532c00411005d2b3a236108e68ea..c6d27b99240a9df838ce38aa74f530868e34bd25 100644 --- a/GUI/inc/SGUI_IconResource.h +++ b/GUI/inc/SGUI_IconResource.h @@ -1,12 +1,12 @@ #ifndef _INCLUDE_SGUI_RESOURCE_H_ #define _INCLUDE_SGUI_RESOURCE_H_ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "SGUI_Typedef.h" //=======================================================================// -//= Public variable declaration. =// +//= Public variable declaration. =// //=======================================================================// SGUI_BMP_RESOURCE_DECLARE(SGUI_RES_ICON_ERROR_16); SGUI_BMP_RESOURCE_DECLARE(SGUI_RES_ICON_INFORMATION_16); diff --git a/GUI/inc/SGUI_Interface.h b/GUI/inc/SGUI_Interface.h index 5345b3cb06d5e8b3c68e3467e67cac205138a465..32eba6ccdff1bcdf860061c01d42089fd1cc7106 100644 --- a/GUI/inc/SGUI_Interface.h +++ b/GUI/inc/SGUI_Interface.h @@ -1,35 +1,35 @@ #ifndef __INCLUDED_SGUI_INTERFACE_H__ #define __INCLUDED_SGUI_INTERFACE_H__ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "SGUI_Typedef.h" #include "SGUI_Common.h" #include //=======================================================================// -//= User Macro definition. =// +//= User Macro definition. =// //=======================================================================// #if defined ( __CC_ARM ) - #define SGUI_ASM __asm // asm keyword for ARM Compiler(Keil MDK). - #define SGUI_INLINE __inline // inline keyword for ARM Compiler. - #pragma diag_suppress 870 // Disabled "multibyte character sequence" warning. + #define SGUI_ASM __asm // asm keyword for ARM Compiler(Keil MDK). + #define SGUI_INLINE __inline // inline keyword for ARM Compiler. + #pragma diag_suppress 870 // Disabled "multibyte character sequence" warning. #elif defined ( __ICCARM__ ) - #define SGUI_ASM __asm // < asm keyword for IAR Compiler. - #define SGUI_INLINE inline // inline keyword for IAR Compiler. Only available in High optimization mode! + #define SGUI_ASM __asm // < asm keyword for IAR Compiler. + #define SGUI_INLINE inline // inline keyword for IAR Compiler. Only available in High optimization mode! #elif defined ( __GNUC__ ) - #define SGUI_ASM __asm // asm keyword for GNU Compiler. - #define SGUI_INLINE inline // inline keyword for GNU Compiler. + #define SGUI_ASM __asm // asm keyword for GNU Compiler. + #define SGUI_INLINE inline // inline keyword for GNU Compiler. #elif defined ( __TASKING__ ) - #define SGUI_ASM __asm // asm keyword for TASKING Compiler. - #define SGUI_INLINE inline // inline keyword for TASKING Compiler. + #define SGUI_ASM __asm // asm keyword for TASKING Compiler. + #define SGUI_INLINE inline // inline keyword for TASKING Compiler. #endif //=======================================================================// -//= Public function declaration. =// +//= Public function declaration. =// //=======================================================================// #ifdef __cplusplus extern "C"{ @@ -37,25 +37,25 @@ extern "C"{ #ifdef _SIMPLE_GUI_ENCODE_TEXT_ // Only used when running in simulated environment and text encode need convert to GB2312. -SGUI_SZSTR SGUI_SystemIF_EncodeConvert(SGUI_CSZSTR szSourceEncode, SGUI_SZSTR szDestinationEncode, SGUI_SZSTR szSource); - #define SGUI_ENCODE_BUFFER_SIZE (512) - #define ENCODE(S) (SGUI_SystemIF_EncodeConvert(_SIMPLE_GUI_ENCODE_TEXT_SRC_, _SIMPLE_GUI_ENCODE_TEXT_DEST_, (char *)(S))) +SGUI_SZSTR SGUI_SystemIF_EncodeConvert(SGUI_CSZSTR szSourceEncode, SGUI_SZSTR szDestinationEncode, SGUI_SZSTR szSource); + #define SGUI_ENCODE_BUFFER_SIZE (512) + #define ENCODE(S) (SGUI_SystemIF_EncodeConvert(_SIMPLE_GUI_ENCODE_TEXT_SRC_, _SIMPLE_GUI_ENCODE_TEXT_DEST_, (char *)(S))) #else - #define ENCODE(S) (S) + #define ENCODE(S) (S) #endif #ifdef _SIMPLE_GUI_ENABLE_DYNAMIC_MEMORY_ -SGUI_PTR SGUI_SystemIF_Allocate(SGUI_SIZE sSize); -void SGUI_SystemIF_Free(SGUI_PTR pFreePointer); +SGUI_PTR SGUI_SystemIF_Allocate(SGUI_SIZE sSize); +void SGUI_SystemIF_Free(SGUI_PTR pFreePointer); #endif -#define SGUI_SystemIF_MemoryCopy(DEST, SOURCE, SIZE) \ +#define SGUI_SystemIF_MemoryCopy(DEST, SOURCE, SIZE) \ (memcpy(DEST, SOURCE, SIZE)) -#define SGUI_SystemIF_MemorySet(PTR, VAL, SIZE) \ +#define SGUI_SystemIF_MemorySet(PTR, VAL, SIZE) \ (memset(PTR, VAL, SIZE)) #define SGUI_SystemIF_StringLength(/* SGUI_CSZSTR */STR) \ ((NULL == (STR))?0:(strlen((STR)))) -#define SGUI_SystemIF_StringCopy(/* SGUI_SZSTR */DEST, /* SGUI_CSZSTR */SRC) \ +#define SGUI_SystemIF_StringCopy(/* SGUI_SZSTR */DEST, /* SGUI_CSZSTR */SRC) \ (strcpy((DEST), (SRC))) #define SGUI_SystemIF_StringLengthCopy(/* SGUI_SZSTR */DEST, /* SGUI_CSZSTR */SRC, /* SGUI_SIZE */SIZE) \ (strncpy((DEST), (SRC), (SIZE))) diff --git a/GUI/inc/SGUI_ItemsBase.h b/GUI/inc/SGUI_ItemsBase.h index 166677c43358484d8ab719f4843c8ac564a49165..e0293aa6657264c9aabcfc8aa53f7ee285eedeb3 100644 --- a/GUI/inc/SGUI_ItemsBase.h +++ b/GUI/inc/SGUI_ItemsBase.h @@ -1,75 +1,75 @@ #ifndef _INCLUDE_SGUI_ITEMS_BASE_H_ #define _INCLUDE_SGUI_ITEMS_BASE_H_ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "SGUI_Common.h" #include "SGUI_Basic.h" #include "SGUI_Text.h" //=======================================================================// -//= User Macro definition. =// +//= User Macro definition. =// //=======================================================================// -#define ITEM_EDGE_WIDTH (1) -#define ITEM_HEIGHT(FONT) ((FONT)->iHeight+(ITEM_EDGE_WIDTH*2)) +#define ITEM_EDGE_WIDTH (1) +#define ITEM_HEIGHT(FONT) ((FONT)->iHeight+(ITEM_EDGE_WIDTH*2)) //=======================================================================// -//= Data type definition. =// +//= Data type definition. =// //=======================================================================// typedef struct _ST_SGUI_ITEMS_ITEM_ { - SGUI_CSZSTR cszLabelText; // This pointer points to a character array constant - SGUI_SZSTR szVariableText; // This pointer points to a character array variable, this member will be used first if existed. - struct _ST_SGUI_ITEMS_ITEM_* pstPrev; - struct _ST_SGUI_ITEMS_ITEM_* pstNext; + SGUI_CSZSTR cszLabelText; // This pointer points to a character array constant + SGUI_SZSTR szVariableText; // This pointer points to a character array variable, this member will be used first if existed. + struct _ST_SGUI_ITEMS_ITEM_* pstPrev; + struct _ST_SGUI_ITEMS_ITEM_* pstNext; }SGUI_ITEMS_ITEM; typedef struct { - SGUI_INT iIndex; - SGUI_ITEMS_ITEM* pstItem; + SGUI_INT iIndex; + SGUI_ITEMS_ITEM* pstItem; }SGUI_ITEM_SELECTION; typedef struct { - SGUI_RECT stLayout; - SGUI_ITEMS_ITEM* pstFirstItem; // Read only - SGUI_ITEMS_ITEM* pstLastItem; - SGUI_INT iCount; - SGUI_ITEM_SELECTION stSelection; // Read only - SGUI_ITEM_SELECTION stVisibleStart; // Read only - SGUI_ITEM_SELECTION stVisibleEnd; // Read only - SGUI_INT iVisibleItems; - SGUI_INT iItemPaintOffset; - const SGUI_FONT_RES* pstFontRes; + SGUI_RECT stLayout; + SGUI_ITEMS_ITEM* pstFirstItem; // Read only + SGUI_ITEMS_ITEM* pstLastItem; + SGUI_INT iCount; + SGUI_ITEM_SELECTION stSelection; // Read only + SGUI_ITEM_SELECTION stVisibleStart; // Read only + SGUI_ITEM_SELECTION stVisibleEnd; // Read only + SGUI_INT iVisibleItems; + SGUI_INT iItemPaintOffset; + const SGUI_FONT_RES* pstFontRes; }SGUI_ITEMS_BASE; //=======================================================================// -//= Public function declaration. =// +//= Public function declaration. =// //=======================================================================// -void SGUI_ItemsBase_Initialize(SGUI_ITEMS_BASE* pstObj, const SGUI_RECT* cpstLayout, const SGUI_FONT_RES* pstFontRes, SGUI_ITEMS_ITEM* pstItemsData, SGUI_INT iItemsCount); -SGUI_ITEMS_ITEM* SGUI_ItemsBase_JumpItem(SGUI_ITEMS_ITEM* pstBaseItem, SGUI_INT iSteps); -void SGUI_ItemsBase_Repaint(SGUI_SCR_DEV* pstDeviceIF, SGUI_ITEMS_BASE* pstObj); -SGUI_ITEMS_ITEM* SGUI_ItemsBase_GetItem(SGUI_ITEMS_BASE* pstObj, SGUI_INT iSelection); -void SGUI_ItemsBase_GetItemExtent(SGUI_ITEMS_BASE* pstObj, SGUI_INT iSelection, SGUI_RECT* pstItemExtent); -void SGUI_ItemsBase_Resize(SGUI_ITEMS_BASE* pstObj, const SGUI_RECT* cpstNewLayout); -#define SGUI_ItemsBase_Count(/* SGUI_ITEMS_BASE */OBJ) \ - ((OBJ)->iCount) -void SGUI_ItemsBase_Selecte(SGUI_ITEMS_BASE* pstObj, SGUI_INT iIndex); -#define SGUI_ItemsBase_SelecteFirst(/* SGUI_ITEMS_BASE */OBJ) \ - { SGUI_ItemsBase_GetSelection(OBJ)->iIndex = 0; \ - SGUI_ItemsBase_GetSelection(OBJ)->pstItem = (OBJ)->pstFirstItem;} -#define SGUI_ItemsBase_SelecteLast(/* SGUI_ITEMS_BASE */OBJ) \ - { SGUI_ItemsBase_GetSelection(OBJ)->iIndex = (OBJ)->iCount - 1; \ - SGUI_ItemsBase_GetSelection(OBJ)->pstItem = (OBJ)->pstLastItem;} -#define SGUI_ItemsBase_GetSelection(/* SGUI_ITEMS_BASE */OBJ) \ - (&((OBJ)->stSelection)) -#define SGUI_ItemsBase_GetFirstVisible(/* SGUI_ITEMS_BASE */OBJ) \ - (&((OBJ)->stVisibleStart)) -#define SGUI_ItemsBase_GetLastVisible(/* SGUI_ITEMS_BASE */OBJ) \ - (&((OBJ)->stVisibleEnd)) -SGUI_ITEMS_ITEM* SGUI_ItemsBase_RemoveItem(SGUI_ITEMS_BASE* pstObj, SGUI_INT iRemoveIndex); -SGUI_ITEMS_ITEM* SGUI_ItemsBase_InsertItem(SGUI_ITEMS_BASE* pstObj, SGUI_ITEMS_ITEM* pstNewItem, SGUI_INT iIndex); +void SGUI_ItemsBase_Initialize(SGUI_ITEMS_BASE* pstObj, const SGUI_RECT* cpstLayout, const SGUI_FONT_RES* pstFontRes, SGUI_ITEMS_ITEM* pstItemsData, SGUI_INT iItemsCount); +SGUI_ITEMS_ITEM* SGUI_ItemsBase_JumpItem(SGUI_ITEMS_ITEM* pstBaseItem, SGUI_INT iSteps); +void SGUI_ItemsBase_Repaint(SGUI_SCR_DEV* pstDeviceIF, SGUI_ITEMS_BASE* pstObj); +SGUI_ITEMS_ITEM* SGUI_ItemsBase_GetItem(SGUI_ITEMS_BASE* pstObj, SGUI_INT iSelection); +void SGUI_ItemsBase_GetItemExtent(SGUI_ITEMS_BASE* pstObj, SGUI_INT iSelection, SGUI_RECT* pstItemExtent); +void SGUI_ItemsBase_Resize(SGUI_ITEMS_BASE* pstObj, const SGUI_RECT* cpstNewLayout); +#define SGUI_ItemsBase_Count(/* SGUI_ITEMS_BASE */OBJ) \ + ((OBJ)->iCount) +void SGUI_ItemsBase_Selecte(SGUI_ITEMS_BASE* pstObj, SGUI_INT iIndex); +#define SGUI_ItemsBase_SelecteFirst(/* SGUI_ITEMS_BASE */OBJ) \ + { SGUI_ItemsBase_GetSelection(OBJ)->iIndex = 0; \ + SGUI_ItemsBase_GetSelection(OBJ)->pstItem = (OBJ)->pstFirstItem;} +#define SGUI_ItemsBase_SelecteLast(/* SGUI_ITEMS_BASE */OBJ) \ + { SGUI_ItemsBase_GetSelection(OBJ)->iIndex = (OBJ)->iCount - 1; \ + SGUI_ItemsBase_GetSelection(OBJ)->pstItem = (OBJ)->pstLastItem;} +#define SGUI_ItemsBase_GetSelection(/* SGUI_ITEMS_BASE */OBJ) \ + (&((OBJ)->stSelection)) +#define SGUI_ItemsBase_GetFirstVisible(/* SGUI_ITEMS_BASE */OBJ) \ + (&((OBJ)->stVisibleStart)) +#define SGUI_ItemsBase_GetLastVisible(/* SGUI_ITEMS_BASE */OBJ) \ + (&((OBJ)->stVisibleEnd)) +SGUI_ITEMS_ITEM* SGUI_ItemsBase_RemoveItem(SGUI_ITEMS_BASE* pstObj, SGUI_INT iRemoveIndex); +SGUI_ITEMS_ITEM* SGUI_ItemsBase_InsertItem(SGUI_ITEMS_BASE* pstObj, SGUI_ITEMS_ITEM* pstNewItem, SGUI_INT iIndex); SGUI_BOOL SGUI_ItemsBase_CanScrollUp(SGUI_ITEMS_BASE* pstObj); SGUI_BOOL SGUI_ItemsBase_CanScrollDown(SGUI_ITEMS_BASE* pstObj); diff --git a/GUI/inc/SGUI_List.h b/GUI/inc/SGUI_List.h index 4b4b1d8499a53cb5d94f081633a83e95ebdd83e9..d74ace2e1aeae6e4686f88b62df6d3d7b8e328d5 100644 --- a/GUI/inc/SGUI_List.h +++ b/GUI/inc/SGUI_List.h @@ -1,7 +1,7 @@ #ifndef __INCLUDE_SGUI_List_H__ #define __INCLUDE_SGUI_List_H__ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "SGUI_Common.h" #include "SGUI_Basic.h" @@ -10,33 +10,33 @@ #include "SGUI_ItemsBase.h" //=======================================================================// -//= Data type definition. =// +//= Data type definition. =// //=======================================================================// typedef struct { - SGUI_RECT stLayout; - SGUI_ITEMS_BASE stItems; - SGUI_CSZSTR szTitle; - SGUI_SCROLLBAR_STRUCT stScrollBar; - const SGUI_FONT_RES* pstFontRes; + SGUI_RECT stLayout; + SGUI_ITEMS_BASE stItems; + SGUI_CSZSTR szTitle; + SGUI_SCROLLBAR_STRUCT stScrollBar; + const SGUI_FONT_RES* pstFontRes; }SGUI_LIST; //=======================================================================// -//= Public function declaration. =// +//= Public function declaration. =// //=======================================================================// -void SGUI_List_Initialize(SGUI_LIST* pstObj, const SGUI_RECT* cpstLayout, const SGUI_FONT_RES* pstFontRes, SGUI_CSZSTR cszTitle, SGUI_ITEMS_ITEM* pstItemsData, SGUI_INT iItemsCount); -void SGUI_List_Repaint(SGUI_SCR_DEV* pstDeviceIF, SGUI_LIST* pstObj); -void SGUI_List_Resize(SGUI_LIST* pstObj, const SGUI_RECT* pstNewLayout); -#define SGUI_List_Count(/* SGUI_LIST */OBJ) \ - (SGUI_ItemsBase_Count(&((OBJ)->stItems))) -#define SGUI_List_Selecte(/* SGUI_LIST */OBJ, /* SGUI_INT */IDX) \ - (SGUI_ItemsBase_Selecte(&((OBJ)->stItems), IDX)) -#define SGUI_List_SelecteFirst(/* SGUI_LIST */OBJ) \ - {SGUI_ItemsBase_SelecteFirst(&((OBJ)->stItems))} -#define SGUI_List_SelecteLast(/* SGUI_LIST */OBJ) \ - {SGUI_ItemsBase_SelecteLast(&((OBJ)->stItems))} -#define SGUI_List_GetSelection(/* SGUI_LIST */OBJ) \ - (SGUI_ItemsBase_GetSelection(&((OBJ)->stItems))) -SGUI_ITEMS_ITEM* SGUI_List_RemoveItem(SGUI_LIST* pstObj, SGUI_INT iRemoveIndex); -SGUI_ITEMS_ITEM* SGUI_List_InsertItem(SGUI_LIST* pstObj, SGUI_ITEMS_ITEM* pstNewItem, SGUI_INT iIndex); +void SGUI_List_Initialize(SGUI_LIST* pstObj, const SGUI_RECT* cpstLayout, const SGUI_FONT_RES* pstFontRes, SGUI_CSZSTR cszTitle, SGUI_ITEMS_ITEM* pstItemsData, SGUI_INT iItemsCount); +void SGUI_List_Repaint(SGUI_SCR_DEV* pstDeviceIF, SGUI_LIST* pstObj); +void SGUI_List_Resize(SGUI_LIST* pstObj, const SGUI_RECT* pstNewLayout); +#define SGUI_List_Count(/* SGUI_LIST */OBJ) \ + (SGUI_ItemsBase_Count(&((OBJ)->stItems))) +#define SGUI_List_Selecte(/* SGUI_LIST */OBJ, /* SGUI_INT */IDX) \ + (SGUI_ItemsBase_Selecte(&((OBJ)->stItems), IDX)) +#define SGUI_List_SelecteFirst(/* SGUI_LIST */OBJ) \ + {SGUI_ItemsBase_SelecteFirst(&((OBJ)->stItems))} +#define SGUI_List_SelecteLast(/* SGUI_LIST */OBJ) \ + {SGUI_ItemsBase_SelecteLast(&((OBJ)->stItems))} +#define SGUI_List_GetSelection(/* SGUI_LIST */OBJ) \ + (SGUI_ItemsBase_GetSelection(&((OBJ)->stItems))) +SGUI_ITEMS_ITEM* SGUI_List_RemoveItem(SGUI_LIST* pstObj, SGUI_INT iRemoveIndex); +SGUI_ITEMS_ITEM* SGUI_List_InsertItem(SGUI_LIST* pstObj, SGUI_ITEMS_ITEM* pstNewItem, SGUI_INT iIndex); #endif // __INCLUDE_SGUI_List_H__ diff --git a/GUI/inc/SGUI_Menu.h b/GUI/inc/SGUI_Menu.h index 23f5d3630f73a63dd3e3e94db9431d4031c3a12b..9bb3d92e830dfbaba134493baafcdc44e369fe21 100644 --- a/GUI/inc/SGUI_Menu.h +++ b/GUI/inc/SGUI_Menu.h @@ -1,37 +1,37 @@ #ifndef _INCLUDE_SGUI_MENU_H_ #define _INCLUDE_SGUI_MENU_H_ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "SGUI_Common.h" #include "SGUI_Basic.h" #include "SGUI_Text.h" #include "SGUI_ItemsBase.h" //=======================================================================// -//= Data type definition. =// +//= Data type definition. =// //=======================================================================// typedef struct { - SGUI_RECT stLayout; - SGUI_ITEMS_BASE stItems; - const SGUI_FONT_RES* pstFontRes; + SGUI_RECT stLayout; + SGUI_ITEMS_BASE stItems; + const SGUI_FONT_RES* pstFontRes; }SGUI_MENU; //=======================================================================// -//= Public function declaration. =// +//= Public function declaration. =// //=======================================================================// -void SGUI_Menu_Initialize(SGUI_MENU* pstObj, const SGUI_RECT* cpstLayout, const SGUI_FONT_RES* pstFontRes, SGUI_ITEMS_ITEM* pstItemsData, SGUI_INT iItemsCount); -void SGUI_Menu_Repaint(SGUI_SCR_DEV* pstDeviceIF, SGUI_MENU* pstObj); -void SGUI_Menu_Resize(SGUI_MENU* pstObj, const SGUI_RECT* pstNewLayout); -void SGUI_Menu_PopupSubMenu(SGUI_SCR_DEV* pstDeviceIF, SGUI_MENU* pstObj, const SGUI_RECT* cpstParentLayout); -#define SGUI_Menu_GetSelection(OBJ) \ - (SGUI_ItemsBase_GetSelection(&(OBJ->stItems))) -#define SGUI_Menu_Selecte(OBJ, IDX) \ - (SGUI_ItemsBase_Selecte(&(OBJ->stItems), IDX)) +void SGUI_Menu_Initialize(SGUI_MENU* pstObj, const SGUI_RECT* cpstLayout, const SGUI_FONT_RES* pstFontRes, SGUI_ITEMS_ITEM* pstItemsData, SGUI_INT iItemsCount); +void SGUI_Menu_Repaint(SGUI_SCR_DEV* pstDeviceIF, SGUI_MENU* pstObj); +void SGUI_Menu_Resize(SGUI_MENU* pstObj, const SGUI_RECT* pstNewLayout); +void SGUI_Menu_PopupSubMenu(SGUI_SCR_DEV* pstDeviceIF, SGUI_MENU* pstObj, const SGUI_RECT* cpstParentLayout); +#define SGUI_Menu_GetSelection(OBJ) \ + (SGUI_ItemsBase_GetSelection(&(OBJ->stItems))) +#define SGUI_Menu_Selecte(OBJ, IDX) \ + (SGUI_ItemsBase_Selecte(&(OBJ->stItems), IDX)) -#define SGUI_Menu_CanScrollUp(OBJ) \ - (SGUI_ItemsBase_CanScrollUp(&(OBJ->stItems))) -#define SGUI_Menu_CanScrollDown(OBJ) \ - (SGUI_ItemsBase_CanScrollDown(&(OBJ->stItems))) +#define SGUI_Menu_CanScrollUp(OBJ) \ + (SGUI_ItemsBase_CanScrollUp(&(OBJ->stItems))) +#define SGUI_Menu_CanScrollDown(OBJ) \ + (SGUI_ItemsBase_CanScrollDown(&(OBJ->stItems))) #endif // _INCLUDE_SGUI_MENU_H_ diff --git a/GUI/inc/SGUI_Notice.h b/GUI/inc/SGUI_Notice.h index b0a14fd4101758b75e13ea70dd6920f808f207a3..28d1ea02655a9bb2a67ee0ebeb98d56418a927c5 100644 --- a/GUI/inc/SGUI_Notice.h +++ b/GUI/inc/SGUI_Notice.h @@ -1,26 +1,26 @@ #ifndef __INCLUDE_GUI_NOTICE_H__ #define __INCLUDE_GUI_NOTICE_H__ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "SGUI_Common.h" #include "SGUI_Basic.h" #include "SGUI_Text.h" //=======================================================================// -//= Data type definition. =// +//= Data type definition. =// //=======================================================================// typedef struct { - SGUI_CSZSTR cszNoticeText; - const SGUI_BMP_RES* pstIcon; - SGUI_RECT stLayout; + SGUI_CSZSTR cszNoticeText; + const SGUI_BMP_RES* pstIcon; + SGUI_RECT stLayout; }SGUI_NOTICT_BOX; //=======================================================================// -//= Public function declaration. =// +//= Public function declaration. =// //=======================================================================// -SGUI_SIZE SGUI_Notice_Repaint(SGUI_SCR_DEV* pstDeviceIF, SGUI_NOTICT_BOX* pstObject, const SGUI_FONT_RES* pstFontRes, SGUI_INT uiTextOffset); -void SGUI_Notice_FitArea(SGUI_SCR_DEV* pstDeviceIF, SGUI_RECT* pstFitArea); +SGUI_SIZE SGUI_Notice_Repaint(SGUI_SCR_DEV* pstDeviceIF, SGUI_NOTICT_BOX* pstObject, const SGUI_FONT_RES* pstFontRes, SGUI_INT uiTextOffset); +void SGUI_Notice_FitArea(SGUI_SCR_DEV* pstDeviceIF, SGUI_RECT* pstFitArea); #endif // __INCLUDE_GUI_NOTICE_H__ diff --git a/GUI/inc/SGUI_ProcessBar.h b/GUI/inc/SGUI_ProcessBar.h index 5adb6e76e77be7c0aa0eb277a2e89ae6f678f74a..ff1c89671f2a54c5839fdf3598daecb5aec49ae8 100644 --- a/GUI/inc/SGUI_ProcessBar.h +++ b/GUI/inc/SGUI_ProcessBar.h @@ -1,46 +1,46 @@ #ifndef __INCLUDE_GUI_PROCESSBAR_H__ #define __INCLUDE_GUI_PROCESSBAR_H__ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "SGUI_Common.h" #include "SGUI_Basic.h" //=======================================================================// -//= Data type definition. =// +//= Data type definition. =// //=======================================================================// typedef enum { - SGUI_PROCBAR_UP = 0, //Process bar direction to up. - SGUI_PROCBAR_DOWN, //Process bar direction to down. - SGUI_PROCBAR_LEFT, //Process bar direction to left. - SGUI_PROCBAR_RIGHT, //Process bar direction to right. + SGUI_PROCBAR_UP = 0, //Process bar direction to up. + SGUI_PROCBAR_DOWN, //Process bar direction to down. + SGUI_PROCBAR_LEFT, //Process bar direction to left. + SGUI_PROCBAR_RIGHT, //Process bar direction to right. }SGUI_PROCBAR_DIRECTION; typedef struct { - SGUI_INT PosX; - SGUI_INT PosY; - SGUI_SIZE Width; - SGUI_SIZE Height; - SGUI_PROCBAR_DIRECTION Direction; - SGUI_UINT32 MaxValue; + SGUI_INT PosX; + SGUI_INT PosY; + SGUI_SIZE Width; + SGUI_SIZE Height; + SGUI_PROCBAR_DIRECTION Direction; + SGUI_UINT32 MaxValue; }SGUI_PROCBAR_PARAMETER; typedef struct { - SGUI_SIZE Value; + SGUI_SIZE Value; }SGUI_PROCBAR_DATA; typedef struct { - SGUI_PROCBAR_PARAMETER Parameter; - SGUI_PROCBAR_DATA Data; + SGUI_PROCBAR_PARAMETER Parameter; + SGUI_PROCBAR_DATA Data; }SGUI_PROCBAR_STRUCT; //=======================================================================// -//= Public function declaration. =// +//= Public function declaration. =// //=======================================================================// void SGUI_ProcessBar_Repaint(SGUI_SCR_DEV* pstDeviceIF, SGUI_PROCBAR_STRUCT *pProcessBarData); diff --git a/GUI/inc/SGUI_RealtimeGraph.h b/GUI/inc/SGUI_RealtimeGraph.h index 2028695ee1b1fe33bbb7a4e0a4d4d0969da21518..f4015b396a5892e4b963935a9b6d8b0858193255 100644 --- a/GUI/inc/SGUI_RealtimeGraph.h +++ b/GUI/inc/SGUI_RealtimeGraph.h @@ -1,49 +1,49 @@ #ifndef __INCLUDE_GUI_REAL_GRAPH_H__ #define __INCLUDE_GUI_REAL_GRAPH_H__ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "SGUI_Common.h" #include "SGUI_Basic.h" //=======================================================================// -//= User Macro definition. =// +//= User Macro definition. =// //=======================================================================// -#define SGUI_RTGRAPH_VALUE_ARRAY_SIZE (128) +#define SGUI_RTGRAPH_VALUE_ARRAY_SIZE (128) //=======================================================================// -//= Data type definition. =// +//= Data type definition. =// //=======================================================================// typedef struct { - SGUI_INT yAxisMax; // Max value on screen display. - SGUI_INT yAxisMin; // Min value on screen display. - SGUI_BOOL EnableBaseline; // Enable to show zero-point line. - SGUI_INT xAxisStepPixel; - SGUI_INT ValueArea; // Display value range, auto calculate when initialize. + SGUI_INT yAxisMax; // Max value on screen display. + SGUI_INT yAxisMin; // Min value on screen display. + SGUI_BOOL EnableBaseline; // Enable to show zero-point line. + SGUI_INT xAxisStepPixel; + SGUI_INT ValueArea; // Display value range, auto calculate when initialize. }SGUI_RTGRAPH_CONTROL; typedef struct { - SGUI_INT ValueArray[SGUI_RTGRAPH_VALUE_ARRAY_SIZE]; - SGUI_INT LimitedValueArray[SGUI_RTGRAPH_VALUE_ARRAY_SIZE]; - SGUI_INT PointYCoordinateArray[SGUI_RTGRAPH_VALUE_ARRAY_SIZE]; - SGUI_INT BaseLineValue; // Base line value on graph map. - SGUI_INT ValueCount; // Display value point number, auto calculate when initialize. + SGUI_INT ValueArray[SGUI_RTGRAPH_VALUE_ARRAY_SIZE]; + SGUI_INT LimitedValueArray[SGUI_RTGRAPH_VALUE_ARRAY_SIZE]; + SGUI_INT PointYCoordinateArray[SGUI_RTGRAPH_VALUE_ARRAY_SIZE]; + SGUI_INT BaseLineValue; // Base line value on graph map. + SGUI_INT ValueCount; // Display value point number, auto calculate when initialize. }SGUI_RTGRAPH_DATA; typedef struct { - SGUI_RECT stLayout; - SGUI_RTGRAPH_DATA* Data; - SGUI_RTGRAPH_CONTROL* Control; + SGUI_RECT stLayout; + SGUI_RTGRAPH_DATA* Data; + SGUI_RTGRAPH_CONTROL* Control; }SGUI_RTGRAPH; //=======================================================================// -//= Public function declaration. =// +//= Public function declaration. =// //=======================================================================// -void SGUI_RealtimeGraph_Initialize(SGUI_RTGRAPH* pstRTGraph); -void SGUI_RealtimeGraph_Repaint(SGUI_SCR_DEV* pstDeviceIF, SGUI_RTGRAPH* pstRTGraph); -void SGUI_RealtimeGraph_AppendValue(SGUI_SCR_DEV* pstDeviceIF, SGUI_RTGRAPH* pstRTGraph, SGUI_INT iNewValue); +void SGUI_RealtimeGraph_Initialize(SGUI_RTGRAPH* pstRTGraph); +void SGUI_RealtimeGraph_Repaint(SGUI_SCR_DEV* pstDeviceIF, SGUI_RTGRAPH* pstRTGraph); +void SGUI_RealtimeGraph_AppendValue(SGUI_SCR_DEV* pstDeviceIF, SGUI_RTGRAPH* pstRTGraph, SGUI_INT iNewValue); #endif // __INCLUDE_GUI_REAL_GRAPH_H__ diff --git a/GUI/inc/SGUI_ScrollBar.h b/GUI/inc/SGUI_ScrollBar.h index fc28e2c6a4eafaca6f29d9e41a11dc58cfe7f7fd..c8117677c63bf0640894bc3028e70a56fd175189 100644 --- a/GUI/inc/SGUI_ScrollBar.h +++ b/GUI/inc/SGUI_ScrollBar.h @@ -1,49 +1,49 @@ #ifndef __INCLUDE_GUI_SCROLLBAR__ #define __INCLUDE_GUI_SCROLLBAR__ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "SGUI_Basic.h" #include "SGUI_Common.h" //=======================================================================// -//= Data type definition. =// +//= Data type definition. =// //=======================================================================// typedef enum { - SGUI_SCROLLBAR_VERTICAL = 0, //Vertical scroll bar. - SGUI_SCROLLBAR_HORIZONTAL, //Horizontal scroll bar. + SGUI_SCROLLBAR_VERTICAL = 0, //Vertical scroll bar. + SGUI_SCROLLBAR_HORIZONTAL, //Horizontal scroll bar. }SGUI_SCROLLBAR_DIRECTION; typedef struct { - SGUI_RECT stLayout; - SGUI_SIZE sMaxValue; - SGUI_SCROLLBAR_DIRECTION eDirection; + SGUI_RECT stLayout; + SGUI_SIZE sMaxValue; + SGUI_SCROLLBAR_DIRECTION eDirection; }SGUI_SCROLLBAR_PARAM; typedef struct { - SGUI_SIZE sValue; + SGUI_SIZE sValue; }SGUI_SCROLLBAR_DATA; typedef struct { - SGUI_SCROLLBAR_PARAM stParam; - SGUI_SCROLLBAR_DATA stData; + SGUI_SCROLLBAR_PARAM stParam; + SGUI_SCROLLBAR_DATA stData; }SGUI_SCROLLBAR_STRUCT; //=======================================================================// -//= Public function declaration. =// +//= Public function declaration. =// //=======================================================================// -void SGUI_ScrollBar_Initialize(SGUI_SCROLLBAR_STRUCT* pstObj, const SGUI_SCROLLBAR_PARAM* pcstInitParam); -#define SGUI_ScrollBar_SetMax(OBJ, MAX) \ - {(OBJ)->stParam.sMaxValue = MAX;} -#define SGUI_ScrollBar_GetMax(OBJ) \ - ((OBJ)->stParam.sMaxValue) -void SGUI_ScrollBar_SetValue(SGUI_SCROLLBAR_STRUCT* pstObj, SGUI_SIZE sNewValue); -#define SGUI_ScrollBar_GetValue(OBJ) \ - ((OBJ)->stData.sValue) -void SGUI_ScrollBar_Repaint(SGUI_SCR_DEV* pstDeviceIF, SGUI_SCROLLBAR_STRUCT* pstObj); +void SGUI_ScrollBar_Initialize(SGUI_SCROLLBAR_STRUCT* pstObj, const SGUI_SCROLLBAR_PARAM* pcstInitParam); +#define SGUI_ScrollBar_SetMax(OBJ, MAX) \ + {(OBJ)->stParam.sMaxValue = MAX;} +#define SGUI_ScrollBar_GetMax(OBJ) \ + ((OBJ)->stParam.sMaxValue) +void SGUI_ScrollBar_SetValue(SGUI_SCROLLBAR_STRUCT* pstObj, SGUI_SIZE sNewValue); +#define SGUI_ScrollBar_GetValue(OBJ) \ + ((OBJ)->stData.sValue) +void SGUI_ScrollBar_Repaint(SGUI_SCR_DEV* pstDeviceIF, SGUI_SCROLLBAR_STRUCT* pstObj); #endif // __INCLUDE_GUI_SCROLLBAR_STRUCT__ diff --git a/GUI/inc/SGUI_Text.h b/GUI/inc/SGUI_Text.h index 9b32f079be6df934c0d8915547f85ada17119d13..15ed7f9466245c937bfb0ea848b403d46714f107 100644 --- a/GUI/inc/SGUI_Text.h +++ b/GUI/inc/SGUI_Text.h @@ -1,36 +1,36 @@ #ifndef _INCLUDE_GUI_FONT_H_ #define _INCLUDE_GUI_FONT_H_ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "SGUI_Common.h" #include "SGUI_Basic.h" //=======================================================================// -//= User Macro definition. =// +//= User Macro definition. =// //=======================================================================// -#define FONT_LIB_ADDR 0X00000 +#define FONT_LIB_ADDR 0X00000 // Max font size is 64 pix, maximum of font data size is 64 * 8 = 512 Bytes. -#define TEXT_NUMBER_STR_LENGTH_MAX (12) -#define TEXT_PLACEHOLDER_CHARACTER ('*') -#define SGUI_IS_VISIBLE_CHAR(C) ((C>0x1F) && (C<0x7F)) +#define TEXT_NUMBER_STR_LENGTH_MAX (12) +#define TEXT_PLACEHOLDER_CHARACTER ('*') +#define SGUI_IS_VISIBLE_CHAR(C) ((C>0x1F) && (C<0x7F)) //=======================================================================// -//= Data type definition. =// +//= Data type definition. =// //=======================================================================// //=======================================================================// -//= Public variable declaration. =// +//= Public variable declaration. =// //=======================================================================// -extern SGUI_CSZSTR SGUI_EMPTY_STRING; +extern SGUI_CSZSTR SGUI_EMPTY_STRING; //=======================================================================// -//= Public function declaration. =// +//= Public function declaration. =// //=======================================================================// -void SGUI_Text_GetTextExtent(SGUI_CSZSTR cszTextBuffer, const SGUI_FONT_RES* pstFontRes, SGUI_AREA_SIZE* pstTextExtent); -void SGUI_Text_DrawText(SGUI_SCR_DEV* pstDeviceIF, SGUI_CSZSTR cszTextBuffer, const SGUI_FONT_RES* pstFontRes, SGUI_RECT* pstDisplayArea, SGUI_POINT* pstInnerPos, SGUI_DRAW_MODE eFontMode); -SGUI_SIZE SGUI_Text_DrawMultipleLinesText(SGUI_SCR_DEV* pstDeviceIF, SGUI_CSZSTR szTextBuffer, const SGUI_FONT_RES* pstFontRes, SGUI_RECT* pstDisplayArea, SGUI_INT iTopOffset, SGUI_DRAW_MODE eFontMode); -SGUI_SIZE SGUI_Text_GetMultiLineTextLines(SGUI_CSZSTR cszText, const SGUI_FONT_RES* pstFontRes, SGUI_SIZE uiDisplayAreaWidth); +void SGUI_Text_GetTextExtent(SGUI_CSZSTR cszTextBuffer, const SGUI_FONT_RES* pstFontRes, SGUI_AREA_SIZE* pstTextExtent); +void SGUI_Text_DrawText(SGUI_SCR_DEV* pstDeviceIF, SGUI_CSZSTR cszTextBuffer, const SGUI_FONT_RES* pstFontRes, SGUI_RECT* pstDisplayArea, SGUI_POINT* pstInnerPos, SGUI_DRAW_MODE eFontMode); +SGUI_SIZE SGUI_Text_DrawMultipleLinesText(SGUI_SCR_DEV* pstDeviceIF, SGUI_CSZSTR szTextBuffer, const SGUI_FONT_RES* pstFontRes, SGUI_RECT* pstDisplayArea, SGUI_INT iTopOffset, SGUI_DRAW_MODE eFontMode); +SGUI_SIZE SGUI_Text_GetMultiLineTextLines(SGUI_CSZSTR cszText, const SGUI_FONT_RES* pstFontRes, SGUI_SIZE uiDisplayAreaWidth); SGUI_SIZE SGUI_Text_GetCharacterData(const SGUI_FONT_RES* pstFontRes, SGUI_UINT32 uiCode, SGUI_BYTE* pDataBuffer, SGUI_SIZE sBufferSize); #endif diff --git a/GUI/inc/SGUI_Typedef.h b/GUI/inc/SGUI_Typedef.h index d174382b60ceb6c8d86490b412e681d01858d701..5aa2ce58ed6430cb8cb4a564be44cf86e1319e96 100644 --- a/GUI/inc/SGUI_Typedef.h +++ b/GUI/inc/SGUI_Typedef.h @@ -1,114 +1,114 @@ #ifndef _INCLUDE_GUI_TYPEDEF_H_ #define _INCLUDE_GUI_TYPEDEF_H_ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "stdint.h" #include "stddef.h" #include //=======================================================================// -//= User Macro definition. =// +//= User Macro definition. =// //=======================================================================// -#define SGUI_MAX_OF(A, B) (A>B?A:B) -#define SGUI_MIN_OF(A, B) (A0)?RECT_WIDTH(DATA):(RECT_WIDTH(DATA)+RECT_X_START(POS))) -#define RECT_VALID_HEIGHT(DATA, POS) ((RECT_Y_START(POS)>0)?RECT_HEIGHT(DATA):(RECT_HEIGHT(DATA)+RECT_Y_START(POS))) - -#define SGUI_DEVPF_IF_DEFINE(R, FN, PARAM) typedef R(*FN)PARAM - -#define SGUI_BMP_RESOURCE_DECLARE(NAME) extern const SGUI_BMP_RES NAME -#define SGUI_BMP_RESOURCE_DEFINE(NAME, W, H, ...) const SGUI_BYTE NAME##DATA[] = {__VA_ARGS__};\ - const SGUI_BMP_RES NAME = {W, H, NAME##DATA} +#define SGUI_MAX_OF(A, B) (A>B?A:B) +#define SGUI_MIN_OF(A, B) (A0)?RECT_WIDTH(DATA):(RECT_WIDTH(DATA)+RECT_X_START(POS))) +#define RECT_VALID_HEIGHT(DATA, POS) ((RECT_Y_START(POS)>0)?RECT_HEIGHT(DATA):(RECT_HEIGHT(DATA)+RECT_Y_START(POS))) + +#define SGUI_DEVPF_IF_DEFINE(R, FN, PARAM) typedef R(*FN)PARAM + +#define SGUI_BMP_RESOURCE_DECLARE(NAME) extern const SGUI_BMP_RES NAME +#define SGUI_BMP_RESOURCE_DEFINE(NAME, W, H, ...) const SGUI_BYTE NAME##DATA[] = {__VA_ARGS__};\ + const SGUI_BMP_RES NAME = {W, H, NAME##DATA} //=======================================================================// -//= Data type definition. =// +//= Data type definition. =// //=======================================================================// -typedef char SGUI_INT8; -typedef unsigned char SGUI_UINT8; -typedef int16_t SGUI_INT16; -typedef uint16_t SGUI_UINT16; -typedef int32_t SGUI_INT32; -typedef uint32_t SGUI_UINT32; - -typedef int SGUI_INT; -typedef unsigned int SGUI_UINT; -typedef long SGUI_LONG; -typedef unsigned long SGUI_ULONG; -typedef unsigned char SGUI_BYTE; -typedef const unsigned char SGUI_CBYTE; -typedef size_t SGUI_SIZE; - -typedef char* SGUI_SZSTR; -typedef const char* SGUI_CSZSTR; -typedef char SGUI_CHAR; -typedef const char SGUI_CCHAR; - -typedef void* SGUI_PTR; - -#define SGUI_INVALID_INDEX (-1) -typedef SGUI_UINT32 SGUI_ROM_ADDRESS; - -#define SGUI_BOOL SGUI_INT -#define SGUI_FALSE (0) -#define SGUI_TRUE (!SGUI_FALSE) +typedef char SGUI_INT8; +typedef unsigned char SGUI_UINT8; +typedef int16_t SGUI_INT16; +typedef uint16_t SGUI_UINT16; +typedef int32_t SGUI_INT32; +typedef uint32_t SGUI_UINT32; + +typedef int SGUI_INT; +typedef unsigned int SGUI_UINT; +typedef long SGUI_LONG; +typedef unsigned long SGUI_ULONG; +typedef unsigned char SGUI_BYTE; +typedef const unsigned char SGUI_CBYTE; +typedef size_t SGUI_SIZE; + +typedef char* SGUI_SZSTR; +typedef const char* SGUI_CSZSTR; +typedef char SGUI_CHAR; +typedef const char SGUI_CCHAR; + +typedef void* SGUI_PTR; + +#define SGUI_INVALID_INDEX (-1) +typedef SGUI_UINT32 SGUI_ROM_ADDRESS; + +#define SGUI_BOOL SGUI_INT +#define SGUI_FALSE (0) +#define SGUI_TRUE (!SGUI_FALSE) typedef struct { - SGUI_INT iX; - SGUI_INT iY; - SGUI_INT iWidth; - SGUI_INT iHeight; + SGUI_INT iX; + SGUI_INT iY; + SGUI_INT iWidth; + SGUI_INT iHeight; }SGUI_RECT; typedef struct { - SGUI_INT iWidth; - SGUI_INT iHeight; + SGUI_INT iWidth; + SGUI_INT iHeight; }SGUI_AREA_SIZE; typedef struct { - SGUI_INT iX; - SGUI_INT iY; + SGUI_INT iX; + SGUI_INT iY; }SGUI_POINT; typedef struct { - SGUI_INT iMin; - SGUI_INT iMax; + SGUI_INT iMin; + SGUI_INT iMax; }SGUI_RANGE; typedef struct { - SGUI_BYTE* pBuffer; - SGUI_SIZE sSize; + SGUI_BYTE* pBuffer; + SGUI_SIZE sSize; }SGUI_BUFFER; typedef enum { - SGUI_COLOR_BKGCLR = 0, - SGUI_COLOR_FRGCLR = 1, - SGUI_COLOR_TRANS = 2, + SGUI_COLOR_BKGCLR = 0, + SGUI_COLOR_FRGCLR = 1, + SGUI_COLOR_TRANS = 2, }SGUI_COLOR; typedef enum { - SGUI_DRAW_NORMAL = 0, - SGUI_DRAW_REVERSE = 1, + SGUI_DRAW_NORMAL = 0, + SGUI_DRAW_REVERSE = 1, }SGUI_DRAW_MODE; typedef enum { - SGUI_RIGHT = 0, - SGUI_CENTER, - SGUI_LEFT, + SGUI_RIGHT = 0, + SGUI_CENTER, + SGUI_LEFT, }SGUI_ALIG_MODE; // Palette color value, 16Bit for RGB555 or RGB565. @@ -117,60 +117,60 @@ typedef SGUI_UINT16 SGUI_PALETTE_COLOUR; //typedef SGUI_UINT32 SGUI_PALETTE_COLOUR; // Screen device operation interface type declare. -SGUI_DEVPF_IF_DEFINE(SGUI_INT, SGUI_FN_IF_INITIALIZE, (void)); -SGUI_DEVPF_IF_DEFINE(void, SGUI_FN_IF_CLEAR, (void)); -SGUI_DEVPF_IF_DEFINE(void, SGUI_FN_IF_SET_POINT, (SGUI_INT iX, SGUI_INT iY, SGUI_INT iColor)); -SGUI_DEVPF_IF_DEFINE(SGUI_INT, SGUI_FN_IF_GET_POINT, (SGUI_INT iX, SGUI_INT iY)); -SGUI_DEVPF_IF_DEFINE(SGUI_INT, SGUI_FN_IF_SET_BYTE, (SGUI_INT iPage, SGUI_INT iColumn)); -SGUI_DEVPF_IF_DEFINE(SGUI_INT, SGUI_FN_IF_GET_BYTE, (SGUI_INT iPage, SGUI_INT iColumn)); -SGUI_DEVPF_IF_DEFINE(void, SGUI_FN_IF_REFRESH, (void)); -SGUI_DEVPF_IF_DEFINE(void, SGUI_FN_IF_SET_PALETTE, (SGUI_PALETTE_COLOUR, SGUI_PALETTE_COLOUR, SGUI_PALETTE_COLOUR)); +SGUI_DEVPF_IF_DEFINE(SGUI_INT, SGUI_FN_IF_INITIALIZE, (void)); +SGUI_DEVPF_IF_DEFINE(void, SGUI_FN_IF_CLEAR, (void)); +SGUI_DEVPF_IF_DEFINE(void, SGUI_FN_IF_SET_POINT, (SGUI_INT iX, SGUI_INT iY, SGUI_INT iColor)); +SGUI_DEVPF_IF_DEFINE(SGUI_INT, SGUI_FN_IF_GET_POINT, (SGUI_INT iX, SGUI_INT iY)); +SGUI_DEVPF_IF_DEFINE(SGUI_INT, SGUI_FN_IF_SET_BYTE, (SGUI_INT iPage, SGUI_INT iColumn)); +SGUI_DEVPF_IF_DEFINE(SGUI_INT, SGUI_FN_IF_GET_BYTE, (SGUI_INT iPage, SGUI_INT iColumn)); +SGUI_DEVPF_IF_DEFINE(void, SGUI_FN_IF_REFRESH, (void)); +SGUI_DEVPF_IF_DEFINE(void, SGUI_FN_IF_SET_PALETTE, (SGUI_PALETTE_COLOUR, SGUI_PALETTE_COLOUR, SGUI_PALETTE_COLOUR)); // System function interface type declare. -SGUI_DEVPF_IF_DEFINE(void, SGUI_FN_IF_GET_RTC, (SGUI_INT iYear, SGUI_INT iMounth, SGUI_INT iDay, SGUI_INT iWeekDay, SGUI_INT iHour, SGUI_INT iMinute, SGUI_INT iSecond)); -SGUI_DEVPF_IF_DEFINE(SGUI_INT, SGUI_FN_IF_GET_CHAR_INDEX, (SGUI_UINT32 uiCode)); +SGUI_DEVPF_IF_DEFINE(void, SGUI_FN_IF_GET_RTC, (SGUI_INT iYear, SGUI_INT iMounth, SGUI_INT iDay, SGUI_INT iWeekDay, SGUI_INT iHour, SGUI_INT iMinute, SGUI_INT iSecond)); +SGUI_DEVPF_IF_DEFINE(SGUI_INT, SGUI_FN_IF_GET_CHAR_INDEX, (SGUI_UINT32 uiCode)); SGUI_DEVPF_IF_DEFINE(SGUI_CSZSTR, SGUI_FN_IF_STEP_NEXT, (SGUI_CSZSTR cszSrc, SGUI_UINT32* puiCode)); SGUI_DEVPF_IF_DEFINE(SGUI_SIZE, SGUI_FN_IF_GET_DATA, (SGUI_SIZE sStartAddr, SGUI_BYTE* pDataBuffer, SGUI_SIZE sReadSize)); SGUI_DEVPF_IF_DEFINE(SGUI_BOOL, SGUI_FN_IF_IS_FULL_WIDTH, (SGUI_UINT32 uiCode)); typedef struct { - //Screen display area size in pixel. - SGUI_AREA_SIZE stSize; - //The area currently allowed to paint. - SGUI_RECT stActiveArea; - //Bitmap data buffer. - SGUI_BUFFER stBuffer; + //Screen display area size in pixel. + SGUI_AREA_SIZE stSize; + //The area currently allowed to paint. + SGUI_RECT stActiveArea; + //Bitmap data buffer. + SGUI_BUFFER stBuffer; //Engine & device initialize function. - SGUI_FN_IF_INITIALIZE fnInitialize; + SGUI_FN_IF_INITIALIZE fnInitialize; //Clear screen function. - SGUI_FN_IF_CLEAR fnClear; + SGUI_FN_IF_CLEAR fnClear; //Set pixel value function. - SGUI_FN_IF_SET_POINT fnSetPixel; + SGUI_FN_IF_SET_POINT fnSetPixel; //Get pixel value function. - SGUI_FN_IF_GET_POINT fnGetPixel; + SGUI_FN_IF_GET_POINT fnGetPixel; // Sync display buffer data to screen device. - SGUI_FN_IF_REFRESH fnSyncBuffer; + SGUI_FN_IF_REFRESH fnSyncBuffer; // Set palette function. - SGUI_FN_IF_SET_PALETTE fnSetPalette; + SGUI_FN_IF_SET_PALETTE fnSetPalette; }SGUI_SCR_DEV; typedef struct { - SGUI_INT iHalfWidth; - SGUI_INT iFullWidth; - SGUI_INT iHeight; - SGUI_FN_IF_GET_CHAR_INDEX fnGetIndex; - SGUI_FN_IF_GET_DATA fnGetData; - SGUI_FN_IF_STEP_NEXT fnStepNext; - SGUI_FN_IF_IS_FULL_WIDTH fnIsFullWidth; + SGUI_INT iHalfWidth; + SGUI_INT iFullWidth; + SGUI_INT iHeight; + SGUI_FN_IF_GET_CHAR_INDEX fnGetIndex; + SGUI_FN_IF_GET_DATA fnGetData; + SGUI_FN_IF_STEP_NEXT fnStepNext; + SGUI_FN_IF_IS_FULL_WIDTH fnIsFullWidth; }SGUI_FONT_RES; typedef struct { - SGUI_INT iWidth; - SGUI_INT iHeight; - const SGUI_BYTE* pData; + SGUI_INT iWidth; + SGUI_INT iHeight; + const SGUI_BYTE* pData; }SGUI_BMP_RES; #endif // _INCLUDE_GUI_TYPEDEF_H_ diff --git a/GUI/inc/SGUI_VariableBox.h b/GUI/inc/SGUI_VariableBox.h index 55470e6265ec5760fcaf2222536ba580ef33b75e..a4f1ab922d73ad2e6af401c75c9e6b26a21bd0bd 100644 --- a/GUI/inc/SGUI_VariableBox.h +++ b/GUI/inc/SGUI_VariableBox.h @@ -1,63 +1,63 @@ #ifndef __INCLUDE_GUI_VARIABLEBOX_H__ #define __INCLUDE_GUI_VARIABLEBOX_H__ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "SGUI_Common.h" #include "SGUI_Basic.h" #include "SGUI_Text.h" //=======================================================================// -//= Data type definition. =// +//= Data type definition. =// //=======================================================================// // Data type of number variable box. typedef struct { - SGUI_RECT stLayout; - SGUI_INT iMin; - SGUI_INT iMax; - const SGUI_FONT_RES* pstFontRes; - SGUI_ALIG_MODE eAlignment; + SGUI_RECT stLayout; + SGUI_INT iMin; + SGUI_INT iMax; + const SGUI_FONT_RES* pstFontRes; + SGUI_ALIG_MODE eAlignment; }SGUI_NUM_VARBOX_PARAM; typedef struct { - SGUI_INT iValue; + SGUI_INT iValue; }SGUI_NUM_VARBOX_DATA; typedef struct { - SGUI_NUM_VARBOX_PARAM stParam; - SGUI_NUM_VARBOX_DATA stData; + SGUI_NUM_VARBOX_PARAM stParam; + SGUI_NUM_VARBOX_DATA stData; }SGUI_NUM_VARBOX_STRUCT; // Data type of text variable box. typedef struct { - SGUI_RECT stLayout; - const SGUI_FONT_RES* pstFontRes; - SGUI_SIZE sTextLengthMax; + SGUI_RECT stLayout; + const SGUI_FONT_RES* pstFontRes; + SGUI_SIZE sTextLengthMax; }SGUI_TEXT_VARBOX_PARAM; typedef struct { - SGUI_SIZE sFocusIndex; - SGUI_SZSTR szValue; + SGUI_SIZE sFocusIndex; + SGUI_SZSTR szValue; }SGUI_TEXT_VARBOX_DATA; typedef struct { - SGUI_TEXT_VARBOX_PARAM stParam; - SGUI_TEXT_VARBOX_DATA stData; + SGUI_TEXT_VARBOX_PARAM stParam; + SGUI_TEXT_VARBOX_DATA stData; }SGUI_TEXT_VARBOX_STRUCT; enum { - SGUI_TEXT_NUMBER = 0x0100, - SGUI_TEXT_ALPHA = 0x0200, - SGUI_TEXT_PUNCTUATION = 0x0400, - SGUI_TEXT_DATE = 0x0800, - SGUI_TEXT_TIME = 0x1000, + SGUI_TEXT_NUMBER = 0x0100, + SGUI_TEXT_ALPHA = 0x0200, + SGUI_TEXT_PUNCTUATION = 0x0400, + SGUI_TEXT_DATE = 0x0800, + SGUI_TEXT_TIME = 0x1000, }; typedef enum @@ -68,62 +68,62 @@ typedef enum }SGUI_TEXT_VARBOX_OPT; //=======================================================================// -//= User Macro definition. =// +//= User Macro definition. =// //=======================================================================// -#define VARBOX_WIDTH(FONT_SIZE, L) (L*(g_stFontSize[FONT_SIZE].Width)-4) -#define VARBOX_HEIGHT(FONT_SIZE) (g_stFontSize[FONT_SIZE].Height+2) -#define VARBOX_TEXT_AREA_WIDTH(W) ((W>2)?(W-2):0) +#define VARBOX_WIDTH(FONT_SIZE, L) (L*(g_stFontSize[FONT_SIZE].Width)-4) +#define VARBOX_HEIGHT(FONT_SIZE) (g_stFontSize[FONT_SIZE].Height+2) +#define VARBOX_TEXT_AREA_WIDTH(W) ((W>2)?(W-2):0) #define VARBOX_TEXT_AREA_HEIGHT(FONT_SIZE) (g_stFontSize[FONT_SIZE].Height) -#define VARBOX_TEXT_LENGTH_MAX (11) -#define VARBOX_TEXT_BUFFER_SIZE (VARBOX_TEXT_LENGTH_MAX+1) -#define VARBOX_TEXT_WIDTH(FONT_SIZE, L) (L*(g_stFontSize[FONT_SIZE].Width)) +#define VARBOX_TEXT_LENGTH_MAX (11) +#define VARBOX_TEXT_BUFFER_SIZE (VARBOX_TEXT_LENGTH_MAX+1) +#define VARBOX_TEXT_WIDTH(FONT_SIZE, L) (L*(g_stFontSize[FONT_SIZE].Width)) -#define SGUI_TEXT_ASCII (SGUI_TEXT_NUMBER|SGUI_TEXT_ALPHA|SGUI_TEXT_PUNCTUATION) +#define SGUI_TEXT_ASCII (SGUI_TEXT_NUMBER|SGUI_TEXT_ALPHA|SGUI_TEXT_PUNCTUATION) -#define GUI_TEXT_ISLOWER(C) ((C>='a' && C<='z')?true:false) -#define GUI_TEXT_ISALPHA(C) (SGUI_IS_UPPER(C) || GUI_TEXT_ISLOWER(C)) -#define GUI_TEXT_ISASCII(C) ((C>=0x20 && C<=0x7E)?true:false) +#define GUI_TEXT_ISLOWER(C) ((C>='a' && C<='z')?true:false) +#define GUI_TEXT_ISALPHA(C) (SGUI_IS_UPPER(C) || GUI_TEXT_ISLOWER(C)) +#define GUI_TEXT_ISASCII(C) ((C>=0x20 && C<=0x7E)?true:false) //=======================================================================// -//= Public function declaration. =// +//= Public function declaration. =// //=======================================================================// -#define SGUI_NumberVariableBox_Increase(POBJ) SGUI_NumberVariableBox_SetValue((POBJ), (POBJ)->stData.iValue+1) -#define SGUI_NumberVariableBox_Decrease(POBJ) SGUI_NumberVariableBox_SetValue((POBJ), (POBJ)->stData.iValue-1) -#define SGUI_NumberVariableBox_SetValue(POBJ, VAL) if(((VAL) <= (POBJ)->stParam.iMax) && ((VAL) >= (POBJ)->stParam.iMin))\ - {\ - (POBJ)->stData.iValue = (VAL);\ - } -#define SGUI_NumberVariableBox_GetValue(POBJ) ((POBJ)->stData.iValue) -void SGUI_NumberVariableBox_Initialize(SGUI_NUM_VARBOX_STRUCT* pstObj, const SGUI_NUM_VARBOX_PARAM* pcstInitParam); -void SGUI_NumberVariableBox_Repaint(SGUI_SCR_DEV* pstDeviceIF, SGUI_NUM_VARBOX_STRUCT* pstValue, SGUI_DRAW_MODE eMode); -void SGUI_TextVariableBox_Initialize(SGUI_TEXT_VARBOX_STRUCT* pstObj, const SGUI_TEXT_VARBOX_PARAM* pcstInitParam, SGUI_SZSTR szTextBuffer); -#define SGUI_TextVariableBox_GetFocusIndex(POBJ) ((POBJ)->stData.sFocusIndex) -#define SGUI_TextVariableBox_SetFocusIndex(POBJ, IDX) if((IDX) < (POBJ)->stParam.sTextLengthMax)\ - {\ - (POBJ)->stData.sFocusIndex = (IDX);\ - } -#define SGUI_TextVariableBox_IncreaseIndex(POBJ) {SGUI_TextVariableBox_SetFocusIndex((POBJ), (POBJ)->stData.sFocusIndex+1);} -#define SGUI_TextVariableBox_DecreaseIndex(POBJ) {SGUI_TextVariableBox_SetFocusIndex((POBJ), (POBJ)->stData.sFocusIndex-1);} -#define SGUI_TextVariableBox_FocusedChar(POBJ) ((POBJ)->stData.szValue[(POBJ)->stData.sFocusIndex]) -#define SGUI_TextVariableBox_IncreaseChar(POBJ) if((POBJ)->stData.szValue[(POBJ)->stData.sFocusIndex] == 0x7E)\ - {\ - (POBJ)->stData.szValue[(POBJ)->stData.sFocusIndex] = 0x20;\ - }\ - else\ - {\ - (POBJ)->stData.szValue[(POBJ)->stData.sFocusIndex]++;\ - } -#define SGUI_TextVariableBox_DecreaseChar(POBJ) if((POBJ)->stData.szValue[(POBJ)->stData.sFocusIndex] == 0x20)\ - {\ - (POBJ)->stData.szValue[(POBJ)->stData.sFocusIndex] = 0x7E;\ - }\ - else\ - {\ - (POBJ)->stData.szValue[(POBJ)->stData.sFocusIndex]--;\ - } -#define SGUI_TextVariableBox_GetText(POBJ) ((POBJ)->stData.szValue) -#define SGUI_TextVariableBox_GetChar(POBJ, IDX) (IDX<(POBJ)->stParam.sMaxTextLength?(POBJ)->stData.szValue[IDX]:'\0') -void SGUI_TextVariableBox_Repaint(SGUI_SCR_DEV* pstDeviceIF, SGUI_TEXT_VARBOX_STRUCT* pstObj, SGUI_DRAW_MODE eMode); +#define SGUI_NumberVariableBox_Increase(POBJ) SGUI_NumberVariableBox_SetValue((POBJ), (POBJ)->stData.iValue+1) +#define SGUI_NumberVariableBox_Decrease(POBJ) SGUI_NumberVariableBox_SetValue((POBJ), (POBJ)->stData.iValue-1) +#define SGUI_NumberVariableBox_SetValue(POBJ, VAL) if(((VAL) <= (POBJ)->stParam.iMax) && ((VAL) >= (POBJ)->stParam.iMin))\ + {\ + (POBJ)->stData.iValue = (VAL);\ + } +#define SGUI_NumberVariableBox_GetValue(POBJ) ((POBJ)->stData.iValue) +void SGUI_NumberVariableBox_Initialize(SGUI_NUM_VARBOX_STRUCT* pstObj, const SGUI_NUM_VARBOX_PARAM* pcstInitParam); +void SGUI_NumberVariableBox_Repaint(SGUI_SCR_DEV* pstDeviceIF, SGUI_NUM_VARBOX_STRUCT* pstValue, SGUI_DRAW_MODE eMode); +void SGUI_TextVariableBox_Initialize(SGUI_TEXT_VARBOX_STRUCT* pstObj, const SGUI_TEXT_VARBOX_PARAM* pcstInitParam, SGUI_SZSTR szTextBuffer); +#define SGUI_TextVariableBox_GetFocusIndex(POBJ) ((POBJ)->stData.sFocusIndex) +#define SGUI_TextVariableBox_SetFocusIndex(POBJ, IDX) if((IDX) < (POBJ)->stParam.sTextLengthMax)\ + {\ + (POBJ)->stData.sFocusIndex = (IDX);\ + } +#define SGUI_TextVariableBox_IncreaseIndex(POBJ) {SGUI_TextVariableBox_SetFocusIndex((POBJ), (POBJ)->stData.sFocusIndex+1);} +#define SGUI_TextVariableBox_DecreaseIndex(POBJ) {SGUI_TextVariableBox_SetFocusIndex((POBJ), (POBJ)->stData.sFocusIndex-1);} +#define SGUI_TextVariableBox_FocusedChar(POBJ) ((POBJ)->stData.szValue[(POBJ)->stData.sFocusIndex]) +#define SGUI_TextVariableBox_IncreaseChar(POBJ) if((POBJ)->stData.szValue[(POBJ)->stData.sFocusIndex] == 0x7E)\ + {\ + (POBJ)->stData.szValue[(POBJ)->stData.sFocusIndex] = 0x20;\ + }\ + else\ + {\ + (POBJ)->stData.szValue[(POBJ)->stData.sFocusIndex]++;\ + } +#define SGUI_TextVariableBox_DecreaseChar(POBJ) if((POBJ)->stData.szValue[(POBJ)->stData.sFocusIndex] == 0x20)\ + {\ + (POBJ)->stData.szValue[(POBJ)->stData.sFocusIndex] = 0x7E;\ + }\ + else\ + {\ + (POBJ)->stData.szValue[(POBJ)->stData.sFocusIndex]--;\ + } +#define SGUI_TextVariableBox_GetText(POBJ) ((POBJ)->stData.szValue) +#define SGUI_TextVariableBox_GetChar(POBJ, IDX) (IDX<(POBJ)->stParam.sMaxTextLength?(POBJ)->stData.szValue[IDX]:'\0') +void SGUI_TextVariableBox_Repaint(SGUI_SCR_DEV* pstDeviceIF, SGUI_TEXT_VARBOX_STRUCT* pstObj, SGUI_DRAW_MODE eMode); #endif // __INCLUDE_GUI_VARIABLEBOX_H__ diff --git a/GUI/src/SGUI_Basic.c b/GUI/src/SGUI_Basic.c index 163d89f4f2731d4eb95ce19b6e985676225653cd..09fec879a7a5cd7ce0c97480969daea238da964c 100644 --- a/GUI/src/SGUI_Basic.c +++ b/GUI/src/SGUI_Basic.c @@ -1,39 +1,39 @@ /*************************************************************************/ -/** Copyright. **/ -/** FileName: SGUI_Basic.c **/ -/** Author: XuYulin **/ -/** Description: Simple GUI basic drawing operating interface. **/ +/** Copyright. **/ +/** FileName: SGUI_Basic.c **/ +/** Author: XuYulin **/ +/** Description: Simple GUI basic drawing operating interface. **/ /*************************************************************************/ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "SGUI_Basic.h" //=======================================================================// -//= User Macro definition. =// +//= User Macro definition. =// //=======================================================================// -#define SGUI_MIN_VAL(A, B) (((A)>(B)?(B):(A))) -#define SGUI_MAX_VAL(A, B) (((A)<(B)?(B):(A))) +#define SGUI_MIN_VAL(A, B) (((A)>(B)?(B):(A))) +#define SGUI_MAX_VAL(A, B) (((A)<(B)?(B):(A))) //=======================================================================// -//= Function define. =// +//= Function define. =// //=======================================================================// /*************************************************************************/ -/** Function Name: SGUI_Basic_DrawPoint **/ -/** Purpose: Set a pixel color or draw a point. **/ -/** Params: **/ -/** @ pstDeviceIF[in]: Device driver object pointer. **/ -/** @ iPosX[in]: X coordinate of point by pixels. **/ -/** @ iPosY[in]: Y coordinate of point by pixels. **/ -/** @ eColor[in]: Point color, GUI_COLOR_BKGCLR means clear pix, **/ -/** GUI_COLOR_FRGCLR means set pix. **/ -/** Return: None. **/ -/** Notice: None. **/ +/** Function Name: SGUI_Basic_DrawPoint **/ +/** Purpose: Set a pixel color or draw a point. **/ +/** Params: **/ +/** @ pstDeviceIF[in]: Device driver object pointer. **/ +/** @ iPosX[in]: X coordinate of point by pixels. **/ +/** @ iPosY[in]: Y coordinate of point by pixels. **/ +/** @ eColor[in]: Point color, GUI_COLOR_BKGCLR means clear pix, **/ +/** GUI_COLOR_FRGCLR means set pix. **/ +/** Return: None. **/ +/** Notice: None. **/ /*************************************************************************/ void SGUI_Basic_DrawPoint(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iPosX, SGUI_INT iPosY, SGUI_COLOR eColor) { /*----------------------------------*/ - /* Process */ + /* Process */ /*----------------------------------*/ if(SGUI_Basic_PointIsInArea(&(pstDeviceIF->stActiveArea), iPosX, iPosY)) { @@ -53,31 +53,31 @@ void SGUI_Basic_DrawPoint(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iPosX, SGUI_INT iP } /*************************************************************************/ -/** Function Name: SGUI_Basic_GetPoint **/ -/** Purpose: Get a pixel color . **/ -/** Params: **/ -/** @ pstDeviceIF[in]: SimpleGUI object pointer. **/ -/** @ iPosX[in]: X coordinate of point by pixels. **/ -/** @ iPosY[in]: Y coordinate of point by pixels. **/ -/** Return: SGUI_COLOR type enumerated for point color. **/ -/** Notice: None. **/ +/** Function Name: SGUI_Basic_GetPoint **/ +/** Purpose: Get a pixel color . **/ +/** Params: **/ +/** @ pstDeviceIF[in]: SimpleGUI object pointer. **/ +/** @ iPosX[in]: X coordinate of point by pixels. **/ +/** @ iPosY[in]: Y coordinate of point by pixels. **/ +/** Return: SGUI_COLOR type enumerated for point color. **/ +/** Notice: None. **/ /*************************************************************************/ SGUI_COLOR SGUI_Basic_GetPoint(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iPosX, SGUI_INT iPosY) { /*----------------------------------*/ - /* Variable Declaration */ + /* Variable Declaration */ /*----------------------------------*/ - SGUI_COLOR eColor; - SGUI_UINT uiPixValue; + SGUI_COLOR eColor; + SGUI_UINT uiPixValue; /*----------------------------------*/ - /* Initialize */ + /* Initialize */ /*----------------------------------*/ - eColor = SGUI_COLOR_BKGCLR; - uiPixValue = 0; + eColor = SGUI_COLOR_BKGCLR; + uiPixValue = 0; /*----------------------------------*/ - /* Process */ + /* Process */ /*----------------------------------*/ if((NULL != pstDeviceIF) && (iPosX < RECT_WIDTH(pstDeviceIF->stSize)) && (iPosY < RECT_HEIGHT(pstDeviceIF->stSize))) { @@ -103,17 +103,17 @@ SGUI_COLOR SGUI_Basic_GetPoint(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iPosX, SGUI_I } /*************************************************************************/ -/** Function Name: SGUI_Basic_ClearScreen **/ -/** Purpose: Clean LCD screen display. **/ -/** Params: **/ -/** @ pstDeviceIF[in]: Device driver object pointer. **/ -/** Return: None. **/ -/** Notice: None. **/ +/** Function Name: SGUI_Basic_ClearScreen **/ +/** Purpose: Clean LCD screen display. **/ +/** Params: **/ +/** @ pstDeviceIF[in]: Device driver object pointer. **/ +/** Return: None. **/ +/** Notice: None. **/ /*************************************************************************/ void SGUI_Basic_ClearScreen(SGUI_SCR_DEV* pstDeviceIF) { /*----------------------------------*/ - /* Process */ + /* Process */ /*----------------------------------*/ if(NULL != pstDeviceIF) { @@ -131,31 +131,31 @@ void SGUI_Basic_ClearScreen(SGUI_SCR_DEV* pstDeviceIF) } /*************************************************************************/ -/** Function Name: SGUI_Basic_DrawLine **/ -/** Purpose: Draw a line by the Bresenham algorithm. **/ -/** Params: **/ -/** @ pstDeviceIF[in]: Device driver object pointer. **/ -/** @ iStartX[in]: X coordinate of start point of line. **/ -/** @ iStartY[in]: Y coordinate of start point of line. **/ -/** @ iEndX[in]: X coordinate of end point of line. **/ -/** @ iEndY[in]: Y coordinate of end point of line. **/ -/** @ eColor[in]: Line color. **/ -/** Return: None. **/ -/** Notice: None. **/ +/** Function Name: SGUI_Basic_DrawLine **/ +/** Purpose: Draw a line by the Bresenham algorithm. **/ +/** Params: **/ +/** @ pstDeviceIF[in]: Device driver object pointer. **/ +/** @ iStartX[in]: X coordinate of start point of line. **/ +/** @ iStartY[in]: Y coordinate of start point of line. **/ +/** @ iEndX[in]: X coordinate of end point of line. **/ +/** @ iEndY[in]: Y coordinate of end point of line. **/ +/** @ eColor[in]: Line color. **/ +/** Return: None. **/ +/** Notice: None. **/ /*************************************************************************/ void SGUI_Basic_DrawLine(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iStartX, SGUI_INT iStartY, SGUI_INT iEndX, SGUI_INT iEndY, SGUI_COLOR eColor) { /*----------------------------------*/ - /* Variable Declaration */ + /* Variable Declaration */ /*----------------------------------*/ - SGUI_INT iDx, iDy; - SGUI_INT iIncX, iIncY; - SGUI_INT iErrX = 0, iErrY = 0; - SGUI_INT i, iDs; - SGUI_INT iCurrentPosX, iCurrentPosY; + SGUI_INT iDx, iDy; + SGUI_INT iIncX, iIncY; + SGUI_INT iErrX = 0, iErrY = 0; + SGUI_INT i, iDs; + SGUI_INT iCurrentPosX, iCurrentPosY; /*----------------------------------*/ - /* Initialize */ + /* Initialize */ /*----------------------------------*/ iErrX = 0; iErrY = 0; @@ -208,7 +208,7 @@ void SGUI_Basic_DrawLine(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iStartX, SGUI_INT i } /*----------------------------------*/ - /* Process */ + /* Process */ /*----------------------------------*/ for(i = 0; i <= iDs+1; i++) { @@ -229,26 +229,26 @@ void SGUI_Basic_DrawLine(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iStartX, SGUI_INT i } /*************************************************************************/ -/** Function Name: SGUI_Basic_DrawHorizontalLine **/ -/** Purpose: Draw a horizontal line by the Bresenham algorithm. **/ -/** Params: **/ -/** @ pstDeviceIF[in]: SimpleGUI object pointer. **/ -/** @ iStartX[in]: X coordinate of start point of line. **/ -/** @ iEndX[in]: X coordinate of end point of line. **/ -/** @ iY[in]: Y coordinate of the line. **/ -/** @ eColor[in]: Line color. **/ -/** Return: None. **/ -/** Notice: None. **/ +/** Function Name: SGUI_Basic_DrawHorizontalLine **/ +/** Purpose: Draw a horizontal line by the Bresenham algorithm. **/ +/** Params: **/ +/** @ pstDeviceIF[in]: SimpleGUI object pointer. **/ +/** @ iStartX[in]: X coordinate of start point of line. **/ +/** @ iEndX[in]: X coordinate of end point of line. **/ +/** @ iY[in]: Y coordinate of the line. **/ +/** @ eColor[in]: Line color. **/ +/** Return: None. **/ +/** Notice: None. **/ /*************************************************************************/ void SGUI_Basic_DrawHorizontalLine(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iStartX, SGUI_INT iEndX, SGUI_INT iY, SGUI_COLOR eColor) { /*----------------------------------*/ - /* Variable Declaration */ + /* Variable Declaration */ /*----------------------------------*/ SGUI_INT iPointX; /*----------------------------------*/ - /* Process */ + /* Process */ /*----------------------------------*/ for(iPointX=iStartX; iPointX<=iEndX; iPointX++) { @@ -257,26 +257,26 @@ void SGUI_Basic_DrawHorizontalLine(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iStartX, } /*************************************************************************/ -/** Function Name: SGUI_Basic_DrawVerticalLine **/ -/** Purpose: Draw a vertical line by the Bresenham algorithm. **/ -/** Params: **/ -/** @ pstDeviceIF[in]: Device driver object pointer. **/ -/** @ iX[in]: X coordinate of the line. **/ -/** @ iStartY[in]: Y coordinate of start point of line. **/ -/** @ iEndY[in]: Y coordinate of end point of line. **/ -/** @ eColor[in]: Line color. **/ -/** Return: None. **/ -/** Notice: None. **/ +/** Function Name: SGUI_Basic_DrawVerticalLine **/ +/** Purpose: Draw a vertical line by the Bresenham algorithm. **/ +/** Params: **/ +/** @ pstDeviceIF[in]: Device driver object pointer. **/ +/** @ iX[in]: X coordinate of the line. **/ +/** @ iStartY[in]: Y coordinate of start point of line. **/ +/** @ iEndY[in]: Y coordinate of end point of line. **/ +/** @ eColor[in]: Line color. **/ +/** Return: None. **/ +/** Notice: None. **/ /*************************************************************************/ void SGUI_Basic_DrawVerticalLine(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iX, SGUI_INT iStartY, SGUI_INT iEndY, SGUI_COLOR eColor) { /*----------------------------------*/ - /* Variable Declaration */ + /* Variable Declaration */ /*----------------------------------*/ SGUI_INT iPointY; /*----------------------------------*/ - /* Process */ + /* Process */ /*----------------------------------*/ for(iPointY=iStartY; iPointY<=iEndY; iPointY++) { @@ -285,23 +285,23 @@ void SGUI_Basic_DrawVerticalLine(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iX, SGUI_IN } /*************************************************************************/ -/** Function Name: SGUI_Basic_DrawRectangle **/ -/** Purpose: Draw a rectangle on screen. **/ -/** Params: **/ -/** @ pstDeviceIF[in]: Device driver object pointer. **/ -/** @ iStartX[in]: X coordinate of the upper-left corner. **/ -/** @ iStartY[in]: Y coordinate of the upper-left corner. **/ -/** @ iWidth[in]: . Width of rectangle. **/ -/** @ iHeight[in]: Height of rectangle. **/ -/** @ eEdgeColor[in]: Edge color. **/ -/** @ eFillColor[in]: Fill color. **/ -/** Return: None. **/ -/** Notice: None. **/ +/** Function Name: SGUI_Basic_DrawRectangle **/ +/** Purpose: Draw a rectangle on screen. **/ +/** Params: **/ +/** @ pstDeviceIF[in]: Device driver object pointer. **/ +/** @ iStartX[in]: X coordinate of the upper-left corner. **/ +/** @ iStartY[in]: Y coordinate of the upper-left corner. **/ +/** @ iWidth[in]: . Width of rectangle. **/ +/** @ iHeight[in]: Height of rectangle. **/ +/** @ eEdgeColor[in]: Edge color. **/ +/** @ eFillColor[in]: Fill color. **/ +/** Return: None. **/ +/** Notice: None. **/ /*************************************************************************/ void SGUI_Basic_DrawRectangle(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iStartX, SGUI_INT iStartY, SGUI_INT iWidth, SGUI_INT iHeight, SGUI_COLOR eEdgeColor, SGUI_COLOR eFillColor) { /*----------------------------------*/ - /* Process */ + /* Process */ /*----------------------------------*/ if((iWidth > 0) && (iHeight > 0)) { @@ -339,22 +339,22 @@ void SGUI_Basic_DrawRectangle(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iStartX, SGUI_ } /*************************************************************************/ -/** Function Name: SGUI_Basic_DrawCircle **/ -/** Purpose: Draw a circle by center coordinate and radius. **/ -/** Params: **/ -/** @ pstDeviceIF[in]: SimpleGUI object pointer. **/ -/** @ iCx[in]: Circle center X coordinate. **/ -/** @ iCy[in]: Circle center Y coordinate. **/ -/** @ iRadius[in]: Circle radius. **/ -/** @ eEdgeColor[in]: Edge color. **/ -/** @ eFillColor[in]: Fill color. **/ -/** Return: None. **/ -/** Notice: None. **/ +/** Function Name: SGUI_Basic_DrawCircle **/ +/** Purpose: Draw a circle by center coordinate and radius. **/ +/** Params: **/ +/** @ pstDeviceIF[in]: SimpleGUI object pointer. **/ +/** @ iCx[in]: Circle center X coordinate. **/ +/** @ iCy[in]: Circle center Y coordinate. **/ +/** @ iRadius[in]: Circle radius. **/ +/** @ eEdgeColor[in]: Edge color. **/ +/** @ eFillColor[in]: Fill color. **/ +/** Return: None. **/ +/** Notice: None. **/ /*************************************************************************/ void SGUI_Basic_DrawCircle(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iCx, SGUI_INT iCy, SGUI_INT iRadius, SGUI_COLOR eEdgeColor, SGUI_COLOR eFillColor) { /*----------------------------------*/ - /* Variable Declaration */ + /* Variable Declaration */ /*----------------------------------*/ SGUI_INT iPosXOffset = iRadius; SGUI_INT iPosYOffset = 0; @@ -365,7 +365,7 @@ void SGUI_Basic_DrawCircle(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iCx, SGUI_INT iCy SGUI_INT iRadiusError = 0; /*----------------------------------*/ - /* Process */ + /* Process */ /*----------------------------------*/ if(iRadius < 1) { @@ -415,26 +415,26 @@ void SGUI_Basic_DrawCircle(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iCx, SGUI_INT iCy } /*************************************************************************/ -/** Function Name: SGUI_Basic_ReverseBlockColor **/ -/** Purpose: Reverse all pixel color in a rectangle area. **/ -/** Params: **/ -/** @ pstDeviceIF[in]:vSimpleGUI object pointer. **/ -/** @ iStartX[in]: X coordinate of the upper-left corner. **/ -/** @ iStartY[in]: Y coordinate of the upper-left corner. **/ -/** @ iWidth[in]: Width of rectangle. **/ -/** @ iHeight[in]: Height of rectangle. **/ -/** Return: None. **/ -/** Notice: None. **/ +/** Function Name: SGUI_Basic_ReverseBlockColor **/ +/** Purpose: Reverse all pixel color in a rectangle area. **/ +/** Params: **/ +/** @ pstDeviceIF[in]:vSimpleGUI object pointer. **/ +/** @ iStartX[in]: X coordinate of the upper-left corner. **/ +/** @ iStartY[in]: Y coordinate of the upper-left corner. **/ +/** @ iWidth[in]: Width of rectangle. **/ +/** @ iHeight[in]: Height of rectangle. **/ +/** Return: None. **/ +/** Notice: None. **/ /*************************************************************************/ void SGUI_Basic_ReverseBlockColor(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iStartX, SGUI_INT iStartY, SGUI_INT iWidth, SGUI_INT iHeight) { /*----------------------------------*/ - /* Variable Declaration */ + /* Variable Declaration */ /*----------------------------------*/ - SGUI_INT iIdxW, iIdxH; + SGUI_INT iIdxW, iIdxH; /*----------------------------------*/ - /* Process */ + /* Process */ /*----------------------------------*/ for(iIdxW=0; iIdxWstSize)) && (RECT_Y_START(*pstDisplayArea) < RECT_HEIGHT(pstDeviceIF->stSize)) && + if( (RECT_X_START(*pstDisplayArea) < RECT_WIDTH(pstDeviceIF->stSize)) && (RECT_Y_START(*pstDisplayArea) < RECT_HEIGHT(pstDeviceIF->stSize)) && (RECT_X_END(*pstDisplayArea) > 0) && (RECT_Y_END(*pstDisplayArea) > 0)) { // Adapt text display area and data area. @@ -602,27 +602,27 @@ void SGUI_Basic_DrawBitMap(SGUI_SCR_DEV* pstDeviceIF, SGUI_RECT* pstDisplayArea, } /*************************************************************************/ -/** Function Name: SGUI_Basic_PointIsInArea **/ -/** Purpose: Judge point is in the specified rectangular area. **/ -/** Params: **/ -/** @ pstArea[in]: Specified rectangular area. **/ -/** @ iPosX[in]: Point coordinate. **/ -/** @ iPosY[in]: Point coordinate. **/ -/** Return: SGUI_TRUE for the point is in the rectangular area. **/ -/** SGUI_FALSE for the point is out of range. **/ -/** Notice: None. **/ +/** Function Name: SGUI_Basic_PointIsInArea **/ +/** Purpose: Judge point is in the specified rectangular area. **/ +/** Params: **/ +/** @ pstArea[in]: Specified rectangular area. **/ +/** @ iPosX[in]: Point coordinate. **/ +/** @ iPosY[in]: Point coordinate. **/ +/** Return: SGUI_TRUE for the point is in the rectangular area. **/ +/** SGUI_FALSE for the point is out of range. **/ +/** Notice: None. **/ /*************************************************************************/ SGUI_BOOL SGUI_Basic_PointIsInArea(const SGUI_RECT* pstArea, SGUI_INT iPosX, SGUI_INT iPosY) { /*----------------------------------*/ - /* Variable Declaration */ + /* Variable Declaration */ /*----------------------------------*/ - SGUI_BOOL bReturn; + SGUI_BOOL bReturn; /*----------------------------------*/ - /* Process */ + /* Process */ /*----------------------------------*/ - if( (iPosX < RECT_X_START(*pstArea)) || + if( (iPosX < RECT_X_START(*pstArea)) || (iPosX > RECT_X_END(*pstArea)) || (iPosY < RECT_Y_START(*pstArea)) || (iPosY > RECT_Y_END(*pstArea))) @@ -638,36 +638,36 @@ SGUI_BOOL SGUI_Basic_PointIsInArea(const SGUI_RECT* pstArea, SGUI_INT iPosX, SGU } /*************************************************************************/ -/** Function Name: SGUI_Basic_DrawRoundedRectangle **/ -/** Purpose: Draw a rounded rectangle. **/ -/** Params: **/ -/** @ pstDeviceIF[in]: Device driver object pointer. **/ -/** @ iStartX[in]: X coordinate of the upper-left corner. **/ -/** @ iStartY[in]: Y coordinate of the upper-left corner. **/ -/** @ iWidth[in]: Width of rectangle. **/ -/** @ iHeight[in]: Height of rectangle. **/ -/** @ iFillet[in]: Fillet radius. **/ -/** @ eEdgeColor[in]: Edge color. **/ -/** @ eFillColor[in]: Fill color. **/ -/** Return: None. **/ -/** Notice: The width and height of the rectangle must greater **/ +/** Function Name: SGUI_Basic_DrawRoundedRectangle **/ +/** Purpose: Draw a rounded rectangle. **/ +/** Params: **/ +/** @ pstDeviceIF[in]: Device driver object pointer. **/ +/** @ iStartX[in]: X coordinate of the upper-left corner. **/ +/** @ iStartY[in]: Y coordinate of the upper-left corner. **/ +/** @ iWidth[in]: Width of rectangle. **/ +/** @ iHeight[in]: Height of rectangle. **/ +/** @ iFillet[in]: Fillet radius. **/ +/** @ eEdgeColor[in]: Edge color. **/ +/** @ eFillColor[in]: Fill color. **/ +/** Return: None. **/ +/** Notice: The width and height of the rectangle must greater **/ /** then double fillet radius. **/ /*************************************************************************/ void SGUI_Basic_DrawRoundedRectangle(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iStartX, SGUI_INT iStartY, SGUI_INT iWidth, SGUI_INT iHeight, SGUI_INT iFillet, SGUI_COLOR eEdgeColor, SGUI_COLOR eFillColor) { /*----------------------------------*/ - /* Variable Declaration */ + /* Variable Declaration */ /*----------------------------------*/ - SGUI_INT iPosXOffset = iFillet; + SGUI_INT iPosXOffset = iFillet; SGUI_INT iPosYOffset = 0; SGUI_INT iYOffset_Old = -1; SGUI_INT iXOffset_Old = -1; - SGUI_INT iXChange = 1 - (iFillet << 1); /* iFillet*2 */ + SGUI_INT iXChange = 1 - (iFillet << 1); /* iFillet*2 */ SGUI_INT iYChange = 1; SGUI_INT iRadiusError = 0; /*----------------------------------*/ - /* Process */ + /* Process */ /*----------------------------------*/ if((iWidth > (iFillet<<1)) && (iHeight > (iFillet<<1))) @@ -746,22 +746,22 @@ void SGUI_Basic_DrawRoundedRectangle(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iStartX } /*************************************************************************/ -/** Function Name: SGUI_Basic_ResetActiveArea **/ -/** Purpose: Reset the active area of the device object. **/ -/** Params: **/ -/** @ pstDeviceIF[in]: Device driver object pointer. **/ -/** @ iStartX[in]: X coordinate of the upper-left corner. **/ -/** @ iStartY[in]: Y coordinate of the upper-left corner. **/ -/** @ iWidth[in]: Width of rectangle. **/ -/** @ iHeight[in]: Height of rectangle. **/ -/** Return: None. **/ -/** Notice: After called this function, the paint action will **/ +/** Function Name: SGUI_Basic_ResetActiveArea **/ +/** Purpose: Reset the active area of the device object. **/ +/** Params: **/ +/** @ pstDeviceIF[in]: Device driver object pointer. **/ +/** @ iStartX[in]: X coordinate of the upper-left corner. **/ +/** @ iStartY[in]: Y coordinate of the upper-left corner. **/ +/** @ iWidth[in]: Width of rectangle. **/ +/** @ iHeight[in]: Height of rectangle. **/ +/** Return: None. **/ +/** Notice: After called this function, the paint action will **/ /** only enabled in the specified rectangular area. **/ /*************************************************************************/ void SGUI_Basic_ResetActiveArea(SGUI_SCR_DEV* pstDeviceIF, SGUI_INT iStartX, SGUI_INT iStartY, SGUI_INT iWidth, SGUI_INT iHeight) { /*----------------------------------*/ - /* Process */ + /* Process */ /*----------------------------------*/ pstDeviceIF->stActiveArea.iX = iStartX; pstDeviceIF->stActiveArea.iY = iStartY; diff --git a/GUI/src/SGUI_Common.c b/GUI/src/SGUI_Common.c index b6aeb5094ea98fd340540269295851be2c48d0dc..d24537c627ebcca4ab8d83555131c3edca4e2583 100644 --- a/GUI/src/SGUI_Common.c +++ b/GUI/src/SGUI_Common.c @@ -1,497 +1,497 @@ /*************************************************************************/ -/** Copyright. **/ -/** FileName: SGUI_Common.c **/ -/** Author: Polarix **/ -/** Description: Simple GUI common process. **/ +/** Copyright. **/ +/** FileName: SGUI_Common.c **/ +/** Author: Polarix **/ +/** Description: Simple GUI common process. **/ /*************************************************************************/ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "SGUI_Common.h" //=======================================================================// -//= Function define. =// +//= Function define. =// //=======================================================================// /*************************************************************************/ -/** Function Name: SGUI_Common_AdaptDisplayInfo **/ -/** Purpose: Adapt display area data and internal position data **/ -/** order by display area position and screen size. **/ -/** Params: **/ -/** @ pstDisplayArea[in/out]: Display area info. **/ -/** @ pstInnerPos[in/out]: Display position info in display rectangular **/ -/** area . **/ -/** Return: None. **/ -/** Notice: This function will reset display information on **/ -/** given data, make sure the display area is within **/ -/** the screen area. **/ +/** Function Name: SGUI_Common_AdaptDisplayInfo **/ +/** Purpose: Adapt display area data and internal position data **/ +/** order by display area position and screen size. **/ +/** Params: **/ +/** @ pstDisplayArea[in/out]: Display area info. **/ +/** @ pstInnerPos[in/out]: Display position info in display rectangular **/ +/** area . **/ +/** Return: None. **/ +/** Notice: This function will reset display information on **/ +/** given data, make sure the display area is within **/ +/** the screen area. **/ /*************************************************************************/ void SGUI_Common_AdaptDisplayInfo(SGUI_RECT* pstDisplayArea, SGUI_POINT* pstInnerPos) { - if((NULL != pstDisplayArea) && (NULL != pstInnerPos)) - { - if(RECT_X_START(*pstDisplayArea) < 0) - { - RECT_X_START(*pstInnerPos) += RECT_X_START(*pstDisplayArea); - RECT_WIDTH(*pstDisplayArea) += RECT_X_START(*pstDisplayArea); - RECT_X_START(*pstDisplayArea) = 0; - } - if(RECT_Y_START(*pstDisplayArea) < 0) - { - RECT_Y_START(*pstInnerPos) += RECT_Y_START(*pstDisplayArea); - RECT_HEIGHT(*pstDisplayArea) += RECT_Y_START(*pstDisplayArea); - RECT_Y_START(*pstDisplayArea) = 0; - } - } + if((NULL != pstDisplayArea) && (NULL != pstInnerPos)) + { + if(RECT_X_START(*pstDisplayArea) < 0) + { + RECT_X_START(*pstInnerPos) += RECT_X_START(*pstDisplayArea); + RECT_WIDTH(*pstDisplayArea) += RECT_X_START(*pstDisplayArea); + RECT_X_START(*pstDisplayArea) = 0; + } + if(RECT_Y_START(*pstDisplayArea) < 0) + { + RECT_Y_START(*pstInnerPos) += RECT_Y_START(*pstDisplayArea); + RECT_HEIGHT(*pstDisplayArea) += RECT_Y_START(*pstDisplayArea); + RECT_Y_START(*pstDisplayArea) = 0; + } + } } /*************************************************************************/ -/** Function Name: SGUI_Common_IntegerToStringWithDecimalPoint **/ -/** Purpose: Convert number to a string and insert decimal point.**/ -/** Params: **/ -/** @iInteger[in]: Source number. **/ -/** @uiDecimalPlaces[in]: Decimal point places. **/ -/** @pszStringBuffer[out]: Bit map data buffer. **/ -/** @iAlignment[in]: Alignment of number string, positive numbers **/ -/** means right aligned and negative means left **/ -/** alignment. **/ -/** @cFillCharacter[in]:When string length less then align width, use **/ -/** this character fill the space. **/ -/** Return: Converted string length(include space). **/ -/** Notice: Only applies to decimal numbers. **/ +/** Function Name: SGUI_Common_IntegerToStringWithDecimalPoint **/ +/** Purpose: Convert number to a string and insert decimal point.**/ +/** Params: **/ +/** @iInteger[in]: Source number. **/ +/** @uiDecimalPlaces[in]: Decimal point places. **/ +/** @pszStringBuffer[out]: Bit map data buffer. **/ +/** @iAlignment[in]: Alignment of number string, positive numbers **/ +/** means right aligned and negative means left **/ +/** alignment. **/ +/** @cFillCharacter[in]:When string length less then align width, use **/ +/** this character fill the space. **/ +/** Return: Converted string length(include space). **/ +/** Notice: Only applies to decimal numbers. **/ /*************************************************************************/ SGUI_INT SGUI_Common_IntegerToStringWithDecimalPoint(SGUI_INT iInteger, SGUI_INT iDecimalPlaces, SGUI_SZSTR pszStringBuffer, SGUI_INT iAlignment, SGUI_CHAR cFillCharacter) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_CHAR szNumberString[SGUI_NUMBER_STR_LENGTH_MAX] = {0x00}; - SGUI_UINT uiSourceNumber; - SGUI_INT iSignBit; - SGUI_INT iNumberStringLength; - SGUI_INT iDecimalLength; - SGUI_INT iOutputLength; - SGUI_SZSTR pcSrcPtr; - SGUI_SZSTR pcDestPtr; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_CHAR szNumberString[SGUI_NUMBER_STR_LENGTH_MAX] = {0x00}; + SGUI_UINT uiSourceNumber; + SGUI_INT iSignBit; + SGUI_INT iNumberStringLength; + SGUI_INT iDecimalLength; + SGUI_INT iOutputLength; + SGUI_SZSTR pcSrcPtr; + SGUI_SZSTR pcDestPtr; - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - // Judged sign - if(iInteger < 0) - { - iSignBit = 1; - uiSourceNumber = -iInteger; - } - else - { - iSignBit = 0; - uiSourceNumber = iInteger; - } + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + // Judged sign + if(iInteger < 0) + { + iSignBit = 1; + uiSourceNumber = -iInteger; + } + else + { + iSignBit = 0; + uiSourceNumber = iInteger; + } - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - // Insert dot to string. - if(iDecimalPlaces > 0) - { - iDecimalLength = iDecimalPlaces; - // Convert number to string, ignore sign. - iNumberStringLength = SGUI_Common_IntegerToString(uiSourceNumber, szNumberString, 10, 0, cFillCharacter); + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + // Insert dot to string. + if(iDecimalPlaces > 0) + { + iDecimalLength = iDecimalPlaces; + // Convert number to string, ignore sign. + iNumberStringLength = SGUI_Common_IntegerToString(uiSourceNumber, szNumberString, 10, 0, cFillCharacter); // Set pointer. - pcSrcPtr = szNumberString + iNumberStringLength - 1; - if(iDecimalLength < iNumberStringLength) - { - iOutputLength = iNumberStringLength + 1; - } - else - { - iOutputLength = iDecimalLength + 2; - } - pcDestPtr = pszStringBuffer + iOutputLength + iSignBit; - // Process decimal string character. - *pcDestPtr = '\0'; - pcDestPtr--; - while((pcSrcPtr >= szNumberString) && (iDecimalLength > 0)) - { - *pcDestPtr = *pcSrcPtr; - pcDestPtr--; - pcSrcPtr--; - iDecimalLength--; - } - while(iDecimalLength > 0) - { - *pcDestPtr = '0'; - pcDestPtr--; - iDecimalLength --; - } - *pcDestPtr = '.'; - pcDestPtr--; - // Process integer string character. - if(iDecimalPlaces >= iNumberStringLength) - { - *pcDestPtr = '0'; - pcDestPtr--; - } - else - { + pcSrcPtr = szNumberString + iNumberStringLength - 1; + if(iDecimalLength < iNumberStringLength) + { + iOutputLength = iNumberStringLength + 1; + } + else + { + iOutputLength = iDecimalLength + 2; + } + pcDestPtr = pszStringBuffer + iOutputLength + iSignBit; + // Process decimal string character. + *pcDestPtr = '\0'; + pcDestPtr--; + while((pcSrcPtr >= szNumberString) && (iDecimalLength > 0)) + { + *pcDestPtr = *pcSrcPtr; + pcDestPtr--; + pcSrcPtr--; + iDecimalLength--; + } + while(iDecimalLength > 0) + { + *pcDestPtr = '0'; + pcDestPtr--; + iDecimalLength --; + } + *pcDestPtr = '.'; + pcDestPtr--; + // Process integer string character. + if(iDecimalPlaces >= iNumberStringLength) + { + *pcDestPtr = '0'; + pcDestPtr--; + } + else + { while(pcSrcPtr >= szNumberString) - { - *pcDestPtr = *pcSrcPtr; - pcDestPtr--; - pcSrcPtr--; - } - } - if(iSignBit > 0) - { - *pcDestPtr = '-'; - } - // Alignment - iOutputLength = iOutputLength + iSignBit; - if(iAlignment > 0) - { - pcSrcPtr = pszStringBuffer + iOutputLength - 1; - if(iOutputLength > iAlignment) - { - iAlignment = iOutputLength; - } - else - { - iOutputLength = iAlignment; - } - pcDestPtr = pszStringBuffer + iAlignment; - *pcDestPtr = '\0'; - pcDestPtr--; + { + *pcDestPtr = *pcSrcPtr; + pcDestPtr--; + pcSrcPtr--; + } + } + if(iSignBit > 0) + { + *pcDestPtr = '-'; + } + // Alignment + iOutputLength = iOutputLength + iSignBit; + if(iAlignment > 0) + { + pcSrcPtr = pszStringBuffer + iOutputLength - 1; + if(iOutputLength > iAlignment) + { + iAlignment = iOutputLength; + } + else + { + iOutputLength = iAlignment; + } + pcDestPtr = pszStringBuffer + iAlignment; + *pcDestPtr = '\0'; + pcDestPtr--; - while(pcDestPtr >= pszStringBuffer) - { - if(pcSrcPtr >= pszStringBuffer) - { - *pcDestPtr = *pcSrcPtr; - pcSrcPtr--; - } - else - { - *pcDestPtr = cFillCharacter; - } - pcDestPtr--; - } - } - else - { - iAlignment = -iAlignment; - pcSrcPtr = pszStringBuffer; - pcDestPtr = pszStringBuffer + iOutputLength; - if(iOutputLength > iAlignment) - { - iAlignment = 0; - } - else - { - iAlignment = iAlignment - iOutputLength; - iOutputLength = iOutputLength + iAlignment; - } - while(iAlignment --) - { - *pcDestPtr = cFillCharacter; - pcDestPtr ++; - } - *pcDestPtr = '\0'; - } + while(pcDestPtr >= pszStringBuffer) + { + if(pcSrcPtr >= pszStringBuffer) + { + *pcDestPtr = *pcSrcPtr; + pcSrcPtr--; + } + else + { + *pcDestPtr = cFillCharacter; + } + pcDestPtr--; + } + } + else + { + iAlignment = -iAlignment; + pcSrcPtr = pszStringBuffer; + pcDestPtr = pszStringBuffer + iOutputLength; + if(iOutputLength > iAlignment) + { + iAlignment = 0; + } + else + { + iAlignment = iAlignment - iOutputLength; + iOutputLength = iOutputLength + iAlignment; + } + while(iAlignment --) + { + *pcDestPtr = cFillCharacter; + pcDestPtr ++; + } + *pcDestPtr = '\0'; + } - } - else - { - // Convert number to string. - iOutputLength = SGUI_Common_IntegerToString(iInteger, pszStringBuffer, 10, iAlignment, cFillCharacter); - } + } + else + { + // Convert number to string. + iOutputLength = SGUI_Common_IntegerToString(iInteger, pszStringBuffer, 10, iAlignment, cFillCharacter); + } - return iOutputLength; + return iOutputLength; } /*************************************************************************/ -/** Function Name: SGUI_Common_IntegerToString **/ -/** Purpose: Convert number to a string. **/ -/** Params: **/ -/** @iInteger[in]: Source number. **/ -/** @pszStringBuffer[out]: Bit map data buffer. **/ -/** @uiBase[in]: Conversion base. **/ -/** @iAlignment[in]: Alignment of number string, positive numbers **/ -/** means right aligned and negative means left **/ -/** alignment. **/ -/** @cFillCharacter[in]:When string length less then align width, use **/ -/** this character fill the space. **/ -/** Return: Converted string length. **/ -/** Notice: None. **/ +/** Function Name: SGUI_Common_IntegerToString **/ +/** Purpose: Convert number to a string. **/ +/** Params: **/ +/** @iInteger[in]: Source number. **/ +/** @pszStringBuffer[out]: Bit map data buffer. **/ +/** @uiBase[in]: Conversion base. **/ +/** @iAlignment[in]: Alignment of number string, positive numbers **/ +/** means right aligned and negative means left **/ +/** alignment. **/ +/** @cFillCharacter[in]:When string length less then align width, use **/ +/** this character fill the space. **/ +/** Return: Converted string length. **/ +/** Notice: None. **/ /*************************************************************************/ SGUI_SIZE SGUI_Common_IntegerToString(SGUI_INT iInteger, SGUI_SZSTR pszStringBuffer, SGUI_UINT uiBase, SGUI_INT iAlignment, SGUI_CHAR cFillCharacter) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_CHAR szNumberString[SGUI_NUMBER_STR_LENGTH_MAX] = {0x00}; - SGUI_UINT uiSourceNumber; - SGUI_UINT uiSignBit; - SGUI_INT iNumberStringLength; - SGUI_SZSTR pcSrcPtr; - SGUI_SZSTR pcDestPtr; - SGUI_SIZE uiDigitBit; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_CHAR szNumberString[SGUI_NUMBER_STR_LENGTH_MAX] = {0x00}; + SGUI_UINT uiSourceNumber; + SGUI_UINT uiSignBit; + SGUI_INT iNumberStringLength; + SGUI_SZSTR pcSrcPtr; + SGUI_SZSTR pcDestPtr; + SGUI_SIZE uiDigitBit; /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - pcSrcPtr = szNumberString + SGUI_NUMBER_STR_LENGTH_MAX - 1; - pcDestPtr = szNumberString; - *pcSrcPtr = '\0'; - pcSrcPtr--; - iNumberStringLength = 0; - // Judged sign + /* Initialize */ + /*----------------------------------*/ + pcSrcPtr = szNumberString + SGUI_NUMBER_STR_LENGTH_MAX - 1; + pcDestPtr = szNumberString; + *pcSrcPtr = '\0'; + pcSrcPtr--; + iNumberStringLength = 0; + // Judged sign if(iInteger < 0) - { - if(uiBase == 16) - { - uiSignBit = 0; - uiSourceNumber = (SGUI_UINT)iInteger; - } - else - { - uiSignBit = 1; - uiSourceNumber = -iInteger; - } - } - else - { - uiSignBit = 0; - uiSourceNumber = (SGUI_UINT)iInteger; - } + { + if(uiBase == 16) + { + uiSignBit = 0; + uiSourceNumber = (SGUI_UINT)iInteger; + } + else + { + uiSignBit = 1; + uiSourceNumber = -iInteger; + } + } + else + { + uiSignBit = 0; + uiSourceNumber = (SGUI_UINT)iInteger; + } - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - // Convert number to string. + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + // Convert number to string. while(uiSourceNumber != 0) - { - uiDigitBit = uiSourceNumber % uiBase; - if(uiDigitBit < 10) - { - *pcSrcPtr = uiDigitBit + '0'; - } - else - { - *pcSrcPtr = uiDigitBit - 10 + 'A'; - } - uiSourceNumber = uiSourceNumber / uiBase; - pcSrcPtr--; - iNumberStringLength++; - } - if(uiSignBit == 1) - { - *pcSrcPtr = '-'; - iNumberStringLength++; - } - else - { - pcSrcPtr++; - } + { + uiDigitBit = uiSourceNumber % uiBase; + if(uiDigitBit < 10) + { + *pcSrcPtr = uiDigitBit + '0'; + } + else + { + *pcSrcPtr = uiDigitBit - 10 + 'A'; + } + uiSourceNumber = uiSourceNumber / uiBase; + pcSrcPtr--; + iNumberStringLength++; + } + if(uiSignBit == 1) + { + *pcSrcPtr = '-'; + iNumberStringLength++; + } + else + { + pcSrcPtr++; + } - while((pcDestPtr - iNumberStringLength) != szNumberString) - { - *pcDestPtr = *pcSrcPtr; - pcSrcPtr++; - pcDestPtr++; - } - if(iNumberStringLength == 0) - { - pcDestPtr = szNumberString; - *pcDestPtr = '0'; - pcDestPtr++; - iNumberStringLength++; - } - *pcDestPtr = '\0'; - // Move to out put buffer - if(iAlignment > 0) - { - pcSrcPtr = szNumberString + iNumberStringLength-1; - if(iNumberStringLength > iAlignment) - { - iAlignment = iNumberStringLength; - } - else - { - iNumberStringLength = iAlignment; - } - pcDestPtr = pszStringBuffer + iAlignment; - *pcDestPtr = '\0'; - pcDestPtr--; + while((pcDestPtr - iNumberStringLength) != szNumberString) + { + *pcDestPtr = *pcSrcPtr; + pcSrcPtr++; + pcDestPtr++; + } + if(iNumberStringLength == 0) + { + pcDestPtr = szNumberString; + *pcDestPtr = '0'; + pcDestPtr++; + iNumberStringLength++; + } + *pcDestPtr = '\0'; + // Move to out put buffer + if(iAlignment > 0) + { + pcSrcPtr = szNumberString + iNumberStringLength-1; + if(iNumberStringLength > iAlignment) + { + iAlignment = iNumberStringLength; + } + else + { + iNumberStringLength = iAlignment; + } + pcDestPtr = pszStringBuffer + iAlignment; + *pcDestPtr = '\0'; + pcDestPtr--; - while(pcDestPtr >= pszStringBuffer) - { - if(pcSrcPtr >= szNumberString) - { - *pcDestPtr = *pcSrcPtr; - pcSrcPtr--; - } - else - { - *pcDestPtr = cFillCharacter; - } - pcDestPtr--; - } - } - else - { - iAlignment = -iAlignment; - if(iNumberStringLength > iAlignment) - { - iAlignment = iNumberStringLength; - } - else - { - iNumberStringLength = iAlignment; - } - pcDestPtr = pszStringBuffer; - pcSrcPtr = szNumberString; - while(iAlignment > 0) - { - if(*pcSrcPtr != '\0') - { - *pcDestPtr = *pcSrcPtr; - pcSrcPtr++; - } - else - { - *pcDestPtr = cFillCharacter; - } - pcDestPtr++; - iAlignment--; - } - *pcDestPtr = '\0'; - } - return iNumberStringLength; + while(pcDestPtr >= pszStringBuffer) + { + if(pcSrcPtr >= szNumberString) + { + *pcDestPtr = *pcSrcPtr; + pcSrcPtr--; + } + else + { + *pcDestPtr = cFillCharacter; + } + pcDestPtr--; + } + } + else + { + iAlignment = -iAlignment; + if(iNumberStringLength > iAlignment) + { + iAlignment = iNumberStringLength; + } + else + { + iNumberStringLength = iAlignment; + } + pcDestPtr = pszStringBuffer; + pcSrcPtr = szNumberString; + while(iAlignment > 0) + { + if(*pcSrcPtr != '\0') + { + *pcDestPtr = *pcSrcPtr; + pcSrcPtr++; + } + else + { + *pcDestPtr = cFillCharacter; + } + pcDestPtr++; + iAlignment--; + } + *pcDestPtr = '\0'; + } + return iNumberStringLength; } /*************************************************************************/ -/** Function Name: SGUI_Common_ConvertStringToUnsignedInteger **/ -/** Purpose: Convert a string to a unsigned integer. **/ -/** Params: **/ -/** @szString[in]: Source number. **/ -/** @ppcEndPointer[out]: Convert end pointer output in string. **/ -/** @uiBase[in]: Conversion base. **/ -/** Return: Converted number. **/ -/** Notice: None. **/ +/** Function Name: SGUI_Common_ConvertStringToUnsignedInteger **/ +/** Purpose: Convert a string to a unsigned integer. **/ +/** Params: **/ +/** @szString[in]: Source number. **/ +/** @ppcEndPointer[out]: Convert end pointer output in string. **/ +/** @uiBase[in]: Conversion base. **/ +/** Return: Converted number. **/ +/** Notice: None. **/ /*************************************************************************/ SGUI_UINT SGUI_Common_ConvertStringToUnsignedInteger(SGUI_SZSTR szString, SGUI_CHAR** ppcEndPointer, SGUI_UINT uiBase) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_UINT32 uiResult; - SGUI_UINT uiBitValue; - SGUI_SZSTR pcCurPtr; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_UINT32 uiResult; + SGUI_UINT uiBitValue; + SGUI_SZSTR pcCurPtr; - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - uiResult = 0; - pcCurPtr = szString; + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + uiResult = 0; + pcCurPtr = szString; - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if(NULL != pcCurPtr) - { - // Skip header space. - while(' ' == *pcCurPtr) - { - pcCurPtr++; - } - // Convert string. - if(uiBase == 16) - { - if((*(pcCurPtr) == '0') && ((*(pcCurPtr+1) == 'x') || (*(pcCurPtr+1) == 'X'))) - { - pcCurPtr += 2; - } - while(('\0' != (*pcCurPtr)) && (true == SGUI_ISHEXDIGIT(*pcCurPtr))) - { - uiBitValue = SGUI_ISDIGIT(*pcCurPtr)?((*pcCurPtr)-'0'):(10+SGUI_TOUPPER(*pcCurPtr)-'A'); - uiResult = uiResult*uiBase + uiBitValue; - pcCurPtr++; - } - } - else if((uiBase == 8) || (uiBase == 10)) - { - while(('\0' != (*pcCurPtr)) && (true == SGUI_ISDIGIT(*pcCurPtr))) - { - uiBitValue =(*pcCurPtr)-'0'; - uiResult = uiResult*uiBase + uiBitValue; - pcCurPtr++; - } - } - } - if(NULL != ppcEndPointer) - { - *ppcEndPointer = pcCurPtr; - } + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(NULL != pcCurPtr) + { + // Skip header space. + while(' ' == *pcCurPtr) + { + pcCurPtr++; + } + // Convert string. + if(uiBase == 16) + { + if((*(pcCurPtr) == '0') && ((*(pcCurPtr+1) == 'x') || (*(pcCurPtr+1) == 'X'))) + { + pcCurPtr += 2; + } + while(('\0' != (*pcCurPtr)) && (true == SGUI_ISHEXDIGIT(*pcCurPtr))) + { + uiBitValue = SGUI_ISDIGIT(*pcCurPtr)?((*pcCurPtr)-'0'):(10+SGUI_TOUPPER(*pcCurPtr)-'A'); + uiResult = uiResult*uiBase + uiBitValue; + pcCurPtr++; + } + } + else if((uiBase == 8) || (uiBase == 10)) + { + while(('\0' != (*pcCurPtr)) && (true == SGUI_ISDIGIT(*pcCurPtr))) + { + uiBitValue =(*pcCurPtr)-'0'; + uiResult = uiResult*uiBase + uiBitValue; + pcCurPtr++; + } + } + } + if(NULL != ppcEndPointer) + { + *ppcEndPointer = pcCurPtr; + } return uiResult; } /*************************************************************************/ -/** Function Name: SGUI_Common_ConvertStringToInteger **/ -/** Purpose: Convert a string to a signed integer. **/ -/** Params: **/ -/** @szString[in]: Source number. **/ -/** @ppcEndPointer[in]: Convert end pointer output in string. **/ -/** @uiBase[in]: Conversion base. **/ -/** Return: Converted number. **/ -/** Notice: None. **/ +/** Function Name: SGUI_Common_ConvertStringToInteger **/ +/** Purpose: Convert a string to a signed integer. **/ +/** Params: **/ +/** @szString[in]: Source number. **/ +/** @ppcEndPointer[in]: Convert end pointer output in string. **/ +/** @uiBase[in]: Conversion base. **/ +/** Return: Converted number. **/ +/** Notice: None. **/ /*************************************************************************/ SGUI_INT SGUI_Common_ConvertStringToInteger(SGUI_SZSTR szString, SGUI_CHAR** ppcEndPointer, SGUI_UINT uiBase) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_INT iResult; - SGUI_INT iSign; - SGUI_SZSTR pcCurPtr; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_INT iResult; + SGUI_INT iSign; + SGUI_SZSTR pcCurPtr; - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - iResult = 0; - iSign = 1; - pcCurPtr = szString; + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + iResult = 0; + iSign = 1; + pcCurPtr = szString; - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if(NULL != pcCurPtr) - { - // Skip header space. - while(' ' == *pcCurPtr) - { - pcCurPtr++; - } - // Check sign. - if((10 == uiBase) || (8 == uiBase)) - { - if('+' == *pcCurPtr) - { - pcCurPtr++; - } - else if('-' == *pcCurPtr) - { - pcCurPtr++; - iSign = -1; - } - } - // Convert string without sign. - iResult = SGUI_Common_ConvertStringToUnsignedInteger(pcCurPtr, ppcEndPointer, uiBase); - if((iResult > 0) && (-1 == iSign)) - { - iResult = -iResult; - } - } - return iResult; + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(NULL != pcCurPtr) + { + // Skip header space. + while(' ' == *pcCurPtr) + { + pcCurPtr++; + } + // Check sign. + if((10 == uiBase) || (8 == uiBase)) + { + if('+' == *pcCurPtr) + { + pcCurPtr++; + } + else if('-' == *pcCurPtr) + { + pcCurPtr++; + iSign = -1; + } + } + // Convert string without sign. + iResult = SGUI_Common_ConvertStringToUnsignedInteger(pcCurPtr, ppcEndPointer, uiBase); + if((iResult > 0) && (-1 == iSign)) + { + iResult = -iResult; + } + } + return iResult; } diff --git a/GUI/src/SGUI_Curve.c b/GUI/src/SGUI_Curve.c index 54e91d2c7fd4fe040ec6cf4ff6f66230427a8e09..e88848c86d3f6cdad0c7e364c35ad1b6bf59b5f1 100644 --- a/GUI/src/SGUI_Curve.c +++ b/GUI/src/SGUI_Curve.c @@ -1,568 +1,568 @@ /*************************************************************************/ -/** Copyright. **/ -/** FileName: SGUI_Curve.c **/ -/** Author: Polarix **/ -/** Description: Draw frames on screen. **/ +/** Copyright. **/ +/** FileName: SGUI_Curve.c **/ +/** Author: Polarix **/ +/** Description: Draw frames on screen. **/ /*************************************************************************/ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "SGUI_Curve.h" //=======================================================================// -//= Static function declaration. =// +//= Static function declaration. =// //=======================================================================// //=======================================================================// -//= Function define. =// +//= Function define. =// //=======================================================================// /*************************************************************************/ -/** Function Name: SGUI_Curve_Initialize **/ -/** Purpose: Initialize curve data structure. **/ -/** Params: **/ -/** @ pstObj[in]: Curve object pointer. **/ -/** @ pcstInitParam[in]: Initialize data pointer. **/ -/** Return: None. **/ -/** Notice: none. **/ +/** Function Name: SGUI_Curve_Initialize **/ +/** Purpose: Initialize curve data structure. **/ +/** Params: **/ +/** @ pstObj[in]: Curve object pointer. **/ +/** @ pcstInitParam[in]: Initialize data pointer. **/ +/** Return: None. **/ +/** Notice: none. **/ /*************************************************************************/ void SGUI_Curve_Initialize(SGUI_CURVE_STRUCT* pstObj, const SGUI_CURVE_PARAM* pcstInitParam) { - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if((NULL != pstObj) && (NULL != pcstInitParam)) - { - SGUI_SystemIF_MemoryCopy(&(pstObj->stParam), (void*)pcstInitParam, sizeof(SGUI_CURVE_PARAM)); - SGUI_SystemIF_MemorySet(&(pstObj->stData), 0x00, sizeof(SGUI_CURVE_DATA)); - } + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if((NULL != pstObj) && (NULL != pcstInitParam)) + { + SGUI_SystemIF_MemoryCopy(&(pstObj->stParam), (void*)pcstInitParam, sizeof(SGUI_CURVE_PARAM)); + SGUI_SystemIF_MemorySet(&(pstObj->stData), 0x00, sizeof(SGUI_CURVE_DATA)); + } } /*************************************************************************/ -/** Function Name: SGUI_Curve_Repaint **/ -/** Purpose: Draw a curve on screen order by point data. **/ -/** Params: **/ -/** @ pstDeviceIF[in]: Device driver object pointer. **/ -/** @ pstObj[in]: Curve object pointer. **/ -/** Return: None. **/ +/** Function Name: SGUI_Curve_Repaint **/ +/** Purpose: Draw a curve on screen order by point data. **/ +/** Params: **/ +/** @ pstDeviceIF[in]: Device driver object pointer. **/ +/** @ pstObj[in]: Curve object pointer. **/ +/** Return: None. **/ /*************************************************************************/ void SGUI_Curve_Repaint(SGUI_SCR_DEV* pstDeviceIF, const SGUI_CURVE_STRUCT* pstObj) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_CURVE_POINT* pcstLineStartPoint; - SGUI_CURVE_POINT* pcstLineEndPoint; - - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if((NULL != pstDeviceIF) && (NULL != pstObj)) - { - /* Clean up background. */ - SGUI_Basic_DrawRectangle(pstDeviceIF, pstObj->stParam.stLayout.iX, pstObj->stParam.stLayout.iY, pstObj->stParam.stLayout.iWidth, pstObj->stParam.stLayout.iHeight, SGUI_COLOR_BKGCLR, SGUI_COLOR_BKGCLR); - if(pstObj->stData.stPoints.sCount > 1) - { + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_CURVE_POINT* pcstLineStartPoint; + SGUI_CURVE_POINT* pcstLineEndPoint; + + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if((NULL != pstDeviceIF) && (NULL != pstObj)) + { + /* Clean up background. */ + SGUI_Basic_DrawRectangle(pstDeviceIF, pstObj->stParam.stLayout.iX, pstObj->stParam.stLayout.iY, pstObj->stParam.stLayout.iWidth, pstObj->stParam.stLayout.iHeight, SGUI_COLOR_BKGCLR, SGUI_COLOR_BKGCLR); + if(pstObj->stData.stPoints.sCount > 1) + { #if 1 - pcstLineStartPoint = pstObj->stData.stPoints.pstHead; - pcstLineEndPoint = pcstLineStartPoint->pstNext; - while(NULL != pcstLineEndPoint) - { - /* Paint visible line. */ - if(SGUI_Basic_PointIsInArea(&(pstObj->stParam.stLayout), pcstLineStartPoint->stPosition.iX, pcstLineStartPoint->stPosition.iY) || - SGUI_Basic_PointIsInArea(&(pstObj->stParam.stLayout), pcstLineStartPoint->stPosition.iX, pcstLineStartPoint->stPosition.iY)) - { - SGUI_Basic_DrawLine(pstDeviceIF, pcstLineStartPoint->stPosition.iX, pcstLineStartPoint->stPosition.iY, - pcstLineEndPoint->stPosition.iX, pcstLineEndPoint->stPosition.iY, SGUI_COLOR_FRGCLR); - } - pcstLineStartPoint = pcstLineStartPoint->pstNext; - pcstLineEndPoint = pcstLineStartPoint->pstNext; - } + pcstLineStartPoint = pstObj->stData.stPoints.pstHead; + pcstLineEndPoint = pcstLineStartPoint->pstNext; + while(NULL != pcstLineEndPoint) + { + /* Paint visible line. */ + if(SGUI_Basic_PointIsInArea(&(pstObj->stParam.stLayout), pcstLineStartPoint->stPosition.iX, pcstLineStartPoint->stPosition.iY) || + SGUI_Basic_PointIsInArea(&(pstObj->stParam.stLayout), pcstLineStartPoint->stPosition.iX, pcstLineStartPoint->stPosition.iY)) + { + SGUI_Basic_DrawLine(pstDeviceIF, pcstLineStartPoint->stPosition.iX, pcstLineStartPoint->stPosition.iY, + pcstLineEndPoint->stPosition.iX, pcstLineEndPoint->stPosition.iY, SGUI_COLOR_FRGCLR); + } + pcstLineStartPoint = pcstLineStartPoint->pstNext; + pcstLineEndPoint = pcstLineStartPoint->pstNext; + } #else - pcstLineStartPoint = pstObj->stData.stPoints.pstEnd; - pcstLineEndPoint = pcstLineStartPoint->pstPrev; - while(NULL != pcstLineEndPoint) - { - /* Paint visible line. */ - if(SGUI_Basic_PointIsInArea(&(pstObj->stParam.stLayout), &(pcstLineStartPoint->stPosition)) || SGUI_Basic_PointIsInArea(&(pstObj->stParam.stLayout), &(pcstLineEndPoint->stPosition))) - { - SGUI_Basic_DrawLine(pstDeviceIF, pcstLineStartPoint->stPosition.iX, pcstLineStartPoint->stPosition.iY, - pcstLineEndPoint->stPosition.iX, pcstLineEndPoint->stPosition.iY, SGUI_COLOR_FRGCLR); - } - pcstLineStartPoint = pcstLineStartPoint->pstPrev; - pcstLineEndPoint = pcstLineStartPoint->pstPrev; - } + pcstLineStartPoint = pstObj->stData.stPoints.pstEnd; + pcstLineEndPoint = pcstLineStartPoint->pstPrev; + while(NULL != pcstLineEndPoint) + { + /* Paint visible line. */ + if(SGUI_Basic_PointIsInArea(&(pstObj->stParam.stLayout), &(pcstLineStartPoint->stPosition)) || SGUI_Basic_PointIsInArea(&(pstObj->stParam.stLayout), &(pcstLineEndPoint->stPosition))) + { + SGUI_Basic_DrawLine(pstDeviceIF, pcstLineStartPoint->stPosition.iX, pcstLineStartPoint->stPosition.iY, + pcstLineEndPoint->stPosition.iX, pcstLineEndPoint->stPosition.iY, SGUI_COLOR_FRGCLR); + } + pcstLineStartPoint = pcstLineStartPoint->pstPrev; + pcstLineEndPoint = pcstLineStartPoint->pstPrev; + } #endif - } - } + } + } } /*************************************************************************/ -/** Function Name: SGUI_Curve_InitializePoint **/ -/** Purpose: Set X and Y value(NOT position) to a point. **/ -/** Params: **/ -/** @ pstNewPoint[in]: Point data pointer. **/ -/** @ iX[in]: Point X value. **/ -/** @ iY[in]: Point Y value. **/ -/** Return: None. **/ +/** Function Name: SGUI_Curve_InitializePoint **/ +/** Purpose: Set X and Y value(NOT position) to a point. **/ +/** Params: **/ +/** @ pstNewPoint[in]: Point data pointer. **/ +/** @ iX[in]: Point X value. **/ +/** @ iY[in]: Point Y value. **/ +/** Return: None. **/ /*************************************************************************/ void SGUI_Curve_InitializePoint(SGUI_CURVE_POINT* pstNewPoint, SGUI_INT iX, SGUI_INT iY) { - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if(NULL != pstNewPoint) - { - SGUI_SystemIF_MemorySet(pstNewPoint, 0x00, sizeof(SGUI_CURVE_POINT)); - pstNewPoint->stPoint.iX = iX; - pstNewPoint->stPoint.iY = iY; - } + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(NULL != pstNewPoint) + { + SGUI_SystemIF_MemorySet(pstNewPoint, 0x00, sizeof(SGUI_CURVE_POINT)); + pstNewPoint->stPoint.iX = iX; + pstNewPoint->stPoint.iY = iY; + } } /*************************************************************************/ -/** Function Name: SGUI_Curve_AddPoint **/ -/** Purpose: Add a new point object to end of curve point chain **/ -/** list. **/ -/** Params: **/ -/** @ pstObj[in]: Curve object pointer. **/ -/** @ pstNewPoint[in]: Point data will be appended. **/ -/** Return: None. **/ +/** Function Name: SGUI_Curve_AddPoint **/ +/** Purpose: Add a new point object to end of curve point chain **/ +/** list. **/ +/** Params: **/ +/** @ pstObj[in]: Curve object pointer. **/ +/** @ pstNewPoint[in]: Point data will be appended. **/ +/** Return: None. **/ /*************************************************************************/ void SGUI_Curve_AddPoint(SGUI_CURVE_STRUCT* pstObj, SGUI_CURVE_POINT* pstNewPoint) { - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if((NULL != pstObj) && (NULL != pstNewPoint)) - { - if(0 == pstObj->stData.stPoints.sCount) - { - pstObj->stData.stPoints.pstHead = pstNewPoint; - pstObj->stData.stPoints.pstEnd = pstNewPoint; - } - else - { - pstObj->stData.stPoints.pstEnd->pstNext = pstNewPoint; - pstNewPoint->pstPrev = pstObj->stData.stPoints.pstEnd; - pstObj->stData.stPoints.pstEnd = pstNewPoint; - } - SGUI_Curve_CalculatePointPosition(pstObj, pstNewPoint); - pstObj->stData.stPoints.sCount++; - } + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if((NULL != pstObj) && (NULL != pstNewPoint)) + { + if(0 == pstObj->stData.stPoints.sCount) + { + pstObj->stData.stPoints.pstHead = pstNewPoint; + pstObj->stData.stPoints.pstEnd = pstNewPoint; + } + else + { + pstObj->stData.stPoints.pstEnd->pstNext = pstNewPoint; + pstNewPoint->pstPrev = pstObj->stData.stPoints.pstEnd; + pstObj->stData.stPoints.pstEnd = pstNewPoint; + } + SGUI_Curve_CalculatePointPosition(pstObj, pstNewPoint); + pstObj->stData.stPoints.sCount++; + } } /*************************************************************************/ -/** Function Name: SGUI_Curve_InsertBeforePoint **/ -/** Purpose: Add a new point before current focused point in **/ -/** chain. **/ -/** Params: **/ -/** @ pstObj[in]: Curve object pointer. **/ -/** @ pstNewPoint[in]: Point data will be inserted. **/ -/** Return: **/ -/** @ SGUI_TRUE Insert success. **/ -/** @ SGUI_FALSE: Insert failed, might be focused point is head or **/ -/** no focused point. **/ -/** Notice: Cannot insert before the first point in chain. **/ +/** Function Name: SGUI_Curve_InsertBeforePoint **/ +/** Purpose: Add a new point before current focused point in **/ +/** chain. **/ +/** Params: **/ +/** @ pstObj[in]: Curve object pointer. **/ +/** @ pstNewPoint[in]: Point data will be inserted. **/ +/** Return: **/ +/** @ SGUI_TRUE Insert success. **/ +/** @ SGUI_FALSE: Insert failed, might be focused point is head or **/ +/** no focused point. **/ +/** Notice: Cannot insert before the first point in chain. **/ /*************************************************************************/ SGUI_BOOL SGUI_Curve_InsertBeforePoint(SGUI_CURVE_STRUCT* pstObj, SGUI_CURVE_POINT* pstNewPoint) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_CURVE_POINT* pstBasePoint; - SGUI_BOOL bReturn; - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if((NULL == pstObj) || (NULL == pstNewPoint)) - { - /* Invalid parameter. */ - bReturn = SGUI_FALSE; - } - else - { - pstBasePoint = pstObj->stData.pstFocused; - do - { - if(NULL == pstBasePoint) - { - /* Current focused point must be set. */ - break; - } + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_CURVE_POINT* pstBasePoint; + SGUI_BOOL bReturn; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if((NULL == pstObj) || (NULL == pstNewPoint)) + { + /* Invalid parameter. */ + bReturn = SGUI_FALSE; + } + else + { + pstBasePoint = pstObj->stData.pstFocused; + do + { + if(NULL == pstBasePoint) + { + /* Current focused point must be set. */ + break; + } if(pstBasePoint == pstObj->stData.stPoints.pstHead) - { - /* Cannot insert before head. */ - bReturn = SGUI_FALSE; - break; - } - /* Judge new point X value. */ - if(pstNewPoint->stPoint.iX > pstBasePoint->stPoint.iX) - { - pstNewPoint->stPoint.iX = pstBasePoint->stPoint.iX; - } - if(pstNewPoint->stPoint.iX < pstBasePoint->pstPrev->stPoint.iX) - { - pstNewPoint->stPoint.iX = pstBasePoint->pstNext->stPoint.iX; - } - - pstBasePoint->pstPrev->pstNext = pstNewPoint; - pstNewPoint->pstPrev = pstBasePoint->pstPrev; - pstNewPoint->pstNext = pstBasePoint; - pstBasePoint->pstPrev = pstNewPoint; - SGUI_Curve_CalculatePointPosition(pstObj, pstNewPoint); - pstObj->stData.stPoints.sCount++; - bReturn = SGUI_TRUE; - }while(0); - } - return bReturn; + { + /* Cannot insert before head. */ + bReturn = SGUI_FALSE; + break; + } + /* Judge new point X value. */ + if(pstNewPoint->stPoint.iX > pstBasePoint->stPoint.iX) + { + pstNewPoint->stPoint.iX = pstBasePoint->stPoint.iX; + } + if(pstNewPoint->stPoint.iX < pstBasePoint->pstPrev->stPoint.iX) + { + pstNewPoint->stPoint.iX = pstBasePoint->pstNext->stPoint.iX; + } + + pstBasePoint->pstPrev->pstNext = pstNewPoint; + pstNewPoint->pstPrev = pstBasePoint->pstPrev; + pstNewPoint->pstNext = pstBasePoint; + pstBasePoint->pstPrev = pstNewPoint; + SGUI_Curve_CalculatePointPosition(pstObj, pstNewPoint); + pstObj->stData.stPoints.sCount++; + bReturn = SGUI_TRUE; + }while(0); + } + return bReturn; } /*************************************************************************/ -/** Function Name: SGUI_Curve_InsertAfterPoint **/ -/** Purpose: Add a new point after current focused point in **/ -/** chain. **/ -/** Params: **/ -/** @ pstObj[in]: Curve object pointer. **/ -/** @ pstNewPoint[in]: Point data will be inserted. **/ -/** Return: **/ -/** @ SGUI_TRUE Insert success. **/ -/** @ SGUI_FALSE: Insert failed, might be focused point is end or no **/ -/** focused point. **/ -/** Notice: Cannot insert after the last point in chain. **/ +/** Function Name: SGUI_Curve_InsertAfterPoint **/ +/** Purpose: Add a new point after current focused point in **/ +/** chain. **/ +/** Params: **/ +/** @ pstObj[in]: Curve object pointer. **/ +/** @ pstNewPoint[in]: Point data will be inserted. **/ +/** Return: **/ +/** @ SGUI_TRUE Insert success. **/ +/** @ SGUI_FALSE: Insert failed, might be focused point is end or no **/ +/** focused point. **/ +/** Notice: Cannot insert after the last point in chain. **/ /*************************************************************************/ SGUI_BOOL SGUI_Curve_InsertAfterPoint(SGUI_CURVE_STRUCT* pstObj, SGUI_CURVE_POINT* pstNewPoint) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_CURVE_POINT* pstBasePoint; - SGUI_BOOL bReturn; - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if((NULL == pstObj) || (NULL == pstNewPoint)) - { - /* Invalid parameter. */ - bReturn = SGUI_FALSE; - } - else - { - pstBasePoint = pstObj->stData.pstFocused; - do - { - if(NULL == pstBasePoint) - { - /* Current focused point must be set. */ - break; - } + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_CURVE_POINT* pstBasePoint; + SGUI_BOOL bReturn; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if((NULL == pstObj) || (NULL == pstNewPoint)) + { + /* Invalid parameter. */ + bReturn = SGUI_FALSE; + } + else + { + pstBasePoint = pstObj->stData.pstFocused; + do + { + if(NULL == pstBasePoint) + { + /* Current focused point must be set. */ + break; + } if(pstBasePoint == pstObj->stData.stPoints.pstEnd) - { - /* Cannot insert after end. */ - bReturn = SGUI_FALSE; - break; - } - /* Judge new point X value. */ - if(pstNewPoint->stPoint.iX < pstBasePoint->stPoint.iX) - { - pstNewPoint->stPoint.iX = pstBasePoint->stPoint.iX; - } - if(pstNewPoint->stPoint.iX > pstBasePoint->pstNext->stPoint.iX) - { - pstNewPoint->stPoint.iX = pstBasePoint->pstNext->stPoint.iX; - } - pstBasePoint->pstNext->pstPrev = pstNewPoint; - pstNewPoint->pstNext = pstBasePoint->pstNext; - pstNewPoint->pstPrev = pstBasePoint; - pstBasePoint->pstNext = pstNewPoint; - SGUI_Curve_CalculatePointPosition(pstObj, pstNewPoint); - pstObj->stData.stPoints.sCount++; - bReturn = SGUI_TRUE; - }while(0); - } - return bReturn; + { + /* Cannot insert after end. */ + bReturn = SGUI_FALSE; + break; + } + /* Judge new point X value. */ + if(pstNewPoint->stPoint.iX < pstBasePoint->stPoint.iX) + { + pstNewPoint->stPoint.iX = pstBasePoint->stPoint.iX; + } + if(pstNewPoint->stPoint.iX > pstBasePoint->pstNext->stPoint.iX) + { + pstNewPoint->stPoint.iX = pstBasePoint->pstNext->stPoint.iX; + } + pstBasePoint->pstNext->pstPrev = pstNewPoint; + pstNewPoint->pstNext = pstBasePoint->pstNext; + pstNewPoint->pstPrev = pstBasePoint; + pstBasePoint->pstNext = pstNewPoint; + SGUI_Curve_CalculatePointPosition(pstObj, pstNewPoint); + pstObj->stData.stPoints.sCount++; + bReturn = SGUI_TRUE; + }while(0); + } + return bReturn; } /*************************************************************************/ -/** Function Name: SGUI_Curve_RemovePoint **/ -/** Purpose: Remove the point object from the curve chain. **/ -/** Params: **/ -/** @ pstObj[in]: Curve object pointer. **/ -/** @ pstPoint[in]: Point data will be removed. **/ -/** Return: **/ -/** @ SGUI_TRUE Point removed from curve point list. **/ -/** @ SGUI_FALSE: Remove failed, might be disable to remove or point **/ -/** is not in curve point list. **/ -/** Notice: This function only removed point form curve chain, **/ -/** memory must release if allocate from heap. **/ +/** Function Name: SGUI_Curve_RemovePoint **/ +/** Purpose: Remove the point object from the curve chain. **/ +/** Params: **/ +/** @ pstObj[in]: Curve object pointer. **/ +/** @ pstPoint[in]: Point data will be removed. **/ +/** Return: **/ +/** @ SGUI_TRUE Point removed from curve point list. **/ +/** @ SGUI_FALSE: Remove failed, might be disable to remove or point **/ +/** is not in curve point list. **/ +/** Notice: This function only removed point form curve chain, **/ +/** memory must release if allocate from heap. **/ /*************************************************************************/ SGUI_BOOL SGUI_Curve_RemovePoint(SGUI_CURVE_STRUCT* pstObj, SGUI_CURVE_POINT* pstPoint) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_BOOL bReturn; - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if((NULL != pstObj) && (NULL != pstPoint) && (pstObj->stData.stPoints.sCount > 2)) - { - if(NULL != pstPoint->pstNext) - { - pstPoint->pstNext->pstPrev = pstPoint->pstPrev; - } - if(NULL != pstPoint->pstPrev) - { - pstPoint->pstPrev->pstNext = pstPoint->pstNext; - } - if(pstPoint == pstObj->stData.pstFocused) - { - pstObj->stData.pstFocused = NULL; - } - pstObj->stData.stPoints.sCount--; - bReturn = SGUI_TRUE; - } - else - { - bReturn = SGUI_FALSE; - } - - return bReturn; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_BOOL bReturn; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if((NULL != pstObj) && (NULL != pstPoint) && (pstObj->stData.stPoints.sCount > 2)) + { + if(NULL != pstPoint->pstNext) + { + pstPoint->pstNext->pstPrev = pstPoint->pstPrev; + } + if(NULL != pstPoint->pstPrev) + { + pstPoint->pstPrev->pstNext = pstPoint->pstNext; + } + if(pstPoint == pstObj->stData.pstFocused) + { + pstObj->stData.pstFocused = NULL; + } + pstObj->stData.stPoints.sCount--; + bReturn = SGUI_TRUE; + } + else + { + bReturn = SGUI_FALSE; + } + + return bReturn; } /*************************************************************************/ -/** Function Name: SGUI_Curve_CalculatePointPosition **/ -/** Purpose: Calculate point position according to point X and Y **/ -/** value and curve display area layout. **/ -/** Params: **/ -/** @ pstObj[in]: Curve object pointer. **/ -/** @ pstPoint[in]: Point data will be removed. **/ -/** Return: None. **/ +/** Function Name: SGUI_Curve_CalculatePointPosition **/ +/** Purpose: Calculate point position according to point X and Y **/ +/** value and curve display area layout. **/ +/** Params: **/ +/** @ pstObj[in]: Curve object pointer. **/ +/** @ pstPoint[in]: Point data will be removed. **/ +/** Return: None. **/ /*************************************************************************/ void SGUI_Curve_CalculatePointPosition(SGUI_CURVE_STRUCT* pstObj, SGUI_CURVE_POINT* pstPoint) { - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if((NULL != pstObj) && (NULL != pstPoint)) - { - pstPoint->stPosition.iX = (RECT_WIDTH(pstObj->stParam.stLayout)-1)*(pstPoint->stPoint.iX-pstObj->stParam.stXRange.iMin)/(RANGE_SIZE(pstObj->stParam.stXRange)-1); - pstPoint->stPosition.iY = (RECT_HEIGHT(pstObj->stParam.stLayout)-1)*(pstPoint->stPoint.iY-pstObj->stParam.stYRange.iMin)/(RANGE_SIZE(pstObj->stParam.stYRange)-1); - pstPoint->stPosition.iX += pstObj->stParam.stLayout.iX; - pstPoint->stPosition.iY = (RECT_HEIGHT(pstObj->stParam.stLayout)-1)-pstPoint->stPosition.iY; - pstPoint->stPosition.iY += pstObj->stParam.stLayout.iY; - } + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if((NULL != pstObj) && (NULL != pstPoint)) + { + pstPoint->stPosition.iX = (RECT_WIDTH(pstObj->stParam.stLayout)-1)*(pstPoint->stPoint.iX-pstObj->stParam.stXRange.iMin)/(RANGE_SIZE(pstObj->stParam.stXRange)-1); + pstPoint->stPosition.iY = (RECT_HEIGHT(pstObj->stParam.stLayout)-1)*(pstPoint->stPoint.iY-pstObj->stParam.stYRange.iMin)/(RANGE_SIZE(pstObj->stParam.stYRange)-1); + pstPoint->stPosition.iX += pstObj->stParam.stLayout.iX; + pstPoint->stPosition.iY = (RECT_HEIGHT(pstObj->stParam.stLayout)-1)-pstPoint->stPosition.iY; + pstPoint->stPosition.iY += pstObj->stParam.stLayout.iY; + } } /*************************************************************************/ -/** Function Name: SGUI_Curve_FocusPoint **/ -/** Purpose: Set focus on a point according to given index start **/ -/** at 0. **/ -/** Params: **/ -/** @ pstObj[in]: Curve object pointer. **/ -/** @ iIndex[in]: Index start at 0 form the head point. **/ -/** Return: Focused point object pointer. NULL pointer will be **/ -/** returned when index is invalid. **/ +/** Function Name: SGUI_Curve_FocusPoint **/ +/** Purpose: Set focus on a point according to given index start **/ +/** at 0. **/ +/** Params: **/ +/** @ pstObj[in]: Curve object pointer. **/ +/** @ iIndex[in]: Index start at 0 form the head point. **/ +/** Return: Focused point object pointer. NULL pointer will be **/ +/** returned when index is invalid. **/ /*************************************************************************/ SGUI_CURVE_POINT* SGUI_Curve_FocusPoint(SGUI_CURVE_STRUCT* pstObj, SGUI_INT iIndex) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_CURVE_POINT* pstFocusedPoint; - - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - pstFocusedPoint = NULL; - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if(NULL != pstObj) - { - pstFocusedPoint = pstObj->stData.stPoints.pstHead; - while((iIndex>0) && (NULL != pstFocusedPoint)) - { - pstFocusedPoint = pstFocusedPoint->pstNext; - iIndex--; - } - - pstObj->stData.pstFocused = pstFocusedPoint; - } - return pstFocusedPoint; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_CURVE_POINT* pstFocusedPoint; + + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + pstFocusedPoint = NULL; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(NULL != pstObj) + { + pstFocusedPoint = pstObj->stData.stPoints.pstHead; + while((iIndex>0) && (NULL != pstFocusedPoint)) + { + pstFocusedPoint = pstFocusedPoint->pstNext; + iIndex--; + } + + pstObj->stData.pstFocused = pstFocusedPoint; + } + return pstFocusedPoint; } /*************************************************************************/ -/** Function Name: SGUI_Curve_UpdateFocusPoint **/ -/** Purpose: Update focused point value. **/ -/** Params: **/ -/** @ pstObj[in]: Curve object pointer. **/ -/** @ iX[in]: New X value for focused point. **/ -/** @ iY[in]: New Y value for focused point. **/ -/** Return: **/ -/** @ SGUI_TRUE New value set successfully. **/ -/** @ SGUI_FALSE: Curve object is invalid or no focused point. **/ +/** Function Name: SGUI_Curve_UpdateFocusPoint **/ +/** Purpose: Update focused point value. **/ +/** Params: **/ +/** @ pstObj[in]: Curve object pointer. **/ +/** @ iX[in]: New X value for focused point. **/ +/** @ iY[in]: New Y value for focused point. **/ +/** Return: **/ +/** @ SGUI_TRUE New value set successfully. **/ +/** @ SGUI_FALSE: Curve object is invalid or no focused point. **/ /*************************************************************************/ SGUI_BOOL SGUI_Curve_UpdateFocusPoint(SGUI_CURVE_STRUCT* pstObj, SGUI_INT iX, SGUI_INT iY) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_BOOL bReturn; - SGUI_CURVE_POINT* pstFocusedPoint; - - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - bReturn = SGUI_FALSE; - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if(NULL == pstObj) - { - /* Invalid parameter. */ - bReturn = SGUI_FALSE; - } - else - { - do - { + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_BOOL bReturn; + SGUI_CURVE_POINT* pstFocusedPoint; + + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + bReturn = SGUI_FALSE; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(NULL == pstObj) + { + /* Invalid parameter. */ + bReturn = SGUI_FALSE; + } + else + { + do + { if(NULL == pstObj->stData.pstFocused) - { - bReturn = SGUI_FALSE; - break; - } - pstFocusedPoint = pstObj->stData.pstFocused; - /* Check point X value. */ - if((pstObj->stData.pstFocused == pstObj->stData.stPoints.pstHead) || (pstObj->stData.pstFocused == pstObj->stData.stPoints.pstEnd)) - { - /* Cannot change X value when focused point is head or end. */ - iX = pstObj->stData.pstFocused->stPoint.iX; - } - else - { - if(NULL == pstObj->stData.pstFocused->pstPrev) - { - iX = SGUI_MAX_OF(pstObj->stParam.stXRange.iMin, iX); - } - else - { - iX = SGUI_MAX_OF(pstFocusedPoint->pstPrev->stPoint.iX, iX); - } - if(NULL == pstObj->stData.pstFocused->pstNext) - { - iX = SGUI_MIN_OF(pstObj->stParam.stXRange.iMax, iX); - } - else - { - iX = SGUI_MIN_OF(pstFocusedPoint->pstNext->stPoint.iX, iX); - } - } - /* Check point Y value. */ - iY = SGUI_MAX_OF(pstObj->stParam.stYRange.iMin, iY); - iY = SGUI_MIN_OF(pstObj->stParam.stYRange.iMax, iY); - - pstFocusedPoint->stPoint.iX = iX; - pstFocusedPoint->stPoint.iY = iY; - /* Recalculate point position. */ - SGUI_Curve_CalculatePointPosition(pstObj, pstFocusedPoint); - bReturn = SGUI_TRUE; - }while(0); - } - return bReturn; + { + bReturn = SGUI_FALSE; + break; + } + pstFocusedPoint = pstObj->stData.pstFocused; + /* Check point X value. */ + if((pstObj->stData.pstFocused == pstObj->stData.stPoints.pstHead) || (pstObj->stData.pstFocused == pstObj->stData.stPoints.pstEnd)) + { + /* Cannot change X value when focused point is head or end. */ + iX = pstObj->stData.pstFocused->stPoint.iX; + } + else + { + if(NULL == pstObj->stData.pstFocused->pstPrev) + { + iX = SGUI_MAX_OF(pstObj->stParam.stXRange.iMin, iX); + } + else + { + iX = SGUI_MAX_OF(pstFocusedPoint->pstPrev->stPoint.iX, iX); + } + if(NULL == pstObj->stData.pstFocused->pstNext) + { + iX = SGUI_MIN_OF(pstObj->stParam.stXRange.iMax, iX); + } + else + { + iX = SGUI_MIN_OF(pstFocusedPoint->pstNext->stPoint.iX, iX); + } + } + /* Check point Y value. */ + iY = SGUI_MAX_OF(pstObj->stParam.stYRange.iMin, iY); + iY = SGUI_MIN_OF(pstObj->stParam.stYRange.iMax, iY); + + pstFocusedPoint->stPoint.iX = iX; + pstFocusedPoint->stPoint.iY = iY; + /* Recalculate point position. */ + SGUI_Curve_CalculatePointPosition(pstObj, pstFocusedPoint); + bReturn = SGUI_TRUE; + }while(0); + } + return bReturn; } /*************************************************************************/ -/** Function Name: SGUI_Curve_HighlightFocus **/ -/** Purpose: Paint a highlight cursor for focused point. **/ -/** Params: **/ -/** @ pstDeviceIF[in]: Device driver object pointer. **/ -/** @ pstObj[in]: Curve object pointer. **/ -/** Return: None. **/ +/** Function Name: SGUI_Curve_HighlightFocus **/ +/** Purpose: Paint a highlight cursor for focused point. **/ +/** Params: **/ +/** @ pstDeviceIF[in]: Device driver object pointer. **/ +/** @ pstObj[in]: Curve object pointer. **/ +/** Return: None. **/ /*************************************************************************/ void SGUI_Curve_HighlightFocus(SGUI_SCR_DEV* pstDeviceIF, SGUI_CURVE_STRUCT* pstObj) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_RECT stHighlightArea; - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if((NULL != pstDeviceIF) && (NULL != pstObj)) - { - if(NULL != pstObj->stData.pstFocused) - { - stHighlightArea.iX = pstObj->stData.pstFocused->stPosition.iX-2; - stHighlightArea.iY = pstObj->stData.pstFocused->stPosition.iY-2; - stHighlightArea.iWidth = 5; - stHighlightArea.iHeight = 5; - - if(RECT_X_START(stHighlightArea) <= RECT_X_START(pstObj->stParam.stLayout)) - { - stHighlightArea.iWidth -= (RECT_X_START(pstObj->stParam.stLayout)-stHighlightArea.iX); - stHighlightArea.iX = RECT_X_START(pstObj->stParam.stLayout); - } - - if(RECT_X_END(stHighlightArea) >= RECT_X_END(pstObj->stParam.stLayout)) - { - stHighlightArea.iWidth -= (RECT_X_END(stHighlightArea)-RECT_X_END(pstObj->stParam.stLayout)); - } - - if(RECT_Y_START(stHighlightArea) <= RECT_Y_START(pstObj->stParam.stLayout)) - { - stHighlightArea.iHeight -= (RECT_Y_START(pstObj->stParam.stLayout)-stHighlightArea.iY); - stHighlightArea.iY = RECT_Y_START(pstObj->stParam.stLayout); - } - - if(RECT_Y_END(stHighlightArea) >= RECT_Y_END(pstObj->stParam.stLayout)) - { - stHighlightArea.iHeight -= (RECT_Y_END(stHighlightArea)-RECT_Y_END(pstObj->stParam.stLayout)); - } - - SGUI_Basic_ReverseBlockColor(pstDeviceIF, stHighlightArea.iX, stHighlightArea.iY, stHighlightArea.iWidth, stHighlightArea.iHeight); - } - } + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_RECT stHighlightArea; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if((NULL != pstDeviceIF) && (NULL != pstObj)) + { + if(NULL != pstObj->stData.pstFocused) + { + stHighlightArea.iX = pstObj->stData.pstFocused->stPosition.iX-2; + stHighlightArea.iY = pstObj->stData.pstFocused->stPosition.iY-2; + stHighlightArea.iWidth = 5; + stHighlightArea.iHeight = 5; + + if(RECT_X_START(stHighlightArea) <= RECT_X_START(pstObj->stParam.stLayout)) + { + stHighlightArea.iWidth -= (RECT_X_START(pstObj->stParam.stLayout)-stHighlightArea.iX); + stHighlightArea.iX = RECT_X_START(pstObj->stParam.stLayout); + } + + if(RECT_X_END(stHighlightArea) >= RECT_X_END(pstObj->stParam.stLayout)) + { + stHighlightArea.iWidth -= (RECT_X_END(stHighlightArea)-RECT_X_END(pstObj->stParam.stLayout)); + } + + if(RECT_Y_START(stHighlightArea) <= RECT_Y_START(pstObj->stParam.stLayout)) + { + stHighlightArea.iHeight -= (RECT_Y_START(pstObj->stParam.stLayout)-stHighlightArea.iY); + stHighlightArea.iY = RECT_Y_START(pstObj->stParam.stLayout); + } + + if(RECT_Y_END(stHighlightArea) >= RECT_Y_END(pstObj->stParam.stLayout)) + { + stHighlightArea.iHeight -= (RECT_Y_END(stHighlightArea)-RECT_Y_END(pstObj->stParam.stLayout)); + } + + SGUI_Basic_ReverseBlockColor(pstDeviceIF, stHighlightArea.iX, stHighlightArea.iY, stHighlightArea.iWidth, stHighlightArea.iHeight); + } + } } /*************************************************************************/ -/** Function Name: SGUI_Curve_PointIsHighlight **/ -/** Purpose: Judge curve point is in highlight state. **/ -/** Params: **/ -/** @ pstDeviceIF[in]: Device driver object pointer. **/ -/** @ pstPoint[in]: Point object will be judged. **/ -/** Return: **/ -/** @ SGUI_TRUE Point is highlight. **/ -/** @ SGUI_FALSE: Point is not highlight. **/ +/** Function Name: SGUI_Curve_PointIsHighlight **/ +/** Purpose: Judge curve point is in highlight state. **/ +/** Params: **/ +/** @ pstDeviceIF[in]: Device driver object pointer. **/ +/** @ pstPoint[in]: Point object will be judged. **/ +/** Return: **/ +/** @ SGUI_TRUE Point is highlight. **/ +/** @ SGUI_FALSE: Point is not highlight. **/ /*************************************************************************/ SGUI_BOOL SGUI_Curve_PointIsHighlight(SGUI_SCR_DEV* pstDeviceIF, SGUI_CURVE_POINT* pstPoint) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_BOOL bReturn; - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if((NULL != pstDeviceIF) && (NULL != pstPoint)) - { - bReturn = (SGUI_COLOR_BKGCLR==SGUI_Basic_GetPoint(pstDeviceIF, pstPoint->stPosition.iX, pstPoint->stPosition.iY))?SGUI_TRUE:SGUI_FALSE; - } - else - { - bReturn = SGUI_FALSE; - } - - return bReturn; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_BOOL bReturn; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if((NULL != pstDeviceIF) && (NULL != pstPoint)) + { + bReturn = (SGUI_COLOR_BKGCLR==SGUI_Basic_GetPoint(pstDeviceIF, pstPoint->stPosition.iX, pstPoint->stPosition.iY))?SGUI_TRUE:SGUI_FALSE; + } + else + { + bReturn = SGUI_FALSE; + } + + return bReturn; } diff --git a/GUI/src/SGUI_FontResource.c b/GUI/src/SGUI_FontResource.c index f76d68fd7e8bb73cbc7c1b6fa68f70175af9ff7d..5cd919d48173a62e62e4c365d7f9b76426180ae1 100644 --- a/GUI/src/SGUI_FontResource.c +++ b/GUI/src/SGUI_FontResource.c @@ -1,113 +1,113 @@ /*************************************************************************/ -/** Copyright. **/ -/** FileName: SGUI_FontResource.c **/ -/** Author: Polarix **/ -/** Description: Internal font data. **/ +/** Copyright. **/ +/** FileName: SGUI_FontResource.c **/ +/** Author: Polarix **/ +/** Description: Internal font data. **/ /*************************************************************************/ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "SGUI_Common.h" #include "SGUI_FontResource.h" //=======================================================================// -//= User Macro definition. =// +//= User Macro definition. =// //=======================================================================// -#define SGUI_FONT_RES_DECLARE(NAME) SGUI_SIZE SGUI_Resource_GetFontData_##NAME(SGUI_SIZE sStartAddr, SGUI_BYTE* pDataBuffer, SGUI_SIZE sReadSize) -#define SGUI_FONT_RES_DEFINE(NAME, SRC) SGUI_SIZE SGUI_Resource_GetFontData_##NAME(SGUI_SIZE sStartAddr, SGUI_BYTE* pDataBuffer, SGUI_SIZE sReadSize)\ - {\ - SGUI_SIZE sReadCount;\ - const SGUI_BYTE* pSrc = SRC+sStartAddr;\ - SGUI_BYTE* pDest = pDataBuffer;\ - if(NULL != pDataBuffer)\ - {\ - for(sReadCount=0; sReadCount -0x02, 0x01, 0x51, 0x09, 0x06, 0x00, // ? -0x32, 0x49, 0x79, 0x41, 0x3E, 0x00, // @ -0x7E, 0x11, 0x11, 0x11, 0x7E, 0x00, // A -0x7F, 0x49, 0x49, 0x49, 0x36, 0x00, // B -0x3E, 0x41, 0x41, 0x41, 0x22, 0x00, // C -0x7F, 0x41, 0x41, 0x22, 0x1C, 0x00, // D -0x7F, 0x49, 0x49, 0x49, 0x41, 0x00, // E -0x7F, 0x09, 0x09, 0x01, 0x01, 0x00, // F -0x3E, 0x41, 0x41, 0x51, 0x32, 0x00, // G -0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, // H -0x00, 0x41, 0x7F, 0x41, 0x00, 0x00, // I -0x20, 0x40, 0x41, 0x3F, 0x01, 0x00, // J -0x7F, 0x08, 0x14, 0x22, 0x41, 0x00, // K -0x7F, 0x40, 0x40, 0x40, 0x40, 0x00, // L -0x7F, 0x02, 0x04, 0x02, 0x7F, 0x00, // M -0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00, // N -0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00, // O -0x7F, 0x09, 0x09, 0x09, 0x06, 0x00, // P -0x3E, 0x41, 0x51, 0x21, 0x5E, 0x00, // Q -0x7F, 0x09, 0x19, 0x29, 0x46, 0x00, // R -0x46, 0x49, 0x49, 0x49, 0x31, 0x00, // S -0x01, 0x01, 0x7F, 0x01, 0x01, 0x00, // T -0x3F, 0x40, 0x40, 0x40, 0x3F, 0x00, // U -0x1F, 0x20, 0x40, 0x20, 0x1F, 0x00, // V -0x7F, 0x20, 0x18, 0x20, 0x7F, 0x00, // W -0x63, 0x14, 0x08, 0x14, 0x63, 0x00, // X -0x03, 0x04, 0x78, 0x04, 0x03, 0x00, // Y -0x61, 0x51, 0x49, 0x45, 0x43, 0x00, // Z -0x00, 0x00, 0x7F, 0x41, 0x41, 0x00, // [ -0x02, 0x04, 0x08, 0x10, 0x20, 0x00, // "\" -0x41, 0x41, 0x7F, 0x00, 0x00, 0x00, // ] -0x04, 0x02, 0x01, 0x02, 0x04, 0x00, // ^ -0x40, 0x40, 0x40, 0x40, 0x40, 0x00, // _ -0x00, 0x01, 0x02, 0x04, 0x00, 0x00, // ` -0x20, 0x54, 0x54, 0x54, 0x78, 0x00, // a -0x7F, 0x48, 0x44, 0x44, 0x38, 0x00, // b -0x38, 0x44, 0x44, 0x44, 0x20, 0x00, // c -0x38, 0x44, 0x44, 0x48, 0x7F, 0x00, // d -0x38, 0x54, 0x54, 0x54, 0x18, 0x00, // e -0x08, 0x7E, 0x09, 0x01, 0x02, 0x00, // f -0x08, 0x14, 0x54, 0x54, 0x3C, 0x00, // g -0x7F, 0x08, 0x04, 0x04, 0x78, 0x00, // h -0x00, 0x44, 0x7D, 0x40, 0x00, 0x00, // i -0x20, 0x40, 0x44, 0x3D, 0x00, 0x00, // j -0x00, 0x7F, 0x10, 0x28, 0x44, 0x00, // k -0x00, 0x41, 0x7F, 0x40, 0x00, 0x00, // l -0x7C, 0x04, 0x18, 0x04, 0x78, 0x00, // m -0x7C, 0x08, 0x04, 0x04, 0x78, 0x00, // n -0x38, 0x44, 0x44, 0x44, 0x38, 0x00, // o -0x7C, 0x14, 0x14, 0x14, 0x08, 0x00, // p -0x08, 0x14, 0x14, 0x18, 0x7C, 0x00, // q -0x7C, 0x08, 0x04, 0x04, 0x08, 0x00, // r -0x48, 0x54, 0x54, 0x54, 0x20, 0x00, // s -0x04, 0x3F, 0x44, 0x40, 0x20, 0x00, // t -0x3C, 0x40, 0x40, 0x20, 0x7C, 0x00, // u -0x1C, 0x20, 0x40, 0x20, 0x1C, 0x00, // v -0x3C, 0x40, 0x30, 0x40, 0x3C, 0x00, // w -0x44, 0x28, 0x10, 0x28, 0x44, 0x00, // x -0x0C, 0x50, 0x50, 0x50, 0x3C, 0x00, // y -0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, // z -0x00, 0x08, 0x36, 0x41, 0x00, 0x00, // { -0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, // | -0x00, 0x41, 0x36, 0x08, 0x00, 0x00, // } -0x00, 0x01, 0x02, 0x00, 0x00, 0x00 // ` index 94 +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // space index 0 +0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, // ! +0x00, 0x07, 0x00, 0x07, 0x00, 0x00, // " +0x14, 0x7F, 0x14, 0x7F, 0x14, 0x00, // # +0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x00, // $ +0x23, 0x13, 0x08, 0x64, 0x62, 0x00, // % +0x36, 0x49, 0x55, 0x22, 0x50, 0x00, // & +0x00, 0x05, 0x03, 0x00, 0x00, 0x00, // ' +0x00, 0x1C, 0x22, 0x41, 0x00, 0x00, // ( +0x00, 0x41, 0x22, 0x1C, 0x00, 0x00, // ) +0x08, 0x2A, 0x1C, 0x2A, 0x08, 0x00, // * +0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, // + +0x00, 0x50, 0x30, 0x00, 0x00, 0x00, // , +0x08, 0x08, 0x08, 0x08, 0x08, 0x00, // - +0x00, 0x30, 0x30, 0x00, 0x00, 0x00, // . +0x20, 0x10, 0x08, 0x04, 0x02, 0x00, // / +0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00, // 0 +0x00, 0x42, 0x7F, 0x40, 0x00, 0x00, // 1 +0x42, 0x61, 0x51, 0x49, 0x46, 0x00, // 2 +0x21, 0x41, 0x45, 0x4B, 0x31, 0x00, // 3 +0x18, 0x14, 0x12, 0x7F, 0x10, 0x00, // 4 +0x27, 0x45, 0x45, 0x45, 0x39, 0x00, // 5 +0x3C, 0x4A, 0x49, 0x49, 0x30, 0x00, // 6 +0x01, 0x71, 0x09, 0x05, 0x03, 0x00, // 7 +0x36, 0x49, 0x49, 0x49, 0x36, 0x00, // 8 +0x06, 0x49, 0x49, 0x29, 0x1E, 0x00, // 9 +0x00, 0x36, 0x36, 0x00, 0x00, 0x00, // : +0x00, 0x56, 0x36, 0x00, 0x00, 0x00, // ; +0x00, 0x08, 0x14, 0x22, 0x41, 0x00, // < +0x14, 0x14, 0x14, 0x14, 0x14, 0x00, // = +0x41, 0x22, 0x14, 0x08, 0x00, 0x00, // > +0x02, 0x01, 0x51, 0x09, 0x06, 0x00, // ? +0x32, 0x49, 0x79, 0x41, 0x3E, 0x00, // @ +0x7E, 0x11, 0x11, 0x11, 0x7E, 0x00, // A +0x7F, 0x49, 0x49, 0x49, 0x36, 0x00, // B +0x3E, 0x41, 0x41, 0x41, 0x22, 0x00, // C +0x7F, 0x41, 0x41, 0x22, 0x1C, 0x00, // D +0x7F, 0x49, 0x49, 0x49, 0x41, 0x00, // E +0x7F, 0x09, 0x09, 0x01, 0x01, 0x00, // F +0x3E, 0x41, 0x41, 0x51, 0x32, 0x00, // G +0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, // H +0x00, 0x41, 0x7F, 0x41, 0x00, 0x00, // I +0x20, 0x40, 0x41, 0x3F, 0x01, 0x00, // J +0x7F, 0x08, 0x14, 0x22, 0x41, 0x00, // K +0x7F, 0x40, 0x40, 0x40, 0x40, 0x00, // L +0x7F, 0x02, 0x04, 0x02, 0x7F, 0x00, // M +0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00, // N +0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00, // O +0x7F, 0x09, 0x09, 0x09, 0x06, 0x00, // P +0x3E, 0x41, 0x51, 0x21, 0x5E, 0x00, // Q +0x7F, 0x09, 0x19, 0x29, 0x46, 0x00, // R +0x46, 0x49, 0x49, 0x49, 0x31, 0x00, // S +0x01, 0x01, 0x7F, 0x01, 0x01, 0x00, // T +0x3F, 0x40, 0x40, 0x40, 0x3F, 0x00, // U +0x1F, 0x20, 0x40, 0x20, 0x1F, 0x00, // V +0x7F, 0x20, 0x18, 0x20, 0x7F, 0x00, // W +0x63, 0x14, 0x08, 0x14, 0x63, 0x00, // X +0x03, 0x04, 0x78, 0x04, 0x03, 0x00, // Y +0x61, 0x51, 0x49, 0x45, 0x43, 0x00, // Z +0x00, 0x00, 0x7F, 0x41, 0x41, 0x00, // [ +0x02, 0x04, 0x08, 0x10, 0x20, 0x00, // "\" +0x41, 0x41, 0x7F, 0x00, 0x00, 0x00, // ] +0x04, 0x02, 0x01, 0x02, 0x04, 0x00, // ^ +0x40, 0x40, 0x40, 0x40, 0x40, 0x00, // _ +0x00, 0x01, 0x02, 0x04, 0x00, 0x00, // ` +0x20, 0x54, 0x54, 0x54, 0x78, 0x00, // a +0x7F, 0x48, 0x44, 0x44, 0x38, 0x00, // b +0x38, 0x44, 0x44, 0x44, 0x20, 0x00, // c +0x38, 0x44, 0x44, 0x48, 0x7F, 0x00, // d +0x38, 0x54, 0x54, 0x54, 0x18, 0x00, // e +0x08, 0x7E, 0x09, 0x01, 0x02, 0x00, // f +0x08, 0x14, 0x54, 0x54, 0x3C, 0x00, // g +0x7F, 0x08, 0x04, 0x04, 0x78, 0x00, // h +0x00, 0x44, 0x7D, 0x40, 0x00, 0x00, // i +0x20, 0x40, 0x44, 0x3D, 0x00, 0x00, // j +0x00, 0x7F, 0x10, 0x28, 0x44, 0x00, // k +0x00, 0x41, 0x7F, 0x40, 0x00, 0x00, // l +0x7C, 0x04, 0x18, 0x04, 0x78, 0x00, // m +0x7C, 0x08, 0x04, 0x04, 0x78, 0x00, // n +0x38, 0x44, 0x44, 0x44, 0x38, 0x00, // o +0x7C, 0x14, 0x14, 0x14, 0x08, 0x00, // p +0x08, 0x14, 0x14, 0x18, 0x7C, 0x00, // q +0x7C, 0x08, 0x04, 0x04, 0x08, 0x00, // r +0x48, 0x54, 0x54, 0x54, 0x20, 0x00, // s +0x04, 0x3F, 0x44, 0x40, 0x20, 0x00, // t +0x3C, 0x40, 0x40, 0x20, 0x7C, 0x00, // u +0x1C, 0x20, 0x40, 0x20, 0x1C, 0x00, // v +0x3C, 0x40, 0x30, 0x40, 0x3C, 0x00, // w +0x44, 0x28, 0x10, 0x28, 0x44, 0x00, // x +0x0C, 0x50, 0x50, 0x50, 0x3C, 0x00, // y +0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, // z +0x00, 0x08, 0x36, 0x41, 0x00, 0x00, // { +0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, // | +0x00, 0x41, 0x36, 0x08, 0x00, 0x00, // } +0x00, 0x01, 0x02, 0x00, 0x00, 0x00 // ` index 94 }; //======================================================================// -//= 12 Pix font library. // +//= 12 Pix font library. // //======================================================================// const SGUI_CBYTE SGUI_FONT_H12[] = { -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // space Index 0 -0x00, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, // ! -0x00, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // " -0x90, 0xD0, 0xBC, 0xD0, 0xBC, 0x90, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, // # -0x18, 0x24, 0xFE, 0x44, 0x88, 0x00, 0x01, 0x02, 0x07, 0x02, 0x01, 0x00, // $ -0x18, 0x24, 0xD8, 0xB0, 0x4C, 0x80, 0x00, 0x03, 0x00, 0x01, 0x02, 0x01, // % -0xC0, 0x38, 0xE4, 0x38, 0x80, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, // & -0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ' -0x00, 0x00, 0x00, 0xF0, 0x0C, 0x02, 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, // ( -0x02, 0x0C, 0xF0, 0x00, 0x00, 0x00, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, // ) -0x90, 0x60, 0xF8, 0x60, 0x90, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, // * -0x20, 0x20, 0xFC, 0x20, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, // + -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x06, 0x00, 0x00, 0x00, 0x00, // , -0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // - -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, // . -0x00, 0x80, 0x60, 0x18, 0x06, 0x00, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, // / -0xF8, 0x04, 0x04, 0x04, 0xF8, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // 0 -0x00, 0x08, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x02, 0x00, 0x00, // 1 -0x18, 0x84, 0x44, 0x24, 0x18, 0x00, 0x03, 0x02, 0x02, 0x02, 0x02, 0x00, // 2 -0x08, 0x04, 0x24, 0x24, 0xD8, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // 3 -0x40, 0xB0, 0x88, 0xFC, 0x80, 0x00, 0x00, 0x00, 0x02, 0x03, 0x02, 0x00, // 4 -0x3C, 0x24, 0x24, 0x24, 0xC4, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // 5 -0xF8, 0x24, 0x24, 0x24, 0xC8, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // 6 -0x0C, 0x04, 0xE4, 0x14, 0x0C, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, // 7 -0xD8, 0x24, 0x24, 0x24, 0xD8, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // 8 -0x38, 0x44, 0x44, 0x44, 0xF8, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // 9 -0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, // : -0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x04, 0x03, 0x00, 0x00, 0x00, // ; -0x00, 0x20, 0x50, 0x88, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, // < -0x90, 0x90, 0x90, 0x90, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // = -0x00, 0x02, 0x04, 0x88, 0x50, 0x20, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, // > -0x18, 0x04, 0xC4, 0x24, 0x18, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, // ? -0xF8, 0x04, 0xE4, 0x94, 0x78, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, // @ -0x00, 0xF0, 0x9C, 0x9C, 0xF0, 0x00, 0x02, 0x03, 0x00, 0x00, 0x03, 0x02, // A -0x04, 0xFC, 0x24, 0x24, 0xD8, 0x00, 0x02, 0x03, 0x02, 0x02, 0x01, 0x00, // B -0xF8, 0x04, 0x04, 0x04, 0x08, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // C -0x04, 0xFC, 0x04, 0x04, 0xF8, 0x00, 0x02, 0x03, 0x02, 0x02, 0x01, 0x00, // D -0x04, 0xFC, 0x24, 0x74, 0x0C, 0x00, 0x02, 0x03, 0x02, 0x02, 0x03, 0x00, // E -0x04, 0xFC, 0x24, 0x74, 0x0C, 0x00, 0x02, 0x03, 0x02, 0x00, 0x00, 0x00, // F -0xF8, 0x04, 0x04, 0x44, 0xCC, 0x40, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // G -0x04, 0xFC, 0x20, 0x20, 0xFC, 0x04, 0x02, 0x03, 0x00, 0x00, 0x03, 0x02, // H -0x04, 0x04, 0xFC, 0x04, 0x04, 0x00, 0x02, 0x02, 0x03, 0x02, 0x02, 0x00, // I -0x00, 0x04, 0x04, 0xFC, 0x04, 0x04, 0x02, 0x04, 0x04, 0x03, 0x00, 0x00, // J -0x04, 0xFC, 0x24, 0xD0, 0x0C, 0x04, 0x02, 0x03, 0x02, 0x00, 0x03, 0x02, // K -0x04, 0xFC, 0x04, 0x00, 0x00, 0x00, 0x02, 0x03, 0x02, 0x02, 0x02, 0x03, // L -0xFC, 0x3C, 0xC0, 0x3C, 0xFC, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, // M -0x04, 0xFC, 0x30, 0xC4, 0xFC, 0x04, 0x02, 0x03, 0x02, 0x00, 0x03, 0x02, // N -0xF8, 0x04, 0x04, 0x04, 0xF8, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // O -0x04, 0xFC, 0x24, 0x24, 0x18, 0x00, 0x02, 0x03, 0x02, 0x00, 0x00, 0x00, // P -0xF8, 0x84, 0x84, 0x04, 0xF8, 0x00, 0x01, 0x02, 0x02, 0x07, 0x04, 0x00, // Q -0x04, 0xFC, 0x24, 0x64, 0x98, 0x00, 0x02, 0x03, 0x02, 0x00, 0x03, 0x02, // R -0x18, 0x24, 0x24, 0x44, 0x88, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // S -0x0C, 0x04, 0xFC, 0x04, 0x0C, 0x00, 0x00, 0x02, 0x03, 0x02, 0x00, 0x00, // T -0x04, 0xFC, 0x00, 0x00, 0xFC, 0x04, 0x00, 0x01, 0x02, 0x02, 0x01, 0x00, // U -0x04, 0x7C, 0x80, 0x80, 0x7C, 0x04, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, // V -0x1C, 0xE0, 0x3C, 0xE0, 0x1C, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, // W -0x04, 0x9C, 0x60, 0x9C, 0x04, 0x00, 0x02, 0x03, 0x00, 0x03, 0x02, 0x00, // X -0x04, 0x1C, 0xE0, 0x1C, 0x04, 0x00, 0x00, 0x02, 0x03, 0x02, 0x00, 0x00, // Y -0x0C, 0x84, 0x64, 0x1C, 0x04, 0x00, 0x02, 0x03, 0x02, 0x02, 0x03, 0x00, // Z -0x00, 0x00, 0xFE, 0x02, 0x02, 0x00, 0x00, 0x00, 0x07, 0x04, 0x04, 0x00, // [ -0x00, 0x0E, 0x30, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, // '\' -0x00, 0x02, 0x02, 0xFE, 0x00, 0x00, 0x00, 0x04, 0x04, 0x07, 0x00, 0x00, // ] -0x00, 0x04, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ^ -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, // _ -0x00, 0x00, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ` -0x00, 0x40, 0xA0, 0xA0, 0xC0, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, // a -0x04, 0xFC, 0x20, 0x20, 0xC0, 0x00, 0x00, 0x03, 0x02, 0x02, 0x01, 0x00, // b -0x00, 0xC0, 0x20, 0x20, 0x60, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, // c -0x00, 0xC0, 0x20, 0x24, 0xFC, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, // d -0x00, 0xC0, 0xA0, 0xA0, 0xC0, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, // e -0x00, 0x20, 0xF8, 0x24, 0x24, 0x04, 0x00, 0x02, 0x03, 0x02, 0x02, 0x00, // f -0x00, 0x40, 0xA0, 0xA0, 0x60, 0x20, 0x00, 0x07, 0x0A, 0x0A, 0x0A, 0x04, // g -0x04, 0xFC, 0x20, 0x20, 0xC0, 0x00, 0x02, 0x03, 0x00, 0x00, 0x03, 0x02, // h -0x00, 0x20, 0xE4, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x02, 0x00, 0x00, // i -0x00, 0x00, 0x20, 0xE4, 0x00, 0x00, 0x08, 0x08, 0x08, 0x07, 0x00, 0x00, // j -0x04, 0xFC, 0x80, 0xA0, 0x60, 0x20, 0x02, 0x03, 0x02, 0x00, 0x03, 0x02, // k -0x04, 0x04, 0xFC, 0x00, 0x00, 0x00, 0x02, 0x02, 0x03, 0x02, 0x02, 0x00, // l -0xE0, 0x20, 0xE0, 0x20, 0xC0, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, // m -0x20, 0xE0, 0x20, 0x20, 0xC0, 0x00, 0x02, 0x03, 0x02, 0x00, 0x03, 0x02, // n -0x00, 0xC0, 0x20, 0x20, 0xC0, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x00, // o -0x20, 0xE0, 0x20, 0x20, 0xC0, 0x00, 0x08, 0x0F, 0x0A, 0x02, 0x01, 0x00, // p -0x00, 0xC0, 0x20, 0x20, 0xE0, 0x00, 0x00, 0x01, 0x02, 0x0A, 0x0F, 0x08, // q -0x20, 0xE0, 0x40, 0x20, 0x20, 0x00, 0x02, 0x03, 0x02, 0x00, 0x00, 0x00, // r -0x00, 0x40, 0xA0, 0xA0, 0x20, 0x00, 0x00, 0x02, 0x02, 0x02, 0x01, 0x00, // s -0x00, 0x20, 0xF8, 0x20, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, // t -0x20, 0xE0, 0x00, 0x20, 0xE0, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, // u -0x20, 0xE0, 0x00, 0x00, 0xE0, 0x20, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, // v -0x60, 0x80, 0xE0, 0x80, 0x60, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, // w -0x20, 0x60, 0x80, 0x60, 0x20, 0x00, 0x02, 0x03, 0x00, 0x03, 0x02, 0x00, // x -0x20, 0xE0, 0x20, 0x80, 0x60, 0x20, 0x08, 0x08, 0x07, 0x01, 0x00, 0x00, // y -0x00, 0x20, 0xA0, 0x60, 0x20, 0x00, 0x00, 0x02, 0x03, 0x02, 0x02, 0x00, // z -0x00, 0x00, 0x60, 0x9E, 0x02, 0x00, 0x00, 0x00, 0x00, 0x07, 0x04, 0x00, // { -0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, // | -0x00, 0x02, 0x9E, 0x60, 0x00, 0x00, 0x00, 0x04, 0x07, 0x00, 0x00, 0x00, // } -0x04, 0x02, 0x02, 0x04, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ~ Index 94 +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // space Index 0 +0x00, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, // ! +0x00, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // " +0x90, 0xD0, 0xBC, 0xD0, 0xBC, 0x90, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, // # +0x18, 0x24, 0xFE, 0x44, 0x88, 0x00, 0x01, 0x02, 0x07, 0x02, 0x01, 0x00, // $ +0x18, 0x24, 0xD8, 0xB0, 0x4C, 0x80, 0x00, 0x03, 0x00, 0x01, 0x02, 0x01, // % +0xC0, 0x38, 0xE4, 0x38, 0x80, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, // & +0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ' +0x00, 0x00, 0x00, 0xF0, 0x0C, 0x02, 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, // ( +0x02, 0x0C, 0xF0, 0x00, 0x00, 0x00, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, // ) +0x90, 0x60, 0xF8, 0x60, 0x90, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, // * +0x20, 0x20, 0xFC, 0x20, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, // + +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x06, 0x00, 0x00, 0x00, 0x00, // , +0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // - +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, // . +0x00, 0x80, 0x60, 0x18, 0x06, 0x00, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, // / +0xF8, 0x04, 0x04, 0x04, 0xF8, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // 0 +0x00, 0x08, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x02, 0x00, 0x00, // 1 +0x18, 0x84, 0x44, 0x24, 0x18, 0x00, 0x03, 0x02, 0x02, 0x02, 0x02, 0x00, // 2 +0x08, 0x04, 0x24, 0x24, 0xD8, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // 3 +0x40, 0xB0, 0x88, 0xFC, 0x80, 0x00, 0x00, 0x00, 0x02, 0x03, 0x02, 0x00, // 4 +0x3C, 0x24, 0x24, 0x24, 0xC4, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // 5 +0xF8, 0x24, 0x24, 0x24, 0xC8, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // 6 +0x0C, 0x04, 0xE4, 0x14, 0x0C, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, // 7 +0xD8, 0x24, 0x24, 0x24, 0xD8, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // 8 +0x38, 0x44, 0x44, 0x44, 0xF8, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // 9 +0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, // : +0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x04, 0x03, 0x00, 0x00, 0x00, // ; +0x00, 0x20, 0x50, 0x88, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, // < +0x90, 0x90, 0x90, 0x90, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // = +0x00, 0x02, 0x04, 0x88, 0x50, 0x20, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, // > +0x18, 0x04, 0xC4, 0x24, 0x18, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, // ? +0xF8, 0x04, 0xE4, 0x94, 0x78, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, // @ +0x00, 0xF0, 0x9C, 0x9C, 0xF0, 0x00, 0x02, 0x03, 0x00, 0x00, 0x03, 0x02, // A +0x04, 0xFC, 0x24, 0x24, 0xD8, 0x00, 0x02, 0x03, 0x02, 0x02, 0x01, 0x00, // B +0xF8, 0x04, 0x04, 0x04, 0x08, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // C +0x04, 0xFC, 0x04, 0x04, 0xF8, 0x00, 0x02, 0x03, 0x02, 0x02, 0x01, 0x00, // D +0x04, 0xFC, 0x24, 0x74, 0x0C, 0x00, 0x02, 0x03, 0x02, 0x02, 0x03, 0x00, // E +0x04, 0xFC, 0x24, 0x74, 0x0C, 0x00, 0x02, 0x03, 0x02, 0x00, 0x00, 0x00, // F +0xF8, 0x04, 0x04, 0x44, 0xCC, 0x40, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // G +0x04, 0xFC, 0x20, 0x20, 0xFC, 0x04, 0x02, 0x03, 0x00, 0x00, 0x03, 0x02, // H +0x04, 0x04, 0xFC, 0x04, 0x04, 0x00, 0x02, 0x02, 0x03, 0x02, 0x02, 0x00, // I +0x00, 0x04, 0x04, 0xFC, 0x04, 0x04, 0x02, 0x04, 0x04, 0x03, 0x00, 0x00, // J +0x04, 0xFC, 0x24, 0xD0, 0x0C, 0x04, 0x02, 0x03, 0x02, 0x00, 0x03, 0x02, // K +0x04, 0xFC, 0x04, 0x00, 0x00, 0x00, 0x02, 0x03, 0x02, 0x02, 0x02, 0x03, // L +0xFC, 0x3C, 0xC0, 0x3C, 0xFC, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, // M +0x04, 0xFC, 0x30, 0xC4, 0xFC, 0x04, 0x02, 0x03, 0x02, 0x00, 0x03, 0x02, // N +0xF8, 0x04, 0x04, 0x04, 0xF8, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // O +0x04, 0xFC, 0x24, 0x24, 0x18, 0x00, 0x02, 0x03, 0x02, 0x00, 0x00, 0x00, // P +0xF8, 0x84, 0x84, 0x04, 0xF8, 0x00, 0x01, 0x02, 0x02, 0x07, 0x04, 0x00, // Q +0x04, 0xFC, 0x24, 0x64, 0x98, 0x00, 0x02, 0x03, 0x02, 0x00, 0x03, 0x02, // R +0x18, 0x24, 0x24, 0x44, 0x88, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, // S +0x0C, 0x04, 0xFC, 0x04, 0x0C, 0x00, 0x00, 0x02, 0x03, 0x02, 0x00, 0x00, // T +0x04, 0xFC, 0x00, 0x00, 0xFC, 0x04, 0x00, 0x01, 0x02, 0x02, 0x01, 0x00, // U +0x04, 0x7C, 0x80, 0x80, 0x7C, 0x04, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, // V +0x1C, 0xE0, 0x3C, 0xE0, 0x1C, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, // W +0x04, 0x9C, 0x60, 0x9C, 0x04, 0x00, 0x02, 0x03, 0x00, 0x03, 0x02, 0x00, // X +0x04, 0x1C, 0xE0, 0x1C, 0x04, 0x00, 0x00, 0x02, 0x03, 0x02, 0x00, 0x00, // Y +0x0C, 0x84, 0x64, 0x1C, 0x04, 0x00, 0x02, 0x03, 0x02, 0x02, 0x03, 0x00, // Z +0x00, 0x00, 0xFE, 0x02, 0x02, 0x00, 0x00, 0x00, 0x07, 0x04, 0x04, 0x00, // [ +0x00, 0x0E, 0x30, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, // '\' +0x00, 0x02, 0x02, 0xFE, 0x00, 0x00, 0x00, 0x04, 0x04, 0x07, 0x00, 0x00, // ] +0x00, 0x04, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ^ +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, // _ +0x00, 0x00, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ` +0x00, 0x40, 0xA0, 0xA0, 0xC0, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, // a +0x04, 0xFC, 0x20, 0x20, 0xC0, 0x00, 0x00, 0x03, 0x02, 0x02, 0x01, 0x00, // b +0x00, 0xC0, 0x20, 0x20, 0x60, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, // c +0x00, 0xC0, 0x20, 0x24, 0xFC, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, // d +0x00, 0xC0, 0xA0, 0xA0, 0xC0, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, // e +0x00, 0x20, 0xF8, 0x24, 0x24, 0x04, 0x00, 0x02, 0x03, 0x02, 0x02, 0x00, // f +0x00, 0x40, 0xA0, 0xA0, 0x60, 0x20, 0x00, 0x07, 0x0A, 0x0A, 0x0A, 0x04, // g +0x04, 0xFC, 0x20, 0x20, 0xC0, 0x00, 0x02, 0x03, 0x00, 0x00, 0x03, 0x02, // h +0x00, 0x20, 0xE4, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x02, 0x00, 0x00, // i +0x00, 0x00, 0x20, 0xE4, 0x00, 0x00, 0x08, 0x08, 0x08, 0x07, 0x00, 0x00, // j +0x04, 0xFC, 0x80, 0xA0, 0x60, 0x20, 0x02, 0x03, 0x02, 0x00, 0x03, 0x02, // k +0x04, 0x04, 0xFC, 0x00, 0x00, 0x00, 0x02, 0x02, 0x03, 0x02, 0x02, 0x00, // l +0xE0, 0x20, 0xE0, 0x20, 0xC0, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, // m +0x20, 0xE0, 0x20, 0x20, 0xC0, 0x00, 0x02, 0x03, 0x02, 0x00, 0x03, 0x02, // n +0x00, 0xC0, 0x20, 0x20, 0xC0, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x00, // o +0x20, 0xE0, 0x20, 0x20, 0xC0, 0x00, 0x08, 0x0F, 0x0A, 0x02, 0x01, 0x00, // p +0x00, 0xC0, 0x20, 0x20, 0xE0, 0x00, 0x00, 0x01, 0x02, 0x0A, 0x0F, 0x08, // q +0x20, 0xE0, 0x40, 0x20, 0x20, 0x00, 0x02, 0x03, 0x02, 0x00, 0x00, 0x00, // r +0x00, 0x40, 0xA0, 0xA0, 0x20, 0x00, 0x00, 0x02, 0x02, 0x02, 0x01, 0x00, // s +0x00, 0x20, 0xF8, 0x20, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, // t +0x20, 0xE0, 0x00, 0x20, 0xE0, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, // u +0x20, 0xE0, 0x00, 0x00, 0xE0, 0x20, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, // v +0x60, 0x80, 0xE0, 0x80, 0x60, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, // w +0x20, 0x60, 0x80, 0x60, 0x20, 0x00, 0x02, 0x03, 0x00, 0x03, 0x02, 0x00, // x +0x20, 0xE0, 0x20, 0x80, 0x60, 0x20, 0x08, 0x08, 0x07, 0x01, 0x00, 0x00, // y +0x00, 0x20, 0xA0, 0x60, 0x20, 0x00, 0x00, 0x02, 0x03, 0x02, 0x02, 0x00, // z +0x00, 0x00, 0x60, 0x9E, 0x02, 0x00, 0x00, 0x00, 0x00, 0x07, 0x04, 0x00, // { +0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, // | +0x00, 0x02, 0x9E, 0x60, 0x00, 0x00, 0x00, 0x04, 0x07, 0x00, 0x00, 0x00, // } +0x04, 0x02, 0x02, 0x04, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ~ Index 94 }; //======================================================================// -//= 16 Pix font library. // +//= 16 Pix font library. // //======================================================================// const SGUI_CBYTE SGUI_FONT_H16[] = { -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // space Index 0 -0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x00,0x00,0x00,0x00, //"!" -0x00,0x00,0x1E,0x06,0x00,0x1E,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //""" -0x40,0x40,0xF8,0x40,0x40,0xF8,0x40,0x00,0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00, //"#" -0x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00, //"$" -0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00, //"%" -0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10, //"&" -0x00,0x1E,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //"'" -0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00, //"(" -0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00, //")" -0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00, //"*" -0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00, //"+" -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00, //"," -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01, //"-" -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00, //"." -0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x06,0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00, //"/" -0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00, //"0" -0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00, //"1" -0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00, //"2" -0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00, //"3" -0x00,0x00,0x80,0x60,0x10,0xF8,0x00,0x00,0x00,0x06,0x05,0x24,0x24,0x3F,0x24,0x00, //"4" -0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00, //"5" -0x00,0xE0,0x10,0x88,0x88,0x08,0x10,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00, //"6" -0x00,0x38,0x08,0x08,0xC8,0x28,0x18,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00, //"7" -0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00, //"8" -0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x10,0x21,0x22,0x22,0x11,0x0F,0x00, //"9" -0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00, //":" -0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x80,0xE0,0x60,0x00,0x00,0x00, //";" -0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00, //"<" -0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00, //"=" -0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00, //">" -0x00,0x70,0x08,0x08,0x08,0x08,0xF0,0x00,0x00,0x00,0x00,0x00,0x36,0x01,0x00,0x00, //"?" -0xC0,0x30,0xC8,0x28,0xC8,0x10,0xE0,0x00,0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00, //"@" -0x00,0x00,0xC0,0x38,0x38,0xC0,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x23,0x3C,0x20, //"A" -0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00, //"B" -0xC0,0x30,0x08,0x08,0x08,0x08,0x30,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00, //"C" -0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00, //"D" -0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00, //"E" -0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00, //"F" -0xC0,0x30,0x08,0x08,0x08,0x18,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00, //"G" -0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20, //"H" -0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00, //"I" -0x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00, //"J" -0x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00, //"K" -0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00, //"L" -0x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00, //"M" -0x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00, //"N" -0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00, //"O" -0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00, //"P" -0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00, //"Q" -0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20, //"R" -0x00,0x70,0x88,0x08,0x08,0x08,0x30,0x00,0x00,0x18,0x20,0x21,0x21,0x22,0x1C,0x00, //"S" -0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00, //"T" -0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00, //"U" -0x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,0x00,0x00,0x07,0x38,0x38,0x07,0x00,0x00, //"V" -0xF8,0x08,0x00,0xF0,0x00,0x08,0xF8,0x00,0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00, //"W" -0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20, //"X" -0x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00, //"Y" -0x18,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,0x20,0x38,0x26,0x21,0x20,0x20,0x38,0x00, //"Z" -0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00, //"[" -0x00,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x0C,0x30,0xC0, //"\" -0x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00, //"]" -0x00,0x00,0x04,0x02,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //"^" -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, //"_" -0x00,0x02,0x06,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //"`" -0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x22,0x22,0x1F,0x20, //"a" -0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00, //"b" -0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00, //"c" -0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20, //"d" -0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00, //"e" -0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00, //"f" -0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00, //"g" -0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20, //"h" -0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00, //"i" -0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00, //"j" -0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00, //"k" -0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00, //"l" -0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F, //"m" -0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20, //"n" -0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00, //"o" -0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00, //"p" -0x00,0x00,0x00,0x80,0x80,0x00,0x80,0x00,0x00,0x0E,0x11,0x20,0x20,0xA1,0xFF,0x80, //"q" -0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00, //"r" -0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x13,0x24,0x24,0x24,0x24,0x19,0x00, //"s" -0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00, //"t" -0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20, //"u" -0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x01,0x0E,0x30,0x30,0x0E,0x01,0x00, //"v" -0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x80,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00, //"w" -0x00,0x80,0x80,0x00,0x00,0x80,0x80,0x00,0x00,0x20,0x31,0x0E,0x0E,0x31,0x20,0x00, //"x" -0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00, //"y" -0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00, //"z" -0x00,0x00,0x00,0x00,0x80,0x7C,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40, //"{" -0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00, //"|" -0x00,0x02,0x02,0x7C,0x80,0x00,0x00,0x00,0x00,0x40,0x40,0x3F,0x00,0x00,0x00,0x00, //"}" -0x00,0x06,0x01,0x01,0x02,0x02,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //"~" Index 94 +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // space Index 0 +0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x00,0x00,0x00,0x00, //"!" +0x00,0x00,0x1E,0x06,0x00,0x1E,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //""" +0x40,0x40,0xF8,0x40,0x40,0xF8,0x40,0x00,0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00, //"#" +0x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00, //"$" +0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00, //"%" +0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10, //"&" +0x00,0x1E,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //"'" +0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00, //"(" +0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00, //")" +0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00, //"*" +0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00, //"+" +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00, //"," +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01, //"-" +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00, //"." +0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x06,0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00, //"/" +0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00, //"0" +0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00, //"1" +0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00, //"2" +0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00, //"3" +0x00,0x00,0x80,0x60,0x10,0xF8,0x00,0x00,0x00,0x06,0x05,0x24,0x24,0x3F,0x24,0x00, //"4" +0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00, //"5" +0x00,0xE0,0x10,0x88,0x88,0x08,0x10,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00, //"6" +0x00,0x38,0x08,0x08,0xC8,0x28,0x18,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00, //"7" +0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00, //"8" +0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x10,0x21,0x22,0x22,0x11,0x0F,0x00, //"9" +0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00, //":" +0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x80,0xE0,0x60,0x00,0x00,0x00, //";" +0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00, //"<" +0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00, //"=" +0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00, //">" +0x00,0x70,0x08,0x08,0x08,0x08,0xF0,0x00,0x00,0x00,0x00,0x00,0x36,0x01,0x00,0x00, //"?" +0xC0,0x30,0xC8,0x28,0xC8,0x10,0xE0,0x00,0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00, //"@" +0x00,0x00,0xC0,0x38,0x38,0xC0,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x23,0x3C,0x20, //"A" +0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00, //"B" +0xC0,0x30,0x08,0x08,0x08,0x08,0x30,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00, //"C" +0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00, //"D" +0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00, //"E" +0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00, //"F" +0xC0,0x30,0x08,0x08,0x08,0x18,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00, //"G" +0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20, //"H" +0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00, //"I" +0x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00, //"J" +0x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00, //"K" +0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00, //"L" +0x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00, //"M" +0x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00, //"N" +0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00, //"O" +0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00, //"P" +0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00, //"Q" +0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20, //"R" +0x00,0x70,0x88,0x08,0x08,0x08,0x30,0x00,0x00,0x18,0x20,0x21,0x21,0x22,0x1C,0x00, //"S" +0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00, //"T" +0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00, //"U" +0x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,0x00,0x00,0x07,0x38,0x38,0x07,0x00,0x00, //"V" +0xF8,0x08,0x00,0xF0,0x00,0x08,0xF8,0x00,0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00, //"W" +0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20, //"X" +0x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00, //"Y" +0x18,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,0x20,0x38,0x26,0x21,0x20,0x20,0x38,0x00, //"Z" +0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00, //"[" +0x00,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x0C,0x30,0xC0, //"\" +0x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00, //"]" +0x00,0x00,0x04,0x02,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //"^" +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, //"_" +0x00,0x02,0x06,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //"`" +0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x22,0x22,0x1F,0x20, //"a" +0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00, //"b" +0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00, //"c" +0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20, //"d" +0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00, //"e" +0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00, //"f" +0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00, //"g" +0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20, //"h" +0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00, //"i" +0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00, //"j" +0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00, //"k" +0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00, //"l" +0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F, //"m" +0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20, //"n" +0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00, //"o" +0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00, //"p" +0x00,0x00,0x00,0x80,0x80,0x00,0x80,0x00,0x00,0x0E,0x11,0x20,0x20,0xA1,0xFF,0x80, //"q" +0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00, //"r" +0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x13,0x24,0x24,0x24,0x24,0x19,0x00, //"s" +0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00, //"t" +0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20, //"u" +0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x01,0x0E,0x30,0x30,0x0E,0x01,0x00, //"v" +0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x80,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00, //"w" +0x00,0x80,0x80,0x00,0x00,0x80,0x80,0x00,0x00,0x20,0x31,0x0E,0x0E,0x31,0x20,0x00, //"x" +0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00, //"y" +0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00, //"z" +0x00,0x00,0x00,0x00,0x80,0x7C,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40, //"{" +0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00, //"|" +0x00,0x02,0x02,0x7C,0x80,0x00,0x00,0x00,0x00,0x40,0x40,0x3F,0x00,0x00,0x00,0x00, //"}" +0x00,0x06,0x01,0x01,0x02,0x02,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //"~" Index 94 }; SGUI_INT SGUI_Resource_GetCharIndex_MiniNum(SGUI_UINT32 uiCode) { /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_INT iIndex; + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_INT iIndex; - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - switch(uiCode) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - iIndex = uiCode - '0'; - break; - } - case '.': - { - iIndex = 10; - break; - } - case '+': - { - iIndex = 11; - break; - } - case '-': - { - iIndex = 12; - break; - } - case '*': - { - iIndex = 13; - break; - } - case '/': - { - iIndex = 14; - break; - } - case '(': - { - iIndex = 15; - break; - } - case ')': - { - iIndex = 16; - break; - } - case ' ': // Space. - { - iIndex = 17; - break; - } - case '%': - { - iIndex = 18; - break; - } - case '=': - { - iIndex = 19; - break; - } - default: - { - iIndex = SGUI_INVALID_INDEX; - break; - } - } - return iIndex; + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + switch(uiCode) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + { + iIndex = uiCode - '0'; + break; + } + case '.': + { + iIndex = 10; + break; + } + case '+': + { + iIndex = 11; + break; + } + case '-': + { + iIndex = 12; + break; + } + case '*': + { + iIndex = 13; + break; + } + case '/': + { + iIndex = 14; + break; + } + case '(': + { + iIndex = 15; + break; + } + case ')': + { + iIndex = 16; + break; + } + case ' ': // Space. + { + iIndex = 17; + break; + } + case '%': + { + iIndex = 18; + break; + } + case '=': + { + iIndex = 19; + break; + } + default: + { + iIndex = SGUI_INVALID_INDEX; + break; + } + } + return iIndex; } SGUI_INT SGUI_Resource_GetCharIndex_Default(SGUI_UINT32 uiCode) { /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_INT iIndex; + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_INT iIndex; - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - // Initialize variable. - iIndex = SGUI_INVALID_INDEX; + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + // Initialize variable. + iIndex = SGUI_INVALID_INDEX; - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if((uiCode > 0x19) && (uiCode < 0x7F)) - { - iIndex = uiCode - (0x20); - } - return iIndex; + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if((uiCode > 0x19) && (uiCode < 0x7F)) + { + iIndex = uiCode - (0x20); + } + return iIndex; } SGUI_CSZSTR SGUI_Resource_StepNext_Default(SGUI_CSZSTR cszSrc, SGUI_UINT32* puiCode) { /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - const SGUI_CHAR* pcNextChar; + /* Variable Declaration */ + /*----------------------------------*/ + const SGUI_CHAR* pcNextChar; - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - pcNextChar = cszSrc; + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + pcNextChar = cszSrc; - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if(NULL != pcNextChar) + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(NULL != pcNextChar) { *puiCode = *pcNextChar; pcNextChar++; diff --git a/GUI/src/SGUI_IconResource.c b/GUI/src/SGUI_IconResource.c index abbe92153e25145b511e25ed7c6ac1890157acb0..e4cf0e34c0d01759dc14a35cca6fc296ccee5ef1 100644 --- a/GUI/src/SGUI_IconResource.c +++ b/GUI/src/SGUI_IconResource.c @@ -1,16 +1,16 @@ /*************************************************************************/ -/** Copyright. **/ -/** FileName: SGUI_IconResource.c **/ -/** Author: XuYulin **/ -/** Description: Simple GUI basic drawing operating interface. **/ +/** Copyright. **/ +/** FileName: SGUI_IconResource.c **/ +/** Author: XuYulin **/ +/** Description: Simple GUI basic drawing operating interface. **/ /*************************************************************************/ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "SGUI_IconResource.h" //=======================================================================// -//= Static variable define. =// +//= Static variable define. =// //=======================================================================// SGUI_BMP_RESOURCE_DEFINE(SGUI_RES_ICON_ERROR_16, 16, 16, 0xFF,0x01,0x01,0x19,0x39,0x71,0xE1,0xC1,0xC1,0xE1,0x71,0x39,0x19,0x01,0x01,0xFF, diff --git a/GUI/src/SGUI_Interface.c b/GUI/src/SGUI_Interface.c index b6bb729ef7d8737ca7caea0e5df3662477d90e2e..e0a8586293078a5299d3360462312cb5c86ac643 100644 --- a/GUI/src/SGUI_Interface.c +++ b/GUI/src/SGUI_Interface.c @@ -1,11 +1,11 @@ /*************************************************************************/ -/** Copyright. **/ -/** FileName: SGUI_Interface.c **/ -/** Author: Polarix **/ -/** Description: System platform interface. **/ +/** Copyright. **/ +/** FileName: SGUI_Interface.c **/ +/** Author: Polarix **/ +/** Description: System platform interface. **/ /*************************************************************************/ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "SGUI_Interface.h" @@ -21,7 +21,7 @@ #include #include #else - // Include platform RTC interface declare here. + // Include platform RTC interface declare here. #include "RTC.h" #endif @@ -32,128 +32,128 @@ #include #endif #else - // Include MMU interface header file here. + // Include MMU interface header file here. #include #endif //=======================================================================// -//= Static variable declaration. =// +//= Static variable declaration. =// //=======================================================================// #ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ #ifdef _SIMPLE_GUI_ENCODE_TEXT_ - static SGUI_CHAR g_arrcEncodeBuffer[SGUI_ENCODE_BUFFER_SIZE]; + static SGUI_CHAR g_arrcEncodeBuffer[SGUI_ENCODE_BUFFER_SIZE]; #endif #endif //=======================================================================// -//= Function define. =// +//= Function define. =// //=======================================================================// #ifdef _SIMPLE_GUI_ENCODE_TEXT_ /*************************************************************************/ -/** Function Name: SGUI_SystemIF_EncodeConvert **/ -/** Purpose: Convert string encode. **/ -/** Resources: None. **/ -/** Params: **/ -/** @ szSourceEncode[in]: Source encoder name. **/ -/** @ szDestinationEncode[in]: Destination encoder name. **/ -/** @ szSource[in]: String will converted. **/ -/** Return: String after convert. **/ +/** Function Name: SGUI_SystemIF_EncodeConvert **/ +/** Purpose: Convert string encode. **/ +/** Resources: None. **/ +/** Params: **/ +/** @ szSourceEncode[in]: Source encoder name. **/ +/** @ szDestinationEncode[in]: Destination encoder name. **/ +/** @ szSource[in]: String will converted. **/ +/** Return: String after convert. **/ /*************************************************************************/ SGUI_SZSTR SGUI_SystemIF_EncodeConvert(SGUI_CSZSTR szSourceEncode, SGUI_SZSTR szDestinationEncode, SGUI_SZSTR szSource) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_SZSTR pszResultPtr; - SGUI_SIZE uiSourceLength, uiOutputBufferSize; - SGUI_SIZE uiEncoderResult; - iconv_t pIconv; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_SZSTR pszResultPtr; + SGUI_SIZE uiSourceLength, uiOutputBufferSize; + SGUI_SIZE uiEncoderResult; + iconv_t pIconv; - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - uiEncoderResult = -1; + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + uiEncoderResult = -1; - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - pIconv = iconv_open(szDestinationEncode, szSourceEncode); - if((iconv_t)-1 != pIconv) - { - uiSourceLength = SGUI_SystemIF_StringLength(szSource) + 1; - uiOutputBufferSize = SGUI_ENCODE_BUFFER_SIZE; - pszResultPtr = g_arrcEncodeBuffer; - uiEncoderResult = iconv(pIconv, &szSource, &uiSourceLength, &pszResultPtr, &uiOutputBufferSize); - if (uiEncoderResult == (SGUI_SIZE)-1) - { - pszResultPtr = NULL; - } - else - { - pszResultPtr = g_arrcEncodeBuffer; - } - } - iconv_close(pIconv); - return pszResultPtr; + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + pIconv = iconv_open(szDestinationEncode, szSourceEncode); + if((iconv_t)-1 != pIconv) + { + uiSourceLength = SGUI_SystemIF_StringLength(szSource) + 1; + uiOutputBufferSize = SGUI_ENCODE_BUFFER_SIZE; + pszResultPtr = g_arrcEncodeBuffer; + uiEncoderResult = iconv(pIconv, &szSource, &uiSourceLength, &pszResultPtr, &uiOutputBufferSize); + if (uiEncoderResult == (SGUI_SIZE)-1) + { + pszResultPtr = NULL; + } + else + { + pszResultPtr = g_arrcEncodeBuffer; + } + } + iconv_close(pIconv); + return pszResultPtr; } #endif #ifdef _SIMPLE_GUI_ENABLE_DYNAMIC_MEMORY_ /*************************************************************************/ -/** Function Name: SGUI_SystemIF_Allocate **/ -/** Purpose: Allocate a memory block. **/ -/** Resources: None. **/ -/** Params: **/ -/** @ uiSize[in]: Allocated memory size. **/ -/** Return: Allocated memory block started address, same as STD **/ -/** malloc interface. **/ +/** Function Name: SGUI_SystemIF_Allocate **/ +/** Purpose: Allocate a memory block. **/ +/** Resources: None. **/ +/** Params: **/ +/** @ uiSize[in]: Allocated memory size. **/ +/** Return: Allocated memory block started address, same as STD **/ +/** malloc interface. **/ /*************************************************************************/ void* SGUI_SystemIF_Allocate(SGUI_SIZE uiSize) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - void *pAllocatedMemory; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + void *pAllocatedMemory; - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - pAllocatedMemory = NULL; + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + pAllocatedMemory = NULL; - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ #ifdef _SIMPLE_GUI_USE_SYS_PF_FUNCTIONS_ - pAllocatedMemory = malloc(uiSize); + pAllocatedMemory = malloc(uiSize); #else - // Add allocate memory function here; - pAllocatedMemory = malloc(uiSize); + // Add allocate memory function here; + pAllocatedMemory = malloc(uiSize); #endif - return pAllocatedMemory; + return pAllocatedMemory; } /*************************************************************************/ -/** Function Name: SGUI_SystemIF_Free **/ -/** Purpose: Free a memory block. **/ -/** Resources: None. **/ -/** Params: **/ -/** @ pFreePointer[in]: Free memory pointer **/ -/** Return: None. **/ +/** Function Name: SGUI_SystemIF_Free **/ +/** Purpose: Free a memory block. **/ +/** Resources: None. **/ +/** Params: **/ +/** @ pFreePointer[in]: Free memory pointer **/ +/** Return: None. **/ /*************************************************************************/ void SGUI_SystemIF_Free(void* pFreePointer) { - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if(NULL != pFreePointer) - { + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(NULL != pFreePointer) + { #ifdef _SIMPLE_GUI_USE_SYS_PF_FUNCTIONS_ - free(pFreePointer); + free(pFreePointer); #else - // Add allocate memory function here; - free(pFreePointer); + // Add allocate memory function here; + free(pFreePointer); #endif - } + } } #endif diff --git a/GUI/src/SGUI_ItemsBase.c b/GUI/src/SGUI_ItemsBase.c index deb2a7762c42809c6950d501c3dbd420da64b503..75e3ef8937e43c85b863760f83ee697ed79eb059 100644 --- a/GUI/src/SGUI_ItemsBase.c +++ b/GUI/src/SGUI_ItemsBase.c @@ -1,675 +1,675 @@ /*************************************************************************/ -/** Copyright. **/ -/** FileName: SGUI_ItemsBase.c **/ -/** Author: XuYulin **/ -/** Description: Simple GUI items base interface, used to extend list **/ -/** components . **/ +/** Copyright. **/ +/** FileName: SGUI_ItemsBase.c **/ +/** Author: XuYulin **/ +/** Description: Simple GUI items base interface, used to extend list **/ +/** components . **/ /*************************************************************************/ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "SGUI_ItemsBase.h" //=======================================================================// -//= User Macro definition. =// +//= User Macro definition. =// //=======================================================================// -#define ITEMS_SENECT_IDX(ITEMS_PTR) (ITEMS_PTR->stSelection.iIndex) -#define ITEMS_SENECT_ITEM(ITEMS_PTR) (ITEMS_PTR->stSelection.pstItem) -#define ITEMS_VISIBLE_START_IDX(ITEMS_PTR) (ITEMS_PTR->stVisibleStart.iIndex) -#define ITEMS_VISIBLE_START_ITEM(ITEMS_PTR) (ITEMS_PTR->stVisibleStart.pstItem) -#define ITEMS_VISIBLE_END_IDX(ITEMS_PTR) (ITEMS_PTR->stVisibleEnd.iIndex) -#define ITEMS_VISIBLE_END_ITEM(ITEMS_PTR) (ITEMS_PTR->stVisibleEnd.pstItem) -#define ITEMS_FIRST_ITEM(ITEMS_PTR) (ITEMS_PTR->pstFirstItem) -#define ITEMS_LAST_ITEM(ITEMS_PTR) (ITEMS_PTR->pstLastItem) -#define ITEMS_VISIBLE_ITEMS(ITEMS_PTR) (ITEMS_PTR->iVisibleItems) +#define ITEMS_SENECT_IDX(ITEMS_PTR) (ITEMS_PTR->stSelection.iIndex) +#define ITEMS_SENECT_ITEM(ITEMS_PTR) (ITEMS_PTR->stSelection.pstItem) +#define ITEMS_VISIBLE_START_IDX(ITEMS_PTR) (ITEMS_PTR->stVisibleStart.iIndex) +#define ITEMS_VISIBLE_START_ITEM(ITEMS_PTR) (ITEMS_PTR->stVisibleStart.pstItem) +#define ITEMS_VISIBLE_END_IDX(ITEMS_PTR) (ITEMS_PTR->stVisibleEnd.iIndex) +#define ITEMS_VISIBLE_END_ITEM(ITEMS_PTR) (ITEMS_PTR->stVisibleEnd.pstItem) +#define ITEMS_FIRST_ITEM(ITEMS_PTR) (ITEMS_PTR->pstFirstItem) +#define ITEMS_LAST_ITEM(ITEMS_PTR) (ITEMS_PTR->pstLastItem) +#define ITEMS_VISIBLE_ITEMS(ITEMS_PTR) (ITEMS_PTR->iVisibleItems) //=======================================================================// -//= Static function declaration. =// +//= Static function declaration. =// //=======================================================================// //=======================================================================// -//= Function define. =// +//= Function define. =// //=======================================================================// /*************************************************************************/ -/** Function Name: SGUI_ItemsBase_Initialize **/ -/** Purpose: Initialize a items-base object data. **/ -/** Params: **/ -/** @ pstObj[in]: Pointer of items-base object will be initialized. **/ -/** @ pstLayout[in]: Layout data object pointer. **/ -/** @ pstFontRes[in]: Font resource object pointer. **/ -/** @ pstItemsData[in]: Items data array. **/ -/** @ iItemsCount[in]: Number of list item data. **/ -/** Return: None. **/ +/** Function Name: SGUI_ItemsBase_Initialize **/ +/** Purpose: Initialize a items-base object data. **/ +/** Params: **/ +/** @ pstObj[in]: Pointer of items-base object will be initialized. **/ +/** @ pstLayout[in]: Layout data object pointer. **/ +/** @ pstFontRes[in]: Font resource object pointer. **/ +/** @ pstItemsData[in]: Items data array. **/ +/** @ iItemsCount[in]: Number of list item data. **/ +/** Return: None. **/ /*************************************************************************/ void SGUI_ItemsBase_Initialize(SGUI_ITEMS_BASE* pstObj, const SGUI_RECT* cpstLayout, const SGUI_FONT_RES* pstFontRes, SGUI_ITEMS_ITEM* pstItemsData, SGUI_INT iItemsCount) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_INT iItemIndex; - SGUI_ITEMS_ITEM* pstItem; - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if((NULL != pstObj) && (NULL != pstFontRes)) - { - /* Paint font. */ - pstObj->pstFontRes = pstFontRes; - /* Layout */ - SGUI_SystemIF_MemoryCopy(&(pstObj->stLayout), cpstLayout, sizeof(SGUI_RECT)); - /* Calculate the number of visible items. */ - ITEMS_VISIBLE_ITEMS(pstObj) = (pstObj->stLayout.iHeight-1)/ITEM_HEIGHT(pstObj->pstFontRes)+1; - /* Items count. */ - pstObj->iCount = iItemsCount; - /* Item paint offset. */ - pstObj->iItemPaintOffset = 0; - /* Items data. */ - if(iItemsCount > 0) - { - /* Initialize for first item. */ - ITEMS_FIRST_ITEM(pstObj) = pstItemsData; - pstItem = ITEMS_FIRST_ITEM(pstObj); - pstItem->pstPrev = NULL; - pstItem->pstNext = NULL; - /* Loop for remaining items if existed. */ - for(iItemIndex=1; iItemIndexpstPrev = pstItem; - (pstItemsData+iItemIndex)->pstNext = NULL; - pstItem->pstNext = (pstItemsData+iItemIndex); - pstItem = pstItemsData+iItemIndex; - } - ITEMS_LAST_ITEM(pstObj) = pstItem; - /* For initialize selection */ - ITEMS_SENECT_IDX(pstObj) = 0; - ITEMS_SENECT_ITEM(pstObj) = ITEMS_FIRST_ITEM(pstObj); - /* For first visible item. */ - ITEMS_VISIBLE_START_IDX(pstObj) = 0; - ITEMS_VISIBLE_START_ITEM(pstObj) = ITEMS_FIRST_ITEM(pstObj); - /* For last visible item. */ - ITEMS_VISIBLE_END_IDX(pstObj) = ITEMS_VISIBLE_START_IDX(pstObj) + ITEMS_VISIBLE_ITEMS(pstObj) - 1; - ITEMS_VISIBLE_END_ITEM(pstObj) = SGUI_ItemsBase_JumpItem(ITEMS_FIRST_ITEM(pstObj), ITEMS_VISIBLE_ITEMS(pstObj)-1); - } - else - { - ITEMS_FIRST_ITEM(pstObj) = NULL; - ITEMS_LAST_ITEM(pstObj) = NULL; - ITEMS_SENECT_IDX(pstObj) = SGUI_INVALID_INDEX; - ITEMS_SENECT_ITEM(pstObj) = NULL; - } - } + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_INT iItemIndex; + SGUI_ITEMS_ITEM* pstItem; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if((NULL != pstObj) && (NULL != pstFontRes)) + { + /* Paint font. */ + pstObj->pstFontRes = pstFontRes; + /* Layout */ + SGUI_SystemIF_MemoryCopy(&(pstObj->stLayout), cpstLayout, sizeof(SGUI_RECT)); + /* Calculate the number of visible items. */ + ITEMS_VISIBLE_ITEMS(pstObj) = (pstObj->stLayout.iHeight-1)/ITEM_HEIGHT(pstObj->pstFontRes)+1; + /* Items count. */ + pstObj->iCount = iItemsCount; + /* Item paint offset. */ + pstObj->iItemPaintOffset = 0; + /* Items data. */ + if(iItemsCount > 0) + { + /* Initialize for first item. */ + ITEMS_FIRST_ITEM(pstObj) = pstItemsData; + pstItem = ITEMS_FIRST_ITEM(pstObj); + pstItem->pstPrev = NULL; + pstItem->pstNext = NULL; + /* Loop for remaining items if existed. */ + for(iItemIndex=1; iItemIndexpstPrev = pstItem; + (pstItemsData+iItemIndex)->pstNext = NULL; + pstItem->pstNext = (pstItemsData+iItemIndex); + pstItem = pstItemsData+iItemIndex; + } + ITEMS_LAST_ITEM(pstObj) = pstItem; + /* For initialize selection */ + ITEMS_SENECT_IDX(pstObj) = 0; + ITEMS_SENECT_ITEM(pstObj) = ITEMS_FIRST_ITEM(pstObj); + /* For first visible item. */ + ITEMS_VISIBLE_START_IDX(pstObj) = 0; + ITEMS_VISIBLE_START_ITEM(pstObj) = ITEMS_FIRST_ITEM(pstObj); + /* For last visible item. */ + ITEMS_VISIBLE_END_IDX(pstObj) = ITEMS_VISIBLE_START_IDX(pstObj) + ITEMS_VISIBLE_ITEMS(pstObj) - 1; + ITEMS_VISIBLE_END_ITEM(pstObj) = SGUI_ItemsBase_JumpItem(ITEMS_FIRST_ITEM(pstObj), ITEMS_VISIBLE_ITEMS(pstObj)-1); + } + else + { + ITEMS_FIRST_ITEM(pstObj) = NULL; + ITEMS_LAST_ITEM(pstObj) = NULL; + ITEMS_SENECT_IDX(pstObj) = SGUI_INVALID_INDEX; + ITEMS_SENECT_ITEM(pstObj) = NULL; + } + } } /*************************************************************************/ -/** Function Name: SGUI_ItemsBase_JumpItem **/ -/** Purpose: Jump item from the base-item. **/ -/** Params: **/ -/** @ pstObj[in]: Pointer of items-base object will be paint. **/ -/** @ iSteps[in]: Jump steps, positive means forward, negative means **/ -/** backward. **/ -/** Return: None. **/ +/** Function Name: SGUI_ItemsBase_JumpItem **/ +/** Purpose: Jump item from the base-item. **/ +/** Params: **/ +/** @ pstObj[in]: Pointer of items-base object will be paint. **/ +/** @ iSteps[in]: Jump steps, positive means forward, negative means **/ +/** backward. **/ +/** Return: None. **/ /*************************************************************************/ SGUI_ITEMS_ITEM* SGUI_ItemsBase_JumpItem(SGUI_ITEMS_ITEM* pstBaseItem, SGUI_INT iSteps) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_ITEMS_ITEM* pstFoundedItem; - SGUI_INT iStepCount; - - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - iStepCount = iSteps; - pstFoundedItem = pstBaseItem; - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if(NULL != pstBaseItem) - { - if(iSteps < 0) - { - iStepCount = (~iStepCount)+1; - while((iStepCount > 0) && (NULL != pstFoundedItem)) - { - pstFoundedItem = pstFoundedItem->pstPrev; - iStepCount--; - } - } - else - { - iStepCount = iSteps; - while((iStepCount > 0) && (NULL != pstFoundedItem)) - { - pstFoundedItem = pstFoundedItem->pstNext; - iStepCount--; - } - } - } - return pstFoundedItem; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_ITEMS_ITEM* pstFoundedItem; + SGUI_INT iStepCount; + + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + iStepCount = iSteps; + pstFoundedItem = pstBaseItem; + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(NULL != pstBaseItem) + { + if(iSteps < 0) + { + iStepCount = (~iStepCount)+1; + while((iStepCount > 0) && (NULL != pstFoundedItem)) + { + pstFoundedItem = pstFoundedItem->pstPrev; + iStepCount--; + } + } + else + { + iStepCount = iSteps; + while((iStepCount > 0) && (NULL != pstFoundedItem)) + { + pstFoundedItem = pstFoundedItem->pstNext; + iStepCount--; + } + } + } + return pstFoundedItem; } /*************************************************************************/ -/** Function Name: SGUI_ItemsBase_Repaint **/ -/** Purpose: Update list display on screen. **/ -/** Params: **/ -/** @ pstDeviceIF[in]: Device driver object pointer. **/ -/** @ pstObj[in]: Pointer of items-base object will be paint. **/ -/** @ bEraseBack[in]: For true, erase background before repaint items. **/ -/** Return: None. **/ +/** Function Name: SGUI_ItemsBase_Repaint **/ +/** Purpose: Update list display on screen. **/ +/** Params: **/ +/** @ pstDeviceIF[in]: Device driver object pointer. **/ +/** @ pstObj[in]: Pointer of items-base object will be paint. **/ +/** @ bEraseBack[in]: For true, erase background before repaint items. **/ +/** Return: None. **/ /*************************************************************************/ void SGUI_ItemsBase_Repaint(SGUI_SCR_DEV* pstDeviceIF, SGUI_ITEMS_BASE* pstObj) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_RECT stItemPaintArea; - SGUI_POINT stItemTextPos; - SGUI_ITEMS_ITEM* pstPaintingItem; - SGUI_CSZSTR cszItemText; - - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - stItemTextPos.iX = 1; - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if((NULL != pstDeviceIF) && (NULL != pstObj)) - { - /* Clear background */ - if(pstObj->iCount < pstObj->iVisibleItems) - { - SGUI_Basic_DrawRectangle(pstDeviceIF, pstObj->stLayout.iX, pstObj->stLayout.iY, pstObj->stLayout.iWidth, pstObj->stLayout.iHeight, SGUI_COLOR_BKGCLR, SGUI_COLOR_BKGCLR); - } - - if(pstObj->iCount > 0) - { - - /* Judge selection index is valid. */ - if(ITEMS_SENECT_IDX(pstObj) < 0) - { - SGUI_ItemsBase_SelecteFirst(pstObj); - } - if(ITEMS_SENECT_IDX(pstObj) >= pstObj->iCount) - { - SGUI_ItemsBase_SelecteLast(pstObj); - } - /* Judge visible area. */ - if(ITEMS_SENECT_IDX(pstObj) < ITEMS_VISIBLE_START_IDX(pstObj)) - { - SGUI_SystemIF_MemoryCopy(&(pstObj->stVisibleStart), &(pstObj->stSelection), sizeof(SGUI_ITEM_SELECTION)); - ITEMS_VISIBLE_END_ITEM(pstObj) = SGUI_ItemsBase_JumpItem(ITEMS_VISIBLE_START_ITEM(pstObj), ITEMS_VISIBLE_ITEMS(pstObj) - 1); - ITEMS_VISIBLE_END_IDX(pstObj) = ITEMS_VISIBLE_START_IDX(pstObj) + ITEMS_VISIBLE_ITEMS(pstObj) - 1; - } - if(ITEMS_SENECT_IDX(pstObj) > ITEMS_VISIBLE_END_IDX(pstObj)) - { - SGUI_SystemIF_MemoryCopy(&(pstObj->stVisibleEnd), &(pstObj->stSelection), sizeof(SGUI_ITEM_SELECTION)); - ITEMS_VISIBLE_START_ITEM(pstObj) = SGUI_ItemsBase_JumpItem(ITEMS_VISIBLE_END_ITEM(pstObj), 1 - ITEMS_VISIBLE_ITEMS(pstObj)); - ITEMS_VISIBLE_START_IDX(pstObj) = ITEMS_VISIBLE_END_IDX(pstObj) - ITEMS_VISIBLE_ITEMS(pstObj) + 1; - } - /* Initialize paint area. */ - stItemPaintArea.iX = pstObj->stLayout.iX; - stItemPaintArea.iY = pstObj->stLayout.iY; - stItemPaintArea.iWidth = pstObj->stLayout.iWidth; - /* Judge items painting offset and calculate the height of the first visible item. */ - if((ITEMS_SENECT_IDX(pstObj) == ITEMS_VISIBLE_START_IDX(pstObj)) || (NULL == ITEMS_VISIBLE_END_ITEM(pstObj))) - { - pstObj->iItemPaintOffset = 0; - stItemPaintArea.iHeight = (pstObj->iVisibleItems>1)?(ITEM_HEIGHT(pstObj->pstFontRes)):(pstObj->stLayout.iHeight); - } - else if(ITEMS_SENECT_IDX(pstObj) == ITEMS_VISIBLE_END_IDX(pstObj)) - { - pstObj->iItemPaintOffset = (((pstObj->stLayout.iHeight)%ITEM_HEIGHT(pstObj->pstFontRes))-ITEM_HEIGHT(pstObj->pstFontRes))%ITEM_HEIGHT(pstObj->pstFontRes); - stItemPaintArea.iHeight = ITEM_HEIGHT(pstObj->pstFontRes)+pstObj->iItemPaintOffset; - } - else - { - stItemPaintArea.iHeight = ITEM_HEIGHT(pstObj->pstFontRes); - } - - /* Paint first visible item. */ - pstPaintingItem = ITEMS_VISIBLE_START_ITEM(pstObj); - stItemTextPos.iY = pstObj->iItemPaintOffset+1; - cszItemText = (NULL == pstPaintingItem->szVariableText) ? (pstPaintingItem->cszLabelText) : (pstPaintingItem->szVariableText); - SGUI_Text_DrawText(pstDeviceIF, cszItemText, pstObj->pstFontRes, &stItemPaintArea, &stItemTextPos, pstPaintingItem==ITEMS_SENECT_ITEM(pstObj)?SGUI_DRAW_REVERSE:SGUI_DRAW_NORMAL); - /* Paint remaining items if existed. */ - pstPaintingItem = pstPaintingItem->pstNext; - stItemPaintArea.iHeight = ITEM_HEIGHT(pstObj->pstFontRes); - if(pstObj->iVisibleItems > 1) - { - stItemPaintArea.iY += ITEM_HEIGHT(pstObj->pstFontRes)+(pstObj->iItemPaintOffset); - stItemTextPos.iY = 1; - while((pstPaintingItem != ITEMS_VISIBLE_END_ITEM(pstObj)) && (NULL != pstPaintingItem)) - { - cszItemText = (NULL == pstPaintingItem->szVariableText) ? (pstPaintingItem->cszLabelText) : (pstPaintingItem->szVariableText); - SGUI_Text_DrawText(pstDeviceIF, cszItemText, pstObj->pstFontRes, &stItemPaintArea, &stItemTextPos, pstPaintingItem==ITEMS_SENECT_ITEM(pstObj)?SGUI_DRAW_REVERSE:SGUI_DRAW_NORMAL); - stItemPaintArea.iY += ITEM_HEIGHT(pstObj->pstFontRes); - pstPaintingItem = pstPaintingItem->pstNext; - } - /* Paint last visible item. */ - if(NULL != pstPaintingItem) - { - /* Paint last visible item. */ - stItemPaintArea.iHeight = (0==pstObj->iItemPaintOffset)?(pstObj->stLayout.iHeight%ITEM_HEIGHT(pstObj->pstFontRes)):(ITEM_HEIGHT(pstObj->pstFontRes)); - /* Correct last visible item height when items area height is an integer multiple of item height. */ - stItemPaintArea.iHeight = (0==stItemPaintArea.iHeight)?ITEM_HEIGHT(pstObj->pstFontRes):stItemPaintArea.iHeight; - cszItemText = (NULL == pstPaintingItem->szVariableText) ? (pstPaintingItem->cszLabelText) : (pstPaintingItem->szVariableText); - SGUI_Text_DrawText(pstDeviceIF, cszItemText, pstObj->pstFontRes, &stItemPaintArea, &stItemTextPos, pstPaintingItem==ITEMS_SENECT_ITEM(pstObj)?SGUI_DRAW_REVERSE:SGUI_DRAW_NORMAL); - } - } - } - } + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_RECT stItemPaintArea; + SGUI_POINT stItemTextPos; + SGUI_ITEMS_ITEM* pstPaintingItem; + SGUI_CSZSTR cszItemText; + + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + stItemTextPos.iX = 1; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if((NULL != pstDeviceIF) && (NULL != pstObj)) + { + /* Clear background */ + if(pstObj->iCount < pstObj->iVisibleItems) + { + SGUI_Basic_DrawRectangle(pstDeviceIF, pstObj->stLayout.iX, pstObj->stLayout.iY, pstObj->stLayout.iWidth, pstObj->stLayout.iHeight, SGUI_COLOR_BKGCLR, SGUI_COLOR_BKGCLR); + } + + if(pstObj->iCount > 0) + { + + /* Judge selection index is valid. */ + if(ITEMS_SENECT_IDX(pstObj) < 0) + { + SGUI_ItemsBase_SelecteFirst(pstObj); + } + if(ITEMS_SENECT_IDX(pstObj) >= pstObj->iCount) + { + SGUI_ItemsBase_SelecteLast(pstObj); + } + /* Judge visible area. */ + if(ITEMS_SENECT_IDX(pstObj) < ITEMS_VISIBLE_START_IDX(pstObj)) + { + SGUI_SystemIF_MemoryCopy(&(pstObj->stVisibleStart), &(pstObj->stSelection), sizeof(SGUI_ITEM_SELECTION)); + ITEMS_VISIBLE_END_ITEM(pstObj) = SGUI_ItemsBase_JumpItem(ITEMS_VISIBLE_START_ITEM(pstObj), ITEMS_VISIBLE_ITEMS(pstObj) - 1); + ITEMS_VISIBLE_END_IDX(pstObj) = ITEMS_VISIBLE_START_IDX(pstObj) + ITEMS_VISIBLE_ITEMS(pstObj) - 1; + } + if(ITEMS_SENECT_IDX(pstObj) > ITEMS_VISIBLE_END_IDX(pstObj)) + { + SGUI_SystemIF_MemoryCopy(&(pstObj->stVisibleEnd), &(pstObj->stSelection), sizeof(SGUI_ITEM_SELECTION)); + ITEMS_VISIBLE_START_ITEM(pstObj) = SGUI_ItemsBase_JumpItem(ITEMS_VISIBLE_END_ITEM(pstObj), 1 - ITEMS_VISIBLE_ITEMS(pstObj)); + ITEMS_VISIBLE_START_IDX(pstObj) = ITEMS_VISIBLE_END_IDX(pstObj) - ITEMS_VISIBLE_ITEMS(pstObj) + 1; + } + /* Initialize paint area. */ + stItemPaintArea.iX = pstObj->stLayout.iX; + stItemPaintArea.iY = pstObj->stLayout.iY; + stItemPaintArea.iWidth = pstObj->stLayout.iWidth; + /* Judge items painting offset and calculate the height of the first visible item. */ + if((ITEMS_SENECT_IDX(pstObj) == ITEMS_VISIBLE_START_IDX(pstObj)) || (NULL == ITEMS_VISIBLE_END_ITEM(pstObj))) + { + pstObj->iItemPaintOffset = 0; + stItemPaintArea.iHeight = (pstObj->iVisibleItems>1)?(ITEM_HEIGHT(pstObj->pstFontRes)):(pstObj->stLayout.iHeight); + } + else if(ITEMS_SENECT_IDX(pstObj) == ITEMS_VISIBLE_END_IDX(pstObj)) + { + pstObj->iItemPaintOffset = (((pstObj->stLayout.iHeight)%ITEM_HEIGHT(pstObj->pstFontRes))-ITEM_HEIGHT(pstObj->pstFontRes))%ITEM_HEIGHT(pstObj->pstFontRes); + stItemPaintArea.iHeight = ITEM_HEIGHT(pstObj->pstFontRes)+pstObj->iItemPaintOffset; + } + else + { + stItemPaintArea.iHeight = ITEM_HEIGHT(pstObj->pstFontRes); + } + + /* Paint first visible item. */ + pstPaintingItem = ITEMS_VISIBLE_START_ITEM(pstObj); + stItemTextPos.iY = pstObj->iItemPaintOffset+1; + cszItemText = (NULL == pstPaintingItem->szVariableText) ? (pstPaintingItem->cszLabelText) : (pstPaintingItem->szVariableText); + SGUI_Text_DrawText(pstDeviceIF, cszItemText, pstObj->pstFontRes, &stItemPaintArea, &stItemTextPos, pstPaintingItem==ITEMS_SENECT_ITEM(pstObj)?SGUI_DRAW_REVERSE:SGUI_DRAW_NORMAL); + /* Paint remaining items if existed. */ + pstPaintingItem = pstPaintingItem->pstNext; + stItemPaintArea.iHeight = ITEM_HEIGHT(pstObj->pstFontRes); + if(pstObj->iVisibleItems > 1) + { + stItemPaintArea.iY += ITEM_HEIGHT(pstObj->pstFontRes)+(pstObj->iItemPaintOffset); + stItemTextPos.iY = 1; + while((pstPaintingItem != ITEMS_VISIBLE_END_ITEM(pstObj)) && (NULL != pstPaintingItem)) + { + cszItemText = (NULL == pstPaintingItem->szVariableText) ? (pstPaintingItem->cszLabelText) : (pstPaintingItem->szVariableText); + SGUI_Text_DrawText(pstDeviceIF, cszItemText, pstObj->pstFontRes, &stItemPaintArea, &stItemTextPos, pstPaintingItem==ITEMS_SENECT_ITEM(pstObj)?SGUI_DRAW_REVERSE:SGUI_DRAW_NORMAL); + stItemPaintArea.iY += ITEM_HEIGHT(pstObj->pstFontRes); + pstPaintingItem = pstPaintingItem->pstNext; + } + /* Paint last visible item. */ + if(NULL != pstPaintingItem) + { + /* Paint last visible item. */ + stItemPaintArea.iHeight = (0==pstObj->iItemPaintOffset)?(pstObj->stLayout.iHeight%ITEM_HEIGHT(pstObj->pstFontRes)):(ITEM_HEIGHT(pstObj->pstFontRes)); + /* Correct last visible item height when items area height is an integer multiple of item height. */ + stItemPaintArea.iHeight = (0==stItemPaintArea.iHeight)?ITEM_HEIGHT(pstObj->pstFontRes):stItemPaintArea.iHeight; + cszItemText = (NULL == pstPaintingItem->szVariableText) ? (pstPaintingItem->cszLabelText) : (pstPaintingItem->szVariableText); + SGUI_Text_DrawText(pstDeviceIF, cszItemText, pstObj->pstFontRes, &stItemPaintArea, &stItemTextPos, pstPaintingItem==ITEMS_SENECT_ITEM(pstObj)?SGUI_DRAW_REVERSE:SGUI_DRAW_NORMAL); + } + } + } + } } /*************************************************************************/ -/** Function Name: SGUI_ItemsBase_GetItem **/ -/** Purpose: Get item object pointer by index. **/ -/** Params: **/ -/** @ pstObj[in]: Pointer of items-base object will be paint. **/ -/** @ iIndex[in]: Index of wanted item. **/ -/** Return: Item object pointer. **/ +/** Function Name: SGUI_ItemsBase_GetItem **/ +/** Purpose: Get item object pointer by index. **/ +/** Params: **/ +/** @ pstObj[in]: Pointer of items-base object will be paint. **/ +/** @ iIndex[in]: Index of wanted item. **/ +/** Return: Item object pointer. **/ /*************************************************************************/ SGUI_ITEMS_ITEM* SGUI_ItemsBase_GetItem(SGUI_ITEMS_BASE* pstObj, SGUI_INT iIndex) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_ITEMS_ITEM* pstSelectedItem; - SGUI_INT iLoopIdx; - - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - pstSelectedItem = pstObj->pstFirstItem; - iLoopIdx = 0; - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - while((iLoopIdx != iIndex) && (NULL != pstSelectedItem)) - { - pstSelectedItem = pstSelectedItem->pstNext; - iLoopIdx++; - } - - return pstSelectedItem; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_ITEMS_ITEM* pstSelectedItem; + SGUI_INT iLoopIdx; + + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + pstSelectedItem = pstObj->pstFirstItem; + iLoopIdx = 0; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + while((iLoopIdx != iIndex) && (NULL != pstSelectedItem)) + { + pstSelectedItem = pstSelectedItem->pstNext; + iLoopIdx++; + } + + return pstSelectedItem; } /*************************************************************************/ -/** Function Name: SGUI_ItemsBase_GetItemExtent **/ -/** Purpose: Get item object display area position and size. **/ -/** Params: **/ -/** @ pstObj[in]: Pointer of items-base object will be paint. **/ -/** @ iSelection[in]: Selected item index. **/ -/** @ pstItemExtent[out]: Item position and display area size. **/ -/** Return: None. **/ -/** Notice: This function only used for the visible item, if **/ -/** selection is invisible, output size will be (0, 0). **/ +/** Function Name: SGUI_ItemsBase_GetItemExtent **/ +/** Purpose: Get item object display area position and size. **/ +/** Params: **/ +/** @ pstObj[in]: Pointer of items-base object will be paint. **/ +/** @ iSelection[in]: Selected item index. **/ +/** @ pstItemExtent[out]: Item position and display area size. **/ +/** Return: None. **/ +/** Notice: This function only used for the visible item, if **/ +/** selection is invisible, output size will be (0, 0). **/ /*************************************************************************/ void SGUI_ItemsBase_GetItemExtent(SGUI_ITEMS_BASE* pstObj, SGUI_INT iSelection, SGUI_RECT* pstItemExtent) { - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if((NULL != pstObj) && (iSelection > SGUI_INVALID_INDEX) && (iSelection < pstObj->iCount) && (NULL != pstItemExtent)) - { - pstItemExtent->iX = pstObj->stLayout.iX; - pstItemExtent->iWidth = pstObj->stLayout.iWidth; - /* Item is not visible. */ + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if((NULL != pstObj) && (iSelection > SGUI_INVALID_INDEX) && (iSelection < pstObj->iCount) && (NULL != pstItemExtent)) + { + pstItemExtent->iX = pstObj->stLayout.iX; + pstItemExtent->iWidth = pstObj->stLayout.iWidth; + /* Item is not visible. */ if((iSelection < ITEMS_VISIBLE_START_IDX(pstObj)) || (iSelection > ITEMS_VISIBLE_END_IDX(pstObj))) - { - pstItemExtent->iY = 0; - pstItemExtent->iHeight = 0; - } - else - { - if((0 == pstObj->iItemPaintOffset) && (ITEMS_SENECT_ITEM(pstObj) == ITEMS_VISIBLE_END_ITEM(pstObj))) - { - pstItemExtent->iY = pstObj->stLayout.iY+(ITEM_HEIGHT(pstObj->pstFontRes)*(pstObj->iVisibleItems-1)); - pstItemExtent->iHeight = (0==pstObj->iItemPaintOffset)?(pstObj->stLayout.iHeight%ITEM_HEIGHT(pstObj->pstFontRes)):(ITEM_HEIGHT(pstObj->pstFontRes)); - /* Correct last visible item height when items area height is an integer multiple of item height. */ - pstItemExtent->iHeight = (0==pstItemExtent->iHeight)?ITEM_HEIGHT(pstObj->pstFontRes):pstItemExtent->iHeight; - } - else if((0 != pstObj->iItemPaintOffset) && (ITEMS_SENECT_ITEM(pstObj) == ITEMS_VISIBLE_START_ITEM(pstObj))) - { - pstItemExtent->iY = pstObj->stLayout.iY; - pstItemExtent->iHeight = ITEM_HEIGHT(pstObj->pstFontRes)+pstObj->iItemPaintOffset; - } - else - { - pstItemExtent->iY = pstObj->stLayout.iY+((ITEMS_SENECT_IDX(pstObj) - ITEMS_VISIBLE_START_IDX(pstObj))*ITEM_HEIGHT(pstObj->pstFontRes))+pstObj->iItemPaintOffset; - pstItemExtent->iHeight = ITEM_HEIGHT(pstObj->pstFontRes); - } - } - } + { + pstItemExtent->iY = 0; + pstItemExtent->iHeight = 0; + } + else + { + if((0 == pstObj->iItemPaintOffset) && (ITEMS_SENECT_ITEM(pstObj) == ITEMS_VISIBLE_END_ITEM(pstObj))) + { + pstItemExtent->iY = pstObj->stLayout.iY+(ITEM_HEIGHT(pstObj->pstFontRes)*(pstObj->iVisibleItems-1)); + pstItemExtent->iHeight = (0==pstObj->iItemPaintOffset)?(pstObj->stLayout.iHeight%ITEM_HEIGHT(pstObj->pstFontRes)):(ITEM_HEIGHT(pstObj->pstFontRes)); + /* Correct last visible item height when items area height is an integer multiple of item height. */ + pstItemExtent->iHeight = (0==pstItemExtent->iHeight)?ITEM_HEIGHT(pstObj->pstFontRes):pstItemExtent->iHeight; + } + else if((0 != pstObj->iItemPaintOffset) && (ITEMS_SENECT_ITEM(pstObj) == ITEMS_VISIBLE_START_ITEM(pstObj))) + { + pstItemExtent->iY = pstObj->stLayout.iY; + pstItemExtent->iHeight = ITEM_HEIGHT(pstObj->pstFontRes)+pstObj->iItemPaintOffset; + } + else + { + pstItemExtent->iY = pstObj->stLayout.iY+((ITEMS_SENECT_IDX(pstObj) - ITEMS_VISIBLE_START_IDX(pstObj))*ITEM_HEIGHT(pstObj->pstFontRes))+pstObj->iItemPaintOffset; + pstItemExtent->iHeight = ITEM_HEIGHT(pstObj->pstFontRes); + } + } + } } /*************************************************************************/ -/** Function Name: SGUI_ItemsBase_Resize **/ -/** Purpose: Resize and calculate layout parameter for display **/ -/** changed. **/ -/** Params: **/ -/** @ pstObj[in]: Pointer of items-base object will be paint. **/ -/** @ cpstNewLayout[in]: New position and size. **/ -/** Return: None. **/ -/** Notice: None. **/ +/** Function Name: SGUI_ItemsBase_Resize **/ +/** Purpose: Resize and calculate layout parameter for display **/ +/** changed. **/ +/** Params: **/ +/** @ pstObj[in]: Pointer of items-base object will be paint. **/ +/** @ cpstNewLayout[in]: New position and size. **/ +/** Return: None. **/ +/** Notice: None. **/ /*************************************************************************/ void SGUI_ItemsBase_Resize(SGUI_ITEMS_BASE* pstObj, const SGUI_RECT* cpstNewLayout) { - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - /* Set new layout. */ - SGUI_SystemIF_MemoryCopy(&(pstObj->stLayout), cpstNewLayout, sizeof(SGUI_RECT)); - /* Calculate visible items number in new size. */ - ITEMS_VISIBLE_ITEMS(pstObj) = (pstObj->stLayout.iHeight-1)/ITEM_HEIGHT(pstObj->pstFontRes)+1; - /* Visible items number is greater then items count. */ - if(ITEMS_VISIBLE_ITEMS(pstObj) > pstObj->iCount) + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + /* Set new layout. */ + SGUI_SystemIF_MemoryCopy(&(pstObj->stLayout), cpstNewLayout, sizeof(SGUI_RECT)); + /* Calculate visible items number in new size. */ + ITEMS_VISIBLE_ITEMS(pstObj) = (pstObj->stLayout.iHeight-1)/ITEM_HEIGHT(pstObj->pstFontRes)+1; + /* Visible items number is greater then items count. */ + if(ITEMS_VISIBLE_ITEMS(pstObj) > pstObj->iCount) + { + ITEMS_VISIBLE_START_ITEM(pstObj) = ITEMS_FIRST_ITEM(pstObj); + ITEMS_VISIBLE_START_IDX(pstObj) = 0; + ITEMS_VISIBLE_END_ITEM(pstObj) = NULL; + ITEMS_VISIBLE_END_IDX(pstObj) = ITEMS_VISIBLE_ITEMS(pstObj) - 1; + pstObj->iItemPaintOffset = 0; + } + /* Visible items number is NOT less then items count. */ + else + { + ITEMS_VISIBLE_END_ITEM(pstObj) = SGUI_ItemsBase_JumpItem(ITEMS_VISIBLE_START_ITEM(pstObj), ITEMS_VISIBLE_ITEMS(pstObj)-1); + if(NULL == ITEMS_VISIBLE_END_ITEM(pstObj)) { - ITEMS_VISIBLE_START_ITEM(pstObj) = ITEMS_FIRST_ITEM(pstObj); - ITEMS_VISIBLE_START_IDX(pstObj) = 0; - ITEMS_VISIBLE_END_ITEM(pstObj) = NULL; - ITEMS_VISIBLE_END_IDX(pstObj) = ITEMS_VISIBLE_ITEMS(pstObj) - 1; - pstObj->iItemPaintOffset = 0; - } - /* Visible items number is NOT less then items count. */ - else - { - ITEMS_VISIBLE_END_ITEM(pstObj) = SGUI_ItemsBase_JumpItem(ITEMS_VISIBLE_START_ITEM(pstObj), ITEMS_VISIBLE_ITEMS(pstObj)-1); - if(NULL == ITEMS_VISIBLE_END_ITEM(pstObj)) - { - ITEMS_VISIBLE_END_ITEM(pstObj) = ITEMS_LAST_ITEM(pstObj); - ITEMS_VISIBLE_END_IDX(pstObj) = pstObj->iCount - 1; - ITEMS_VISIBLE_START_ITEM(pstObj) = SGUI_ItemsBase_JumpItem(ITEMS_VISIBLE_END_ITEM(pstObj), 1-ITEMS_VISIBLE_ITEMS(pstObj)); - ITEMS_VISIBLE_START_IDX(pstObj) = pstObj->iCount - ITEMS_VISIBLE_ITEMS(pstObj); - pstObj->iItemPaintOffset = 0; - } - else - { - ITEMS_VISIBLE_END_IDX(pstObj) = ITEMS_VISIBLE_START_IDX(pstObj) + ITEMS_VISIBLE_ITEMS(pstObj) - 1; - } - } + ITEMS_VISIBLE_END_ITEM(pstObj) = ITEMS_LAST_ITEM(pstObj); + ITEMS_VISIBLE_END_IDX(pstObj) = pstObj->iCount - 1; + ITEMS_VISIBLE_START_ITEM(pstObj) = SGUI_ItemsBase_JumpItem(ITEMS_VISIBLE_END_ITEM(pstObj), 1-ITEMS_VISIBLE_ITEMS(pstObj)); + ITEMS_VISIBLE_START_IDX(pstObj) = pstObj->iCount - ITEMS_VISIBLE_ITEMS(pstObj); + pstObj->iItemPaintOffset = 0; + } + else + { + ITEMS_VISIBLE_END_IDX(pstObj) = ITEMS_VISIBLE_START_IDX(pstObj) + ITEMS_VISIBLE_ITEMS(pstObj) - 1; + } + } } /*************************************************************************/ -/** Function Name: SGUI_List_GetSelection **/ -/** Purpose: Get selected object pointer. **/ -/** Params: **/ -/** @ pstObj[in]: Pointer of items-base object. **/ -/** Return: Selection object include select index and item. **/ -/** Notice: None. **/ +/** Function Name: SGUI_List_GetSelection **/ +/** Purpose: Get selected object pointer. **/ +/** Params: **/ +/** @ pstObj[in]: Pointer of items-base object. **/ +/** Return: Selection object include select index and item. **/ +/** Notice: None. **/ /*************************************************************************/ void SGUI_ItemsBase_Selecte(SGUI_ITEMS_BASE* pstObj, SGUI_INT iSelectIndex) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_INT iSteps; - - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - iSteps = iSelectIndex - SGUI_ItemsBase_GetSelection(pstObj)->iIndex; - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if(iSteps != 0) - { - ITEMS_SENECT_ITEM(pstObj) = SGUI_ItemsBase_JumpItem(ITEMS_SENECT_ITEM(pstObj), iSteps); - if(NULL == ITEMS_SENECT_ITEM(pstObj)) - { - ITEMS_SENECT_IDX(pstObj) = SGUI_INVALID_INDEX; - } - else - { - ITEMS_SENECT_IDX(pstObj) = iSelectIndex; - } - } + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_INT iSteps; + + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + iSteps = iSelectIndex - SGUI_ItemsBase_GetSelection(pstObj)->iIndex; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(iSteps != 0) + { + ITEMS_SENECT_ITEM(pstObj) = SGUI_ItemsBase_JumpItem(ITEMS_SENECT_ITEM(pstObj), iSteps); + if(NULL == ITEMS_SENECT_ITEM(pstObj)) + { + ITEMS_SENECT_IDX(pstObj) = SGUI_INVALID_INDEX; + } + else + { + ITEMS_SENECT_IDX(pstObj) = iSelectIndex; + } + } } /*************************************************************************/ -/** Function Name: SGUI_ItemsBase_RemoveItem **/ -/** Purpose: Remove a item from items-base list. **/ -/** Params: **/ -/** @ pstObj[in]: Pointer of items-base object. **/ -/** @ iRemoveIndex[in]: Index of item will be removed. **/ -/** Return: Removed item object pointer. **/ -/** Notice: if memory of item is dynamically allocated, Please **/ -/** release MANUALLY. **/ +/** Function Name: SGUI_ItemsBase_RemoveItem **/ +/** Purpose: Remove a item from items-base list. **/ +/** Params: **/ +/** @ pstObj[in]: Pointer of items-base object. **/ +/** @ iRemoveIndex[in]: Index of item will be removed. **/ +/** Return: Removed item object pointer. **/ +/** Notice: if memory of item is dynamically allocated, Please **/ +/** release MANUALLY. **/ /*************************************************************************/ SGUI_ITEMS_ITEM* SGUI_ItemsBase_RemoveItem(SGUI_ITEMS_BASE* pstObj, SGUI_INT iRemoveIndex) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_ITEMS_ITEM* pstRemovedItem; - - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - pstRemovedItem = SGUI_ItemsBase_JumpItem(pstObj->pstFirstItem, iRemoveIndex); - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if(NULL != pstRemovedItem) - { - /* Count changes. */ - --(pstObj->iCount); - /* Judge first and last. */ - if(pstObj->pstFirstItem == pstRemovedItem) - { - pstObj->pstFirstItem = pstRemovedItem->pstNext; - } - if(pstObj->pstLastItem == pstRemovedItem) - { - pstObj->pstLastItem = pstRemovedItem->pstPrev; - } - /* Remove node from linked-list */ - if(NULL != pstRemovedItem->pstNext) - { - pstRemovedItem->pstNext->pstPrev = pstRemovedItem->pstPrev; - } - if(NULL != pstRemovedItem->pstPrev) - { - pstRemovedItem->pstPrev->pstNext = pstRemovedItem->pstNext; - } - /* Removed item is visible */ - if((iRemoveIndex >= ITEMS_VISIBLE_START_IDX(pstObj)) && (iRemoveIndex <= ITEMS_VISIBLE_END_IDX(pstObj))) - { - /* Reset selection when removed item is selected. */ - if(pstRemovedItem == pstObj->stSelection.pstItem) - { - if(NULL != pstRemovedItem->pstNext) - { - ITEMS_SENECT_ITEM(pstObj) = pstRemovedItem->pstNext; - if(NULL == ITEMS_SENECT_ITEM(pstObj)) - { - ITEMS_SENECT_IDX(pstObj) = SGUI_INVALID_INDEX; - } - } - else - { - ITEMS_SENECT_ITEM(pstObj) = pstRemovedItem->pstPrev; - --ITEMS_SENECT_IDX(pstObj); - } - } - /* When removed items is first visible. */ - if(pstRemovedItem == ITEMS_VISIBLE_START_ITEM(pstObj)) - { - ITEMS_VISIBLE_START_ITEM(pstObj) = ITEMS_VISIBLE_START_ITEM(pstObj)->pstNext; - } - /* Set last visible item. */ - if(NULL != ITEMS_VISIBLE_START_ITEM(pstObj)) - { - if(NULL != ITEMS_VISIBLE_END_ITEM(pstObj)) - { - if((NULL == ITEMS_VISIBLE_END_ITEM(pstObj)->pstNext) && (NULL != ITEMS_VISIBLE_START_ITEM(pstObj)->pstPrev)) - { - ITEMS_VISIBLE_START_ITEM(pstObj) = ITEMS_VISIBLE_START_ITEM(pstObj)->pstPrev; - --ITEMS_VISIBLE_START_IDX(pstObj); - --ITEMS_VISIBLE_END_IDX(pstObj); - } - else - { - ITEMS_VISIBLE_END_ITEM(pstObj) = ITEMS_VISIBLE_END_ITEM(pstObj)->pstNext; - } - } - } - } - - pstRemovedItem->pstNext = NULL; - pstRemovedItem->pstPrev = NULL; - } - - return pstRemovedItem; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_ITEMS_ITEM* pstRemovedItem; + + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + pstRemovedItem = SGUI_ItemsBase_JumpItem(pstObj->pstFirstItem, iRemoveIndex); + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(NULL != pstRemovedItem) + { + /* Count changes. */ + --(pstObj->iCount); + /* Judge first and last. */ + if(pstObj->pstFirstItem == pstRemovedItem) + { + pstObj->pstFirstItem = pstRemovedItem->pstNext; + } + if(pstObj->pstLastItem == pstRemovedItem) + { + pstObj->pstLastItem = pstRemovedItem->pstPrev; + } + /* Remove node from linked-list */ + if(NULL != pstRemovedItem->pstNext) + { + pstRemovedItem->pstNext->pstPrev = pstRemovedItem->pstPrev; + } + if(NULL != pstRemovedItem->pstPrev) + { + pstRemovedItem->pstPrev->pstNext = pstRemovedItem->pstNext; + } + /* Removed item is visible */ + if((iRemoveIndex >= ITEMS_VISIBLE_START_IDX(pstObj)) && (iRemoveIndex <= ITEMS_VISIBLE_END_IDX(pstObj))) + { + /* Reset selection when removed item is selected. */ + if(pstRemovedItem == pstObj->stSelection.pstItem) + { + if(NULL != pstRemovedItem->pstNext) + { + ITEMS_SENECT_ITEM(pstObj) = pstRemovedItem->pstNext; + if(NULL == ITEMS_SENECT_ITEM(pstObj)) + { + ITEMS_SENECT_IDX(pstObj) = SGUI_INVALID_INDEX; + } + } + else + { + ITEMS_SENECT_ITEM(pstObj) = pstRemovedItem->pstPrev; + --ITEMS_SENECT_IDX(pstObj); + } + } + /* When removed items is first visible. */ + if(pstRemovedItem == ITEMS_VISIBLE_START_ITEM(pstObj)) + { + ITEMS_VISIBLE_START_ITEM(pstObj) = ITEMS_VISIBLE_START_ITEM(pstObj)->pstNext; + } + /* Set last visible item. */ + if(NULL != ITEMS_VISIBLE_START_ITEM(pstObj)) + { + if(NULL != ITEMS_VISIBLE_END_ITEM(pstObj)) + { + if((NULL == ITEMS_VISIBLE_END_ITEM(pstObj)->pstNext) && (NULL != ITEMS_VISIBLE_START_ITEM(pstObj)->pstPrev)) + { + ITEMS_VISIBLE_START_ITEM(pstObj) = ITEMS_VISIBLE_START_ITEM(pstObj)->pstPrev; + --ITEMS_VISIBLE_START_IDX(pstObj); + --ITEMS_VISIBLE_END_IDX(pstObj); + } + else + { + ITEMS_VISIBLE_END_ITEM(pstObj) = ITEMS_VISIBLE_END_ITEM(pstObj)->pstNext; + } + } + } + } + + pstRemovedItem->pstNext = NULL; + pstRemovedItem->pstPrev = NULL; + } + + return pstRemovedItem; } /*************************************************************************/ -/** Function Name: SGUI_ItemsBase_InsertItem **/ -/** Purpose: Insert a new item before item with the index. **/ -/** Params: **/ -/** @ pstObj[in]: Pointer of items-base object. **/ -/** @ pstNewItem[in]: Inserted new item object. **/ -/** @ iIndex[in]: Index of new inserted item . **/ -/** Return: Inserted item object pointer. **/ -/** Notice: Return NULL when insert failed. **/ +/** Function Name: SGUI_ItemsBase_InsertItem **/ +/** Purpose: Insert a new item before item with the index. **/ +/** Params: **/ +/** @ pstObj[in]: Pointer of items-base object. **/ +/** @ pstNewItem[in]: Inserted new item object. **/ +/** @ iIndex[in]: Index of new inserted item . **/ +/** Return: Inserted item object pointer. **/ +/** Notice: Return NULL when insert failed. **/ /*************************************************************************/ SGUI_ITEMS_ITEM* SGUI_ItemsBase_InsertItem(SGUI_ITEMS_BASE* pstObj, SGUI_ITEMS_ITEM* pstNewItem, SGUI_INT iIndex) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_ITEMS_ITEM* pstInsertedItem; - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - /* New items cannot greater then count of items. */ - if((iIndex > SGUI_INVALID_INDEX) && (iIndex <= pstObj->iCount)) - { - pstNewItem->pstNext = NULL; - pstNewItem->pstPrev = NULL; - - if(iIndex < pstObj->iCount) - { - /* Find the base items by given index. */ - pstInsertedItem = SGUI_ItemsBase_JumpItem(pstObj->pstFirstItem, iIndex); - /* Insert new items to linked list. */ - pstNewItem->pstNext = pstInsertedItem; - pstNewItem->pstPrev = pstInsertedItem->pstPrev; - if(NULL != pstInsertedItem->pstPrev) - { - pstInsertedItem->pstPrev->pstNext = pstNewItem; - } - pstInsertedItem->pstPrev = pstNewItem; - if(iIndex <= ITEMS_SENECT_IDX(pstObj)) - { - ++ITEMS_SENECT_IDX(pstObj); - } - /* Insert to first item. */ - if(ITEMS_FIRST_ITEM(pstObj) == pstInsertedItem) - { - ITEMS_FIRST_ITEM(pstObj) = pstNewItem; - } - /* Insert before first visible item. */ - if(iIndex < ITEMS_VISIBLE_START_IDX(pstObj)) - { - ++ITEMS_VISIBLE_START_IDX(pstObj); - ++ITEMS_VISIBLE_END_IDX(pstObj); - } - /* Insert after last visible item. */ - else if(iIndex > ITEMS_VISIBLE_END_IDX(pstObj)) - { - /* Do nothing. */ - } - /* Insert to visible area. */ - else - { - /* Insert to first visible item. */ - if(iIndex == ITEMS_VISIBLE_START_IDX(pstObj)) - { - ITEMS_VISIBLE_START_ITEM(pstObj) = pstNewItem; - } - if(NULL != ITEMS_VISIBLE_END_ITEM(pstObj)) - { - ITEMS_VISIBLE_END_ITEM(pstObj) = ITEMS_VISIBLE_END_ITEM(pstObj)->pstPrev; - } - else if(ITEMS_VISIBLE_ITEMS(pstObj) == (SGUI_ItemsBase_Count(pstObj)+1)) - { - ITEMS_VISIBLE_END_ITEM(pstObj) = ITEMS_LAST_ITEM(pstObj); - } - } - } - /* Insert the new item to last of linked list. */ - else - { - /* Insert first item. */ - if(NULL == ITEMS_FIRST_ITEM(pstObj)) - { - ITEMS_FIRST_ITEM(pstObj) = pstNewItem; - ITEMS_LAST_ITEM(pstObj) = pstNewItem; - ITEMS_VISIBLE_START_ITEM(pstObj) = pstNewItem; - ITEMS_VISIBLE_START_IDX(pstObj) = 0; - ITEMS_VISIBLE_END_ITEM(pstObj) = NULL; - ITEMS_VISIBLE_END_IDX(pstObj) = ITEMS_VISIBLE_ITEMS(pstObj)-1; - } - else - { - ITEMS_LAST_ITEM(pstObj)->pstNext = pstNewItem; - pstNewItem->pstPrev = ITEMS_LAST_ITEM(pstObj); - ITEMS_LAST_ITEM(pstObj) = pstNewItem; - if(ITEMS_VISIBLE_ITEMS(pstObj) == (SGUI_ItemsBase_Count(pstObj)+1)) - { - ITEMS_VISIBLE_END_ITEM(pstObj) = pstNewItem->pstNext; - } - } - } - /* Count changes. */ - pstObj->iCount += 1; - } - /* Return NULL when inserted index is invalid. */ - else - { - pstNewItem = NULL; - } - - return pstNewItem; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_ITEMS_ITEM* pstInsertedItem; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + /* New items cannot greater then count of items. */ + if((iIndex > SGUI_INVALID_INDEX) && (iIndex <= pstObj->iCount)) + { + pstNewItem->pstNext = NULL; + pstNewItem->pstPrev = NULL; + + if(iIndex < pstObj->iCount) + { + /* Find the base items by given index. */ + pstInsertedItem = SGUI_ItemsBase_JumpItem(pstObj->pstFirstItem, iIndex); + /* Insert new items to linked list. */ + pstNewItem->pstNext = pstInsertedItem; + pstNewItem->pstPrev = pstInsertedItem->pstPrev; + if(NULL != pstInsertedItem->pstPrev) + { + pstInsertedItem->pstPrev->pstNext = pstNewItem; + } + pstInsertedItem->pstPrev = pstNewItem; + if(iIndex <= ITEMS_SENECT_IDX(pstObj)) + { + ++ITEMS_SENECT_IDX(pstObj); + } + /* Insert to first item. */ + if(ITEMS_FIRST_ITEM(pstObj) == pstInsertedItem) + { + ITEMS_FIRST_ITEM(pstObj) = pstNewItem; + } + /* Insert before first visible item. */ + if(iIndex < ITEMS_VISIBLE_START_IDX(pstObj)) + { + ++ITEMS_VISIBLE_START_IDX(pstObj); + ++ITEMS_VISIBLE_END_IDX(pstObj); + } + /* Insert after last visible item. */ + else if(iIndex > ITEMS_VISIBLE_END_IDX(pstObj)) + { + /* Do nothing. */ + } + /* Insert to visible area. */ + else + { + /* Insert to first visible item. */ + if(iIndex == ITEMS_VISIBLE_START_IDX(pstObj)) + { + ITEMS_VISIBLE_START_ITEM(pstObj) = pstNewItem; + } + if(NULL != ITEMS_VISIBLE_END_ITEM(pstObj)) + { + ITEMS_VISIBLE_END_ITEM(pstObj) = ITEMS_VISIBLE_END_ITEM(pstObj)->pstPrev; + } + else if(ITEMS_VISIBLE_ITEMS(pstObj) == (SGUI_ItemsBase_Count(pstObj)+1)) + { + ITEMS_VISIBLE_END_ITEM(pstObj) = ITEMS_LAST_ITEM(pstObj); + } + } + } + /* Insert the new item to last of linked list. */ + else + { + /* Insert first item. */ + if(NULL == ITEMS_FIRST_ITEM(pstObj)) + { + ITEMS_FIRST_ITEM(pstObj) = pstNewItem; + ITEMS_LAST_ITEM(pstObj) = pstNewItem; + ITEMS_VISIBLE_START_ITEM(pstObj) = pstNewItem; + ITEMS_VISIBLE_START_IDX(pstObj) = 0; + ITEMS_VISIBLE_END_ITEM(pstObj) = NULL; + ITEMS_VISIBLE_END_IDX(pstObj) = ITEMS_VISIBLE_ITEMS(pstObj)-1; + } + else + { + ITEMS_LAST_ITEM(pstObj)->pstNext = pstNewItem; + pstNewItem->pstPrev = ITEMS_LAST_ITEM(pstObj); + ITEMS_LAST_ITEM(pstObj) = pstNewItem; + if(ITEMS_VISIBLE_ITEMS(pstObj) == (SGUI_ItemsBase_Count(pstObj)+1)) + { + ITEMS_VISIBLE_END_ITEM(pstObj) = pstNewItem->pstNext; + } + } + } + /* Count changes. */ + pstObj->iCount += 1; + } + /* Return NULL when inserted index is invalid. */ + else + { + pstNewItem = NULL; + } + + return pstNewItem; } SGUI_BOOL SGUI_ItemsBase_CanScrollUp(SGUI_ITEMS_BASE* pstObj) { /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_BOOL bReturn; + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_BOOL bReturn; /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ - bReturn = ((ITEMS_VISIBLE_START_ITEM(pstObj) != ITEMS_FIRST_ITEM(pstObj)) || (pstObj->iItemPaintOffset != 0)); + bReturn = ((ITEMS_VISIBLE_START_ITEM(pstObj) != ITEMS_FIRST_ITEM(pstObj)) || (pstObj->iItemPaintOffset != 0)); - return bReturn; + return bReturn; } SGUI_BOOL SGUI_ItemsBase_CanScrollDown(SGUI_ITEMS_BASE* pstObj) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_BOOL bReturn; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_BOOL bReturn; - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ - bReturn = ((ITEMS_VISIBLE_END_ITEM(pstObj) != ITEMS_LAST_ITEM(pstObj)) || (pstObj->iItemPaintOffset == 0)); + bReturn = ((ITEMS_VISIBLE_END_ITEM(pstObj) != ITEMS_LAST_ITEM(pstObj)) || (pstObj->iItemPaintOffset == 0)); - return bReturn; + return bReturn; } diff --git a/GUI/src/SGUI_List.c b/GUI/src/SGUI_List.c index 8598fdd17488e664216f3d1f70a32a96b1c9ea90..10f182caf383ceb472b30b154307367c01afdf9b 100644 --- a/GUI/src/SGUI_List.c +++ b/GUI/src/SGUI_List.c @@ -1,231 +1,231 @@ /*************************************************************************/ -/** Copyright. **/ -/** FileName: SGUI_List.c **/ -/** Author: XuYulin **/ -/** Description: Draw list interface. **/ +/** Copyright. **/ +/** FileName: SGUI_List.c **/ +/** Author: XuYulin **/ +/** Description: Draw list interface. **/ /*************************************************************************/ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "SGUI_List.h" //=======================================================================// -//= User Macro definition. =// +//= User Macro definition. =// //=======================================================================// // User settings -#define LIST_SCROLLBAR_WIDTH (5) +#define LIST_SCROLLBAR_WIDTH (5) // Automatic calculation -#define LIST_EDGE_SIZE 1 -#define LIST_TITLE_HEIGHT(FONT) ((FONT)->iHeight+2) +#define LIST_EDGE_SIZE 1 +#define LIST_TITLE_HEIGHT(FONT) ((FONT)->iHeight+2) //=======================================================================// -//= Static function declaration. =// +//= Static function declaration. =// //=======================================================================// //=======================================================================// -//= Function define. =// +//= Function define. =// //=======================================================================// /*************************************************************************/ -/** Function Name: SGUI_List_InitializeListData **/ -/** Purpose: Initialize a list control data. **/ -/** Params: **/ -/** @ pstObj[in]: Pointer of list data will be initialized. **/ -/** @ pstFontRes[in]: Font resource object pointer. **/ -/** Return: None. **/ -/** Notice: None. **/ +/** Function Name: SGUI_List_InitializeListData **/ +/** Purpose: Initialize a list control data. **/ +/** Params: **/ +/** @ pstObj[in]: Pointer of list data will be initialized. **/ +/** @ pstFontRes[in]: Font resource object pointer. **/ +/** Return: None. **/ +/** Notice: None. **/ /*************************************************************************/ void SGUI_List_Initialize(SGUI_LIST* pstObj, const SGUI_RECT* cpstLayout, const SGUI_FONT_RES* pstFontRes, SGUI_CSZSTR cszTitle, SGUI_ITEMS_ITEM* pstItemsData, SGUI_INT iItemsCount) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_SCROLLBAR_PARAM stScrollBarParam; - SGUI_RECT stSubLayout; - - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - SGUI_SystemIF_MemorySet(&stSubLayout, 0x00, sizeof(SGUI_RECT)); - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - // Copy layout. - SGUI_SystemIF_MemoryCopy(&(pstObj->stLayout), cpstLayout, sizeof(SGUI_RECT)); - // Title - pstObj->szTitle = cszTitle; - // Initialize font resource. - pstObj->pstFontRes = pstFontRes; - // Initialize Items. - stSubLayout.iX = pstObj->stLayout.iX+2; - stSubLayout.iWidth = pstObj->stLayout.iWidth-4-LIST_SCROLLBAR_WIDTH; - if(NULL == pstObj->szTitle) - { - stSubLayout.iY = pstObj->stLayout.iY+2; - stSubLayout.iHeight = pstObj->stLayout.iHeight-4; - } - else - { - stSubLayout.iY = stSubLayout.iY+LIST_TITLE_HEIGHT(pstFontRes)+2; - stSubLayout.iHeight = pstObj->stLayout.iHeight-LIST_TITLE_HEIGHT(pstFontRes)-3; - } - SGUI_ItemsBase_Initialize(&(pstObj->stItems), &stSubLayout, pstFontRes, pstItemsData, iItemsCount); - // Initialize scroll bar. - stScrollBarParam.eDirection = SGUI_SCROLLBAR_VERTICAL; - stScrollBarParam.stLayout.iX = pstObj->stItems.stLayout.iX+pstObj->stItems.stLayout.iWidth+1; - stScrollBarParam.stLayout.iY = pstObj->stItems.stLayout.iY; - stScrollBarParam.stLayout.iWidth = LIST_SCROLLBAR_WIDTH; - stScrollBarParam.stLayout.iHeight = pstObj->stItems.stLayout.iHeight; - stScrollBarParam.sMaxValue = (pstObj->stItems.iCount > pstObj->stItems.iVisibleItems)?(pstObj->stItems.iCount - pstObj->stItems.iVisibleItems):0; - SGUI_ScrollBar_Initialize(&(pstObj->stScrollBar), &stScrollBarParam); + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_SCROLLBAR_PARAM stScrollBarParam; + SGUI_RECT stSubLayout; + + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + SGUI_SystemIF_MemorySet(&stSubLayout, 0x00, sizeof(SGUI_RECT)); + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + // Copy layout. + SGUI_SystemIF_MemoryCopy(&(pstObj->stLayout), cpstLayout, sizeof(SGUI_RECT)); + // Title + pstObj->szTitle = cszTitle; + // Initialize font resource. + pstObj->pstFontRes = pstFontRes; + // Initialize Items. + stSubLayout.iX = pstObj->stLayout.iX+2; + stSubLayout.iWidth = pstObj->stLayout.iWidth-4-LIST_SCROLLBAR_WIDTH; + if(NULL == pstObj->szTitle) + { + stSubLayout.iY = pstObj->stLayout.iY+2; + stSubLayout.iHeight = pstObj->stLayout.iHeight-4; + } + else + { + stSubLayout.iY = stSubLayout.iY+LIST_TITLE_HEIGHT(pstFontRes)+2; + stSubLayout.iHeight = pstObj->stLayout.iHeight-LIST_TITLE_HEIGHT(pstFontRes)-3; + } + SGUI_ItemsBase_Initialize(&(pstObj->stItems), &stSubLayout, pstFontRes, pstItemsData, iItemsCount); + // Initialize scroll bar. + stScrollBarParam.eDirection = SGUI_SCROLLBAR_VERTICAL; + stScrollBarParam.stLayout.iX = pstObj->stItems.stLayout.iX+pstObj->stItems.stLayout.iWidth+1; + stScrollBarParam.stLayout.iY = pstObj->stItems.stLayout.iY; + stScrollBarParam.stLayout.iWidth = LIST_SCROLLBAR_WIDTH; + stScrollBarParam.stLayout.iHeight = pstObj->stItems.stLayout.iHeight; + stScrollBarParam.sMaxValue = (pstObj->stItems.iCount > pstObj->stItems.iVisibleItems)?(pstObj->stItems.iCount - pstObj->stItems.iVisibleItems):0; + SGUI_ScrollBar_Initialize(&(pstObj->stScrollBar), &stScrollBarParam); } /*************************************************************************/ -/** Function Name: SGUI_List_Repaint **/ -/** Purpose: Refresh list display. **/ -/** Params: **/ -/** @ pstDeviceIF[in]: Device driver object pointer. **/ -/** @ pstObj[in]: Pointer of list data will be refreshed. **/ -/** Return: None. **/ -/** Notice: This function will refresh all list display on **/ -/** screen, include edge, items, title and scrollbar. **/ +/** Function Name: SGUI_List_Repaint **/ +/** Purpose: Refresh list display. **/ +/** Params: **/ +/** @ pstDeviceIF[in]: Device driver object pointer. **/ +/** @ pstObj[in]: Pointer of list data will be refreshed. **/ +/** Return: None. **/ +/** Notice: This function will refresh all list display on **/ +/** screen, include edge, items, title and scrollbar. **/ /*************************************************************************/ void SGUI_List_Repaint(SGUI_SCR_DEV* pstDeviceIF, SGUI_LIST* pstObj) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_RECT stTitleTextDisplayArea; - SGUI_POINT stInnerPos; - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if(NULL != pstObj) - { - // Clear list item display area. - SGUI_Basic_DrawRectangle(pstDeviceIF, pstObj->stLayout.iX, pstObj->stLayout.iY, pstObj->stLayout.iWidth, pstObj->stLayout.iHeight, SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); - // Paint title. - if(NULL != pstObj->szTitle) - { - stTitleTextDisplayArea.iX = pstObj->stLayout.iX+2; - stTitleTextDisplayArea.iY = pstObj->stLayout.iY+2; - stTitleTextDisplayArea.iWidth = pstObj->stLayout.iWidth-4; - stTitleTextDisplayArea.iHeight = pstObj->pstFontRes->iHeight; - stInnerPos.iX = 0; - stInnerPos.iY = 0; - SGUI_Text_DrawText(pstDeviceIF, pstObj->szTitle, pstObj->pstFontRes, &stTitleTextDisplayArea, &stInnerPos, SGUI_DRAW_NORMAL); - SGUI_Basic_DrawLine(pstDeviceIF, pstObj->stLayout.iX, pstObj->stLayout.iY+pstObj->pstFontRes->iHeight+3, pstObj->stLayout.iX+pstObj->stLayout.iWidth-1, pstObj->stLayout.iY+pstObj->pstFontRes->iHeight+3, SGUI_COLOR_FRGCLR); - } - // Paint items. - SGUI_ItemsBase_Repaint(pstDeviceIF, &(pstObj->stItems)); - // Paint scroll bar. - SGUI_ScrollBar_SetValue(&(pstObj->stScrollBar), pstObj->stItems.stVisibleStart.iIndex); - SGUI_ScrollBar_Repaint(pstDeviceIF, &(pstObj->stScrollBar)); - } + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_RECT stTitleTextDisplayArea; + SGUI_POINT stInnerPos; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(NULL != pstObj) + { + // Clear list item display area. + SGUI_Basic_DrawRectangle(pstDeviceIF, pstObj->stLayout.iX, pstObj->stLayout.iY, pstObj->stLayout.iWidth, pstObj->stLayout.iHeight, SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); + // Paint title. + if(NULL != pstObj->szTitle) + { + stTitleTextDisplayArea.iX = pstObj->stLayout.iX+2; + stTitleTextDisplayArea.iY = pstObj->stLayout.iY+2; + stTitleTextDisplayArea.iWidth = pstObj->stLayout.iWidth-4; + stTitleTextDisplayArea.iHeight = pstObj->pstFontRes->iHeight; + stInnerPos.iX = 0; + stInnerPos.iY = 0; + SGUI_Text_DrawText(pstDeviceIF, pstObj->szTitle, pstObj->pstFontRes, &stTitleTextDisplayArea, &stInnerPos, SGUI_DRAW_NORMAL); + SGUI_Basic_DrawLine(pstDeviceIF, pstObj->stLayout.iX, pstObj->stLayout.iY+pstObj->pstFontRes->iHeight+3, pstObj->stLayout.iX+pstObj->stLayout.iWidth-1, pstObj->stLayout.iY+pstObj->pstFontRes->iHeight+3, SGUI_COLOR_FRGCLR); + } + // Paint items. + SGUI_ItemsBase_Repaint(pstDeviceIF, &(pstObj->stItems)); + // Paint scroll bar. + SGUI_ScrollBar_SetValue(&(pstObj->stScrollBar), pstObj->stItems.stVisibleStart.iIndex); + SGUI_ScrollBar_Repaint(pstDeviceIF, &(pstObj->stScrollBar)); + } } /*************************************************************************/ -/** Function Name: SGUI_List_Resize **/ -/** Purpose: Resize and calculate layout parameter for display **/ -/** changed. **/ -/** Params: **/ -/** @ pstObj[in]: Pointer of list object will be paint. **/ -/** @ cpstNewLayout[in]: New position and size. **/ -/** Return: None. **/ -/** Notice: None. **/ +/** Function Name: SGUI_List_Resize **/ +/** Purpose: Resize and calculate layout parameter for display **/ +/** changed. **/ +/** Params: **/ +/** @ pstObj[in]: Pointer of list object will be paint. **/ +/** @ cpstNewLayout[in]: New position and size. **/ +/** Return: None. **/ +/** Notice: None. **/ /*************************************************************************/ void SGUI_List_Resize(SGUI_LIST* pstObj, const SGUI_RECT* pstNewLayout) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_RECT stSubLayout; - - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - SGUI_SystemIF_MemorySet(&stSubLayout, 0x00, sizeof(SGUI_RECT)); - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - // Copy layout. - SGUI_SystemIF_MemoryCopy(&(pstObj->stLayout), pstNewLayout, sizeof(SGUI_RECT)); - // Resize Items. - stSubLayout.iX = pstObj->stLayout.iX+2; - stSubLayout.iWidth = pstObj->stLayout.iWidth-4-LIST_SCROLLBAR_WIDTH; - if(NULL == pstObj->szTitle) - { - stSubLayout.iY = pstObj->stLayout.iY+2; - stSubLayout.iHeight = pstObj->stLayout.iHeight-4; - } - else - { - stSubLayout.iY = stSubLayout.iY+LIST_TITLE_HEIGHT(pstObj->pstFontRes)+2; - stSubLayout.iHeight = pstObj->stLayout.iHeight-LIST_TITLE_HEIGHT(pstObj->pstFontRes)-3; - } - SGUI_ItemsBase_Resize(&(pstObj->stItems), &stSubLayout); - // Resize scroll bar. - pstObj->stScrollBar.stParam.stLayout.iX = pstObj->stItems.stLayout.iX+pstObj->stItems.stLayout.iWidth+1; - pstObj->stScrollBar.stParam.stLayout.iY = pstObj->stItems.stLayout.iY; - pstObj->stScrollBar.stParam.stLayout.iWidth = LIST_SCROLLBAR_WIDTH; - pstObj->stScrollBar.stParam.stLayout.iHeight = pstObj->stItems.stLayout.iHeight; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_RECT stSubLayout; + + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + SGUI_SystemIF_MemorySet(&stSubLayout, 0x00, sizeof(SGUI_RECT)); + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + // Copy layout. + SGUI_SystemIF_MemoryCopy(&(pstObj->stLayout), pstNewLayout, sizeof(SGUI_RECT)); + // Resize Items. + stSubLayout.iX = pstObj->stLayout.iX+2; + stSubLayout.iWidth = pstObj->stLayout.iWidth-4-LIST_SCROLLBAR_WIDTH; + if(NULL == pstObj->szTitle) + { + stSubLayout.iY = pstObj->stLayout.iY+2; + stSubLayout.iHeight = pstObj->stLayout.iHeight-4; + } + else + { + stSubLayout.iY = stSubLayout.iY+LIST_TITLE_HEIGHT(pstObj->pstFontRes)+2; + stSubLayout.iHeight = pstObj->stLayout.iHeight-LIST_TITLE_HEIGHT(pstObj->pstFontRes)-3; + } + SGUI_ItemsBase_Resize(&(pstObj->stItems), &stSubLayout); + // Resize scroll bar. + pstObj->stScrollBar.stParam.stLayout.iX = pstObj->stItems.stLayout.iX+pstObj->stItems.stLayout.iWidth+1; + pstObj->stScrollBar.stParam.stLayout.iY = pstObj->stItems.stLayout.iY; + pstObj->stScrollBar.stParam.stLayout.iWidth = LIST_SCROLLBAR_WIDTH; + pstObj->stScrollBar.stParam.stLayout.iHeight = pstObj->stItems.stLayout.iHeight; } /*************************************************************************/ -/** Function Name: SGUI_List_RemoveItem **/ -/** Purpose: Remove a item from list. **/ -/** Params: **/ -/** @ pstObj[in]: Pointer of list object. **/ -/** @ iRemoveIndex[in]: Index of item will be removed. **/ -/** Return: Removed item object pointer. **/ -/** Notice: if memory of item is dynamically allocated, Please **/ -/** release MANUALLY. **/ +/** Function Name: SGUI_List_RemoveItem **/ +/** Purpose: Remove a item from list. **/ +/** Params: **/ +/** @ pstObj[in]: Pointer of list object. **/ +/** @ iRemoveIndex[in]: Index of item will be removed. **/ +/** Return: Removed item object pointer. **/ +/** Notice: if memory of item is dynamically allocated, Please **/ +/** release MANUALLY. **/ /*************************************************************************/ SGUI_ITEMS_ITEM* SGUI_List_RemoveItem(SGUI_LIST* pstObj, SGUI_INT iRemoveIndex) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_ITEMS_ITEM* pstRemovedItem; - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - pstRemovedItem = SGUI_ItemsBase_RemoveItem(&(pstObj->stItems), iRemoveIndex); - // Paint scroll bar. - SGUI_ScrollBar_SetMax(&(pstObj->stScrollBar), (pstObj->stItems.iCount > pstObj->stItems.iVisibleItems)?(pstObj->stItems.iCount - pstObj->stItems.iVisibleItems):0) - SGUI_ScrollBar_SetValue(&(pstObj->stScrollBar), pstObj->stItems.stVisibleStart.iIndex); - - return pstRemovedItem; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_ITEMS_ITEM* pstRemovedItem; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + pstRemovedItem = SGUI_ItemsBase_RemoveItem(&(pstObj->stItems), iRemoveIndex); + // Paint scroll bar. + SGUI_ScrollBar_SetMax(&(pstObj->stScrollBar), (pstObj->stItems.iCount > pstObj->stItems.iVisibleItems)?(pstObj->stItems.iCount - pstObj->stItems.iVisibleItems):0) + SGUI_ScrollBar_SetValue(&(pstObj->stScrollBar), pstObj->stItems.stVisibleStart.iIndex); + + return pstRemovedItem; } /*************************************************************************/ -/** Function Name: SGUI_List_InsertItem **/ -/** Purpose: Insert a new item before item with the index. **/ -/** Params: **/ -/** @ pstObj[in]: Pointer of items-base object. **/ -/** @ pstNewItem[in]: Inserted new item object. **/ -/** @ iIndex[in]: Index of new inserted item . **/ -/** Return: Inserted item object pointer. **/ -/** Notice: Return NULL when insert failed. **/ +/** Function Name: SGUI_List_InsertItem **/ +/** Purpose: Insert a new item before item with the index. **/ +/** Params: **/ +/** @ pstObj[in]: Pointer of items-base object. **/ +/** @ pstNewItem[in]: Inserted new item object. **/ +/** @ iIndex[in]: Index of new inserted item . **/ +/** Return: Inserted item object pointer. **/ +/** Notice: Return NULL when insert failed. **/ /*************************************************************************/ SGUI_ITEMS_ITEM* SGUI_List_InsertItem(SGUI_LIST* pstObj, SGUI_ITEMS_ITEM* pstNewItem, SGUI_INT iIndex) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_ITEMS_ITEM* pstInsertedItem; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_ITEMS_ITEM* pstInsertedItem; - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - pstInsertedItem = SGUI_ItemsBase_InsertItem(&(pstObj->stItems), pstNewItem, iIndex); + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + pstInsertedItem = SGUI_ItemsBase_InsertItem(&(pstObj->stItems), pstNewItem, iIndex); - // Paint scroll bar. - SGUI_ScrollBar_SetMax(&(pstObj->stScrollBar), (pstObj->stItems.iCount > pstObj->stItems.iVisibleItems)?(pstObj->stItems.iCount - pstObj->stItems.iVisibleItems):0) - SGUI_ScrollBar_SetValue(&(pstObj->stScrollBar), pstObj->stItems.stVisibleStart.iIndex); + // Paint scroll bar. + SGUI_ScrollBar_SetMax(&(pstObj->stScrollBar), (pstObj->stItems.iCount > pstObj->stItems.iVisibleItems)?(pstObj->stItems.iCount - pstObj->stItems.iVisibleItems):0) + SGUI_ScrollBar_SetValue(&(pstObj->stScrollBar), pstObj->stItems.stVisibleStart.iIndex); - return pstInsertedItem; + return pstInsertedItem; } diff --git a/GUI/src/SGUI_Menu.c b/GUI/src/SGUI_Menu.c index d05ef2d509484f7348873478879d90c6e1f17d70..eca8299c395716e20b8084969eeffa1e0d76aba2 100644 --- a/GUI/src/SGUI_Menu.c +++ b/GUI/src/SGUI_Menu.c @@ -1,22 +1,22 @@ /*************************************************************************/ -/** Copyright. **/ -/** FileName: SGUI_Menu.c **/ -/** Author: Polarix **/ -/** Description: Menu component interface. **/ +/** Copyright. **/ +/** FileName: SGUI_Menu.c **/ +/** Author: Polarix **/ +/** Description: Menu component interface. **/ /*************************************************************************/ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "SGUI_Menu.h" //=======================================================================// -//= User Macro definition. =// +//= User Macro definition. =// //=======================================================================// -#define SGUI_MENU_ICON_DECLARE(NAME) extern const SGUI_BMP_RES NAME -#define SGUI_MENU_ICON_DEFINE(NAME, W, H, ...) const SGUI_BYTE NAME##DATA[] = {__VA_ARGS__};\ - const SGUI_BMP_RES NAME = {W, H, NAME##DATA} +#define SGUI_MENU_ICON_DECLARE(NAME) extern const SGUI_BMP_RES NAME +#define SGUI_MENU_ICON_DEFINE(NAME, W, H, ...) const SGUI_BYTE NAME##DATA[] = {__VA_ARGS__};\ + const SGUI_BMP_RES NAME = {W, H, NAME##DATA} //=======================================================================// -//= Static variable define. =// +//= Static variable define. =// //=======================================================================// static SGUI_MENU_ICON_DEFINE(SGUI_MENU_ICON_MOVEUP, 5, 3, 0x04,0x06,0x07,0x06,0x04); @@ -24,192 +24,192 @@ static SGUI_MENU_ICON_DEFINE(SGUI_MENU_ICON_MOVEDOWN, 5, 3, 0x01,0x03,0x07,0x03,0x01); //=======================================================================// -//= Function define. =// +//= Function define. =// //=======================================================================// /*************************************************************************/ -/** Function Name: SGUI_Menu_Initialize **/ -/** Purpose: Initialize a menu structure data. **/ -/** Params: **/ -/** @ pstObj[in]: Pointer of menu data will be initialized. **/ -/** @ pstFontRes[in]: Font resource object pointer. **/ -/** @ pstItemsData[in]: List items data array. **/ -/** @ iItemsCount[in]: Number of list item data. **/ -/** Return: None. **/ -/** Notice: None. **/ +/** Function Name: SGUI_Menu_Initialize **/ +/** Purpose: Initialize a menu structure data. **/ +/** Params: **/ +/** @ pstObj[in]: Pointer of menu data will be initialized. **/ +/** @ pstFontRes[in]: Font resource object pointer. **/ +/** @ pstItemsData[in]: List items data array. **/ +/** @ iItemsCount[in]: Number of list item data. **/ +/** Return: None. **/ +/** Notice: None. **/ /*************************************************************************/ void SGUI_Menu_Initialize(SGUI_MENU* pstObj, const SGUI_RECT* cpstLayout, const SGUI_FONT_RES* pstFontRes, SGUI_ITEMS_ITEM* pstItemsData, SGUI_INT iItemsCount) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_RECT sItemstLayout; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_RECT sItemstLayout; - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if((NULL != pstObj) && (NULL != pstFontRes)) - { - // Save layout. - SGUI_SystemIF_MemoryCopy(&(pstObj->stLayout), cpstLayout, sizeof(SGUI_RECT)); - // Initialize member object pointer. - pstObj->pstFontRes = pstFontRes; - pstObj->stItems.pstFirstItem = NULL; - sItemstLayout.iX = pstObj->stLayout.iX+1; - sItemstLayout.iY = pstObj->stLayout.iY+SGUI_MENU_ICON_MOVEUP.iHeight+1; - sItemstLayout.iWidth = pstObj->stLayout.iWidth-2; - sItemstLayout.iHeight = pstObj->stLayout.iHeight-(SGUI_MENU_ICON_MOVEUP.iHeight+SGUI_MENU_ICON_MOVEDOWN.iHeight+2); - SGUI_ItemsBase_Initialize(&(pstObj->stItems), &sItemstLayout, pstObj->pstFontRes, pstItemsData, iItemsCount); - } + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if((NULL != pstObj) && (NULL != pstFontRes)) + { + // Save layout. + SGUI_SystemIF_MemoryCopy(&(pstObj->stLayout), cpstLayout, sizeof(SGUI_RECT)); + // Initialize member object pointer. + pstObj->pstFontRes = pstFontRes; + pstObj->stItems.pstFirstItem = NULL; + sItemstLayout.iX = pstObj->stLayout.iX+1; + sItemstLayout.iY = pstObj->stLayout.iY+SGUI_MENU_ICON_MOVEUP.iHeight+1; + sItemstLayout.iWidth = pstObj->stLayout.iWidth-2; + sItemstLayout.iHeight = pstObj->stLayout.iHeight-(SGUI_MENU_ICON_MOVEUP.iHeight+SGUI_MENU_ICON_MOVEDOWN.iHeight+2); + SGUI_ItemsBase_Initialize(&(pstObj->stItems), &sItemstLayout, pstObj->pstFontRes, pstItemsData, iItemsCount); + } } /*************************************************************************/ -/** Function Name: SGUI_Menu_Repaint **/ -/** Purpose: Refresh list display. **/ -/** Params: **/ -/** @ pstDeviceIF[in]: Device driver object pointer. **/ -/** @ pstObj[in]: Pointer of menu structure will be refreshed. **/ -/** Return: None. **/ -/** Notice: This function will refresh all list display on **/ -/** screen, include edge, items, title and scrollbar. **/ +/** Function Name: SGUI_Menu_Repaint **/ +/** Purpose: Refresh list display. **/ +/** Params: **/ +/** @ pstDeviceIF[in]: Device driver object pointer. **/ +/** @ pstObj[in]: Pointer of menu structure will be refreshed. **/ +/** Return: None. **/ +/** Notice: This function will refresh all list display on **/ +/** screen, include edge, items, title and scrollbar. **/ /*************************************************************************/ void SGUI_Menu_Repaint(SGUI_SCR_DEV* pstDeviceIF, SGUI_MENU* pstObj) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_RECT stIconArea; - SGUI_POINT stIconInnerPos; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_RECT stIconArea; + SGUI_POINT stIconInnerPos; - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - stIconInnerPos.iX = 0; - stIconInnerPos.iY = 0; + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + stIconInnerPos.iX = 0; + stIconInnerPos.iY = 0; - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if(NULL != pstObj) - { - /* Clear list item display area. */ - SGUI_Basic_DrawRectangle(pstDeviceIF, pstObj->stLayout.iX, pstObj->stLayout.iY, pstObj->stLayout.iWidth, pstObj->stLayout.iHeight, SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); - // Paint items. - //SGUI_ItemsBase_Resize(&(pstObj->stItems)); - SGUI_ItemsBase_Repaint(pstDeviceIF, &(pstObj->stItems)); - /* Paint arrow icon. */ - stIconArea.iWidth = 5; - stIconArea.iHeight = 3; - stIconArea.iX = pstObj->stLayout.iX+((pstObj->stLayout.iWidth-stIconArea.iWidth)/2); - if(SGUI_Menu_CanScrollUp(pstObj)) - { - stIconArea.iY = pstObj->stLayout.iY+1; + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(NULL != pstObj) + { + /* Clear list item display area. */ + SGUI_Basic_DrawRectangle(pstDeviceIF, pstObj->stLayout.iX, pstObj->stLayout.iY, pstObj->stLayout.iWidth, pstObj->stLayout.iHeight, SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); + // Paint items. + //SGUI_ItemsBase_Resize(&(pstObj->stItems)); + SGUI_ItemsBase_Repaint(pstDeviceIF, &(pstObj->stItems)); + /* Paint arrow icon. */ + stIconArea.iWidth = 5; + stIconArea.iHeight = 3; + stIconArea.iX = pstObj->stLayout.iX+((pstObj->stLayout.iWidth-stIconArea.iWidth)/2); + if(SGUI_Menu_CanScrollUp(pstObj)) + { + stIconArea.iY = pstObj->stLayout.iY+1; SGUI_Basic_DrawBitMap(pstDeviceIF, &stIconArea, &stIconInnerPos, &SGUI_MENU_ICON_MOVEUP, SGUI_DRAW_NORMAL); - } - if(SGUI_Menu_CanScrollDown(pstObj)) - { - stIconArea.iY = RECT_Y_END(pstObj->stItems.stLayout)+1; - SGUI_Basic_DrawBitMap(pstDeviceIF, &stIconArea, &stIconInnerPos, &SGUI_MENU_ICON_MOVEDOWN, SGUI_DRAW_NORMAL); - } - } + } + if(SGUI_Menu_CanScrollDown(pstObj)) + { + stIconArea.iY = RECT_Y_END(pstObj->stItems.stLayout)+1; + SGUI_Basic_DrawBitMap(pstDeviceIF, &stIconArea, &stIconInnerPos, &SGUI_MENU_ICON_MOVEDOWN, SGUI_DRAW_NORMAL); + } + } } /*************************************************************************/ -/** Function Name: SGUI_Menu_FitLayout **/ -/** Purpose: Resize menu to best fit size order by position and **/ -/** screen size. **/ -/** Params: **/ -/** @ pstDeviceIF[in]: Device driver object pointer. **/ -/** @ pstObj[in]: Pointer of menu structure will be refreshed. **/ -/** Return: None. **/ -/** Notice: This function must called after initialize. **/ +/** Function Name: SGUI_Menu_FitLayout **/ +/** Purpose: Resize menu to best fit size order by position and **/ +/** screen size. **/ +/** Params: **/ +/** @ pstDeviceIF[in]: Device driver object pointer. **/ +/** @ pstObj[in]: Pointer of menu structure will be refreshed. **/ +/** Return: None. **/ +/** Notice: This function must called after initialize. **/ /*************************************************************************/ void SGUI_Menu_Resize(SGUI_MENU* pstObj, const SGUI_RECT* cpstNewLayout) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_RECT stItemsLayout; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_RECT stItemsLayout; - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if((NULL != pstObj) && (NULL != cpstNewLayout)) - { - pstObj->stLayout.iX = cpstNewLayout->iX; - pstObj->stLayout.iY = cpstNewLayout->iY; - pstObj->stLayout.iWidth = cpstNewLayout->iWidth; - pstObj->stLayout.iHeight = cpstNewLayout->iHeight; - stItemsLayout.iX = cpstNewLayout->iX+1; - stItemsLayout.iY = cpstNewLayout->iY+SGUI_MENU_ICON_MOVEUP.iHeight+1; - stItemsLayout.iWidth = cpstNewLayout->iWidth-2; - stItemsLayout.iHeight = cpstNewLayout->iHeight-(SGUI_MENU_ICON_MOVEUP.iHeight+SGUI_MENU_ICON_MOVEDOWN.iHeight+2); - SGUI_ItemsBase_Resize(&(pstObj->stItems), &stItemsLayout); - } + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if((NULL != pstObj) && (NULL != cpstNewLayout)) + { + pstObj->stLayout.iX = cpstNewLayout->iX; + pstObj->stLayout.iY = cpstNewLayout->iY; + pstObj->stLayout.iWidth = cpstNewLayout->iWidth; + pstObj->stLayout.iHeight = cpstNewLayout->iHeight; + stItemsLayout.iX = cpstNewLayout->iX+1; + stItemsLayout.iY = cpstNewLayout->iY+SGUI_MENU_ICON_MOVEUP.iHeight+1; + stItemsLayout.iWidth = cpstNewLayout->iWidth-2; + stItemsLayout.iHeight = cpstNewLayout->iHeight-(SGUI_MENU_ICON_MOVEUP.iHeight+SGUI_MENU_ICON_MOVEDOWN.iHeight+2); + SGUI_ItemsBase_Resize(&(pstObj->stItems), &stItemsLayout); + } } /*************************************************************************/ -/** Function Name: SGUI_Menu_PopupSubMenu **/ -/** Purpose: Resize menu to best fit size order by position and **/ -/** screen size. **/ -/** Params: **/ -/** @ pstDeviceIF[in]: Device driver object pointer. **/ -/** @ pstObj[in]: Pointer of menu structure will be refreshed. **/ -/** @ cpstParentItemLayout[in]: Pointer of parent menu item, sub menu **/ -/** layout will update order by parent item layout. **/ -/** Return: None. **/ -/** Notice: For **/ -/** screen, include edge, items, title and scrollbar. **/ +/** Function Name: SGUI_Menu_PopupSubMenu **/ +/** Purpose: Resize menu to best fit size order by position and **/ +/** screen size. **/ +/** Params: **/ +/** @ pstDeviceIF[in]: Device driver object pointer. **/ +/** @ pstObj[in]: Pointer of menu structure will be refreshed. **/ +/** @ cpstParentItemLayout[in]: Pointer of parent menu item, sub menu **/ +/** layout will update order by parent item layout. **/ +/** Return: None. **/ +/** Notice: For **/ +/** screen, include edge, items, title and scrollbar. **/ /*************************************************************************/ void SGUI_Menu_PopupSubMenu(SGUI_SCR_DEV* pstDeviceIF, SGUI_MENU* pstObj, const SGUI_RECT* cpstParentItemLayout) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_INT iFullHeight; - SGUI_INT iVisibleHeight; - SGUI_RECT stLayout; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_INT iFullHeight; + SGUI_INT iVisibleHeight; + SGUI_RECT stLayout; - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if((NULL != pstObj) && (pstObj->stItems.iCount >0)) - { - /* Calculate a virtual height when display all items. */ - iFullHeight = pstObj->stItems.iCount*ITEM_HEIGHT(pstObj->pstFontRes); - iFullHeight = iFullHeight+SGUI_MENU_ICON_MOVEUP.iHeight+SGUI_MENU_ICON_MOVEDOWN.iHeight+2; + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if((NULL != pstObj) && (pstObj->stItems.iCount >0)) + { + /* Calculate a virtual height when display all items. */ + iFullHeight = pstObj->stItems.iCount*ITEM_HEIGHT(pstObj->pstFontRes); + iFullHeight = iFullHeight+SGUI_MENU_ICON_MOVEUP.iHeight+SGUI_MENU_ICON_MOVEDOWN.iHeight+2; - stLayout.iX = RECT_X_END(*cpstParentItemLayout)+1; - iVisibleHeight = pstDeviceIF->stSize.iHeight-cpstParentItemLayout->iY-1; - if((iVisibleHeight < iFullHeight) && (cpstParentItemLayout->iY > (pstDeviceIF->stSize.iHeight/2))) - { - iVisibleHeight = cpstParentItemLayout->iY+cpstParentItemLayout->iHeight+1; - stLayout.iY = iVisibleHeight-iFullHeight-1; - if(stLayout.iY<0) - { - stLayout.iY = 0; - } - } - else - { - stLayout.iY = cpstParentItemLayout->iY; - } - stLayout.iWidth = cpstParentItemLayout->iWidth+2; - if(iFullHeight > iVisibleHeight) - { - stLayout.iHeight = iVisibleHeight; - } - else - { - stLayout.iHeight = iFullHeight; - } - SGUI_Menu_Resize(pstObj, &stLayout); - } + stLayout.iX = RECT_X_END(*cpstParentItemLayout)+1; + iVisibleHeight = pstDeviceIF->stSize.iHeight-cpstParentItemLayout->iY-1; + if((iVisibleHeight < iFullHeight) && (cpstParentItemLayout->iY > (pstDeviceIF->stSize.iHeight/2))) + { + iVisibleHeight = cpstParentItemLayout->iY+cpstParentItemLayout->iHeight+1; + stLayout.iY = iVisibleHeight-iFullHeight-1; + if(stLayout.iY<0) + { + stLayout.iY = 0; + } + } + else + { + stLayout.iY = cpstParentItemLayout->iY; + } + stLayout.iWidth = cpstParentItemLayout->iWidth+2; + if(iFullHeight > iVisibleHeight) + { + stLayout.iHeight = iVisibleHeight; + } + else + { + stLayout.iHeight = iFullHeight; + } + SGUI_Menu_Resize(pstObj, &stLayout); + } } diff --git a/GUI/src/SGUI_Notice.c b/GUI/src/SGUI_Notice.c index fd82f2871b1acc5dc92954e49be95244c105faf6..3abb18ba51e4cc992114b08ffa1803a3405e20f6 100644 --- a/GUI/src/SGUI_Notice.c +++ b/GUI/src/SGUI_Notice.c @@ -1,90 +1,90 @@ /*************************************************************************/ -/** Copyright. **/ -/** FileName: SGUI_Notice.c **/ -/** Author: XuYulin **/ -/** Description: Notice box display interface. **/ +/** Copyright. **/ +/** FileName: SGUI_Notice.c **/ +/** Author: XuYulin **/ +/** Description: Notice box display interface. **/ /*************************************************************************/ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "SGUI_Notice.h" //=======================================================================// -//= User Macro definition. =// +//= User Macro definition. =// //=======================================================================// -#define SGUI_NOTICE_MARGIN (5) +#define SGUI_NOTICE_MARGIN (5) //=======================================================================// -//= Function define. =// +//= Function define. =// //=======================================================================// /*************************************************************************/ -/** Function Name: SGUI_Notice_RefreshNotice **/ -/** Purpose: Show a notice box. **/ -/** Params: **/ -/** Params: **/ -/** @ pstDeviceIF[in]: SimpleGUI object pointer. **/ -/** @ pstObject[in]: Object structure pointer. **/ -/** @ pstFontRes[in]: Text font resource. **/ -/** @ uiTextOffset[in]: Text top offset. **/ -/** Return: Remaining text height display. **/ -/** Notice: None. **/ +/** Function Name: SGUI_Notice_RefreshNotice **/ +/** Purpose: Show a notice box. **/ +/** Params: **/ +/** Params: **/ +/** @ pstDeviceIF[in]: SimpleGUI object pointer. **/ +/** @ pstObject[in]: Object structure pointer. **/ +/** @ pstFontRes[in]: Text font resource. **/ +/** @ uiTextOffset[in]: Text top offset. **/ +/** Return: Remaining text height display. **/ +/** Notice: None. **/ /*************************************************************************/ SGUI_SIZE SGUI_Notice_Repaint(SGUI_SCR_DEV* pstDeviceIF, SGUI_NOTICT_BOX* pstObject, const SGUI_FONT_RES* pstFontRes, SGUI_INT uiTextOffset) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_SIZE uiTextLines; - SGUI_RECT stIconDisplayArea; - SGUI_POINT stIconPosition; - SGUI_RECT stTextDisplayArea; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_SIZE uiTextLines; + SGUI_RECT stIconDisplayArea; + SGUI_POINT stIconPosition; + SGUI_RECT stTextDisplayArea; - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if((NULL != pstObject) && (NULL != pstObject->cszNoticeText)) - { - // Draw edgeNOTICE_BOX_MARGIN - SGUI_Basic_DrawRectangle(pstDeviceIF, pstObject->stLayout.iX, pstObject->stLayout.iY, pstObject->stLayout.iWidth, pstObject->stLayout.iHeight, SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if((NULL != pstObject) && (NULL != pstObject->cszNoticeText)) + { + // Draw edgeNOTICE_BOX_MARGIN + SGUI_Basic_DrawRectangle(pstDeviceIF, pstObject->stLayout.iX, pstObject->stLayout.iY, pstObject->stLayout.iWidth, pstObject->stLayout.iHeight, SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); - stTextDisplayArea.iY = pstObject->stLayout.iY+2; - stTextDisplayArea.iHeight = pstObject->stLayout.iHeight-4; - if(NULL == pstObject->pstIcon) - { - stTextDisplayArea.iX = pstObject->stLayout.iX+2; - stTextDisplayArea.iWidth = pstObject->stLayout.iWidth-4; - } - else - { - stTextDisplayArea.iX = pstObject->stLayout.iX+pstObject->pstIcon->iWidth+4; - stTextDisplayArea.iWidth = pstObject->stLayout.iWidth-pstObject->pstIcon->iWidth-6; + stTextDisplayArea.iY = pstObject->stLayout.iY+2; + stTextDisplayArea.iHeight = pstObject->stLayout.iHeight-4; + if(NULL == pstObject->pstIcon) + { + stTextDisplayArea.iX = pstObject->stLayout.iX+2; + stTextDisplayArea.iWidth = pstObject->stLayout.iWidth-4; + } + else + { + stTextDisplayArea.iX = pstObject->stLayout.iX+pstObject->pstIcon->iWidth+4; + stTextDisplayArea.iWidth = pstObject->stLayout.iWidth-pstObject->pstIcon->iWidth-6; - stIconDisplayArea.iX = pstObject->stLayout.iX+2; - stIconDisplayArea.iY = pstObject->stLayout.iY+2; - stIconDisplayArea.iWidth = pstObject->pstIcon->iWidth; - stIconDisplayArea.iHeight = pstObject->pstIcon->iHeight; - stIconPosition.iX = 0; - stIconPosition.iY = 0; - // Paint icon. - SGUI_Basic_DrawBitMap(pstDeviceIF, &stIconDisplayArea, &stIconPosition, pstObject->pstIcon, SGUI_DRAW_NORMAL); - } - // Draw text; - uiTextLines = SGUI_Text_DrawMultipleLinesText(pstDeviceIF, pstObject->cszNoticeText, pstFontRes, &stTextDisplayArea, uiTextOffset, SGUI_DRAW_NORMAL); - } + stIconDisplayArea.iX = pstObject->stLayout.iX+2; + stIconDisplayArea.iY = pstObject->stLayout.iY+2; + stIconDisplayArea.iWidth = pstObject->pstIcon->iWidth; + stIconDisplayArea.iHeight = pstObject->pstIcon->iHeight; + stIconPosition.iX = 0; + stIconPosition.iY = 0; + // Paint icon. + SGUI_Basic_DrawBitMap(pstDeviceIF, &stIconDisplayArea, &stIconPosition, pstObject->pstIcon, SGUI_DRAW_NORMAL); + } + // Draw text; + uiTextLines = SGUI_Text_DrawMultipleLinesText(pstDeviceIF, pstObject->cszNoticeText, pstFontRes, &stTextDisplayArea, uiTextOffset, SGUI_DRAW_NORMAL); + } return uiTextLines; } void SGUI_Notice_FitArea(SGUI_SCR_DEV* pstDeviceIF, SGUI_RECT* pstFitArea) { - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if((NULL != pstDeviceIF) && (NULL != pstFitArea)) - { - pstFitArea->iX = SGUI_NOTICE_MARGIN; - pstFitArea->iY = SGUI_NOTICE_MARGIN; - pstFitArea->iWidth = pstDeviceIF->stSize.iWidth-(SGUI_NOTICE_MARGIN<<1); - pstFitArea->iHeight = pstDeviceIF->stSize.iHeight-(SGUI_NOTICE_MARGIN<<1); - } + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if((NULL != pstDeviceIF) && (NULL != pstFitArea)) + { + pstFitArea->iX = SGUI_NOTICE_MARGIN; + pstFitArea->iY = SGUI_NOTICE_MARGIN; + pstFitArea->iWidth = pstDeviceIF->stSize.iWidth-(SGUI_NOTICE_MARGIN<<1); + pstFitArea->iHeight = pstDeviceIF->stSize.iHeight-(SGUI_NOTICE_MARGIN<<1); + } } diff --git a/GUI/src/SGUI_ProcessBar.c b/GUI/src/SGUI_ProcessBar.c index d3d7393777ede929dbf8767275eee25cd46a914b..709bd2d2c06e48771e7522dd499f24499d98761b 100644 --- a/GUI/src/SGUI_ProcessBar.c +++ b/GUI/src/SGUI_ProcessBar.c @@ -1,98 +1,98 @@ /*************************************************************************/ -/** Copyright. **/ -/** FileName: SGUI_ProcessBar.c **/ -/** Author: XuYulin **/ -/** Description: Process bar display interface. **/ +/** Copyright. **/ +/** FileName: SGUI_ProcessBar.c **/ +/** Author: XuYulin **/ +/** Description: Process bar display interface. **/ /*************************************************************************/ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "SGUI_ProcessBar.h" //=======================================================================// -//= Function define. =// +//= Function define. =// //=======================================================================// /*************************************************************************/ -/** Function Name: SGUI_RefreshProcessBar **/ -/** Purpose: Display or update a process bar. **/ -/** Resources: Process bar data structure. **/ -/** Params: **/ -/** @ pstDeviceIF[in]: SimpleGUI object pointer. **/ -/** @ pstProcessBarData[in]: Process bar data whitch will update on **/ -/** screen. **/ -/** Return: None. **/ -/** Notice: None. **/ +/** Function Name: SGUI_RefreshProcessBar **/ +/** Purpose: Display or update a process bar. **/ +/** Resources: Process bar data structure. **/ +/** Params: **/ +/** @ pstDeviceIF[in]: SimpleGUI object pointer. **/ +/** @ pstProcessBarData[in]: Process bar data whitch will update on **/ +/** screen. **/ +/** Return: None. **/ +/** Notice: None. **/ /*************************************************************************/ void SGUI_ProcessBar_Repaint(SGUI_SCR_DEV* pstDeviceIF, SGUI_PROCBAR_STRUCT *pstProcessBarData) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_UINT16 uiProcessBlockStartX, uiProcessBlockStartY; - SGUI_UINT16 uiProcessBlockWidth, uiProcessBlockHeight; - SGUI_COLOR eBackColor, eFillColor; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_UINT16 uiProcessBlockStartX, uiProcessBlockStartY; + SGUI_UINT16 uiProcessBlockWidth, uiProcessBlockHeight; + SGUI_COLOR eBackColor, eFillColor; - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if(NULL != pstProcessBarData) - { - if((pstProcessBarData->Parameter.Width > 3) && (pstProcessBarData->Parameter.Height > 3)) - { - // Check value must be less then PROCBAR_VALUE_MAX. - if(pstProcessBarData->Data.Value > pstProcessBarData->Parameter.MaxValue) - { - pstProcessBarData->Data.Value = pstProcessBarData->Parameter.MaxValue; - } - // Update process bar data. - switch(pstProcessBarData->Parameter.Direction) - { - case SGUI_PROCBAR_DOWN: // Process from up to down. - { - uiProcessBlockStartX = pstProcessBarData->Parameter.PosX + 1; - uiProcessBlockStartY = pstProcessBarData->Parameter.PosY + 1; - uiProcessBlockWidth = pstProcessBarData->Parameter.Width - 2; - uiProcessBlockHeight = (pstProcessBarData->Parameter.Height - 2) * (pstProcessBarData->Data.Value) / pstProcessBarData->Parameter.MaxValue; - eBackColor = SGUI_COLOR_BKGCLR; - eFillColor = SGUI_COLOR_FRGCLR; - break; - } - case SGUI_PROCBAR_LEFT: // Process from right to left. - { - uiProcessBlockStartX = pstProcessBarData->Parameter.PosX + 1; - uiProcessBlockStartY = pstProcessBarData->Parameter.PosY + 1; - uiProcessBlockWidth = (pstProcessBarData->Parameter.Width - 2) * (pstProcessBarData->Parameter.MaxValue - pstProcessBarData->Data.Value) / pstProcessBarData->Parameter.MaxValue; - uiProcessBlockHeight = pstProcessBarData->Parameter.Height - 2; - eBackColor = SGUI_COLOR_FRGCLR; - eFillColor = SGUI_COLOR_BKGCLR; - break; - } - case SGUI_PROCBAR_RIGHT: // Process from left to right. - { - uiProcessBlockStartX = pstProcessBarData->Parameter.PosX + 1; - uiProcessBlockStartY = pstProcessBarData->Parameter.PosY + 1; - uiProcessBlockWidth = (pstProcessBarData->Parameter.Width - 2) * (pstProcessBarData->Data.Value) / pstProcessBarData->Parameter.MaxValue; - uiProcessBlockHeight = pstProcessBarData->Parameter.Height - 2; - eBackColor = SGUI_COLOR_BKGCLR; - eFillColor = SGUI_COLOR_FRGCLR; - break; - } - case SGUI_PROCBAR_UP: // Process from down to up. - default: - { - uiProcessBlockStartX = pstProcessBarData->Parameter.PosX + 1; - uiProcessBlockStartY = pstProcessBarData->Parameter.PosY + 1; - uiProcessBlockWidth = pstProcessBarData->Parameter.Width - 2; - uiProcessBlockHeight = (pstProcessBarData->Parameter.Height - 2) * (pstProcessBarData->Parameter.MaxValue - pstProcessBarData->Data.Value) / pstProcessBarData->Parameter.MaxValue; - eBackColor = SGUI_COLOR_FRGCLR; - eFillColor = SGUI_COLOR_BKGCLR; - } - } - // Redraw edge and clean up area. - SGUI_Basic_DrawRectangle(pstDeviceIF, pstProcessBarData->Parameter.PosX, pstProcessBarData->Parameter.PosY, pstProcessBarData->Parameter.Width, pstProcessBarData->Parameter.Height, SGUI_COLOR_FRGCLR, eBackColor); - // Draw process block. - SGUI_Basic_DrawRectangle(pstDeviceIF, uiProcessBlockStartX, uiProcessBlockStartY, uiProcessBlockWidth, uiProcessBlockHeight, eFillColor, eFillColor); - } - } + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(NULL != pstProcessBarData) + { + if((pstProcessBarData->Parameter.Width > 3) && (pstProcessBarData->Parameter.Height > 3)) + { + // Check value must be less then PROCBAR_VALUE_MAX. + if(pstProcessBarData->Data.Value > pstProcessBarData->Parameter.MaxValue) + { + pstProcessBarData->Data.Value = pstProcessBarData->Parameter.MaxValue; + } + // Update process bar data. + switch(pstProcessBarData->Parameter.Direction) + { + case SGUI_PROCBAR_DOWN: // Process from up to down. + { + uiProcessBlockStartX = pstProcessBarData->Parameter.PosX + 1; + uiProcessBlockStartY = pstProcessBarData->Parameter.PosY + 1; + uiProcessBlockWidth = pstProcessBarData->Parameter.Width - 2; + uiProcessBlockHeight = (pstProcessBarData->Parameter.Height - 2) * (pstProcessBarData->Data.Value) / pstProcessBarData->Parameter.MaxValue; + eBackColor = SGUI_COLOR_BKGCLR; + eFillColor = SGUI_COLOR_FRGCLR; + break; + } + case SGUI_PROCBAR_LEFT: // Process from right to left. + { + uiProcessBlockStartX = pstProcessBarData->Parameter.PosX + 1; + uiProcessBlockStartY = pstProcessBarData->Parameter.PosY + 1; + uiProcessBlockWidth = (pstProcessBarData->Parameter.Width - 2) * (pstProcessBarData->Parameter.MaxValue - pstProcessBarData->Data.Value) / pstProcessBarData->Parameter.MaxValue; + uiProcessBlockHeight = pstProcessBarData->Parameter.Height - 2; + eBackColor = SGUI_COLOR_FRGCLR; + eFillColor = SGUI_COLOR_BKGCLR; + break; + } + case SGUI_PROCBAR_RIGHT: // Process from left to right. + { + uiProcessBlockStartX = pstProcessBarData->Parameter.PosX + 1; + uiProcessBlockStartY = pstProcessBarData->Parameter.PosY + 1; + uiProcessBlockWidth = (pstProcessBarData->Parameter.Width - 2) * (pstProcessBarData->Data.Value) / pstProcessBarData->Parameter.MaxValue; + uiProcessBlockHeight = pstProcessBarData->Parameter.Height - 2; + eBackColor = SGUI_COLOR_BKGCLR; + eFillColor = SGUI_COLOR_FRGCLR; + break; + } + case SGUI_PROCBAR_UP: // Process from down to up. + default: + { + uiProcessBlockStartX = pstProcessBarData->Parameter.PosX + 1; + uiProcessBlockStartY = pstProcessBarData->Parameter.PosY + 1; + uiProcessBlockWidth = pstProcessBarData->Parameter.Width - 2; + uiProcessBlockHeight = (pstProcessBarData->Parameter.Height - 2) * (pstProcessBarData->Parameter.MaxValue - pstProcessBarData->Data.Value) / pstProcessBarData->Parameter.MaxValue; + eBackColor = SGUI_COLOR_FRGCLR; + eFillColor = SGUI_COLOR_BKGCLR; + } + } + // Redraw edge and clean up area. + SGUI_Basic_DrawRectangle(pstDeviceIF, pstProcessBarData->Parameter.PosX, pstProcessBarData->Parameter.PosY, pstProcessBarData->Parameter.Width, pstProcessBarData->Parameter.Height, SGUI_COLOR_FRGCLR, eBackColor); + // Draw process block. + SGUI_Basic_DrawRectangle(pstDeviceIF, uiProcessBlockStartX, uiProcessBlockStartY, uiProcessBlockWidth, uiProcessBlockHeight, eFillColor, eFillColor); + } + } } diff --git a/GUI/src/SGUI_RealtimeGraph.c b/GUI/src/SGUI_RealtimeGraph.c index 633602c9d6c47e7f2a32e655406f2f7fdb3c3171..fcdc505c8e6b14ca523b4bafccec221b4b715351 100644 --- a/GUI/src/SGUI_RealtimeGraph.c +++ b/GUI/src/SGUI_RealtimeGraph.c @@ -1,235 +1,235 @@ /*************************************************************************/ -/** Copyright. **/ -/** FileName: SGUI_RealtimeGraph.c **/ -/** Author: Polarix **/ -/** Description: Graph adjustment UI interface. **/ +/** Copyright. **/ +/** FileName: SGUI_RealtimeGraph.c **/ +/** Author: Polarix **/ +/** Description: Graph adjustment UI interface. **/ /*************************************************************************/ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "SGUI_RealtimeGraph.h" //=======================================================================// -//= Static function declaration. =// +//= Static function declaration. =// //=======================================================================// static SGUI_INT SGUI_RealtimeGraph_GetValuePointYCoordinate(SGUI_RTGRAPH* pstRTGraph, SGUI_INT iValue); //=======================================================================// -//= Function define. =// +//= Function define. =// //=======================================================================// /*************************************************************************/ -/** Function Name: SGUI_RealtimeGraph_Initialize **/ -/** Purpose: Initialize a graph control data. **/ -/** Params: **/ -/** @ pstRTGraph[in]: Graph map data. **/ -/** Return: None. **/ -/** Notice: None. **/ +/** 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; - - // 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+1; - - // Zero point value must NOT greater then yAxisMax and NOT less then yAxisMin. - if(pstData->BaseLineValue > pstControl->yAxisMax) - { - pstData->BaseLineValue = pstControl->yAxisMax; - } - if(pstData->BaseLineValue < pstControl->yAxisMin) - { - pstData->BaseLineValue = pstControl->yAxisMin; - } - // Calculate the number of value points that can be used. - pstData->ValueCount = (RECT_WIDTH(pstRTGraph->stLayout)-2)/pstControl->xAxisStepPixel; - - // Initialize value array. - for(iValueIndex=0; iValueIndexValueCount; iValueIndex++) - { - pstData->PointYCoordinateArray[iValueIndex] = SGUI_RealtimeGraph_GetValuePointYCoordinate(pstRTGraph, pstData->BaseLineValue);; - } - } + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_RTGRAPH_DATA* pstData; + SGUI_RTGRAPH_CONTROL* pstControl; + SGUI_INT iValueIndex; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(NULL != pstRTGraph) + { + pstData = pstRTGraph->Data; + pstControl = pstRTGraph->Control; + + // 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+1; + + // Zero point value must NOT greater then yAxisMax and NOT less then yAxisMin. + if(pstData->BaseLineValue > pstControl->yAxisMax) + { + pstData->BaseLineValue = pstControl->yAxisMax; + } + if(pstData->BaseLineValue < pstControl->yAxisMin) + { + pstData->BaseLineValue = pstControl->yAxisMin; + } + // Calculate the number of value points that can be used. + pstData->ValueCount = (RECT_WIDTH(pstRTGraph->stLayout)-2)/pstControl->xAxisStepPixel; + + // Initialize value array. + for(iValueIndex=0; iValueIndexValueCount; iValueIndex++) + { + pstData->PointYCoordinateArray[iValueIndex] = SGUI_RealtimeGraph_GetValuePointYCoordinate(pstRTGraph, pstData->BaseLineValue);; + } + } } /*************************************************************************/ -/** Function Name: SGUI_Graph_Refresh **/ -/** Purpose: Refresh graph map display. **/ -/** Resources: Graph data. **/ -/** Params: **/ -/** @ pstDeviceIF[in]: SimpleGUI object pointer. **/ -/** @ pstRTGraph[in]: Graph map data used refreshed. **/ -/** Return: None. **/ -/** Notice: None. **/ +/** Function Name: SGUI_Graph_Refresh **/ +/** Purpose: Refresh graph map display. **/ +/** Resources: Graph data. **/ +/** Params: **/ +/** @ pstDeviceIF[in]: SimpleGUI object pointer. **/ +/** @ pstRTGraph[in]: Graph map data used refreshed. **/ +/** Return: None. **/ +/** Notice: None. **/ /*************************************************************************/ void SGUI_RealtimeGraph_Repaint(SGUI_SCR_DEV* pstDeviceIF, SGUI_RTGRAPH* pstRTGraph) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_RTGRAPH_DATA* pstData; - SGUI_RTGRAPH_CONTROL* pstControl; - SGUI_INT iValueIndex; - SGUI_INT iPixelCoordinateStartX, iPixelCoordinateEndX; - SGUI_INT iBaseLineCoordinateY; - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if((NULL != pstRTGraph) && (NULL != pstDeviceIF)) - { - pstData = pstRTGraph->Data; - pstControl = pstRTGraph->Control; - - // Draw frame - SGUI_Basic_DrawRectangle(pstDeviceIF, RECT_X_START(pstRTGraph->stLayout), RECT_Y_START(pstRTGraph->stLayout), - RECT_WIDTH(pstRTGraph->stLayout), RECT_HEIGHT(pstRTGraph->stLayout), SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); - - if(SGUI_TRUE == pstControl->EnableBaseline) - { - iBaseLineCoordinateY = SGUI_RealtimeGraph_GetValuePointYCoordinate(pstRTGraph, pstData->BaseLineValue); - SGUI_Basic_DrawLine(pstDeviceIF, 1, iBaseLineCoordinateY, RECT_WIDTH(pstDeviceIF->stSize)-2, iBaseLineCoordinateY, SGUI_COLOR_FRGCLR); - } - - if(pstData->ValueCount > 1) - { - for(iValueIndex=1; iValueIndexValueCount; iValueIndex++) - { - iPixelCoordinateStartX = 1 + ((iValueIndex-1) * pstControl->xAxisStepPixel) + RECT_X_START(pstRTGraph->stLayout); - iPixelCoordinateEndX = 1 + (iValueIndex * pstControl->xAxisStepPixel) + RECT_X_START(pstRTGraph->stLayout); - SGUI_Basic_DrawLine(pstDeviceIF, iPixelCoordinateStartX, pstData->PointYCoordinateArray[iValueIndex-1], - iPixelCoordinateEndX, pstData->PointYCoordinateArray[iValueIndex], SGUI_COLOR_FRGCLR); - } - } - } + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_RTGRAPH_DATA* pstData; + SGUI_RTGRAPH_CONTROL* pstControl; + SGUI_INT iValueIndex; + SGUI_INT iPixelCoordinateStartX, iPixelCoordinateEndX; + SGUI_INT iBaseLineCoordinateY; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if((NULL != pstRTGraph) && (NULL != pstDeviceIF)) + { + pstData = pstRTGraph->Data; + pstControl = pstRTGraph->Control; + + // Draw frame + SGUI_Basic_DrawRectangle(pstDeviceIF, RECT_X_START(pstRTGraph->stLayout), RECT_Y_START(pstRTGraph->stLayout), + RECT_WIDTH(pstRTGraph->stLayout), RECT_HEIGHT(pstRTGraph->stLayout), SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); + + if(SGUI_TRUE == pstControl->EnableBaseline) + { + iBaseLineCoordinateY = SGUI_RealtimeGraph_GetValuePointYCoordinate(pstRTGraph, pstData->BaseLineValue); + SGUI_Basic_DrawLine(pstDeviceIF, 1, iBaseLineCoordinateY, RECT_WIDTH(pstDeviceIF->stSize)-2, iBaseLineCoordinateY, SGUI_COLOR_FRGCLR); + } + + if(pstData->ValueCount > 1) + { + for(iValueIndex=1; iValueIndexValueCount; iValueIndex++) + { + iPixelCoordinateStartX = 1 + ((iValueIndex-1) * pstControl->xAxisStepPixel) + RECT_X_START(pstRTGraph->stLayout); + iPixelCoordinateEndX = 1 + (iValueIndex * pstControl->xAxisStepPixel) + RECT_X_START(pstRTGraph->stLayout); + SGUI_Basic_DrawLine(pstDeviceIF, iPixelCoordinateStartX, pstData->PointYCoordinateArray[iValueIndex-1], + iPixelCoordinateEndX, pstData->PointYCoordinateArray[iValueIndex], SGUI_COLOR_FRGCLR); + } + } + } } /*************************************************************************/ -/** Function Name: SGUI_RealtimeGraph_AppendValue **/ -/** Purpose: Append a new value to graph. **/ -/** Params: **/ -/** @ pstDeviceIF[in]: SimpleGUI object pointer. **/ -/** @ pstRTGraph[in]: Real-time graph object pointer. **/ -/** @ iNewValue[in]: New value will be appended. **/ -/** Return: None. **/ -/** Notice: None. **/ +/** Function Name: SGUI_RealtimeGraph_AppendValue **/ +/** Purpose: Append a new value to graph. **/ +/** Params: **/ +/** @ pstDeviceIF[in]: SimpleGUI object pointer. **/ +/** @ pstRTGraph[in]: Real-time graph object pointer. **/ +/** @ iNewValue[in]: New value will be appended. **/ +/** Return: None. **/ +/** Notice: None. **/ /*************************************************************************/ void SGUI_RealtimeGraph_AppendValue(SGUI_SCR_DEV* pstDeviceIF, 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; - - // Push value. - for(iValueIndex=0; iValueIndexValueCount-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); - } + /*----------------------------------*/ + /* 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; + + // Push value. + for(iValueIndex=0; iValueIndexValueCount-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. **/ +/** 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_CONTROL* pstControl; - SGUI_INT iDisplayValuePointAreaHeight; - SGUI_INT iAbsoluteValue; - SGUI_INT iValuePointCoordinate; - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - iValuePointCoordinate = -1; - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if(NULL != pstRTGraph) - { - pstControl = pstRTGraph->Control; - - iDisplayValuePointAreaHeight = RECT_HEIGHT(pstRTGraph->stLayout); - - //Make sure the value is within the valid range - 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 + RECT_Y_START(pstRTGraph->stLayout)-1; - } - - return iValuePointCoordinate; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_RTGRAPH_CONTROL* pstControl; + SGUI_INT iDisplayValuePointAreaHeight; + SGUI_INT iAbsoluteValue; + SGUI_INT iValuePointCoordinate; + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + iValuePointCoordinate = -1; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(NULL != pstRTGraph) + { + pstControl = pstRTGraph->Control; + + iDisplayValuePointAreaHeight = RECT_HEIGHT(pstRTGraph->stLayout); + + //Make sure the value is within the valid range + 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 + RECT_Y_START(pstRTGraph->stLayout)-1; + } + + return iValuePointCoordinate; } diff --git a/GUI/src/SGUI_ScrollBar.c b/GUI/src/SGUI_ScrollBar.c index 072509299ac4d3190df9917ac73e4e06f7484c90..0eecab8e00e0189827a4576967f75d4dda14dd40 100644 --- a/GUI/src/SGUI_ScrollBar.c +++ b/GUI/src/SGUI_ScrollBar.c @@ -1,136 +1,136 @@ /*************************************************************************/ -/** Copyright. **/ -/** FileName: SGUI_ScrollBar.c **/ -/** Author: XuYulin **/ -/** Description: Create and display a scrollbar on screen. **/ +/** Copyright. **/ +/** FileName: SGUI_ScrollBar.c **/ +/** Author: XuYulin **/ +/** Description: Create and display a scrollbar on screen. **/ /*************************************************************************/ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "SGUI_ScrollBar.h" //=======================================================================// -//= Function define. =// +//= Function define. =// //=======================================================================// /*************************************************************************/ -/** Function Name: SGUI_ScrollBar_Initialize **/ -/** Purpose: Initialize a scroll bar structure. **/ -/** Params: **/ -/** @ pstObj[in]: Scroll bar object pointer. **/ -/** @ pcstInitParam[in]: Initialize parameter data. **/ -/** Return: None. **/ +/** Function Name: SGUI_ScrollBar_Initialize **/ +/** Purpose: Initialize a scroll bar structure. **/ +/** Params: **/ +/** @ pstObj[in]: Scroll bar object pointer. **/ +/** @ pcstInitParam[in]: Initialize parameter data. **/ +/** Return: None. **/ /*************************************************************************/ void SGUI_ScrollBar_Initialize(SGUI_SCROLLBAR_STRUCT* pstObj, const SGUI_SCROLLBAR_PARAM* pcstInitParam) { - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if((NULL != pstObj) && (NULL != pcstInitParam)) - { - SGUI_SystemIF_MemorySet(pstObj, 0x00, sizeof(SGUI_SCROLLBAR_STRUCT)); - SGUI_SystemIF_MemoryCopy(&(pstObj->stParam), (void*)pcstInitParam, sizeof(SGUI_SCROLLBAR_PARAM)); - } + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if((NULL != pstObj) && (NULL != pcstInitParam)) + { + SGUI_SystemIF_MemorySet(pstObj, 0x00, sizeof(SGUI_SCROLLBAR_STRUCT)); + SGUI_SystemIF_MemoryCopy(&(pstObj->stParam), (void*)pcstInitParam, sizeof(SGUI_SCROLLBAR_PARAM)); + } } /*************************************************************************/ -/** Function Name: SGUI_ScrollBar_SetValue **/ -/** Purpose: Initialize a scroll bar structure. **/ -/** Params: **/ -/** @ pstObj[in]: Scroll bar object pointer. **/ -/** @ sNewValue[in]: New value will be set. **/ -/** Return: None. **/ +/** Function Name: SGUI_ScrollBar_SetValue **/ +/** Purpose: Initialize a scroll bar structure. **/ +/** Params: **/ +/** @ pstObj[in]: Scroll bar object pointer. **/ +/** @ sNewValue[in]: New value will be set. **/ +/** Return: None. **/ /*************************************************************************/ void SGUI_ScrollBar_SetValue(SGUI_SCROLLBAR_STRUCT* pstObj, SGUI_SIZE sNewValue) { - if(NULL != pstObj) - { - if(sNewValue > pstObj->stParam.sMaxValue) - { - pstObj->stData.sValue = pstObj->stParam.sMaxValue; - } - else - { - pstObj->stData.sValue = sNewValue; - } - } + if(NULL != pstObj) + { + if(sNewValue > pstObj->stParam.sMaxValue) + { + pstObj->stData.sValue = pstObj->stParam.sMaxValue; + } + else + { + pstObj->stData.sValue = sNewValue; + } + } } /*************************************************************************/ -/** Function Name: SGUI_ScrollBar_RefreshScrollBar **/ -/** Purpose: Display or update a scroll bar. **/ -/** Resources: Scroll bar data structure. **/ -/** Params: **/ -/** @ pstObj[in]: Scroll bar data structure pointer. **/ -/** Return: None. **/ -/** Notice: None. **/ +/** Function Name: SGUI_ScrollBar_RefreshScrollBar **/ +/** Purpose: Display or update a scroll bar. **/ +/** Resources: Scroll bar data structure. **/ +/** Params: **/ +/** @ pstObj[in]: Scroll bar data structure pointer. **/ +/** Return: None. **/ +/** Notice: None. **/ /*************************************************************************/ void SGUI_ScrollBar_Repaint(SGUI_SCR_DEV* pstDeviceIF, SGUI_SCROLLBAR_STRUCT* pstObj) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_INT uiScrollBlockPos; - SGUI_SIZE uiScrollBlockSize; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_INT uiScrollBlockPos; + SGUI_SIZE uiScrollBlockSize; - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - if(SGUI_SCROLLBAR_VERTICAL == pstObj->stParam.eDirection) - { - uiScrollBlockSize = pstObj->stParam.stLayout.iWidth-2; - } - else - { - uiScrollBlockSize = pstObj->stParam.stLayout.iHeight-2; - } + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + if(SGUI_SCROLLBAR_VERTICAL == pstObj->stParam.eDirection) + { + uiScrollBlockSize = pstObj->stParam.stLayout.iWidth-2; + } + else + { + uiScrollBlockSize = pstObj->stParam.stLayout.iHeight-2; + } - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if(((pstObj->stParam.stLayout.iHeight > 2) && (pstObj->stParam.stLayout.iWidth > 2)) && (pstObj->stParam.stLayout.iHeight != pstObj->stParam.stLayout.iWidth)) - { - // Check new value must be less then max value. - if(pstObj->stData.sValue > pstObj->stParam.sMaxValue) - { - pstObj->stData.sValue = pstObj->stParam.sMaxValue; - } - // Draw scroll bar edge. - SGUI_Basic_DrawRectangle(pstDeviceIF, pstObj->stParam.stLayout.iX, pstObj->stParam.stLayout.iY, - pstObj->stParam.stLayout.iWidth, pstObj->stParam.stLayout.iHeight, - SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(((pstObj->stParam.stLayout.iHeight > 2) && (pstObj->stParam.stLayout.iWidth > 2)) && (pstObj->stParam.stLayout.iHeight != pstObj->stParam.stLayout.iWidth)) + { + // Check new value must be less then max value. + if(pstObj->stData.sValue > pstObj->stParam.sMaxValue) + { + pstObj->stData.sValue = pstObj->stParam.sMaxValue; + } + // Draw scroll bar edge. + SGUI_Basic_DrawRectangle(pstDeviceIF, pstObj->stParam.stLayout.iX, pstObj->stParam.stLayout.iY, + pstObj->stParam.stLayout.iWidth, pstObj->stParam.stLayout.iHeight, + SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR); - if(SGUI_SCROLLBAR_VERTICAL == pstObj->stParam.eDirection) - { - // Value lower limit is 0, scroll blocks must be greater then 0. - if(pstObj->stParam.sMaxValue > 0) - { - uiScrollBlockPos = pstObj->stParam.stLayout.iY+1+((pstObj->stParam.stLayout.iHeight-uiScrollBlockSize-2)*pstObj->stData.sValue/pstObj->stParam.sMaxValue); - // Redraw process block - SGUI_Basic_DrawRectangle(pstDeviceIF, pstObj->stParam.stLayout.iX+1, uiScrollBlockPos, - uiScrollBlockSize, uiScrollBlockSize, SGUI_COLOR_FRGCLR, SGUI_COLOR_FRGCLR); - } - else - { - SGUI_Basic_DrawRectangle(pstDeviceIF, pstObj->stParam.stLayout.iX+1, pstObj->stParam.stLayout.iY+1, - uiScrollBlockSize, uiScrollBlockSize, SGUI_COLOR_FRGCLR, SGUI_COLOR_FRGCLR); - } - } - else // Horizontal - { - // Value lower limit is 0, scroll blocks must be greater then 0. - if(pstObj->stParam.sMaxValue > 0) - { - uiScrollBlockPos = pstObj->stParam.stLayout.iX+1+((pstObj->stParam.stLayout.iWidth-uiScrollBlockSize-2)*pstObj->stData.sValue/pstObj->stParam.sMaxValue); - // Redraw process block - SGUI_Basic_DrawRectangle(pstDeviceIF, uiScrollBlockPos, pstObj->stParam.stLayout.iY+1, - uiScrollBlockSize, uiScrollBlockSize, SGUI_COLOR_FRGCLR, SGUI_COLOR_FRGCLR); - } - else - { - SGUI_Basic_DrawRectangle(pstDeviceIF, pstObj->stParam.stLayout.iX+1, pstObj->stParam.stLayout.iY+1, - uiScrollBlockSize, uiScrollBlockSize, SGUI_COLOR_FRGCLR, SGUI_COLOR_FRGCLR); - } - } - } + if(SGUI_SCROLLBAR_VERTICAL == pstObj->stParam.eDirection) + { + // Value lower limit is 0, scroll blocks must be greater then 0. + if(pstObj->stParam.sMaxValue > 0) + { + uiScrollBlockPos = pstObj->stParam.stLayout.iY+1+((pstObj->stParam.stLayout.iHeight-uiScrollBlockSize-2)*pstObj->stData.sValue/pstObj->stParam.sMaxValue); + // Redraw process block + SGUI_Basic_DrawRectangle(pstDeviceIF, pstObj->stParam.stLayout.iX+1, uiScrollBlockPos, + uiScrollBlockSize, uiScrollBlockSize, SGUI_COLOR_FRGCLR, SGUI_COLOR_FRGCLR); + } + else + { + SGUI_Basic_DrawRectangle(pstDeviceIF, pstObj->stParam.stLayout.iX+1, pstObj->stParam.stLayout.iY+1, + uiScrollBlockSize, uiScrollBlockSize, SGUI_COLOR_FRGCLR, SGUI_COLOR_FRGCLR); + } + } + else // Horizontal + { + // Value lower limit is 0, scroll blocks must be greater then 0. + if(pstObj->stParam.sMaxValue > 0) + { + uiScrollBlockPos = pstObj->stParam.stLayout.iX+1+((pstObj->stParam.stLayout.iWidth-uiScrollBlockSize-2)*pstObj->stData.sValue/pstObj->stParam.sMaxValue); + // Redraw process block + SGUI_Basic_DrawRectangle(pstDeviceIF, uiScrollBlockPos, pstObj->stParam.stLayout.iY+1, + uiScrollBlockSize, uiScrollBlockSize, SGUI_COLOR_FRGCLR, SGUI_COLOR_FRGCLR); + } + else + { + SGUI_Basic_DrawRectangle(pstDeviceIF, pstObj->stParam.stLayout.iX+1, pstObj->stParam.stLayout.iY+1, + uiScrollBlockSize, uiScrollBlockSize, SGUI_COLOR_FRGCLR, SGUI_COLOR_FRGCLR); + } + } + } } diff --git a/GUI/src/SGUI_Text.c b/GUI/src/SGUI_Text.c index fbd6bb872f7a970ed3e285124b63d6c1abe543c9..f188d8b88127a3ba77cbb2b28a3ca429c1f9ca12 100644 --- a/GUI/src/SGUI_Text.c +++ b/GUI/src/SGUI_Text.c @@ -1,320 +1,320 @@ /*************************************************************************/ -/** Copyright. **/ -/** FileName: SGUI_Text.c **/ -/** Author: XuYulin **/ -/** Description: Text display interface **/ +/** Copyright. **/ +/** FileName: SGUI_Text.c **/ +/** Author: XuYulin **/ +/** Description: Text display interface **/ /*************************************************************************/ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "SGUI_Text.h" //=======================================================================// -//= Public variable declaration. =// +//= Public variable declaration. =// //=======================================================================// -SGUI_CSZSTR SGUI_EMPTY_STRING = {""}; +SGUI_CSZSTR SGUI_EMPTY_STRING = {""}; //=======================================================================// -//= Static function declaration. =// +//= Static function declaration. =// //=======================================================================// //=======================================================================// -//= Function define. =// +//= Function define. =// //=======================================================================// /*************************************************************************/ -/** Function Name: SGUI_Text_GetTextExtent **/ -/** Purpose: Get the area size if show given text completely. **/ -/** Params: **/ -/** @ szText[in]: Text array pointer. **/ -/** @ pstFontRes[in]: Font resource, improve font size info. **/ -/** @ pstTextExtent[out]: Text extent size. **/ -/** Return: Next character X coordinate in current line. **/ -/** Limitation: None. **/ +/** Function Name: SGUI_Text_GetTextExtent **/ +/** Purpose: Get the area size if show given text completely. **/ +/** Params: **/ +/** @ szText[in]: Text array pointer. **/ +/** @ pstFontRes[in]: Font resource, improve font size info. **/ +/** @ pstTextExtent[out]: Text extent size. **/ +/** Return: Next character X coordinate in current line. **/ +/** Limitation: None. **/ /*************************************************************************/ void SGUI_Text_GetTextExtent(SGUI_CSZSTR cszText, const SGUI_FONT_RES* pstFontRes, SGUI_AREA_SIZE* pstTextExtent) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - const SGUI_CHAR* pcChar; - SGUI_UINT32 uiCharacterCode; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + const SGUI_CHAR* pcChar; + SGUI_UINT32 uiCharacterCode; - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - pcChar = (SGUI_CSZSTR)ENCODE(cszText); + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + pcChar = (SGUI_CSZSTR)ENCODE(cszText); - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if((NULL != pcChar) && (NULL != pstTextExtent)) - { - pstTextExtent->iHeight = pstFontRes->iHeight; - pstTextExtent->iWidth=0; - while('\0' != *pcChar) - { - uiCharacterCode = 0; - pcChar = pstFontRes->fnStepNext(pcChar, &uiCharacterCode); - if('\0' !=uiCharacterCode) - { + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if((NULL != pcChar) && (NULL != pstTextExtent)) + { + pstTextExtent->iHeight = pstFontRes->iHeight; + pstTextExtent->iWidth=0; + while('\0' != *pcChar) + { + uiCharacterCode = 0; + pcChar = pstFontRes->fnStepNext(pcChar, &uiCharacterCode); + if('\0' !=uiCharacterCode) + { pstTextExtent->iWidth+=(pstFontRes->fnIsFullWidth(uiCharacterCode)?pstFontRes->iFullWidth:pstFontRes->iHalfWidth); - } - } - } + } + } + } } /*************************************************************************/ -/** Function Name: SGUI_Text_DrawSingleLineText **/ -/** Purpose: Write a single line text in a fixed area. **/ -/** Params: **/ -/** @ pstDeviceIF[in]: SimpleGUI object pointer. **/ -/** @ cszText[in]: Text array pointer. **/ -/** @ pstFontRes[in]: Font resource object. **/ -/** @ pstDisplayArea[in]: Display area size. **/ -/** @ pstInnerPos[in]: Text paint position in display area. **/ -/** @ eFontMode[in] Character display mode(normal or reverse color). **/ -/** Return: None. **/ +/** Function Name: SGUI_Text_DrawSingleLineText **/ +/** Purpose: Write a single line text in a fixed area. **/ +/** Params: **/ +/** @ pstDeviceIF[in]: SimpleGUI object pointer. **/ +/** @ cszText[in]: Text array pointer. **/ +/** @ pstFontRes[in]: Font resource object. **/ +/** @ pstDisplayArea[in]: Display area size. **/ +/** @ pstInnerPos[in]: Text paint position in display area. **/ +/** @ eFontMode[in] Character display mode(normal or reverse color). **/ +/** Return: None. **/ /*************************************************************************/ void SGUI_Text_DrawText(SGUI_SCR_DEV* pstDeviceIF, SGUI_CSZSTR cszText, const SGUI_FONT_RES* pstFontRes, SGUI_RECT* pstDisplayArea, SGUI_POINT* pstInnerPos, SGUI_DRAW_MODE eFontMode) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - const SGUI_CHAR* pcChar; // Text character pointer. - SGUI_UINT32 uiCharacterCode; // Character byte, might be tow bytes. - SGUI_COLOR eBackColor; - SGUI_BMP_RES stCharBitmap; - SGUI_POINT stPaintPos; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + const SGUI_CHAR* pcChar; // Text character pointer. + SGUI_UINT32 uiCharacterCode; // Character byte, might be tow bytes. + SGUI_COLOR eBackColor; + SGUI_BMP_RES stCharBitmap; + SGUI_POINT stPaintPos; - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - // Initialize variable. - pcChar = (SGUI_CSZSTR)ENCODE(cszText); - eBackColor = (eFontMode == SGUI_DRAW_NORMAL)?SGUI_COLOR_BKGCLR:SGUI_COLOR_FRGCLR; + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + // Initialize variable. + pcChar = (SGUI_CSZSTR)ENCODE(cszText); + eBackColor = (eFontMode == SGUI_DRAW_NORMAL)?SGUI_COLOR_BKGCLR:SGUI_COLOR_FRGCLR; - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if((NULL != pcChar) && (RECT_X_START(*pstDisplayArea) < RECT_WIDTH(pstDeviceIF->stSize))) + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if((NULL != pcChar) && (RECT_X_START(*pstDisplayArea) < RECT_WIDTH(pstDeviceIF->stSize))) { // Adapt text display area and data area. SGUI_Common_AdaptDisplayInfo(pstDisplayArea, pstInnerPos); - // Clear text area. + // Clear text area. SGUI_Basic_DrawRectangle(pstDeviceIF, RECT_X_START(*pstDisplayArea), RECT_Y_START(*pstDisplayArea), - RECT_WIDTH(*pstDisplayArea), RECT_HEIGHT(*pstDisplayArea), - eBackColor, eBackColor); - // Initialize drawing area data. - RECT_X_START(stPaintPos) = RECT_X_START(*pstInnerPos); - RECT_Y_START(stPaintPos) = RECT_Y_START(*pstInnerPos); - RECT_HEIGHT(stCharBitmap) = pstFontRes->iHeight; - stCharBitmap.pData = pstDeviceIF->stBuffer.pBuffer; + RECT_WIDTH(*pstDisplayArea), RECT_HEIGHT(*pstDisplayArea), + eBackColor, eBackColor); + // Initialize drawing area data. + RECT_X_START(stPaintPos) = RECT_X_START(*pstInnerPos); + RECT_Y_START(stPaintPos) = RECT_Y_START(*pstInnerPos); + RECT_HEIGHT(stCharBitmap) = pstFontRes->iHeight; + stCharBitmap.pData = pstDeviceIF->stBuffer.pBuffer; - // Loop for Each char. - while(((NULL != pcChar) && ('\0' != *pcChar)) && (RECT_X_START(stPaintPos) < RECT_WIDTH(*pstDisplayArea))) - { - uiCharacterCode = 0; + // Loop for Each char. + while(((NULL != pcChar) && ('\0' != *pcChar)) && (RECT_X_START(stPaintPos) < RECT_WIDTH(*pstDisplayArea))) + { + uiCharacterCode = 0; pcChar = pstFontRes->fnStepNext(pcChar, &uiCharacterCode); //if(SGUI_IS_VISIBLE_CHAR(uiCharacterCode)) - { - RECT_WIDTH(stCharBitmap) = pstFontRes->fnIsFullWidth(uiCharacterCode)?pstFontRes->iFullWidth:pstFontRes->iHalfWidth; - if((stPaintPos.iX+stCharBitmap.iWidth-1) >= 0) - { - SGUI_Text_GetCharacterData(pstFontRes, uiCharacterCode, pstDeviceIF->stBuffer.pBuffer, pstDeviceIF->stBuffer.sSize); - SGUI_Basic_DrawBitMap(pstDeviceIF, pstDisplayArea, &stPaintPos, &stCharBitmap, eFontMode); - } - RECT_X_START(stPaintPos) += RECT_WIDTH(stCharBitmap); - } - } - } + { + RECT_WIDTH(stCharBitmap) = pstFontRes->fnIsFullWidth(uiCharacterCode)?pstFontRes->iFullWidth:pstFontRes->iHalfWidth; + if((stPaintPos.iX+stCharBitmap.iWidth-1) >= 0) + { + SGUI_Text_GetCharacterData(pstFontRes, uiCharacterCode, pstDeviceIF->stBuffer.pBuffer, pstDeviceIF->stBuffer.sSize); + SGUI_Basic_DrawBitMap(pstDeviceIF, pstDisplayArea, &stPaintPos, &stCharBitmap, eFontMode); + } + RECT_X_START(stPaintPos) += RECT_WIDTH(stCharBitmap); + } + } + } } /*************************************************************************/ -/** Function Name: GUI_DrawMultipleLinesText **/ -/** Purpose: Write a mulitiplt line text in a rectangular area. **/ -/** Params: **/ -/** @ pstDeviceIF[in]: SimpleGUI object pointer. **/ -/** @ cszText[in]: Text array pointer. **/ -/** @ pstFontRes[in]: Font resource object. **/ -/** @ pstDisplayArea[in]: Display area size. **/ -/** @ iTopOffset[in]: Text paint offset in vertical. **/ -/** @ eFontMode[in]: Character display mode(normal or reverse color). **/ -/** Return: Used line count. **/ -/** Notice: None. **/ +/** Function Name: GUI_DrawMultipleLinesText **/ +/** Purpose: Write a mulitiplt line text in a rectangular area. **/ +/** Params: **/ +/** @ pstDeviceIF[in]: SimpleGUI object pointer. **/ +/** @ cszText[in]: Text array pointer. **/ +/** @ pstFontRes[in]: Font resource object. **/ +/** @ pstDisplayArea[in]: Display area size. **/ +/** @ iTopOffset[in]: Text paint offset in vertical. **/ +/** @ eFontMode[in]: Character display mode(normal or reverse color). **/ +/** Return: Used line count. **/ +/** Notice: None. **/ /*************************************************************************/ SGUI_SIZE SGUI_Text_DrawMultipleLinesText(SGUI_SCR_DEV* pstDeviceIF, SGUI_CSZSTR cszText, const SGUI_FONT_RES* pstFontRes, SGUI_RECT* pstDisplayArea, SGUI_INT iTopOffset, SGUI_DRAW_MODE eFontMode) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - const SGUI_CHAR* pcChar; - SGUI_UINT32 uiCharacterCode; - SGUI_SIZE uiLines; - SGUI_COLOR eBackColor; - SGUI_BMP_RES stCharBitmap; - SGUI_POINT stPaintPos; - SGUI_INT iStartOffsetX; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + const SGUI_CHAR* pcChar; + SGUI_UINT32 uiCharacterCode; + SGUI_SIZE uiLines; + SGUI_COLOR eBackColor; + SGUI_BMP_RES stCharBitmap; + SGUI_POINT stPaintPos; + SGUI_INT iStartOffsetX; - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - pcChar = (SGUI_CSZSTR)ENCODE(cszText); - uiCharacterCode = 0; - uiLines = 0; - eBackColor = (eFontMode == SGUI_DRAW_NORMAL)?SGUI_COLOR_BKGCLR:SGUI_COLOR_FRGCLR; + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + pcChar = (SGUI_CSZSTR)ENCODE(cszText); + uiCharacterCode = 0; + uiLines = 0; + eBackColor = (eFontMode == SGUI_DRAW_NORMAL)?SGUI_COLOR_BKGCLR:SGUI_COLOR_FRGCLR; - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if((cszText != NULL) && (RECT_X_START(*pstDisplayArea) < RECT_WIDTH(pstDeviceIF->stSize))) - { - // Initialize drawing position. - RECT_X_START(stPaintPos) = 0; - RECT_Y_START(stPaintPos) = iTopOffset; - // Adapt text display area and data area. + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if((cszText != NULL) && (RECT_X_START(*pstDisplayArea) < RECT_WIDTH(pstDeviceIF->stSize))) + { + // Initialize drawing position. + RECT_X_START(stPaintPos) = 0; + RECT_Y_START(stPaintPos) = iTopOffset; + // Adapt text display area and data area. SGUI_Common_AdaptDisplayInfo(pstDisplayArea, &stPaintPos); iStartOffsetX = stPaintPos.iX; - // Clear text area. + // Clear text area. SGUI_Basic_DrawRectangle(pstDeviceIF, - RECT_X_START(*pstDisplayArea), RECT_Y_START(*pstDisplayArea), - RECT_WIDTH(*pstDisplayArea), RECT_HEIGHT(*pstDisplayArea), - eBackColor, eBackColor); + RECT_X_START(*pstDisplayArea), RECT_Y_START(*pstDisplayArea), + RECT_WIDTH(*pstDisplayArea), RECT_HEIGHT(*pstDisplayArea), + eBackColor, eBackColor); - RECT_HEIGHT(stCharBitmap) = pstFontRes->iHeight; - uiLines = 1; - stCharBitmap.pData = pstDeviceIF->stBuffer.pBuffer; - // Loop for each word in display area. - while(((NULL != pcChar) && ('\0' != *pcChar))) - { - uiCharacterCode = 0; + RECT_HEIGHT(stCharBitmap) = pstFontRes->iHeight; + uiLines = 1; + stCharBitmap.pData = pstDeviceIF->stBuffer.pBuffer; + // Loop for each word in display area. + while(((NULL != pcChar) && ('\0' != *pcChar))) + { + uiCharacterCode = 0; pcChar = pstFontRes->fnStepNext(pcChar, &uiCharacterCode); - // Judge change line symbol. - if(uiCharacterCode == '\n') - { - // Change lines. - RECT_X_START(stPaintPos) = iStartOffsetX; - RECT_Y_START(stPaintPos) += pstFontRes->iHeight; - uiLines ++; - continue; - } - // Get character width; - RECT_WIDTH(stCharBitmap) = pstFontRes->fnIsFullWidth(uiCharacterCode)?pstFontRes->iFullWidth:pstFontRes->iHalfWidth; + // Judge change line symbol. + if(uiCharacterCode == '\n') + { + // Change lines. + RECT_X_START(stPaintPos) = iStartOffsetX; + RECT_Y_START(stPaintPos) += pstFontRes->iHeight; + uiLines ++; + continue; + } + // Get character width; + RECT_WIDTH(stCharBitmap) = pstFontRes->fnIsFullWidth(uiCharacterCode)?pstFontRes->iFullWidth:pstFontRes->iHalfWidth; - // Judge change line - if((stPaintPos.iX+stCharBitmap.iWidth-1) >= RECT_WIDTH(*pstDisplayArea)) - { - // Change lines. - RECT_X_START(stPaintPos) = iStartOffsetX; - RECT_Y_START(stPaintPos) += pstFontRes->iHeight; - uiLines ++; - } - // Draw characters. - if(((stPaintPos.iX+stCharBitmap.iWidth-1) >= 0) && (RECT_Y_START(stPaintPos) < RECT_HEIGHT(*pstDisplayArea))) - { - // Draw character. - SGUI_Text_GetCharacterData(pstFontRes, uiCharacterCode, pstDeviceIF->stBuffer.pBuffer, pstDeviceIF->stBuffer.sSize); + // Judge change line + if((stPaintPos.iX+stCharBitmap.iWidth-1) >= RECT_WIDTH(*pstDisplayArea)) + { + // Change lines. + RECT_X_START(stPaintPos) = iStartOffsetX; + RECT_Y_START(stPaintPos) += pstFontRes->iHeight; + uiLines ++; + } + // Draw characters. + if(((stPaintPos.iX+stCharBitmap.iWidth-1) >= 0) && (RECT_Y_START(stPaintPos) < RECT_HEIGHT(*pstDisplayArea))) + { + // Draw character. + SGUI_Text_GetCharacterData(pstFontRes, uiCharacterCode, pstDeviceIF->stBuffer.pBuffer, pstDeviceIF->stBuffer.sSize); SGUI_Basic_DrawBitMap(pstDeviceIF, pstDisplayArea, &stPaintPos, &stCharBitmap, eFontMode); - } - else - { - // character is not in visible area, ignore. - } - RECT_X_START(stPaintPos) += RECT_WIDTH(stCharBitmap); - } - } - return uiLines; + } + else + { + // character is not in visible area, ignore. + } + RECT_X_START(stPaintPos) += RECT_WIDTH(stCharBitmap); + } + } + return uiLines; } /*************************************************************************/ -/** Function Name: SGUI_Text_GetMultiLineTextLines **/ -/** Purpose: Get a string's lines in a fixed width area. **/ -/** Resources: None. **/ -/** Params: **/ -/** @ cszText[in]: Text array pointer. **/ -/** @ pstFontRes[in]: Font resource object. **/ -/** @ uiDisplayAreaWidth[in]: Display area width. **/ -/** Return: String lines. **/ +/** Function Name: SGUI_Text_GetMultiLineTextLines **/ +/** Purpose: Get a string's lines in a fixed width area. **/ +/** Resources: None. **/ +/** Params: **/ +/** @ cszText[in]: Text array pointer. **/ +/** @ pstFontRes[in]: Font resource object. **/ +/** @ uiDisplayAreaWidth[in]: Display area width. **/ +/** Return: String lines. **/ /*************************************************************************/ SGUI_SIZE SGUI_Text_GetMultiLineTextLines(SGUI_CSZSTR cszText, const SGUI_FONT_RES* pstFontRes, SGUI_SIZE uiDisplayAreaWidth) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_SIZE uiLineNumber, uiLineLength; - SGUI_UINT32 uiCharacterCode; - SGUI_UINT16 uiCharWidth; - SGUI_CSZSTR pcChar; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_SIZE uiLineNumber, uiLineLength; + SGUI_UINT32 uiCharacterCode; + SGUI_UINT16 uiCharWidth; + SGUI_CSZSTR pcChar; - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - uiLineLength = 0; - uiLineNumber = 1; - pcChar = (SGUI_CSZSTR)ENCODE(cszText); + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + uiLineLength = 0; + uiLineNumber = 1; + pcChar = (SGUI_CSZSTR)ENCODE(cszText); - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - while('\0' != *pcChar) - { - uiCharacterCode = 0; - pcChar = pstFontRes->fnStepNext(pcChar, &uiCharacterCode); - if('\n' == uiCharacterCode) - { - uiLineNumber++; - uiLineLength = 0; - } - else - { - uiCharWidth = pstFontRes->fnIsFullWidth(uiCharacterCode)?pstFontRes->iFullWidth:pstFontRes->iHalfWidth; + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + while('\0' != *pcChar) + { + uiCharacterCode = 0; + pcChar = pstFontRes->fnStepNext(pcChar, &uiCharacterCode); + if('\n' == uiCharacterCode) + { + uiLineNumber++; + uiLineLength = 0; + } + else + { + uiCharWidth = pstFontRes->fnIsFullWidth(uiCharacterCode)?pstFontRes->iFullWidth:pstFontRes->iHalfWidth; if((uiLineLength+uiCharWidth)>uiDisplayAreaWidth) - { - uiLineNumber++; - uiLineLength = uiCharWidth; - } - else - { - uiLineLength+=uiCharWidth; - } - } - } - return uiLineNumber; + { + uiLineNumber++; + uiLineLength = uiCharWidth; + } + else + { + uiLineLength+=uiCharWidth; + } + } + } + return uiLineNumber; } /*****************************************************************************/ -/** Function Name: SGUI_Text_GetCharacterData **/ -/** Purpose: Get character data form font resource by char code. **/ -/** Params: **/ -/** @ pstFontRes[in]: Font resource structure pointer. **/ -/** @ uiCode[in]: Character code. **/ -/** @ pDataBuffer[out]: Buffer for output char data. **/ -/** @ sBufferSize[in]: Output buffer size. **/ -/** Return: Number of read data, return 0 when error occurred. **/ +/** Function Name: SGUI_Text_GetCharacterData **/ +/** Purpose: Get character data form font resource by char code. **/ +/** Params: **/ +/** @ pstFontRes[in]: Font resource structure pointer. **/ +/** @ uiCode[in]: Character code. **/ +/** @ pDataBuffer[out]: Buffer for output char data. **/ +/** @ sBufferSize[in]: Output buffer size. **/ +/** Return: Number of read data, return 0 when error occurred. **/ /*****************************************************************************/ SGUI_SIZE SGUI_Text_GetCharacterData(const SGUI_FONT_RES* pstFontRes, SGUI_UINT32 uiCode, SGUI_BYTE* pDataBuffer, SGUI_SIZE sBufferSize) { /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_SIZE sGetDataSize; - SGUI_SIZE sReadDataSize; - SGUI_SIZE sDataBlockSize; - SGUI_INT iCharIndex; + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_SIZE sGetDataSize; + SGUI_SIZE sReadDataSize; + SGUI_SIZE sDataBlockSize; + SGUI_INT iCharIndex; - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - sGetDataSize = 0; + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + sGetDataSize = 0; - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if((NULL != pstFontRes) && (NULL != pDataBuffer) && (0 != sBufferSize)) + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if((NULL != pstFontRes) && (NULL != pDataBuffer) && (0 != sBufferSize)) { - iCharIndex = pstFontRes->fnGetIndex(uiCode); + iCharIndex = pstFontRes->fnGetIndex(uiCode); if(SGUI_INVALID_INDEX != iCharIndex) { sDataBlockSize = SGUI_USED_BYTE(pstFontRes->iHeight)*(pstFontRes->iHalfWidth); @@ -323,5 +323,5 @@ SGUI_SIZE SGUI_Text_GetCharacterData(const SGUI_FONT_RES* pstFontRes, SGUI_UINT3 } } - return sGetDataSize; + return sGetDataSize; } diff --git a/GUI/src/SGUI_VariableBox.c b/GUI/src/SGUI_VariableBox.c index 3499f61d58f21be975b0fadc01050ca7f5fb6bba..7bac86f9e32987d3d756563c62c681e5b7da8bc5 100644 --- a/GUI/src/SGUI_VariableBox.c +++ b/GUI/src/SGUI_VariableBox.c @@ -1,196 +1,196 @@ /*************************************************************************/ -/** Copyright. **/ -/** FileName: SGUI_VariableBox.c **/ -/** Author: XuYulin **/ -/** Description: Show and change variable box. **/ +/** Copyright. **/ +/** FileName: SGUI_VariableBox.c **/ +/** Author: XuYulin **/ +/** Description: Show and change variable box. **/ /*************************************************************************/ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "SGUI_VariableBox.h" //=======================================================================// -//= Static function declaration. =// +//= Static function declaration. =// //=======================================================================// //=======================================================================// -//= Function define. =// +//= Function define. =// //=======================================================================// /*************************************************************************/ -/** Function Name: SGUI_NumberVariableBox_Initialize **/ -/** Purpose: Initialize a integer value edit box structure. **/ -/** Params: **/ -/** @ pstObj[in]: Number variable box object pointer. **/ -/** @ pcstInitParam[in]: Initialize parameter for initialize. **/ -/** Return: None. **/ -/** Notice: iValue will be changed when more then max value or **/ -/** less then minimum value. **/ +/** Function Name: SGUI_NumberVariableBox_Initialize **/ +/** Purpose: Initialize a integer value edit box structure. **/ +/** Params: **/ +/** @ pstObj[in]: Number variable box object pointer. **/ +/** @ pcstInitParam[in]: Initialize parameter for initialize. **/ +/** Return: None. **/ +/** Notice: iValue will be changed when more then max value or **/ +/** less then minimum value. **/ /*************************************************************************/ void SGUI_NumberVariableBox_Initialize(SGUI_NUM_VARBOX_STRUCT* pstObj, const SGUI_NUM_VARBOX_PARAM* pcstInitParam) { - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if((NULL != pstObj) && (NULL != pcstInitParam)) - { - SGUI_SystemIF_MemorySet(pstObj, 0x00, sizeof(SGUI_NUM_VARBOX_STRUCT)); - SGUI_SystemIF_MemoryCopy(&(pstObj->stParam), (void*)pcstInitParam, sizeof(SGUI_NUM_VARBOX_PARAM)); - } + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if((NULL != pstObj) && (NULL != pcstInitParam)) + { + SGUI_SystemIF_MemorySet(pstObj, 0x00, sizeof(SGUI_NUM_VARBOX_STRUCT)); + SGUI_SystemIF_MemoryCopy(&(pstObj->stParam), (void*)pcstInitParam, sizeof(SGUI_NUM_VARBOX_PARAM)); + } } /*************************************************************************/ -/** Function Name: SGUI_NumberVariableBox_Repaint **/ -/** Purpose: Display or refresh a integer value edit box. **/ -/** Params: **/ -/** @ pstDeviceIF[in]: Device driver object pointer. **/ -/** @ pstObj[in]: Value structure, include max value, min value and **/ -/** current value. **/ -/** @ eMode[in]: Display mode, normal or reveres. **/ -/** Return: None. **/ -/** Notice: None. **/ +/** Function Name: SGUI_NumberVariableBox_Repaint **/ +/** Purpose: Display or refresh a integer value edit box. **/ +/** Params: **/ +/** @ pstDeviceIF[in]: Device driver object pointer. **/ +/** @ pstObj[in]: Value structure, include max value, min value and **/ +/** current value. **/ +/** @ eMode[in]: Display mode, normal or reveres. **/ +/** Return: None. **/ +/** Notice: None. **/ /*************************************************************************/ void SGUI_NumberVariableBox_Repaint(SGUI_SCR_DEV* pstDeviceIF, SGUI_NUM_VARBOX_STRUCT* pstObj, SGUI_DRAW_MODE eMode) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_AREA_SIZE stTextExtentSize; - SGUI_POINT stTextInnerPos; - SGUI_COLOR eBackColor; - SGUI_CHAR szTextBuffer[VARBOX_TEXT_BUFFER_SIZE]; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_AREA_SIZE stTextExtentSize; + SGUI_POINT stTextInnerPos; + SGUI_COLOR eBackColor; + SGUI_CHAR szTextBuffer[VARBOX_TEXT_BUFFER_SIZE]; - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - SGUI_SystemIF_MemorySet(szTextBuffer, 0x00, VARBOX_TEXT_BUFFER_SIZE); - eBackColor = ((eMode==SGUI_DRAW_NORMAL)?SGUI_COLOR_BKGCLR:SGUI_COLOR_FRGCLR); + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + SGUI_SystemIF_MemorySet(szTextBuffer, 0x00, VARBOX_TEXT_BUFFER_SIZE); + eBackColor = ((eMode==SGUI_DRAW_NORMAL)?SGUI_COLOR_BKGCLR:SGUI_COLOR_FRGCLR); - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ - if(NULL != pstObj) - { - // Draw edge - SGUI_Basic_DrawRectangle(pstDeviceIF, LAYOUT(pstObj).iX, LAYOUT(pstObj).iY, LAYOUT(pstObj).iWidth, LAYOUT(pstObj).iHeight, eBackColor, eBackColor); + if(NULL != pstObj) + { + // Draw edge + SGUI_Basic_DrawRectangle(pstDeviceIF, LAYOUT(pstObj).iX, LAYOUT(pstObj).iY, LAYOUT(pstObj).iWidth, LAYOUT(pstObj).iHeight, eBackColor, eBackColor); - // Convert number to string - (void)SGUI_Common_IntegerToString(pstObj->stData.iValue, szTextBuffer, 10, -1, ' '); - SGUI_Text_GetTextExtent(szTextBuffer, pstObj->stParam.pstFontRes, &stTextExtentSize); - switch(pstObj->stParam.eAlignment) - { - case SGUI_RIGHT: - { - stTextInnerPos.iX = LAYOUT(pstObj).iWidth - stTextExtentSize.iWidth; - break; - } - case SGUI_CENTER: - { - stTextInnerPos.iX = (LAYOUT(pstObj).iWidth - stTextExtentSize.iWidth) / 2; - break; - } - default: - { - stTextInnerPos.iX = 0; - } - } - stTextInnerPos.iY = 0; - SGUI_Text_DrawText(pstDeviceIF, szTextBuffer, pstObj->stParam.pstFontRes, &(LAYOUT(pstObj)), &stTextInnerPos, eMode); - } + // Convert number to string + (void)SGUI_Common_IntegerToString(pstObj->stData.iValue, szTextBuffer, 10, -1, ' '); + SGUI_Text_GetTextExtent(szTextBuffer, pstObj->stParam.pstFontRes, &stTextExtentSize); + switch(pstObj->stParam.eAlignment) + { + case SGUI_RIGHT: + { + stTextInnerPos.iX = LAYOUT(pstObj).iWidth - stTextExtentSize.iWidth; + break; + } + case SGUI_CENTER: + { + stTextInnerPos.iX = (LAYOUT(pstObj).iWidth - stTextExtentSize.iWidth) / 2; + break; + } + default: + { + stTextInnerPos.iX = 0; + } + } + stTextInnerPos.iY = 0; + SGUI_Text_DrawText(pstDeviceIF, szTextBuffer, pstObj->stParam.pstFontRes, &(LAYOUT(pstObj)), &stTextInnerPos, eMode); + } } /*************************************************************************/ -/** Function Name: SGUI_TextVariableBox_Initialize **/ -/** Purpose: Initialize a text value edit box structure. **/ -/** Params: **/ -/** @ pstObj[in]: Text variable box object pointer. **/ -/** @ pcstInitParam[in]: Parameter data for initialize. **/ -/** @ szTextBuffer[in]: Text buffer for text variable. **/ -/** Return: None. **/ -/** Notice: TextBuffer length cannot less then sMaxTextLength. **/ +/** Function Name: SGUI_TextVariableBox_Initialize **/ +/** Purpose: Initialize a text value edit box structure. **/ +/** Params: **/ +/** @ pstObj[in]: Text variable box object pointer. **/ +/** @ pcstInitParam[in]: Parameter data for initialize. **/ +/** @ szTextBuffer[in]: Text buffer for text variable. **/ +/** Return: None. **/ +/** Notice: TextBuffer length cannot less then sMaxTextLength. **/ /*************************************************************************/ void SGUI_TextVariableBox_Initialize(SGUI_TEXT_VARBOX_STRUCT* pstObj, const SGUI_TEXT_VARBOX_PARAM* pcstInitParam, SGUI_SZSTR szTextBuffer) { - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if((NULL != pstObj) && (NULL != pcstInitParam)) - { - SGUI_SystemIF_MemorySet(pstObj, 0x00, sizeof(SGUI_TEXT_VARBOX_STRUCT)); - SGUI_SystemIF_MemoryCopy(&(pstObj->stParam), (void*)pcstInitParam, sizeof(SGUI_TEXT_VARBOX_PARAM)); - pstObj->stData.szValue = szTextBuffer; - } + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if((NULL != pstObj) && (NULL != pcstInitParam)) + { + SGUI_SystemIF_MemorySet(pstObj, 0x00, sizeof(SGUI_TEXT_VARBOX_STRUCT)); + SGUI_SystemIF_MemoryCopy(&(pstObj->stParam), (void*)pcstInitParam, sizeof(SGUI_TEXT_VARBOX_PARAM)); + pstObj->stData.szValue = szTextBuffer; + } } /*************************************************************************/ -/** Function Name: SGUI_TextVariableBox_Paint **/ -/** Purpose: Display or refresh a integer value edit box. **/ -/** Params: **/ -/** @ pstDeviceIF[in]: Device driver object pointer. **/ -/** @ pstObj[in]: Text value edit box pointer. **/ -/** @ cNewCharacters[in]: New character of value. **/ -/** @ eMode[in]: Display mode, normal or reveres. **/ -/** Return: None. **/ -/** Notice: Static function, call by others interface. **/ +/** Function Name: SGUI_TextVariableBox_Paint **/ +/** Purpose: Display or refresh a integer value edit box. **/ +/** Params: **/ +/** @ pstDeviceIF[in]: Device driver object pointer. **/ +/** @ pstObj[in]: Text value edit box pointer. **/ +/** @ cNewCharacters[in]: New character of value. **/ +/** @ eMode[in]: Display mode, normal or reveres. **/ +/** Return: None. **/ +/** Notice: Static function, call by others interface. **/ /*************************************************************************/ void SGUI_TextVariableBox_Repaint(SGUI_SCR_DEV* pstDeviceIF, SGUI_TEXT_VARBOX_STRUCT* pstObj, SGUI_DRAW_MODE eMode) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - SGUI_COLOR eBackColor; - SGUI_POINT stTextInnerPos; - SGUI_RECT stFocusArea; - SGUI_UINT16 uiFontWidth, uiFontHeight; - SGUI_SIZE uiTextLength, uiFocusIndexMax; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_COLOR eBackColor; + SGUI_POINT stTextInnerPos; + SGUI_RECT stFocusArea; + SGUI_UINT16 uiFontWidth, uiFontHeight; + SGUI_SIZE uiTextLength, uiFocusIndexMax; - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - eBackColor = ((eMode==SGUI_DRAW_NORMAL)?SGUI_COLOR_BKGCLR:SGUI_COLOR_FRGCLR); + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + eBackColor = ((eMode==SGUI_DRAW_NORMAL)?SGUI_COLOR_BKGCLR:SGUI_COLOR_FRGCLR); - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if((NULL != pstObj) && (NULL != pstObj->stData.szValue)) - { - // Clear background. - SGUI_Basic_DrawRectangle(pstDeviceIF, LAYOUT(pstObj).iX, LAYOUT(pstObj).iY, LAYOUT(pstObj).iWidth, LAYOUT(pstObj).iHeight, eBackColor, eBackColor); - // Get font graphics size. - uiFontWidth = pstObj->stParam.pstFontRes->iHalfWidth; - uiFontHeight = pstObj->stParam.pstFontRes->iHeight; + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if((NULL != pstObj) && (NULL != pstObj->stData.szValue)) + { + // Clear background. + SGUI_Basic_DrawRectangle(pstDeviceIF, LAYOUT(pstObj).iX, LAYOUT(pstObj).iY, LAYOUT(pstObj).iWidth, LAYOUT(pstObj).iHeight, eBackColor, eBackColor); + // Get font graphics size. + uiFontWidth = pstObj->stParam.pstFontRes->iHalfWidth; + uiFontHeight = pstObj->stParam.pstFontRes->iHeight; - // Get max text length and graphics width. - uiFocusIndexMax = pstObj->stParam.sTextLengthMax-1; - // Ignore too long text string. - uiTextLength = SGUI_SystemIF_StringLength(pstObj->stData.szValue); - if(uiTextLength > pstObj->stParam.sTextLengthMax) - { - uiTextLength = pstObj->stParam.sTextLengthMax; - *(pstObj->stData.szValue+uiTextLength) = '\0'; + // Get max text length and graphics width. + uiFocusIndexMax = pstObj->stParam.sTextLengthMax-1; + // Ignore too long text string. + uiTextLength = SGUI_SystemIF_StringLength(pstObj->stData.szValue); + if(uiTextLength > pstObj->stParam.sTextLengthMax) + { + uiTextLength = pstObj->stParam.sTextLengthMax; + *(pstObj->stData.szValue+uiTextLength) = '\0'; // Point at to last character position if index is more then string length. - if(pstObj->stData.sFocusIndex > uiFocusIndexMax) - { - pstObj->stData.sFocusIndex = uiFocusIndexMax; - } - } - // Set text display area. - stTextInnerPos.iX = 0; - stTextInnerPos.iY = 0; - // Set focus character area. - stFocusArea.iX = LAYOUT(pstObj).iX+pstObj->stData.sFocusIndex*uiFontWidth; - stFocusArea.iY = LAYOUT(pstObj).iY; - stFocusArea.iWidth = uiFontWidth; - stFocusArea.iHeight = uiFontHeight; - if(RECT_X_END(stFocusArea) > RECT_X_END(LAYOUT(pstObj))) - { - stTextInnerPos.iX = RECT_X_END(LAYOUT(pstObj)) - RECT_X_END(stFocusArea); - stFocusArea.iX = stFocusArea.iX + stTextInnerPos.iX; - } - // Display text. - SGUI_Text_DrawText(pstDeviceIF, pstObj->stData.szValue, pstObj->stParam.pstFontRes, &LAYOUT(pstObj), &stTextInnerPos, eMode); - // Focus first character. + if(pstObj->stData.sFocusIndex > uiFocusIndexMax) + { + pstObj->stData.sFocusIndex = uiFocusIndexMax; + } + } + // Set text display area. + stTextInnerPos.iX = 0; + stTextInnerPos.iY = 0; + // Set focus character area. + stFocusArea.iX = LAYOUT(pstObj).iX+pstObj->stData.sFocusIndex*uiFontWidth; + stFocusArea.iY = LAYOUT(pstObj).iY; + stFocusArea.iWidth = uiFontWidth; + stFocusArea.iHeight = uiFontHeight; + if(RECT_X_END(stFocusArea) > RECT_X_END(LAYOUT(pstObj))) + { + stTextInnerPos.iX = RECT_X_END(LAYOUT(pstObj)) - RECT_X_END(stFocusArea); + stFocusArea.iX = stFocusArea.iX + stTextInnerPos.iX; + } + // Display text. + SGUI_Text_DrawText(pstDeviceIF, pstObj->stData.szValue, pstObj->stParam.pstFontRes, &LAYOUT(pstObj), &stTextInnerPos, eMode); + // Focus first character. SGUI_Basic_ReverseBlockColor(pstDeviceIF, stFocusArea.iX, stFocusArea.iY, stFocusArea.iWidth, stFocusArea.iHeight); - } + } } diff --git a/HMI/inc/HMI_Engine.h b/HMI/inc/HMI_Engine.h index ea4f66591b0eb868a0180c1cdb814f8e9bb53156..94098cd1d46b5ac0b60258cccdab362eb5a29c85 100644 --- a/HMI/inc/HMI_Engine.h +++ b/HMI/inc/HMI_Engine.h @@ -1,43 +1,43 @@ #ifndef __INCLUDE_HMI_ENGINE_H__ #define __INCLUDE_HMI_ENGINE_H__ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "SGUI_Typedef.h" //=======================================================================// -//= User Macro definition. =// +//= User Macro definition. =// //=======================================================================// // GoBack history size -#define HMI_SCREEN_HISTORY_MAX (20) +#define HMI_SCREEN_HISTORY_MAX (20) #define HMI_EVENT_KEY_VALUE_LENGTH_MAX (4) // Parameter post label. -#define HMI_SCREEN_ID_ANY (-1) // This label means parameter will posted to every screen. +#define HMI_SCREEN_ID_ANY (-1) // This label means parameter will posted to every screen. -#define HMI_PROCESS_SUCCESSFUL(RESULT) (RESULT >= 0) -#define HMI_PROCESS_FAILED(RESULT) (!(HMI_PROCESS_SUCCESSFUL(RESULT))) +#define HMI_PROCESS_SUCCESSFUL(RESULT) (RESULT >= 0) +#define HMI_PROCESS_FAILED(RESULT) (!(HMI_PROCESS_SUCCESSFUL(RESULT))) // Start screen definition -#define HMI_SCREEN_START (0) +#define HMI_SCREEN_START (0) -#define HMI_EVENT_TYPE_DECLARE(NAME, DATA) typedef struct \ - { \ - HMI_EVENT_BASE Head; \ - DATA Data; \ - }NAME; +#define HMI_EVENT_TYPE_DECLARE(NAME, DATA) typedef struct \ + { \ + HMI_EVENT_BASE Head; \ + DATA Data; \ + }NAME; -#define HMI_EVENT_DATA_MEMSET(EVENT) SGUI_SystemIF_MemorySet(&EVENT, 0x00, sizeof(EVENT)) +#define HMI_EVENT_DATA_MEMSET(EVENT) SGUI_SystemIF_MemorySet(&EVENT, 0x00, sizeof(EVENT)) -#define HMI_EVENT_INIT(EVENT) { \ - HMI_EVENT_DATA_MEMSET(EVENT); \ - EVENT.Head.iSize = sizeof(EVENT); \ - EVENT.Head.iType = EVENT_TYPE_ANY; \ - } +#define HMI_EVENT_INIT(EVENT) { \ + HMI_EVENT_DATA_MEMSET(EVENT); \ + EVENT.Head.iSize = sizeof(EVENT); \ + EVENT.Head.iType = EVENT_TYPE_ANY; \ + } -#define HMI_EVENT_SIZE_CHK(EVENT, TYPE) (((EVENT).Head.iSize == sizeof(TYPE))?SGUI_TRUE:SGUI_FALSE) +#define HMI_EVENT_SIZE_CHK(EVENT, TYPE) (((EVENT).Head.iSize == sizeof(TYPE))?SGUI_TRUE:SGUI_FALSE) //=======================================================================// -//= Data type definition. =// +//= Data type definition. =// //=======================================================================// // HMI process result typedef enum @@ -47,65 +47,65 @@ typedef enum HMI_RET_INVALID_DATA = -2, HMI_RET_ERROR_STATE = -1, // Normal. - HMI_RET_ABNORMAL = 0, + HMI_RET_ABNORMAL = 0, HMI_RET_NORMAL = 1, }HMI_ENGINE_RESULT; typedef enum { - HMI_ENGINE_SCR_SWITCH = 0,// Switch screen and record to history. - HMI_ENGINE_SCR_POPUP, // Show up screen only. + HMI_ENGINE_SCR_SWITCH = 0,// Switch screen and record to history. + HMI_ENGINE_SCR_POPUP, // Show up screen only. }HMI_SCREEN_DISP_TYPE; typedef struct { - SGUI_INT iType; - SGUI_INT iID; - SGUI_INT iSize; + SGUI_INT iType; + SGUI_INT iID; + SGUI_INT iSize; }HMI_EVENT_BASE; typedef struct { - HMI_EVENT_BASE Head; + HMI_EVENT_BASE Head; }HMI_GENERAL_EVENT; // Screen action interface function pointer structure. typedef struct { - // Initialize screen data and parameter. - HMI_ENGINE_RESULT (*Initialize) (SGUI_SCR_DEV* Interface); + // Initialize screen data and parameter. + HMI_ENGINE_RESULT (*Initialize) (SGUI_SCR_DEV* Interface); // Do some thing before current screen display. - HMI_ENGINE_RESULT (*Prepare) (SGUI_SCR_DEV* Interface, const void* pstParameters); - // Repaint screen if needed. - HMI_ENGINE_RESULT (*Repaint) (SGUI_SCR_DEV* Interface, const void* pstParameters); - // Process event. - HMI_ENGINE_RESULT (*ProcessEvent) (SGUI_SCR_DEV* Interface, const HMI_EVENT_BASE* pstEvent, SGUI_INT* piActionID); - // Post process. - HMI_ENGINE_RESULT (*PostProcess) (SGUI_SCR_DEV* Interface, HMI_ENGINE_RESULT eProcResult, SGUI_INT iActionID); + HMI_ENGINE_RESULT (*Prepare) (SGUI_SCR_DEV* Interface, const void* pstParameters); + // Repaint screen if needed. + HMI_ENGINE_RESULT (*Repaint) (SGUI_SCR_DEV* Interface, const void* pstParameters); + // Process event. + HMI_ENGINE_RESULT (*ProcessEvent) (SGUI_SCR_DEV* Interface, const HMI_EVENT_BASE* pstEvent, SGUI_INT* piActionID); + // Post process. + HMI_ENGINE_RESULT (*PostProcess) (SGUI_SCR_DEV* Interface, HMI_ENGINE_RESULT eProcResult, SGUI_INT iActionID); }HMI_SCREEN_ACTION; // Screen data structure. typedef struct _T_HMI_SCREEN_OBJECT_ { - SGUI_INT iScreenID; - HMI_SCREEN_ACTION* pstActions; - struct _T_HMI_SCREEN_OBJECT_* pstPrevious; + SGUI_INT iScreenID; + HMI_SCREEN_ACTION* pstActions; + struct _T_HMI_SCREEN_OBJECT_* pstPrevious; }HMI_SCREEN_OBJECT; typedef struct { - HMI_SCREEN_OBJECT** ScreenObjPtr; + HMI_SCREEN_OBJECT** ScreenObjPtr; SGUI_INT ScreenCount; HMI_SCREEN_OBJECT* CurrentScreenObject; - SGUI_SCR_DEV* Interface; + SGUI_SCR_DEV* Interface; }HMI_ENGINE_OBJECT; //=======================================================================// -//= Public function declaration. =// +//= Public function declaration. =// //=======================================================================// HMI_ENGINE_RESULT HMI_ActiveEngine(HMI_ENGINE_OBJECT* pstHMIEngineObject, SGUI_INT iScreenID); HMI_ENGINE_RESULT HMI_StartEngine(const void* pstParameters); -HMI_ENGINE_RESULT HMI_ProcessEvent(const HMI_EVENT_BASE* pstEvent); +HMI_ENGINE_RESULT HMI_ProcessEvent(const HMI_EVENT_BASE* pstEvent); HMI_ENGINE_RESULT HMI_SwitchScreen(SGUI_INT iDestScreenID, const void* pstParameters); HMI_ENGINE_RESULT HMI_GoBack(const void* pstParameters); -HMI_ENGINE_RESULT HMI_SetDeviceObject(SGUI_SCR_DEV* pstDeviceObj); +HMI_ENGINE_RESULT HMI_SetDeviceObject(SGUI_SCR_DEV* pstDeviceObj); #endif // __INCLUDE_HMI_ENGINE_H__ diff --git a/HMI/src/HMI_Engine.c b/HMI/src/HMI_Engine.c index 6580d914f8bcb846a592bff4390be459d2c3d17a..8b2a9269521a7dad1cd0b027874e0cb353c84299 100644 --- a/HMI/src/HMI_Engine.c +++ b/HMI/src/HMI_Engine.c @@ -1,137 +1,137 @@ /*************************************************************************/ -/** Copyright. **/ -/** FileName: HMI_Process.c **/ -/** Author: Polarix **/ -/** Version: 1.0.0.0 **/ -/** Description: This file provides ActionMap interface function. **/ +/** Copyright. **/ +/** FileName: HMI_Process.c **/ +/** Author: Polarix **/ +/** Version: 1.0.0.0 **/ +/** Description: This file provides ActionMap interface function. **/ /*************************************************************************/ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "HMI_Engine.h" //=======================================================================// -//= Static variable declaration. =// +//= Static variable declaration. =// //=======================================================================// static HMI_ENGINE_OBJECT* g_pstActivedEngineObject; //=======================================================================// -//= Static function declaration. =// +//= Static function declaration. =// //=======================================================================// static HMI_SCREEN_OBJECT* HMI_GetScreenObjectInEngine(HMI_ENGINE_OBJECT* pstHMIEngineObject, SGUI_INT iScreenID); //=======================================================================// -//= Function define. =// +//= Function define. =// //=======================================================================// /*****************************************************************************/ -/** Function Name: HMI_ActiveEngine **/ -/** Purpose: Set a HMI engine object to the activated state. **/ -/** Params: **/ +/** Function Name: HMI_ActiveEngine **/ +/** Purpose: Set a HMI engine object to the activated state. **/ +/** Params: **/ /** @pstHMIEngineObject[in]: The pointer of the engine object will active. **/ /** @iScreenID[in]: Specif a screen ID, this screen will be show first **/ /** when engine start, for HMI_SCREEN_ID_ANY to keep **/ /** last screen when this engine activated, and if the **/ /** screen not add into the engine object, the error **/ /** HMI_RET_INVALID_DATA will be returned. **/ -/** Return: HMI_ENGINE_RESULT **/ -/** @HMI_RET_NORMAL: Engine activated. **/ +/** Return: HMI_ENGINE_RESULT **/ +/** @HMI_RET_NORMAL: Engine activated. **/ /** @HMI_RET_ERROR_STATE: Current engine object is in processing. **/ /** @HMI_RET_INVALID_DATA: Specified screen ID is invalid or not add to **/ /** this engine. **/ -/** Notice: The process event will post to the activated engine. **/ +/** Notice: The process event will post to the activated engine. **/ /*****************************************************************************/ HMI_ENGINE_RESULT HMI_ActiveEngine(HMI_ENGINE_OBJECT* pstHMIEngineObject, SGUI_INT iScreenID) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - HMI_ENGINE_RESULT eProcessResult; - HMI_SCREEN_OBJECT* pstScreenObject; - - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - eProcessResult = HMI_RET_NORMAL; - pstScreenObject = NULL; - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if(NULL != pstHMIEngineObject) - { - if(HMI_SCREEN_ID_ANY != iScreenID) - { - pstScreenObject = HMI_GetScreenObjectInEngine(pstHMIEngineObject, iScreenID); - } - else - { - pstScreenObject = pstHMIEngineObject->ScreenObjPtr[0]; - } - if(NULL != pstScreenObject) - { - pstHMIEngineObject->CurrentScreenObject = pstScreenObject; - } - else - { - eProcessResult = HMI_RET_INVALID_DATA; - } - } - else - { - eProcessResult = HMI_RET_INVALID_DATA; - } + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + HMI_ENGINE_RESULT eProcessResult; + HMI_SCREEN_OBJECT* pstScreenObject; + + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + eProcessResult = HMI_RET_NORMAL; + pstScreenObject = NULL; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(NULL != pstHMIEngineObject) + { + if(HMI_SCREEN_ID_ANY != iScreenID) + { + pstScreenObject = HMI_GetScreenObjectInEngine(pstHMIEngineObject, iScreenID); + } + else + { + pstScreenObject = pstHMIEngineObject->ScreenObjPtr[0]; + } + if(NULL != pstScreenObject) + { + pstHMIEngineObject->CurrentScreenObject = pstScreenObject; + } + else + { + eProcessResult = HMI_RET_INVALID_DATA; + } + } + else + { + eProcessResult = HMI_RET_INVALID_DATA; + } if(HMI_RET_NORMAL == eProcessResult) - { - g_pstActivedEngineObject = pstHMIEngineObject; - } + { + g_pstActivedEngineObject = pstHMIEngineObject; + } return eProcessResult; } /*****************************************************************************/ -/** Function Name: HMI_StartEngine **/ -/** Purpose: Start HMI engine and show screen display. **/ -/** Params: None. **/ -/** Return: HMI_ENGINE_RESULT **/ -/** @ HMI_RET_NORMAL: Engine activated. **/ -/** @ HMI_RET_ERROR_STATE: Current engine object is in processing. **/ -/** @ HMI_RET_INVALID_DATA: Specified screen ID is invalid or not add to **/ +/** Function Name: HMI_StartEngine **/ +/** Purpose: Start HMI engine and show screen display. **/ +/** Params: None. **/ +/** Return: HMI_ENGINE_RESULT **/ +/** @ HMI_RET_NORMAL: Engine activated. **/ +/** @ HMI_RET_ERROR_STATE: Current engine object is in processing. **/ +/** @ HMI_RET_INVALID_DATA: Specified screen ID is invalid or not add to **/ /** this engine. **/ -/** Notice: The process event will post to the activated engine. **/ -/** Notice: Screen will only refresh when pstPreProcessData is NULL **/ +/** Notice: The process event will post to the activated engine. **/ +/** Notice: Screen will only refresh when pstPreProcessData is NULL **/ /*****************************************************************************/ HMI_ENGINE_RESULT HMI_StartEngine(const void* pstParameters) { /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - HMI_ENGINE_RESULT eProcessResult; - HMI_SCREEN_OBJECT* pstStartScreen; + /* Variable Declaration */ + /*----------------------------------*/ + HMI_ENGINE_RESULT eProcessResult; + HMI_SCREEN_OBJECT* pstStartScreen; - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - eProcessResult = HMI_RET_NORMAL; - pstStartScreen = NULL; + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + eProcessResult = HMI_RET_NORMAL; + pstStartScreen = NULL; - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ if(NULL != g_pstActivedEngineObject) { - pstStartScreen = g_pstActivedEngineObject->CurrentScreenObject; - if(NULL != pstStartScreen) - { - if(NULL != pstStartScreen->pstActions) - { - if(NULL != pstStartScreen->pstActions->Prepare) - { - eProcessResult = pstStartScreen->pstActions->Prepare(g_pstActivedEngineObject->Interface, pstParameters); - g_pstActivedEngineObject->Interface->fnSyncBuffer(); - } - } - } + pstStartScreen = g_pstActivedEngineObject->CurrentScreenObject; + if(NULL != pstStartScreen) + { + if(NULL != pstStartScreen->pstActions) + { + if(NULL != pstStartScreen->pstActions->Prepare) + { + eProcessResult = pstStartScreen->pstActions->Prepare(g_pstActivedEngineObject->Interface, pstParameters); + g_pstActivedEngineObject->Interface->fnSyncBuffer(); + } + } + } } else { @@ -139,66 +139,66 @@ HMI_ENGINE_RESULT HMI_StartEngine(const void* pstParameters) eProcessResult = HMI_RET_INVALID_DATA; } - return eProcessResult; + return eProcessResult; } /*****************************************************************************/ -/** Function Name: HMI_ProcessEvent **/ -/** Purpose: Receive posted event and post to screen object. **/ -/** Params: **/ -/** @ pstEvent[in]: Event data, include action type and parameter data. **/ -/** Return: HMI_ENGINE_RESULT. **/ -/** Notice: None. **/ +/** Function Name: HMI_ProcessEvent **/ +/** Purpose: Receive posted event and post to screen object. **/ +/** Params: **/ +/** @ pstEvent[in]: Event data, include action type and parameter data. **/ +/** Return: HMI_ENGINE_RESULT. **/ +/** Notice: None. **/ /*****************************************************************************/ HMI_ENGINE_RESULT HMI_ProcessEvent(const HMI_EVENT_BASE* pstEvent) { /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - HMI_ENGINE_RESULT eProcessResult; - HMI_SCREEN_OBJECT* pstCurrentScreen; - SGUI_INT iActionID; - - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - eProcessResult = HMI_RET_NORMAL; - pstCurrentScreen = NULL; - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + HMI_ENGINE_RESULT eProcessResult; + HMI_SCREEN_OBJECT* pstCurrentScreen; + SGUI_INT iActionID; + + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + eProcessResult = HMI_RET_NORMAL; + pstCurrentScreen = NULL; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ if(NULL != g_pstActivedEngineObject) { - // Get current displayed screen object. - pstCurrentScreen = g_pstActivedEngineObject->CurrentScreenObject; - if( (NULL == pstCurrentScreen) || - (NULL == pstCurrentScreen->pstActions) || - (NULL == pstCurrentScreen->pstActions->ProcessEvent)) - { - // Screen ID is invalid or screen object is invalid. - eProcessResult = HMI_RET_INVALID_DATA; - - } - else - { - // Process event. - eProcessResult = pstCurrentScreen->pstActions->ProcessEvent(g_pstActivedEngineObject->Interface, pstEvent, &iActionID); - } - - // Run post process. - eProcessResult = pstCurrentScreen->pstActions->PostProcess(g_pstActivedEngineObject->Interface, eProcessResult, iActionID); - /* - if(HMI_PROCESS_FAILED(eProcResult)) - { - // Post process return failed. - } - */ - if( (NULL != g_pstActivedEngineObject->Interface) && - (NULL != g_pstActivedEngineObject->Interface->fnSyncBuffer)) - { - g_pstActivedEngineObject->Interface->fnSyncBuffer(); - } + // Get current displayed screen object. + pstCurrentScreen = g_pstActivedEngineObject->CurrentScreenObject; + if( (NULL == pstCurrentScreen) || + (NULL == pstCurrentScreen->pstActions) || + (NULL == pstCurrentScreen->pstActions->ProcessEvent)) + { + // Screen ID is invalid or screen object is invalid. + eProcessResult = HMI_RET_INVALID_DATA; + + } + else + { + // Process event. + eProcessResult = pstCurrentScreen->pstActions->ProcessEvent(g_pstActivedEngineObject->Interface, pstEvent, &iActionID); + } + + // Run post process. + eProcessResult = pstCurrentScreen->pstActions->PostProcess(g_pstActivedEngineObject->Interface, eProcessResult, iActionID); + /* + if(HMI_PROCESS_FAILED(eProcResult)) + { + // Post process return failed. + } + */ + if( (NULL != g_pstActivedEngineObject->Interface) && + (NULL != g_pstActivedEngineObject->Interface->fnSyncBuffer)) + { + g_pstActivedEngineObject->Interface->fnSyncBuffer(); + } } else { @@ -206,59 +206,59 @@ HMI_ENGINE_RESULT HMI_ProcessEvent(const HMI_EVENT_BASE* pstEvent) eProcessResult = HMI_RET_INVALID_DATA; } - return eProcessResult; + return eProcessResult; } /*****************************************************************************/ -/** Function Name: HMI_SwitchScreen **/ -/** Purpose: Turn to a screen with screen index. **/ -/** Params: **/ -/** @ iDestScreenID[in]: Screen ID witch will be going to. **/ -/** @ pstParameters[in]: Screen prepare data pointer. **/ -/** Return: HMI_ENGINE_RESULT. **/ -/** Notice: Screen will only refresh when pstPreProcessData is NULL **/ +/** Function Name: HMI_SwitchScreen **/ +/** Purpose: Turn to a screen with screen index. **/ +/** Params: **/ +/** @ iDestScreenID[in]: Screen ID witch will be going to. **/ +/** @ pstParameters[in]: Screen prepare data pointer. **/ +/** Return: HMI_ENGINE_RESULT. **/ +/** Notice: Screen will only refresh when pstPreProcessData is NULL **/ /*****************************************************************************/ HMI_ENGINE_RESULT HMI_SwitchScreen(SGUI_INT iDestScreenID, const void* pstParameters) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - HMI_ENGINE_RESULT eProcessResult; - HMI_SCREEN_OBJECT* pstDestScreen; - - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - eProcessResult = HMI_RET_NORMAL; - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if(NULL != g_pstActivedEngineObject) + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + HMI_ENGINE_RESULT eProcessResult; + HMI_SCREEN_OBJECT* pstDestScreen; + + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + eProcessResult = HMI_RET_NORMAL; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(NULL != g_pstActivedEngineObject) { - pstDestScreen = HMI_GetScreenObjectInEngine(g_pstActivedEngineObject, iDestScreenID); - if(NULL == pstDestScreen) - { - /* Not find screen object by ID. */ - eProcessResult = HMI_RET_INVALID_DATA; - } - else if(NULL != pstDestScreen->pstPrevious) - { - /* Cannot reenter to a screen object. */ - eProcessResult = HMI_RET_ERROR; - } - else - { - pstDestScreen->pstPrevious = g_pstActivedEngineObject->CurrentScreenObject; - g_pstActivedEngineObject->CurrentScreenObject = pstDestScreen; - if(NULL != pstDestScreen->pstActions) - { - if(NULL != pstDestScreen->pstActions->Prepare) - { - eProcessResult = pstDestScreen->pstActions->Prepare(g_pstActivedEngineObject->Interface, pstParameters); - } - } - } + pstDestScreen = HMI_GetScreenObjectInEngine(g_pstActivedEngineObject, iDestScreenID); + if(NULL == pstDestScreen) + { + /* Not find screen object by ID. */ + eProcessResult = HMI_RET_INVALID_DATA; + } + else if(NULL != pstDestScreen->pstPrevious) + { + /* Cannot reenter to a screen object. */ + eProcessResult = HMI_RET_ERROR; + } + else + { + pstDestScreen->pstPrevious = g_pstActivedEngineObject->CurrentScreenObject; + g_pstActivedEngineObject->CurrentScreenObject = pstDestScreen; + if(NULL != pstDestScreen->pstActions) + { + if(NULL != pstDestScreen->pstActions->Prepare) + { + eProcessResult = pstDestScreen->pstActions->Prepare(g_pstActivedEngineObject->Interface, pstParameters); + } + } + } } else @@ -271,50 +271,50 @@ HMI_ENGINE_RESULT HMI_SwitchScreen(SGUI_INT iDestScreenID, const void* pstParame } /*****************************************************************************/ -/** Function Name: HMI_GoBack. **/ -/** Purpose: Go back to previous screen in actions history. **/ -/** Resources: Screen data structure and action process function. **/ -/** Params: **/ -/** @pstPreProcessData[in]: Update screen data. **/ -/** Return: HMI_ENGINE_RESULT. **/ -/** Notice: Screen will only refresh when pstPreProcessData is NULL **/ +/** Function Name: HMI_GoBack. **/ +/** Purpose: Go back to previous screen in actions history. **/ +/** Resources: Screen data structure and action process function. **/ +/** Params: **/ +/** @pstPreProcessData[in]: Update screen data. **/ +/** Return: HMI_ENGINE_RESULT. **/ +/** Notice: Screen will only refresh when pstPreProcessData is NULL **/ /*****************************************************************************/ HMI_ENGINE_RESULT HMI_GoBack(const void* pstParameters) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - HMI_ENGINE_RESULT eProcessResult; - HMI_SCREEN_OBJECT* pstPreviousScreen; - - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - eProcessResult = HMI_RET_NORMAL; - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if(NULL != g_pstActivedEngineObject) + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + HMI_ENGINE_RESULT eProcessResult; + HMI_SCREEN_OBJECT* pstPreviousScreen; + + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + eProcessResult = HMI_RET_NORMAL; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if(NULL != g_pstActivedEngineObject) { - pstPreviousScreen = g_pstActivedEngineObject->CurrentScreenObject->pstPrevious; - g_pstActivedEngineObject->CurrentScreenObject->pstPrevious = NULL; - - if(NULL != pstPreviousScreen) - { - g_pstActivedEngineObject->CurrentScreenObject = pstPreviousScreen; - if(NULL != pstPreviousScreen->pstActions) - { - if(NULL != pstPreviousScreen->pstActions->Prepare) - { - eProcessResult = pstPreviousScreen->pstActions->Prepare(g_pstActivedEngineObject->Interface, pstParameters); - } - } - } - else - { - eProcessResult = HMI_RET_INVALID_DATA; - } + pstPreviousScreen = g_pstActivedEngineObject->CurrentScreenObject->pstPrevious; + g_pstActivedEngineObject->CurrentScreenObject->pstPrevious = NULL; + + if(NULL != pstPreviousScreen) + { + g_pstActivedEngineObject->CurrentScreenObject = pstPreviousScreen; + if(NULL != pstPreviousScreen->pstActions) + { + if(NULL != pstPreviousScreen->pstActions->Prepare) + { + eProcessResult = pstPreviousScreen->pstActions->Prepare(g_pstActivedEngineObject->Interface, pstParameters); + } + } + } + else + { + eProcessResult = HMI_RET_INVALID_DATA; + } } else { @@ -326,35 +326,35 @@ HMI_ENGINE_RESULT HMI_GoBack(const void* pstParameters) } /*****************************************************************************/ -/** Function Name: HMI_GetScreenObjectInEngine. **/ -/** Purpose: Get a screen object pointer form a existed HMI engine **/ +/** Function Name: HMI_GetScreenObjectInEngine. **/ +/** Purpose: Get a screen object pointer form a existed HMI engine **/ /** object, return NULL if screen not existed. **/ -/** Params: **/ +/** Params: **/ /** @pstHMIEngineObject[in]: The pointer of the engine object. **/ /** @iScreenID[in]: Screen ID of screen object will be searched in HMI **/ /** engine object. **/ -/** Return: HMI_SCREEN_OBJECT pointer. **/ +/** Return: HMI_SCREEN_OBJECT pointer. **/ /** @NULL: Screen object not existed or not add in this HMI **/ -/** engine. **/ -/** Notice: None. **/ +/** engine. **/ +/** Notice: None. **/ /*****************************************************************************/ HMI_SCREEN_OBJECT* HMI_GetScreenObjectInEngine(HMI_ENGINE_OBJECT* pstHMIEngineObject, SGUI_INT iScreenID) { /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - HMI_SCREEN_OBJECT* pstScreenObject; - SGUI_INT iIndex; + /* Variable Declaration */ + /*----------------------------------*/ + HMI_SCREEN_OBJECT* pstScreenObject; + SGUI_INT iIndex; - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - pstScreenObject = NULL; - iIndex = 0; + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + pstScreenObject = NULL; + iIndex = 0; - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ if(NULL != pstHMIEngineObject) { while(iIndex < pstHMIEngineObject->ScreenCount) @@ -371,41 +371,41 @@ HMI_SCREEN_OBJECT* HMI_GetScreenObjectInEngine(HMI_ENGINE_OBJECT* pstHMIEngineOb } } - return pstScreenObject; + return pstScreenObject; } /*****************************************************************************/ -/** Function Name: HMI_SetDeviceObject. **/ -/** Purpose: Set a new screen device interface object pointer to **/ -/** actived HMI object. **/ -/** Params: **/ -/** @ pstDeviceObj[in]: New device driver interface object pointer. **/ -/** Return: HMI_ENGINE_RESULT **/ -/** Notice: None. **/ +/** Function Name: HMI_SetDeviceObject. **/ +/** Purpose: Set a new screen device interface object pointer to **/ +/** actived HMI object. **/ +/** Params: **/ +/** @ pstDeviceObj[in]: New device driver interface object pointer. **/ +/** Return: HMI_ENGINE_RESULT **/ +/** Notice: None. **/ /*****************************************************************************/ HMI_ENGINE_RESULT HMI_SetDeviceObject(SGUI_SCR_DEV* pstDeviceObj) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - HMI_ENGINE_RESULT eProcessResult; - - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - eProcessResult = HMI_RET_NORMAL; - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - if((NULL == pstDeviceObj) || (NULL == g_pstActivedEngineObject)) - { - eProcessResult = HMI_RET_INVALID_DATA; - } - else - { - g_pstActivedEngineObject->Interface = pstDeviceObj; - } - - return eProcessResult; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + HMI_ENGINE_RESULT eProcessResult; + + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + eProcessResult = HMI_RET_NORMAL; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + if((NULL == pstDeviceObj) || (NULL == g_pstActivedEngineObject)) + { + eProcessResult = HMI_RET_INVALID_DATA; + } + else + { + g_pstActivedEngineObject->Interface = pstDeviceObj; + } + + return eProcessResult; } diff --git a/Transplant/MiniDevCore/BSP/inc/base_timer.h b/Transplant/MiniDevCore/BSP/inc/base_timer.h index 27c6d9ee0003b0d187ccfb3e3a4aa4cfc4af2564..0018750914192ff4cd1b41bb6ed61987e5fd0841 100644 --- a/Transplant/MiniDevCore/BSP/inc/base_timer.h +++ b/Transplant/MiniDevCore/BSP/inc/base_timer.h @@ -6,12 +6,12 @@ #include #include "stm32f10x_tim.h" -#define TIMER_REV_INT_CFG_DECLARE(TIMER) void TIMER##_ConfigReceiveInterrupt(TIMER_INT_FP pfCallBack, int iPreemptionPriority, int SubPriority) +#define TIMER_REV_INT_CFG_DECLARE(TIMER) void TIMER##_ConfigReceiveInterrupt(TIMER_INT_FP pfCallBack, int iPreemptionPriority, int SubPriority) typedef void(*TIMER_INT_FP)(void); void BASE_TIMER_Initialize(TIM_TypeDef* pstTimerBase, uint16_t uiReloadValue, uint16_t uiPrescaler); -void BASE_TIMER_ActiveInterrupt(TIM_TypeDef* pstTimerBase, bool bEnable); +void BASE_TIMER_ActiveInterrupt(TIM_TypeDef* pstTimerBase, bool bEnable); TIMER_REV_INT_CFG_DECLARE(TIM3); TIMER_REV_INT_CFG_DECLARE(TIM4); diff --git a/Transplant/MiniDevCore/BSP/inc/keyboard.h b/Transplant/MiniDevCore/BSP/inc/keyboard.h index e82a358c556dde3d28e9c00f2f71b176907efdc0..3813121d1ffdc1d0fa7ca6d50f32d1123309a30a 100644 --- a/Transplant/MiniDevCore/BSP/inc/keyboard.h +++ b/Transplant/MiniDevCore/BSP/inc/keyboard.h @@ -5,25 +5,25 @@ #include #include -#define KEY_STATE_DOWN Bit_RESET -#define KEY_STATE_UP Bit_SET -#define KEY_STATE BitAction +#define KEY_STATE_DOWN Bit_RESET +#define KEY_STATE_UP Bit_SET +#define KEY_STATE BitAction -#define KEY_CODE_F1 (0x30) -#define KEY_CODE_F2 (0x32) +#define KEY_CODE_F1 (0x30) +#define KEY_CODE_F2 (0x32) typedef enum { - KEY_EVENT_DOWN, - KEY_EVENT_UP + KEY_EVENT_DOWN, + KEY_EVENT_UP }KEY_EVENT; typedef void(*KB_EVENT_CB_FP)(uint16_t uiKeyCode, KEY_EVENT eEvent); -void KB_Initialize(void); -void KB_Scan(void); -void KB_RegisterEventProc(KB_EVENT_CB_FP fpKBEventCallBackFunc); -KEY_STATE KB_CheckKeyState(uint8_t uiKeyCode); +void KB_Initialize(void); +void KB_Scan(void); +void KB_RegisterEventProc(KB_EVENT_CB_FP fpKBEventCallBackFunc); +KEY_STATE KB_CheckKeyState(uint8_t uiKeyCode); #endif diff --git a/Transplant/MiniDevCore/BSP/inc/led.h b/Transplant/MiniDevCore/BSP/inc/led.h index 0f3ce755d204fa83508ce04f6e66e6fb3c547d58..504693bd78eb66fcb3f89ce325f8092666634600 100644 --- a/Transplant/MiniDevCore/BSP/inc/led.h +++ b/Transplant/MiniDevCore/BSP/inc/led.h @@ -3,10 +3,10 @@ #include -void LED_Initialize(void); -void LED_On(void); -void LED_Off(void); -void LED_Reverse(void); -uint8_t LED_GetState(void); +void LED_Initialize(void); +void LED_On(void); +void LED_Off(void); +void LED_Reverse(void); +uint8_t LED_GetState(void); #endif diff --git a/Transplant/MiniDevCore/BSP/inc/rtc.h b/Transplant/MiniDevCore/BSP/inc/rtc.h index 72459a8b110eeab86a33804079fb62e995bb9c3f..6141a41c7f7e3245afadd8c1918b700155b4b74d 100644 --- a/Transplant/MiniDevCore/BSP/inc/rtc.h +++ b/Transplant/MiniDevCore/BSP/inc/rtc.h @@ -9,13 +9,13 @@ typedef void(*RTC_INT_FP)(uint32_t uiTimeStamp); -typedef struct tm RTC_CALENDAR_STRUCT; +typedef struct tm RTC_CALENDAR_STRUCT; void RTC_Initialize(void); void RTC_UpdateCalendar(RTC_CALENDAR_STRUCT *pstCalendar); uint32_t RTC_GetTimeStamp(void); RTC_CALENDAR_STRUCT* RTC_ConvertToCalendar(time_t uiTimeStamp); -void RTC_ConfigReceiveInterrupt(RTC_INT_FP pfCallBack, int iPreemptionPriority, int SubPriority); - +void RTC_ConfigReceiveInterrupt(RTC_INT_FP pfCallBack, int iPreemptionPriority, int SubPriority); + #endif //_INCLUDE_RTC_H_ diff --git a/Transplant/MiniDevCore/BSP/inc/screen.h b/Transplant/MiniDevCore/BSP/inc/screen.h index 06c085fda8cef6b1d1c3dd31cf079d6eb0db6d04..fd7372e933d0216b6f0035552bcac95251809341 100644 --- a/Transplant/MiniDevCore/BSP/inc/screen.h +++ b/Transplant/MiniDevCore/BSP/inc/screen.h @@ -8,20 +8,20 @@ typedef enum { - SCREEN_COLOR_BKG = 0, - SCREEN_COLOR_FRG = 1, - SCREEN_COLOR_TRS = 2, + SCREEN_COLOR_BKG = 0, + SCREEN_COLOR_FRG = 1, + SCREEN_COLOR_TRS = 2, }SCREEN_COLOR; //Common operation -#define SET_PAGE_BIT(PAGE, Bit) ((PAGE) = (PAGE) | (0x01 << (Bit))) -#define CLR_PAGE_BIT(PAGE, Bit) ((PAGE) = (PAGE) & (~(0x01 << (Bit)))) -#define GET_PAGE_BIT(PAGE, Bit) ((((PAGE) & (0x01 << (Bit)))>0)?1:0) +#define SET_PAGE_BIT(PAGE, Bit) ((PAGE) = (PAGE) | (0x01 << (Bit))) +#define CLR_PAGE_BIT(PAGE, Bit) ((PAGE) = (PAGE) & (~(0x01 << (Bit)))) +#define GET_PAGE_BIT(PAGE, Bit) ((((PAGE) & (0x01 << (Bit)))>0)?1:0) -void SCREEN_SetPixel(int iPosX, int iPosY, int iColor); -int SCREEN_GetPixel(int iPosX, int iPosY); -int SCREEN_Initialize(void); -void SCREEN_ClearDisplay(void); -void SCREEN_RefreshScreen(void); +void SCREEN_SetPixel(int iPosX, int iPosY, int iColor); +int SCREEN_GetPixel(int iPosX, int iPosY); +int SCREEN_Initialize(void); +void SCREEN_ClearDisplay(void); +void SCREEN_RefreshScreen(void); #endif /* _INCLUDE_SCREEN_H__ */ diff --git a/Transplant/MiniDevCore/BSP/inc/spi_flash.h b/Transplant/MiniDevCore/BSP/inc/spi_flash.h index 0874e89fa37965ecbe17161278b594010a93ebf7..dafe699f8b3b3bbb9be26b70319f80000685c057 100644 --- a/Transplant/MiniDevCore/BSP/inc/spi_flash.h +++ b/Transplant/MiniDevCore/BSP/inc/spi_flash.h @@ -4,31 +4,31 @@ #include #include -#define W25X_WriteEnable (0x06) -#define W25X_WriteDisable (0x04) -#define W25X_ReadStatusReg (0x05) -#define W25X_WriteStatusReg (0x01) -#define W25X_ReadData (0x03) -#define W25X_FastReadData (0x0B) -#define W25X_FastReadDual (0x3B) -#define W25X_PageProgram (0x02) -#define W25X_BlockErase (0xD8) -#define W25X_SectorErase (0x20) -#define W25X_ChipErase (0xC7) -#define W25X_PowerDown (0xB9) -#define W25X_ReleasePowerDown (0xAB) -#define W25X_DeviceID (0xAB) -#define W25X_ManufactDeviceID (0x90) -#define W25X_JedecDeviceID (0x9F) +#define W25X_WriteEnable (0x06) +#define W25X_WriteDisable (0x04) +#define W25X_ReadStatusReg (0x05) +#define W25X_WriteStatusReg (0x01) +#define W25X_ReadData (0x03) +#define W25X_FastReadData (0x0B) +#define W25X_FastReadDual (0x3B) +#define W25X_PageProgram (0x02) +#define W25X_BlockErase (0xD8) +#define W25X_SectorErase (0x20) +#define W25X_ChipErase (0xC7) +#define W25X_PowerDown (0xB9) +#define W25X_ReleasePowerDown (0xAB) +#define W25X_DeviceID (0xAB) +#define W25X_ManufactDeviceID (0x90) +#define W25X_JedecDeviceID (0x9F) -void SPI_FLASH_Initialize(void); -uint8_t SPI_FLASH_TransferByte(uint8_t uiByte); -uint32_t SPI_FLASH_ReadID(void); -void SPI_FLASH_Erase_Sector(uint32_t uiAddr); -void SPI_FLASH_WriteEnable(void); -void SPI_FLASH_ReadData(uint32_t uiAddr,uint8_t *readBuff,uint32_t numByteToRead); -void SPI_FLASH_WriteData(uint32_t uiAddr,uint8_t *writeBuff,uint32_t numByteToWrite); -void SPI_FLASH_WaitBusy(void); -void SPI_FLASH_EraseChip(void); +void SPI_FLASH_Initialize(void); +uint8_t SPI_FLASH_TransferByte(uint8_t uiByte); +uint32_t SPI_FLASH_ReadID(void); +void SPI_FLASH_Erase_Sector(uint32_t uiAddr); +void SPI_FLASH_WriteEnable(void); +void SPI_FLASH_ReadData(uint32_t uiAddr,uint8_t *readBuff,uint32_t numByteToRead); +void SPI_FLASH_WriteData(uint32_t uiAddr,uint8_t *writeBuff,uint32_t numByteToWrite); +void SPI_FLASH_WaitBusy(void); +void SPI_FLASH_EraseChip(void); #endif diff --git a/Transplant/MiniDevCore/BSP/inc/ssd1306_spi.h b/Transplant/MiniDevCore/BSP/inc/ssd1306_spi.h index 3b8ebff34aeca2aa1dac40b5028bb586c55261f5..db26fb7602dee7001be7d50e0e4a6b1db754ab4f 100644 --- a/Transplant/MiniDevCore/BSP/inc/ssd1306_spi.h +++ b/Transplant/MiniDevCore/BSP/inc/ssd1306_spi.h @@ -2,11 +2,11 @@ #define _INCLUDE_SSD1306_SPI_H_ #include -#define SSD1306_Clear() SSD1306_Fill(0x00) +#define SSD1306_Clear() SSD1306_Fill(0x00) -void SSD1306_WriteData(uint8_t uiData); -void SSD1306_SetPosition(uint8_t uiColumn, uint8_t uiPage); -void SSD1306_Fill(uint8_t uiByte); -void SSD1306_Initialize(void); +void SSD1306_WriteData(uint8_t uiData); +void SSD1306_SetPosition(uint8_t uiColumn, uint8_t uiPage); +void SSD1306_Fill(uint8_t uiByte); +void SSD1306_Initialize(void); #endif diff --git a/Transplant/MiniDevCore/BSP/inc/trigger_flags.h b/Transplant/MiniDevCore/BSP/inc/trigger_flags.h index 7c78c850b6b24f2ed75fa8d8abaf60ba3bb6588e..da3165ecefce6ef8288a91d67db6a636aeac2c27 100644 --- a/Transplant/MiniDevCore/BSP/inc/trigger_flags.h +++ b/Transplant/MiniDevCore/BSP/inc/trigger_flags.h @@ -10,15 +10,15 @@ typedef union { - uint8_t uiByte[2]; - uint16_t uiKeyCode; + uint8_t uiByte[2]; + uint16_t uiKeyCode; }KEY_VALUE; typedef struct { - KEY_VALUE unKeyValue; - __IO bool bIsTriggered; - __IO bool bHalfRev; + KEY_VALUE unKeyValue; + __IO bool bIsTriggered; + __IO bool bHalfRev; }USART_INPUT; diff --git a/Transplant/MiniDevCore/BSP/inc/uc1604c_softspi.h b/Transplant/MiniDevCore/BSP/inc/uc1604c_softspi.h index 82098392f69202ec4f56b451a5e3726b1bf93e01..2136b61b18c08a2b03c6e2f1ea22c0c3c254afdc 100644 --- a/Transplant/MiniDevCore/BSP/inc/uc1604c_softspi.h +++ b/Transplant/MiniDevCore/BSP/inc/uc1604c_softspi.h @@ -5,11 +5,11 @@ ////////////////////////////////////////////////////////////////////////////////// #include -#define COLUMN_MAX 192 -#define PAGE_MAX 8 +#define COLUMN_MAX 192 +#define PAGE_MAX 8 -void UC1604C_Initialize(void); -void UC1604C_SetPosition(uint8_t uiColumn, uint8_t uiPage); -void UC1604C_WriteData(uint8_t uiData); -void UC1604C_Fill(uint8_t bmp_dat); +void UC1604C_Initialize(void); +void UC1604C_SetPosition(uint8_t uiColumn, uint8_t uiPage); +void UC1604C_WriteData(uint8_t uiData); +void UC1604C_Fill(uint8_t bmp_dat); #endif //_INCLUDE_UC1604C_SOFT_SPI_H_ diff --git a/Transplant/MiniDevCore/BSP/inc/usart.h b/Transplant/MiniDevCore/BSP/inc/usart.h index cb39ce17fbabc77fa9fb0e84536aaaced76f6cf4..5e76d1c84c099ce149a8f087e48d28804d3c9a4a 100644 --- a/Transplant/MiniDevCore/BSP/inc/usart.h +++ b/Transplant/MiniDevCore/BSP/inc/usart.h @@ -5,20 +5,20 @@ #include #include "stm32f10x_usart.h" -#define USART_REV_INT_CFG_DECLARE(PORT) void PORT##_ConfigReceiveInterrupt(USART_INT_FP pfCallBack, int iPreemptionPriority, int SubPriority) +#define USART_REV_INT_CFG_DECLARE(PORT) void PORT##_ConfigReceiveInterrupt(USART_INT_FP pfCallBack, int iPreemptionPriority, int SubPriority) typedef enum { - USART_INT_REASON_UNKNOW = 0, - USART_INT_REASON_IDLE, - USART_INT_REASON_REV + USART_INT_REASON_UNKNOW = 0, + USART_INT_REASON_IDLE, + USART_INT_REASON_REV }USART_INT_REASON; typedef void(*USART_INT_FP)(USART_INT_REASON eReason, uint8_t uiReceiveData); -void USART_Initialize(USART_TypeDef* pstUSARTx, uint32_t Baudrate); +void USART_Initialize(USART_TypeDef* pstUSARTx, uint32_t Baudrate); void USART_SendByte(USART_TypeDef* pstUSARTx, uint16_t uiByte); -void USART_ActiveInterrupt(USART_TypeDef* pstUSARTx, bool bEnable); +void USART_ActiveInterrupt(USART_TypeDef* pstUSARTx, bool bEnable); USART_REV_INT_CFG_DECLARE(USART1); USART_REV_INT_CFG_DECLARE(USART2); diff --git a/Transplant/MiniDevCore/BSP/inc/usart_stdio.h b/Transplant/MiniDevCore/BSP/inc/usart_stdio.h index f7b9cf348dcac416201cca5e23e16ca8df8f9bd5..b1c5292553a417da4fa5b2e8eba45e298337356f 100644 --- a/Transplant/MiniDevCore/BSP/inc/usart_stdio.h +++ b/Transplant/MiniDevCore/BSP/inc/usart_stdio.h @@ -4,11 +4,11 @@ #include "stm32f10x_rcc.h" #include "stm32f10x_gpio.h" -struct __FILE -{ - int handle; +struct __FILE +{ + int handle; }; -void USART_Stdio_Initialize(uint32_t Baudrate); +void USART_Stdio_Initialize(uint32_t Baudrate); #endif diff --git a/Transplant/MiniDevCore/BSP/src/base_timer.c b/Transplant/MiniDevCore/BSP/src/base_timer.c index f56a1c964c03161cdaab63270f74d0dfff904d26..fb26077193b8a03d24fd1d36937011d4dba193c8 100644 --- a/Transplant/MiniDevCore/BSP/src/base_timer.c +++ b/Transplant/MiniDevCore/BSP/src/base_timer.c @@ -1,29 +1,29 @@ #include "base_timer.h" -#define TIMER_REV_INT_CBPF_DEFINE(TIMER, INIT) static TIMER_INT_FP TIMER##_INIT_CALLBACK = (INIT) - -#define TIMER_REV_INT_CFG_DEFINE(TIMER) void TIMER##_ConfigReceiveInterrupt(TIMER_INT_FP pfCallBack, int iPreemptionPriority, int SubPriority)\ - {\ - NVIC_InitTypeDef NVIC_InitStructure;\ - NVIC_InitStructure.NVIC_IRQChannel = TIMER##_IRQn;\ - NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=iPreemptionPriority;\ - NVIC_InitStructure.NVIC_IRQChannelSubPriority = SubPriority;\ - NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;\ - NVIC_Init(&NVIC_InitStructure);\ - TIMER##_INIT_CALLBACK = pfCallBack;\ - } - -#define TIMER_REV_INT_SRV_DEFINE(TIMER) void TIMER##_IRQHandler(void)\ - {\ - if (TIM_GetITStatus(TIMER, TIM_IT_Update) != RESET)\ - {\ - TIM_ClearITPendingBit(TIMER, TIM_IT_Update);\ - if(NULL != TIMER##_INIT_CALLBACK)\ - {\ - TIMER##_INIT_CALLBACK();\ - }\ - }\ - } +#define TIMER_REV_INT_CBPF_DEFINE(TIMER, INIT) static TIMER_INT_FP TIMER##_INIT_CALLBACK = (INIT) + +#define TIMER_REV_INT_CFG_DEFINE(TIMER) void TIMER##_ConfigReceiveInterrupt(TIMER_INT_FP pfCallBack, int iPreemptionPriority, int SubPriority)\ + {\ + NVIC_InitTypeDef NVIC_InitStructure;\ + NVIC_InitStructure.NVIC_IRQChannel = TIMER##_IRQn;\ + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=iPreemptionPriority;\ + NVIC_InitStructure.NVIC_IRQChannelSubPriority = SubPriority;\ + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;\ + NVIC_Init(&NVIC_InitStructure);\ + TIMER##_INIT_CALLBACK = pfCallBack;\ + } + +#define TIMER_REV_INT_SRV_DEFINE(TIMER) void TIMER##_IRQHandler(void)\ + {\ + if (TIM_GetITStatus(TIMER, TIM_IT_Update) != RESET)\ + {\ + TIM_ClearITPendingBit(TIMER, TIM_IT_Update);\ + if(NULL != TIMER##_INIT_CALLBACK)\ + {\ + TIMER##_INIT_CALLBACK();\ + }\ + }\ + } TIMER_REV_INT_CBPF_DEFINE(TIM3, NULL); @@ -35,26 +35,26 @@ TIMER_REV_INT_CFG_DEFINE(TIM4); TIMER_REV_INT_SRV_DEFINE(TIM4); void BASE_TIMER_Initialize(TIM_TypeDef* pstTimerBase, uint16_t uiReloadValue, uint16_t uiPrescaler) -{ +{ TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; - /* Configure timer data. */ - TIM_TimeBaseStructure.TIM_Period = uiReloadValue; - TIM_TimeBaseStructure.TIM_Prescaler = uiPrescaler; - TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1; - TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; - TIM_TimeBaseInit(pstTimerBase, &TIM_TimeBaseStructure); + /* Configure timer data. */ + TIM_TimeBaseStructure.TIM_Period = uiReloadValue; + TIM_TimeBaseStructure.TIM_Prescaler = uiPrescaler; + TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1; + TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; + TIM_TimeBaseInit(pstTimerBase, &TIM_TimeBaseStructure); } void BASE_TIMER_ActiveInterrupt(TIM_TypeDef* pstTimerBase, bool bEnable) { - TIM_Cmd(pstTimerBase, DISABLE); - if(true == bEnable) - { - TIM_ITConfig(pstTimerBase,TIM_IT_Update, ENABLE); - } - else - { - TIM_ITConfig(pstTimerBase,TIM_IT_Update, DISABLE); - } - TIM_Cmd(pstTimerBase, ENABLE); + TIM_Cmd(pstTimerBase, DISABLE); + if(true == bEnable) + { + TIM_ITConfig(pstTimerBase,TIM_IT_Update, ENABLE); + } + else + { + TIM_ITConfig(pstTimerBase,TIM_IT_Update, DISABLE); + } + TIM_Cmd(pstTimerBase, ENABLE); } diff --git a/Transplant/MiniDevCore/BSP/src/keyboard.c b/Transplant/MiniDevCore/BSP/src/keyboard.c index 6b404af25cf5e25ec7b1973b57db41dc55dc7c2a..5d649cea88b16f5cc752ed134371f08ebec8e163 100644 --- a/Transplant/MiniDevCore/BSP/src/keyboard.c +++ b/Transplant/MiniDevCore/BSP/src/keyboard.c @@ -1,142 +1,142 @@ #include "keyboard.h" #include -static KB_EVENT_CB_FP KB_CB_FUN = NULL; +static KB_EVENT_CB_FP KB_CB_FUN = NULL; -#define KB_GPIO_APBxClock_FUN RCC_APB2PeriphClockCmd -#define KB_GPIO_CLK RCC_APB2Periph_GPIOB -#define KB_GPIO_PORT GPIOB -#define KB_GPIO_PIN0 GPIO_Pin_9 -#define KB_GPIO_PIN1 GPIO_Pin_8 -#define KB_GPIO_PIN2 GPIO_Pin_7 -#define KB_GPIO_PIN3 GPIO_Pin_6 +#define KB_GPIO_APBxClock_FUN RCC_APB2PeriphClockCmd +#define KB_GPIO_CLK RCC_APB2Periph_GPIOB +#define KB_GPIO_PORT GPIOB +#define KB_GPIO_PIN0 GPIO_Pin_9 +#define KB_GPIO_PIN1 GPIO_Pin_8 +#define KB_GPIO_PIN2 GPIO_Pin_7 +#define KB_GPIO_PIN3 GPIO_Pin_6 -typedef uint16_t GPIO_Pin; +typedef uint16_t GPIO_Pin; typedef struct { - GPIO_Pin uiPin; - KEY_STATE eLastState; + GPIO_Pin uiPin; + KEY_STATE eLastState; }KEY; typedef struct { - uint16_t uiComPin; - KEY pstKeys[3]; + uint16_t uiComPin; + KEY pstKeys[3]; }KEY_IO; -KEY_IO s_arrstKeyIOGroups[4] = +KEY_IO s_arrstKeyIOGroups[4] = { - {KB_GPIO_PIN0, {{KB_GPIO_PIN1, KEY_STATE_UP}, {KB_GPIO_PIN2, KEY_STATE_UP}, {KB_GPIO_PIN3, KEY_STATE_UP}}}, - {KB_GPIO_PIN1, {{KB_GPIO_PIN0, KEY_STATE_UP}, {KB_GPIO_PIN2, KEY_STATE_UP}, {KB_GPIO_PIN3, KEY_STATE_UP}}}, - {KB_GPIO_PIN2, {{KB_GPIO_PIN0, KEY_STATE_UP}, {KB_GPIO_PIN1, KEY_STATE_UP}, {KB_GPIO_PIN3, KEY_STATE_UP}}}, - {KB_GPIO_PIN3, {{KB_GPIO_PIN0, KEY_STATE_UP}, {KB_GPIO_PIN1, KEY_STATE_UP}, {KB_GPIO_PIN2, KEY_STATE_UP}}} + {KB_GPIO_PIN0, {{KB_GPIO_PIN1, KEY_STATE_UP}, {KB_GPIO_PIN2, KEY_STATE_UP}, {KB_GPIO_PIN3, KEY_STATE_UP}}}, + {KB_GPIO_PIN1, {{KB_GPIO_PIN0, KEY_STATE_UP}, {KB_GPIO_PIN2, KEY_STATE_UP}, {KB_GPIO_PIN3, KEY_STATE_UP}}}, + {KB_GPIO_PIN2, {{KB_GPIO_PIN0, KEY_STATE_UP}, {KB_GPIO_PIN1, KEY_STATE_UP}, {KB_GPIO_PIN3, KEY_STATE_UP}}}, + {KB_GPIO_PIN3, {{KB_GPIO_PIN0, KEY_STATE_UP}, {KB_GPIO_PIN1, KEY_STATE_UP}, {KB_GPIO_PIN2, KEY_STATE_UP}}} }; -#define KB_SwitchToInput(PIN) KB_SwitchGPIOMode(PIN, GPIO_Mode_IPU) -#define KB_SwitchToOutput(PIN) KB_SwitchGPIOMode(PIN, GPIO_Mode_Out_PP) -#define KB_PinHigh(PIN) GPIO_SetBits(KB_GPIO_PORT, PIN); -#define KB_PinLow(PIN) GPIO_ResetBits(KB_GPIO_PORT, PIN); +#define KB_SwitchToInput(PIN) KB_SwitchGPIOMode(PIN, GPIO_Mode_IPU) +#define KB_SwitchToOutput(PIN) KB_SwitchGPIOMode(PIN, GPIO_Mode_Out_PP) +#define KB_PinHigh(PIN) GPIO_SetBits(KB_GPIO_PORT, PIN); +#define KB_PinLow(PIN) GPIO_ResetBits(KB_GPIO_PORT, PIN); -static void KB_SwitchGPIOMode(uint16_t uiPin, GPIOMode_TypeDef eNewMode); -static KEY_STATE KB_ReadPin(uint16_t uiPin); +static void KB_SwitchGPIOMode(uint16_t uiPin, GPIOMode_TypeDef eNewMode); +static KEY_STATE KB_ReadPin(uint16_t uiPin); /*****************************************************************************/ -/** Function Name: KB_InitializeGPIO. **/ -/** Purpose: Config and initialize GPIO for key. **/ -/** Params: None. **/ -/** Return: None. **/ +/** Function Name: KB_InitializeGPIO. **/ +/** Purpose: Config and initialize GPIO for key. **/ +/** Params: None. **/ +/** Return: None. **/ /*****************************************************************************/ void KB_Initialize(void) { - GPIO_InitTypeDef GPIO_InitStructure; - // Enable RCC. - KB_GPIO_APBxClock_FUN(KB_GPIO_CLK, ENABLE); - // Loop for initialize each GPIO in array list. - GPIO_InitStructure.GPIO_Pin = KB_GPIO_PIN0|KB_GPIO_PIN1|KB_GPIO_PIN2|KB_GPIO_PIN3; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; - GPIO_Init(KB_GPIO_PORT, &GPIO_InitStructure); + GPIO_InitTypeDef GPIO_InitStructure; + // Enable RCC. + KB_GPIO_APBxClock_FUN(KB_GPIO_CLK, ENABLE); + // Loop for initialize each GPIO in array list. + GPIO_InitStructure.GPIO_Pin = KB_GPIO_PIN0|KB_GPIO_PIN1|KB_GPIO_PIN2|KB_GPIO_PIN3; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; + GPIO_Init(KB_GPIO_PORT, &GPIO_InitStructure); } /*****************************************************************************/ -/** Function Name: KB_SwitchGPIOMode. **/ -/** Purpose: Switch GPIO working mode. **/ -/** Params: None. **/ -/** Return: None. **/ +/** Function Name: KB_SwitchGPIOMode. **/ +/** Purpose: Switch GPIO working mode. **/ +/** Params: None. **/ +/** Return: None. **/ /*****************************************************************************/ void KB_SwitchGPIOMode(uint16_t uiPin, GPIOMode_TypeDef eNewMode) { - GPIO_InitTypeDef GPIO_InitStructure; - // Config GPIO. - GPIO_InitStructure.GPIO_Pin = uiPin; - GPIO_InitStructure.GPIO_Mode = eNewMode; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; - GPIO_Init(KB_GPIO_PORT, &GPIO_InitStructure); + GPIO_InitTypeDef GPIO_InitStructure; + // Config GPIO. + GPIO_InitStructure.GPIO_Pin = uiPin; + GPIO_InitStructure.GPIO_Mode = eNewMode; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; + GPIO_Init(KB_GPIO_PORT, &GPIO_InitStructure); } KEY_STATE KB_ReadPin(uint16_t uiPin) { - return (KEY_STATE)GPIO_ReadInputDataBit(KB_GPIO_PORT, uiPin); + return (KEY_STATE)GPIO_ReadInputDataBit(KB_GPIO_PORT, uiPin); } void KB_Scan(void) { - uint8_t uiRowIdx; - uint8_t uiColumnIdx; - uint8_t uiKeyCode; - KEY_STATE eNowState; - - for(uiRowIdx=0; uiRowIdx<(sizeof(s_arrstKeyIOGroups)/sizeof(KEY_IO)); uiRowIdx++) - { - KB_SwitchToOutput(s_arrstKeyIOGroups[uiRowIdx].uiComPin); - KB_PinLow(s_arrstKeyIOGroups[uiRowIdx].uiComPin); - for(uiColumnIdx=0; uiColumnIdx<3; uiColumnIdx++) - { - eNowState = KB_ReadPin(s_arrstKeyIOGroups[uiRowIdx].pstKeys[uiColumnIdx].uiPin); - uiKeyCode = ((uiRowIdx << 4) & 0xF0) | (uiColumnIdx & 0x0F); - if(s_arrstKeyIOGroups[uiRowIdx].pstKeys[uiColumnIdx].eLastState^eNowState) - { - if(KEY_STATE_DOWN == eNowState) - { - - if(NULL != KB_CB_FUN) - { - KB_CB_FUN(uiKeyCode, KEY_EVENT_DOWN); - } - } - else if(KEY_STATE_UP == eNowState) - { - if(NULL != KB_CB_FUN) - { - KB_CB_FUN(uiKeyCode, KEY_EVENT_UP); - } - } - /* Key state is changed. */ - s_arrstKeyIOGroups[uiRowIdx].pstKeys[uiColumnIdx].eLastState = eNowState; - } - - } - KB_SwitchToInput(s_arrstKeyIOGroups[uiRowIdx].uiComPin); - KB_PinHigh(s_arrstKeyIOGroups[uiRowIdx].uiComPin); - } + uint8_t uiRowIdx; + uint8_t uiColumnIdx; + uint8_t uiKeyCode; + KEY_STATE eNowState; + + for(uiRowIdx=0; uiRowIdx<(sizeof(s_arrstKeyIOGroups)/sizeof(KEY_IO)); uiRowIdx++) + { + KB_SwitchToOutput(s_arrstKeyIOGroups[uiRowIdx].uiComPin); + KB_PinLow(s_arrstKeyIOGroups[uiRowIdx].uiComPin); + for(uiColumnIdx=0; uiColumnIdx<3; uiColumnIdx++) + { + eNowState = KB_ReadPin(s_arrstKeyIOGroups[uiRowIdx].pstKeys[uiColumnIdx].uiPin); + uiKeyCode = ((uiRowIdx << 4) & 0xF0) | (uiColumnIdx & 0x0F); + if(s_arrstKeyIOGroups[uiRowIdx].pstKeys[uiColumnIdx].eLastState^eNowState) + { + if(KEY_STATE_DOWN == eNowState) + { + + if(NULL != KB_CB_FUN) + { + KB_CB_FUN(uiKeyCode, KEY_EVENT_DOWN); + } + } + else if(KEY_STATE_UP == eNowState) + { + if(NULL != KB_CB_FUN) + { + KB_CB_FUN(uiKeyCode, KEY_EVENT_UP); + } + } + /* Key state is changed. */ + s_arrstKeyIOGroups[uiRowIdx].pstKeys[uiColumnIdx].eLastState = eNowState; + } + + } + KB_SwitchToInput(s_arrstKeyIOGroups[uiRowIdx].uiComPin); + KB_PinHigh(s_arrstKeyIOGroups[uiRowIdx].uiComPin); + } } void KB_RegisterEventProc(KB_EVENT_CB_FP fpKBEventCallBackFunc) { - KB_CB_FUN = fpKBEventCallBackFunc; + KB_CB_FUN = fpKBEventCallBackFunc; } KEY_STATE KB_CheckKeyState(uint8_t uiKeyCode) { - uint8_t uiRowIdx; - uint8_t uiColumnIdx; - KEY_STATE eKeyState; - - uiRowIdx = (uiKeyCode>>4); - uiColumnIdx = uiKeyCode & 0x0F; - eKeyState = KB_ReadPin(s_arrstKeyIOGroups[uiRowIdx].pstKeys[uiColumnIdx].uiPin); - - return eKeyState; + uint8_t uiRowIdx; + uint8_t uiColumnIdx; + KEY_STATE eKeyState; + + uiRowIdx = (uiKeyCode>>4); + uiColumnIdx = uiKeyCode & 0x0F; + eKeyState = KB_ReadPin(s_arrstKeyIOGroups[uiRowIdx].pstKeys[uiColumnIdx].uiPin); + + return eKeyState; } diff --git a/Transplant/MiniDevCore/BSP/src/led.c b/Transplant/MiniDevCore/BSP/src/led.c index 229ba6dfc6b7d21e5964ecf685930b39013b8847..2b9ea307a8d430e67f47205e0132d7208512f6e0 100644 --- a/Transplant/MiniDevCore/BSP/src/led.c +++ b/Transplant/MiniDevCore/BSP/src/led.c @@ -1,50 +1,50 @@ #include -#define LED_RCC (RCC_APB2Periph_GPIOC) -#define LED_PORT (GPIOC) -#define LED_PIN (GPIO_Pin_13) +#define LED_RCC (RCC_APB2Periph_GPIOC) +#define LED_PORT (GPIOC) +#define LED_PIN (GPIO_Pin_13) void LED_Initialize(void) { - // Initialize data structure. - GPIO_InitTypeDef GPIO_InitStructure; - // Loop for initialize each GPIO in array list. - // Enable RCC. - RCC_APB2PeriphClockCmd(LED_RCC, ENABLE); - // Enable GPIO. - GPIO_InitStructure.GPIO_Pin = LED_PIN; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; - GPIO_Init(LED_PORT, &GPIO_InitStructure); + // Initialize data structure. + GPIO_InitTypeDef GPIO_InitStructure; + // Loop for initialize each GPIO in array list. + // Enable RCC. + RCC_APB2PeriphClockCmd(LED_RCC, ENABLE); + // Enable GPIO. + GPIO_InitStructure.GPIO_Pin = LED_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; + GPIO_Init(LED_PORT, &GPIO_InitStructure); } void LED_On(void) { - // Set pin low. - GPIO_ResetBits(LED_PORT, LED_PIN); + // Set pin low. + GPIO_ResetBits(LED_PORT, LED_PIN); } void LED_Off(void) { - // Set pin high. - GPIO_SetBits(LED_PORT, LED_PIN); + // Set pin high. + GPIO_SetBits(LED_PORT, LED_PIN); } void LED_Reverse(void) { - // Reverse pin state. - if(1 == LED_GetState()) - { - LED_On(); - } - else - { - LED_Off(); - } + // Reverse pin state. + if(1 == LED_GetState()) + { + LED_On(); + } + else + { + LED_Off(); + } } uint8_t LED_GetState(void) { - // Read pin state. - return GPIO_ReadOutputDataBit(LED_PORT, LED_PIN); + // Read pin state. + return GPIO_ReadOutputDataBit(LED_PORT, LED_PIN); } diff --git a/Transplant/MiniDevCore/BSP/src/rtc.c b/Transplant/MiniDevCore/BSP/src/rtc.c index 35be91c4b00665cf23bb51a51bf58eb34a8feb88..ce300fcee08a16aca3d6dafd64832fd23d74c40a 100644 --- a/Transplant/MiniDevCore/BSP/src/rtc.c +++ b/Transplant/MiniDevCore/BSP/src/rtc.c @@ -4,207 +4,207 @@ #include #include -#define RTC_CONFIG_FLAG (0x5050) -#define FREQUENCY_DIVISION (32767) +#define RTC_CONFIG_FLAG (0x5050) +#define FREQUENCY_DIVISION (32767) #define START_YEAR (1900) static RTC_INT_FP RTC_INIT_CALLBACK = NULL; -RTC_CALENDAR_STRUCT g_stCleandar; +RTC_CALENDAR_STRUCT g_stCleandar; -void RTC_RefreshCalendar(void); -time_t RTC_ConvertToTimestamp(RTC_CALENDAR_STRUCT* pstCalendar); +void RTC_RefreshCalendar(void); +time_t RTC_ConvertToTimestamp(RTC_CALENDAR_STRUCT* pstCalendar); /*****************************************************************************/ -/** Function Name: RTC_ConfigReceiveInterrupt. **/ -/** Purpose: Update date and time to RTC controler. **/ -/** Params: **/ -/** @uiTimeStamp: None. **/ -/** Return: None. **/ -/** Notice: Non-thread-safe function, Please pay attention to deal **/ -/** with multi-thread calls. **/ +/** Function Name: RTC_ConfigReceiveInterrupt. **/ +/** Purpose: Update date and time to RTC controler. **/ +/** Params: **/ +/** @uiTimeStamp: None. **/ +/** Return: None. **/ +/** Notice: Non-thread-safe function, Please pay attention to deal **/ +/** with multi-thread calls. **/ /*****************************************************************************/ void RTC_ConfigReceiveInterrupt(RTC_INT_FP pfCallBack, int iPreemptionPriority, int SubPriority) { - NVIC_InitTypeDef NVIC_InitStructure; - NVIC_InitStructure.NVIC_IRQChannel = RTC_IRQn; - NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = iPreemptionPriority; - NVIC_InitStructure.NVIC_IRQChannelSubPriority = SubPriority; - NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; - NVIC_Init(&NVIC_InitStructure); - RTC_INIT_CALLBACK = pfCallBack; + NVIC_InitTypeDef NVIC_InitStructure; + NVIC_InitStructure.NVIC_IRQChannel = RTC_IRQn; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = iPreemptionPriority; + NVIC_InitStructure.NVIC_IRQChannelSubPriority = SubPriority; + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; + NVIC_Init(&NVIC_InitStructure); + RTC_INIT_CALLBACK = pfCallBack; } /*****************************************************************************/ -/** Function Name: RTC_Initialize. **/ -/** Purpose: Configure RTC controler. **/ -/** Resources: Backup register. **/ -/** Params: None. **/ -/** Return: None. **/ -/** Notice: None. **/ +/** Function Name: RTC_Initialize. **/ +/** Purpose: Configure RTC controler. **/ +/** Resources: Backup register. **/ +/** Params: None. **/ +/** Return: None. **/ +/** Notice: None. **/ /*****************************************************************************/ void RTC_Initialize(void) { - // Read backup register to check if RTC has been configed. - if (BKP_ReadBackupRegister(BKP_DR1) != RTC_CONFIG_FLAG) - { - // Configure RTC for the first time - RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE); - // Enable backup register access. - PWR_BackupAccessCmd(ENABLE); - // Reset backup register access. - BKP_DeInit(); - // Enable low-speed external clock. - RCC_LSEConfig(RCC_LSE_ON); - // Wait for low-speed external clock initialized - while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET) - { - // Add error handling here for LSE initialize failed. - } - RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE); // Set RTC clock source. - RCC_RTCCLKCmd(ENABLE); // Enable RTC clock. - RTC_WaitForLastTask(); // Wait for processing to complete. - RTC_WaitForSynchro(); // Wait for the registers to synchronize. - RTC_ITConfig(RTC_IT_SEC, ENABLE); // Enable RTC interrupt. - RTC_WaitForLastTask(); // Wait for processing to complete. - RTC_EnterConfigMode(); // Enter RTC configuration mode - RTC_SetPrescaler(FREQUENCY_DIVISION); // Set RTC clock division factor. - RTC_WaitForLastTask(); // Wait for processing to complete. - RTC_ExitConfigMode(); // Exit RTC configuration mode - BKP_WriteBackupRegister(BKP_DR1, RTC_CONFIG_FLAG); // Write RTC configuration tag backup register. - } - else - { - RTC_WaitForSynchro(); - RTC_ITConfig(RTC_IT_SEC, ENABLE); - RTC_WaitForLastTask(); - } - RTC_RefreshCalendar(); + // Read backup register to check if RTC has been configed. + if (BKP_ReadBackupRegister(BKP_DR1) != RTC_CONFIG_FLAG) + { + // Configure RTC for the first time + RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE); + // Enable backup register access. + PWR_BackupAccessCmd(ENABLE); + // Reset backup register access. + BKP_DeInit(); + // Enable low-speed external clock. + RCC_LSEConfig(RCC_LSE_ON); + // Wait for low-speed external clock initialized + while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET) + { + // Add error handling here for LSE initialize failed. + } + RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE); // Set RTC clock source. + RCC_RTCCLKCmd(ENABLE); // Enable RTC clock. + RTC_WaitForLastTask(); // Wait for processing to complete. + RTC_WaitForSynchro(); // Wait for the registers to synchronize. + RTC_ITConfig(RTC_IT_SEC, ENABLE); // Enable RTC interrupt. + RTC_WaitForLastTask(); // Wait for processing to complete. + RTC_EnterConfigMode(); // Enter RTC configuration mode + RTC_SetPrescaler(FREQUENCY_DIVISION); // Set RTC clock division factor. + RTC_WaitForLastTask(); // Wait for processing to complete. + RTC_ExitConfigMode(); // Exit RTC configuration mode + BKP_WriteBackupRegister(BKP_DR1, RTC_CONFIG_FLAG); // Write RTC configuration tag backup register. + } + else + { + RTC_WaitForSynchro(); + RTC_ITConfig(RTC_IT_SEC, ENABLE); + RTC_WaitForLastTask(); + } + RTC_RefreshCalendar(); } /*****************************************************************************/ -/** Function Name: RTC_IRQHandler. **/ -/** Purpose: RTC interrupt service function. **/ -/** Resources: NVIC controler. **/ -/** Params: None. **/ -/** Return: None. **/ -/** Notice: None. **/ +/** Function Name: RTC_IRQHandler. **/ +/** Purpose: RTC interrupt service function. **/ +/** Resources: NVIC controler. **/ +/** Params: None. **/ +/** Return: None. **/ +/** Notice: None. **/ /*****************************************************************************/ void RTC_IRQHandler(void) { - // Second interrupt - if (RTC_GetITStatus(RTC_IT_SEC) != RESET) - { - RTC_RefreshCalendar(); // Update time date. - if(NULL != RTC_INIT_CALLBACK) - { - RTC_INIT_CALLBACK(RTC_GetCounter()); - } - } - // Alarm interrupt - if(RTC_GetITStatus(RTC_IT_ALR)!= RESET) - { - // Clear Alarm interrupt tag. - RTC_ClearITPendingBit(RTC_IT_ALR); - } - // Clear interrupt - RTC_ClearITPendingBit(RTC_IT_SEC|RTC_IT_OW); - RTC_WaitForLastTask(); + // Second interrupt + if (RTC_GetITStatus(RTC_IT_SEC) != RESET) + { + RTC_RefreshCalendar(); // Update time date. + if(NULL != RTC_INIT_CALLBACK) + { + RTC_INIT_CALLBACK(RTC_GetCounter()); + } + } + // Alarm interrupt + if(RTC_GetITStatus(RTC_IT_ALR)!= RESET) + { + // Clear Alarm interrupt tag. + RTC_ClearITPendingBit(RTC_IT_ALR); + } + // Clear interrupt + RTC_ClearITPendingBit(RTC_IT_SEC|RTC_IT_OW); + RTC_WaitForLastTask(); } /*****************************************************************************/ -/** Function Name: RTC_ConvertToUnix. **/ -/** Purpose: Convert real time to unix timestamp. **/ -/** Resources: C standard library time.h file. **/ -/** Params: **/ -/** @pstCalendar: Calendar structure pointer. **/ -/** Return: Unix timestamp. **/ -/** Notice: None. **/ +/** Function Name: RTC_ConvertToUnix. **/ +/** Purpose: Convert real time to unix timestamp. **/ +/** Resources: C standard library time.h file. **/ +/** Params: **/ +/** @pstCalendar: Calendar structure pointer. **/ +/** Return: Unix timestamp. **/ +/** Notice: None. **/ /*****************************************************************************/ time_t RTC_ConvertToTimestamp(RTC_CALENDAR_STRUCT* pstCalendar) { - pstCalendar->tm_year -= START_YEAR; - pstCalendar->tm_mon -= 1; - return mktime(pstCalendar); + pstCalendar->tm_year -= START_YEAR; + pstCalendar->tm_mon -= 1; + return mktime(pstCalendar); } /*****************************************************************************/ -/** Function Name: RTC_ConvertToCalendar. **/ -/** Purpose: Refresh date or time from RTC controler. **/ -/** Resources: C standard library time.h file. **/ -/** Params: **/ -/** @uiTimeStamp: Unix timestamp value. **/ -/** Return: Calendar structure pointer. **/ -/** Notice: Non-thread-safe function, Please pay attention to deal **/ -/** with multi-thread calls. **/ +/** Function Name: RTC_ConvertToCalendar. **/ +/** Purpose: Refresh date or time from RTC controler. **/ +/** Resources: C standard library time.h file. **/ +/** Params: **/ +/** @uiTimeStamp: Unix timestamp value. **/ +/** Return: Calendar structure pointer. **/ +/** Notice: Non-thread-safe function, Please pay attention to deal **/ +/** with multi-thread calls. **/ /*****************************************************************************/ RTC_CALENDAR_STRUCT* RTC_ConvertToCalendar(time_t uiTimeStamp) { - RTC_CALENDAR_STRUCT *pstCalendar; - pstCalendar = localtime(&uiTimeStamp); - pstCalendar->tm_year += START_YEAR; - pstCalendar->tm_mon += 1; - return pstCalendar; + RTC_CALENDAR_STRUCT *pstCalendar; + pstCalendar = localtime(&uiTimeStamp); + pstCalendar->tm_year += START_YEAR; + pstCalendar->tm_mon += 1; + return pstCalendar; } /*****************************************************************************/ -/** Function Name: RTC_RefreshCalendar. **/ -/** Purpose: Refresh date and time from RTC controler. **/ -/** Resources: C standard library time.h file. **/ -/** Params: **/ -/** @uiTimeStamp: None. **/ -/** Return: None. **/ -/** Notice: Non-thread-safe function, Please pay attention to deal **/ -/** with multi-thread calls. **/ +/** Function Name: RTC_RefreshCalendar. **/ +/** Purpose: Refresh date and time from RTC controler. **/ +/** Resources: C standard library time.h file. **/ +/** Params: **/ +/** @uiTimeStamp: None. **/ +/** Return: None. **/ +/** Notice: Non-thread-safe function, Please pay attention to deal **/ +/** with multi-thread calls. **/ /*****************************************************************************/ void RTC_RefreshCalendar(void) { - time_t uiTimestamp; - // Get RTC timestamp value. - uiTimestamp = RTC_GetCounter(); - // Convert RTC timestamp value to calendar. - memcpy(&g_stCleandar, RTC_ConvertToCalendar(uiTimestamp), sizeof(g_stCleandar)); + time_t uiTimestamp; + // Get RTC timestamp value. + uiTimestamp = RTC_GetCounter(); + // Convert RTC timestamp value to calendar. + memcpy(&g_stCleandar, RTC_ConvertToCalendar(uiTimestamp), sizeof(g_stCleandar)); } /*****************************************************************************/ -/** Function Name: RTC_UpdateCalendar. **/ -/** Purpose: Update date and time to RTC controler. **/ -/** Resources: C standard library time.h file. **/ -/** Params: **/ -/** @uiTimeStamp: None. **/ -/** Return: None. **/ -/** Notice: Non-thread-safe function, Please pay attention to deal **/ -/** with multi-thread calls. **/ +/** Function Name: RTC_UpdateCalendar. **/ +/** Purpose: Update date and time to RTC controler. **/ +/** Resources: C standard library time.h file. **/ +/** Params: **/ +/** @uiTimeStamp: None. **/ +/** Return: None. **/ +/** Notice: Non-thread-safe function, Please pay attention to deal **/ +/** with multi-thread calls. **/ /*****************************************************************************/ void RTC_UpdateCalendar(RTC_CALENDAR_STRUCT *pstCalendar) { - time_t uiTimestamp; - // Convert calendar data to timestamp. - uiTimestamp = RTC_ConvertToTimestamp(pstCalendar); - // Enable backup register access. - RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE); - PWR_BackupAccessCmd(ENABLE); - RTC_SetCounter(uiTimestamp); - RTC_WaitForLastTask(); + time_t uiTimestamp; + // Convert calendar data to timestamp. + uiTimestamp = RTC_ConvertToTimestamp(pstCalendar); + // Enable backup register access. + RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE); + PWR_BackupAccessCmd(ENABLE); + RTC_SetCounter(uiTimestamp); + RTC_WaitForLastTask(); } /*****************************************************************************/ -/** Function Name: RTC_GetTimeStamp. **/ -/** Purpose: Update date and time to RTC controler. **/ -/** Params: **/ -/** @uiTimeStamp: None. **/ -/** Return: None. **/ -/** Notice: Non-thread-safe function, Please pay attention to deal **/ -/** with multi-thread calls. **/ +/** Function Name: RTC_GetTimeStamp. **/ +/** Purpose: Update date and time to RTC controler. **/ +/** Params: **/ +/** @uiTimeStamp: None. **/ +/** Return: None. **/ +/** Notice: Non-thread-safe function, Please pay attention to deal **/ +/** with multi-thread calls. **/ /*****************************************************************************/ uint32_t RTC_GetTimeStamp(void) { time_t uiTimestamp; - // Get RTC timestamp value. - uiTimestamp = RTC_GetCounter(); + // Get RTC timestamp value. + uiTimestamp = RTC_GetCounter(); - return uiTimestamp; + return uiTimestamp; } diff --git a/Transplant/MiniDevCore/BSP/src/screen.c b/Transplant/MiniDevCore/BSP/src/screen.c index 488f4741bbcf3849c4e8bf89e9afca5445508628..d19fd021a254ec454f910b40406aac6da2b8d5b3 100644 --- a/Transplant/MiniDevCore/BSP/src/screen.c +++ b/Transplant/MiniDevCore/BSP/src/screen.c @@ -3,198 +3,198 @@ static struct { - struct - { - uint16_t uiStartPageIndex; - uint16_t uiStartColumnIndex; - uint16_t uiEndPageIndex; - uint16_t uiEndColumnIndex; - }stUpdateArea; - uint16_t auiDisplayCache[LCD_SIZE_WIDTH][LCD_SIZE_PAGES]; + struct + { + uint16_t uiStartPageIndex; + uint16_t uiStartColumnIndex; + uint16_t uiEndPageIndex; + uint16_t uiEndColumnIndex; + }stUpdateArea; + uint16_t auiDisplayCache[LCD_SIZE_WIDTH][LCD_SIZE_PAGES]; }s_stLCDBuffer; static void SCREEN_UpdateChangedBufferAreaRecord(uint8_t uiPageIndex, uint8_t uiColumnIndex); static void SCREEN_ClearDisplayBuffer(void); /*************************************************************************/ -/** Function Name: SCREEN_UpdateChangedBufferAreaRecord **/ -/** Purpose: Check changed area recodr and update. **/ -/** Resources: None. **/ -/** Params: **/ -/** @ uiPageIndex: Operated page index. **/ -/** @ uiColumnIndex: Operated column index. **/ -/** Return: None. **/ -/** Limitation: None. **/ +/** Function Name: SCREEN_UpdateChangedBufferAreaRecord **/ +/** Purpose: Check changed area recodr and update. **/ +/** Resources: None. **/ +/** Params: **/ +/** @ uiPageIndex: Operated page index. **/ +/** @ uiColumnIndex: Operated column index. **/ +/** Return: None. **/ +/** Limitation: None. **/ /*************************************************************************/ void SCREEN_UpdateChangedBufferAreaRecord(uint8_t uiPageIndex, uint8_t uiColumnIndex) { - // Check and set page and column index. - if(uiPageIndex < s_stLCDBuffer.stUpdateArea.uiStartPageIndex) - { - s_stLCDBuffer.stUpdateArea.uiStartPageIndex = uiPageIndex; - } - if(uiPageIndex > s_stLCDBuffer.stUpdateArea.uiEndPageIndex) - { - s_stLCDBuffer.stUpdateArea.uiEndPageIndex = uiPageIndex; - } - if(uiColumnIndex < s_stLCDBuffer.stUpdateArea.uiStartColumnIndex) - { - s_stLCDBuffer.stUpdateArea.uiStartColumnIndex = uiColumnIndex; - } - if(uiColumnIndex > s_stLCDBuffer.stUpdateArea.uiEndColumnIndex) - { - s_stLCDBuffer.stUpdateArea.uiEndColumnIndex = uiColumnIndex; - } + // Check and set page and column index. + if(uiPageIndex < s_stLCDBuffer.stUpdateArea.uiStartPageIndex) + { + s_stLCDBuffer.stUpdateArea.uiStartPageIndex = uiPageIndex; + } + if(uiPageIndex > s_stLCDBuffer.stUpdateArea.uiEndPageIndex) + { + s_stLCDBuffer.stUpdateArea.uiEndPageIndex = uiPageIndex; + } + if(uiColumnIndex < s_stLCDBuffer.stUpdateArea.uiStartColumnIndex) + { + s_stLCDBuffer.stUpdateArea.uiStartColumnIndex = uiColumnIndex; + } + if(uiColumnIndex > s_stLCDBuffer.stUpdateArea.uiEndColumnIndex) + { + s_stLCDBuffer.stUpdateArea.uiEndColumnIndex = uiColumnIndex; + } } /*************************************************************************/ -/** Function Name: LCD_ClearDisplayBuffer **/ -/** Purpose: Clean display buffer. **/ -/** Resources: None. **/ -/** Params: None. **/ -/** Return: None. **/ -/** Limitation: None. **/ +/** Function Name: LCD_ClearDisplayBuffer **/ +/** Purpose: Clean display buffer. **/ +/** Resources: None. **/ +/** Params: None. **/ +/** Return: None. **/ +/** Limitation: None. **/ /*************************************************************************/ void SCREEN_ClearDisplayBuffer(void) { - uint16_t uiCurrentPageIndex, uiCurrentColumnIndex; + uint16_t uiCurrentPageIndex, uiCurrentColumnIndex; - for(uiCurrentPageIndex = 0; uiCurrentPageIndex < LCD_SIZE_PAGES; uiCurrentPageIndex++) - { - for(uiCurrentColumnIndex = 0; uiCurrentColumnIndex < LCD_SIZE_WIDTH; uiCurrentColumnIndex++) - { - s_stLCDBuffer.auiDisplayCache[uiCurrentColumnIndex][uiCurrentPageIndex] = 0x00; - } - } - s_stLCDBuffer.stUpdateArea.uiStartPageIndex = (LCD_SIZE_HEIGHT/8) - 1; - s_stLCDBuffer.stUpdateArea.uiEndPageIndex = 0; - s_stLCDBuffer.stUpdateArea.uiStartColumnIndex = LCD_SIZE_WIDTH - 1; - s_stLCDBuffer.stUpdateArea.uiEndColumnIndex = 0; + for(uiCurrentPageIndex = 0; uiCurrentPageIndex < LCD_SIZE_PAGES; uiCurrentPageIndex++) + { + for(uiCurrentColumnIndex = 0; uiCurrentColumnIndex < LCD_SIZE_WIDTH; uiCurrentColumnIndex++) + { + s_stLCDBuffer.auiDisplayCache[uiCurrentColumnIndex][uiCurrentPageIndex] = 0x00; + } + } + s_stLCDBuffer.stUpdateArea.uiStartPageIndex = (LCD_SIZE_HEIGHT/8) - 1; + s_stLCDBuffer.stUpdateArea.uiEndPageIndex = 0; + s_stLCDBuffer.stUpdateArea.uiStartColumnIndex = LCD_SIZE_WIDTH - 1; + s_stLCDBuffer.stUpdateArea.uiEndColumnIndex = 0; } /*************************************************************************/ -/** Function Name: SCREEN_SetPixel **/ -/** Purpose: Set a pixel color or draw a point. **/ -/** Resources: None. **/ -/** Params: **/ -/** @ iPosX: X location of point by pixels. **/ -/** @ iPosY: Y location of point by pixels. **/ -/** @ iColor: Point color, 0 is white, Nonzero is Black. **/ -/** Return: None. **/ -/** Limitation: None. **/ +/** Function Name: SCREEN_SetPixel **/ +/** Purpose: Set a pixel color or draw a point. **/ +/** Resources: None. **/ +/** Params: **/ +/** @ iPosX: X location of point by pixels. **/ +/** @ iPosY: Y location of point by pixels. **/ +/** @ iColor: Point color, 0 is white, Nonzero is Black. **/ +/** Return: None. **/ +/** Limitation: None. **/ /*************************************************************************/ void SCREEN_SetPixel(int iPosX, int iPosY, int iColor) { - // Operating position check. - if((iPosX < LCD_SIZE_WIDTH) && (iPosY < LCD_SIZE_HEIGHT)) - { - // Check and set page and column index. - SCREEN_UpdateChangedBufferAreaRecord(iPosY/8, iPosX); - // Set point data. - if(SCREEN_COLOR_FRG == iColor) - { - SET_PAGE_BIT(s_stLCDBuffer.auiDisplayCache[iPosX][iPosY/8], iPosY%8); - } - else - { - CLR_PAGE_BIT(s_stLCDBuffer.auiDisplayCache[iPosX][iPosY/8], iPosY%8); - } - } + // Operating position check. + if((iPosX < LCD_SIZE_WIDTH) && (iPosY < LCD_SIZE_HEIGHT)) + { + // Check and set page and column index. + SCREEN_UpdateChangedBufferAreaRecord(iPosY/8, iPosX); + // Set point data. + if(SCREEN_COLOR_FRG == iColor) + { + SET_PAGE_BIT(s_stLCDBuffer.auiDisplayCache[iPosX][iPosY/8], iPosY%8); + } + else + { + CLR_PAGE_BIT(s_stLCDBuffer.auiDisplayCache[iPosX][iPosY/8], iPosY%8); + } + } } /*************************************************************************/ -/** Function Name: SCREEN_GetPixel **/ -/** Purpose: Get a pixel from buffer. **/ -/** Resources: None. **/ -/** Params: **/ -/** @ iPosX: X location of point by pixels. **/ -/** @ iPosY: Y location of point by pixels. **/ -/** Return: None. **/ -/** Limitation: None. **/ +/** Function Name: SCREEN_GetPixel **/ +/** Purpose: Get a pixel from buffer. **/ +/** Resources: None. **/ +/** Params: **/ +/** @ iPosX: X location of point by pixels. **/ +/** @ iPosY: Y location of point by pixels. **/ +/** Return: None. **/ +/** Limitation: None. **/ /*************************************************************************/ int SCREEN_GetPixel(int iPosX, int iPosY) { - // Operating position check. - if((iPosX < LCD_SIZE_WIDTH) && (iPosY < LCD_SIZE_HEIGHT)) - { - return GET_PAGE_BIT(s_stLCDBuffer.auiDisplayCache[iPosX][iPosY/8], iPosY%8); - } - else - { - return 0; - } + // Operating position check. + if((iPosX < LCD_SIZE_WIDTH) && (iPosY < LCD_SIZE_HEIGHT)) + { + return GET_PAGE_BIT(s_stLCDBuffer.auiDisplayCache[iPosX][iPosY/8], iPosY%8); + } + else + { + return 0; + } } /*************************************************************************/ -/** Function Name: SCREEN_Initialize **/ -/** Purpose: Simple delay function for KS0108 controler. **/ -/** Resources: None. **/ -/** Params: None. **/ -/** Return: None. **/ -/** Limitation: None. **/ +/** Function Name: SCREEN_Initialize **/ +/** Purpose: Simple delay function for KS0108 controler. **/ +/** Resources: None. **/ +/** Params: None. **/ +/** Return: None. **/ +/** Limitation: None. **/ /*************************************************************************/ int SCREEN_Initialize(void) { - SSD1306_Initialize(); - SCREEN_ClearDisplayBuffer(); - - return 0; + SSD1306_Initialize(); + SCREEN_ClearDisplayBuffer(); + + return 0; } /*************************************************************************/ -/** Function Name: LCD_RefreshScreen **/ -/** Purpose: Update Screen with cache data. **/ -/** Resources: None. **/ -/** Params: None. **/ -/** Return: None. **/ -/** Limitation: None. **/ +/** Function Name: LCD_RefreshScreen **/ +/** Purpose: Update Screen with cache data. **/ +/** Resources: None. **/ +/** Params: None. **/ +/** Return: None. **/ +/** Limitation: None. **/ /*************************************************************************/ void SCREEN_RefreshScreen(void) { - uint8_t uiChangedPageIndex, uiChangedColumnIndex; + uint8_t uiChangedPageIndex, uiChangedColumnIndex; - if(s_stLCDBuffer.stUpdateArea.uiEndColumnIndex > LCD_SIZE_WIDTH-1) - { - s_stLCDBuffer.stUpdateArea.uiEndColumnIndex = LCD_SIZE_WIDTH-1; - } - if(s_stLCDBuffer.stUpdateArea.uiEndPageIndex > (LCD_SIZE_HEIGHT/8)-1) - { - s_stLCDBuffer.stUpdateArea.uiEndPageIndex = (LCD_SIZE_HEIGHT/8)-1; - } - uiChangedPageIndex = s_stLCDBuffer.stUpdateArea.uiStartPageIndex; - // Loop for each changed page. - while(uiChangedPageIndex <= s_stLCDBuffer.stUpdateArea.uiEndPageIndex) - { - uiChangedColumnIndex = s_stLCDBuffer.stUpdateArea.uiStartColumnIndex; - SSD1306_SetPosition(s_stLCDBuffer.stUpdateArea.uiStartColumnIndex, uiChangedPageIndex); - // Loop for each changed column data in current page. - while(uiChangedColumnIndex <= s_stLCDBuffer.stUpdateArea.uiEndColumnIndex) - { - // Write data to screen controler. - SSD1306_WriteData(s_stLCDBuffer.auiDisplayCache[uiChangedColumnIndex][uiChangedPageIndex]); - uiChangedColumnIndex++; - } - uiChangedPageIndex++; - } + if(s_stLCDBuffer.stUpdateArea.uiEndColumnIndex > LCD_SIZE_WIDTH-1) + { + s_stLCDBuffer.stUpdateArea.uiEndColumnIndex = LCD_SIZE_WIDTH-1; + } + if(s_stLCDBuffer.stUpdateArea.uiEndPageIndex > (LCD_SIZE_HEIGHT/8)-1) + { + s_stLCDBuffer.stUpdateArea.uiEndPageIndex = (LCD_SIZE_HEIGHT/8)-1; + } + uiChangedPageIndex = s_stLCDBuffer.stUpdateArea.uiStartPageIndex; + // Loop for each changed page. + while(uiChangedPageIndex <= s_stLCDBuffer.stUpdateArea.uiEndPageIndex) + { + uiChangedColumnIndex = s_stLCDBuffer.stUpdateArea.uiStartColumnIndex; + SSD1306_SetPosition(s_stLCDBuffer.stUpdateArea.uiStartColumnIndex, uiChangedPageIndex); + // Loop for each changed column data in current page. + while(uiChangedColumnIndex <= s_stLCDBuffer.stUpdateArea.uiEndColumnIndex) + { + // Write data to screen controler. + SSD1306_WriteData(s_stLCDBuffer.auiDisplayCache[uiChangedColumnIndex][uiChangedPageIndex]); + uiChangedColumnIndex++; + } + uiChangedPageIndex++; + } - // Reset global variable. - s_stLCDBuffer.stUpdateArea.uiStartPageIndex = (LCD_SIZE_HEIGHT/8) - 1; - s_stLCDBuffer.stUpdateArea.uiEndPageIndex = 0; - s_stLCDBuffer.stUpdateArea.uiStartColumnIndex = LCD_SIZE_WIDTH - 1; - s_stLCDBuffer.stUpdateArea.uiEndColumnIndex = 0; + // Reset global variable. + s_stLCDBuffer.stUpdateArea.uiStartPageIndex = (LCD_SIZE_HEIGHT/8) - 1; + s_stLCDBuffer.stUpdateArea.uiEndPageIndex = 0; + s_stLCDBuffer.stUpdateArea.uiStartColumnIndex = LCD_SIZE_WIDTH - 1; + s_stLCDBuffer.stUpdateArea.uiEndColumnIndex = 0; } /*************************************************************************/ -/** Function Name: SCREEN_ClearDisplay **/ -/** Purpose: Clean display buffer. **/ -/** Resources: None. **/ -/** Params: None. **/ -/** Return: None. **/ -/** Limitation: None. **/ +/** Function Name: SCREEN_ClearDisplay **/ +/** Purpose: Clean display buffer. **/ +/** Resources: None. **/ +/** Params: None. **/ +/** Return: None. **/ +/** Limitation: None. **/ /*************************************************************************/ void SCREEN_ClearDisplay(void) { - SCREEN_ClearDisplayBuffer(); - SSD1306_Fill(0x00); + SCREEN_ClearDisplayBuffer(); + SSD1306_Fill(0x00); } diff --git a/Transplant/MiniDevCore/BSP/src/spi_flash.c b/Transplant/MiniDevCore/BSP/src/spi_flash.c index 1056c823eaaeef10038a15d8de19e13a7da3b925..35e800f7a08cab5d82e2a9dede3f9272ce63968d 100644 --- a/Transplant/MiniDevCore/BSP/src/spi_flash.c +++ b/Transplant/MiniDevCore/BSP/src/spi_flash.c @@ -1,92 +1,92 @@ #include #include -#define SPI_FLASHx SPI1 -#define SPI_FLASH_APBxClock_FUN RCC_APB2PeriphClockCmd -#define SPI_FLASH_CLK RCC_APB2Periph_SPI1 +#define SPI_FLASHx SPI1 +#define SPI_FLASH_APBxClock_FUN RCC_APB2PeriphClockCmd +#define SPI_FLASH_CLK RCC_APB2Periph_SPI1 //GPIO -#define SPI_FLASH_GPIO_APBxClock_FUN RCC_APB2PeriphClockCmd -#define SPI_FLASH_GPIO_CLK RCC_APB2Periph_GPIOA -#define SPI_FLASH_GPIO_PORT GPIOA +#define SPI_FLASH_GPIO_APBxClock_FUN RCC_APB2PeriphClockCmd +#define SPI_FLASH_GPIO_CLK RCC_APB2Periph_GPIOA +#define SPI_FLASH_GPIO_PORT GPIOA //CS(NSS) -#define SPI_FLASH_CS_PIN GPIO_Pin_4 +#define SPI_FLASH_CS_PIN GPIO_Pin_4 //SCK -#define SPI_FLASH_SCK_PIN GPIO_Pin_5 +#define SPI_FLASH_SCK_PIN GPIO_Pin_5 //MISO -#define SPI_FLASH_MISO_PIN GPIO_Pin_6 +#define SPI_FLASH_MISO_PIN GPIO_Pin_6 //MOSI -#define SPI_FLASH_MOSI_PIN GPIO_Pin_7 +#define SPI_FLASH_MOSI_PIN GPIO_Pin_7 -#define SPI_FLASH_CS_LOW() GPIO_ResetBits(SPI_FLASH_GPIO_PORT, SPI_FLASH_CS_PIN) -#define SPI_FLASH_CS_HIGH() GPIO_SetBits(SPI_FLASH_GPIO_PORT, SPI_FLASH_CS_PIN) +#define SPI_FLASH_CS_LOW() GPIO_ResetBits(SPI_FLASH_GPIO_PORT, SPI_FLASH_CS_PIN) +#define SPI_FLASH_CS_HIGH() GPIO_SetBits(SPI_FLASH_GPIO_PORT, SPI_FLASH_CS_PIN) -#define SPI_FLASH_DUMMY_BYTE (0xFF) -#define SPIT_FLAG_TIMEOUT ((uint32_t)0x1000) -#define SPIT_LONG_TIMEOUT ((uint32_t)(10 * SPIT_FLAG_TIMEOUT)) +#define SPI_FLASH_DUMMY_BYTE (0xFF) +#define SPIT_FLAG_TIMEOUT ((uint32_t)0x1000) +#define SPIT_LONG_TIMEOUT ((uint32_t)(10 * SPIT_FLAG_TIMEOUT)) -static __IO uint32_t SPITimeout = SPIT_LONG_TIMEOUT; +static __IO uint32_t SPITimeout = SPIT_LONG_TIMEOUT; static uint32_t SPI_TIMEOUT_UserCallback(uint8_t errorCode); -#define FLASH_INFO(fmt,arg...) printf("<<-FLASH-INFO->> "fmt"\n",##arg) -#define FLASH_ERROR(fmt,arg...) printf("<<-FLASH-ERROR->> "fmt"\n",##arg) +#define FLASH_INFO(fmt,arg...) printf("<<-FLASH-INFO->> "fmt"\n",##arg) +#define FLASH_ERROR(fmt,arg...) printf("<<-FLASH-ERROR->> "fmt"\n",##arg) + - void SPI_FLASH_Initialize(void) { - SPI_InitTypeDef SPI_InitStructure; - GPIO_InitTypeDef GPIO_InitStructure; - - SPI_FLASH_APBxClock_FUN(SPI_FLASH_CLK, ENABLE); - SPI_FLASH_GPIO_APBxClock_FUN(SPI_FLASH_GPIO_CLK, ENABLE); - - GPIO_InitStructure.GPIO_Pin = SPI_FLASH_CS_PIN; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; - GPIO_Init(SPI_FLASH_GPIO_PORT, &GPIO_InitStructure); - - GPIO_InitStructure.GPIO_Pin = SPI_FLASH_SCK_PIN|SPI_FLASH_MISO_PIN|SPI_FLASH_MOSI_PIN; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; - GPIO_Init(SPI_FLASH_GPIO_PORT, &GPIO_InitStructure); - - SPI_FLASH_CS_HIGH(); - - SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; - SPI_InitStructure.SPI_Mode = SPI_Mode_Master; - SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; - SPI_InitStructure.SPI_CPOL = SPI_CPOL_High; - SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge; - SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; - SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_4; - SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; - SPI_InitStructure.SPI_CRCPolynomial = 7; - SPI_Init(SPI_FLASHx, &SPI_InitStructure); - - SPI_Cmd(SPI_FLASHx, ENABLE); + SPI_InitTypeDef SPI_InitStructure; + GPIO_InitTypeDef GPIO_InitStructure; + + SPI_FLASH_APBxClock_FUN(SPI_FLASH_CLK, ENABLE); + SPI_FLASH_GPIO_APBxClock_FUN(SPI_FLASH_GPIO_CLK, ENABLE); + + GPIO_InitStructure.GPIO_Pin = SPI_FLASH_CS_PIN; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; + GPIO_Init(SPI_FLASH_GPIO_PORT, &GPIO_InitStructure); + + GPIO_InitStructure.GPIO_Pin = SPI_FLASH_SCK_PIN|SPI_FLASH_MISO_PIN|SPI_FLASH_MOSI_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; + GPIO_Init(SPI_FLASH_GPIO_PORT, &GPIO_InitStructure); + + SPI_FLASH_CS_HIGH(); + + SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; + SPI_InitStructure.SPI_Mode = SPI_Mode_Master; + SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; + SPI_InitStructure.SPI_CPOL = SPI_CPOL_High; + SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge; + SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; + SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_4; + SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; + SPI_InitStructure.SPI_CRCPolynomial = 7; + SPI_Init(SPI_FLASHx, &SPI_InitStructure); + + SPI_Cmd(SPI_FLASHx, ENABLE); } uint8_t SPI_FLASH_TransferByte(uint8_t uiByte) { - SPITimeout = SPIT_FLAG_TIMEOUT; - - while (SPI_I2S_GetFlagStatus(SPI_FLASHx, SPI_I2S_FLAG_TXE) == RESET) - { - if ((SPITimeout--) == 0) - { - return SPI_TIMEOUT_UserCallback(0); - } - } - SPI_I2S_SendData(SPI_FLASHx, uiByte); - SPITimeout = SPIT_FLAG_TIMEOUT; - - while (SPI_I2S_GetFlagStatus(SPI_FLASHx, SPI_I2S_FLAG_RXNE) == RESET) - { - if ((SPITimeout--) == 0) - { - return SPI_TIMEOUT_UserCallback(1); - } - } - - return SPI_I2S_ReceiveData(SPI_FLASHx); + SPITimeout = SPIT_FLAG_TIMEOUT; + + while (SPI_I2S_GetFlagStatus(SPI_FLASHx, SPI_I2S_FLAG_TXE) == RESET) + { + if ((SPITimeout--) == 0) + { + return SPI_TIMEOUT_UserCallback(0); + } + } + SPI_I2S_SendData(SPI_FLASHx, uiByte); + SPITimeout = SPIT_FLAG_TIMEOUT; + + while (SPI_I2S_GetFlagStatus(SPI_FLASHx, SPI_I2S_FLAG_RXNE) == RESET) + { + if ((SPITimeout--) == 0) + { + return SPI_TIMEOUT_UserCallback(1); + } + } + + return SPI_I2S_ReceiveData(SPI_FLASHx); } uint32_t SPI_FLASH_ReadID(void) @@ -97,22 +97,22 @@ uint32_t SPI_FLASH_ReadID(void) (void)SPI_FLASH_TransferByte(W25X_JedecDeviceID); uiID = SPI_FLASH_TransferByte(SPI_FLASH_DUMMY_BYTE); uiID <<= 8; - uiID |= SPI_FLASH_TransferByte(SPI_FLASH_DUMMY_BYTE); + uiID |= SPI_FLASH_TransferByte(SPI_FLASH_DUMMY_BYTE); uiID <<= 8; - uiID |= SPI_FLASH_TransferByte(SPI_FLASH_DUMMY_BYTE); - SPI_FLASH_CS_HIGH(); + uiID |= SPI_FLASH_TransferByte(SPI_FLASH_DUMMY_BYTE); + SPI_FLASH_CS_HIGH(); return uiID; } void SPI_FLASH_Erase_Sector(uint32_t uiAddr) -{ +{ SPI_FLASH_WriteEnable(); SPI_FLASH_CS_LOW(); (void)SPI_FLASH_TransferByte(W25X_SectorErase); SPI_FLASH_TransferByte((uiAddr>>16)&0xff); - SPI_FLASH_TransferByte((uiAddr>>8)&0xff); - SPI_FLASH_TransferByte(uiAddr&0xff); - SPI_FLASH_CS_HIGH(); + SPI_FLASH_TransferByte((uiAddr>>8)&0xff); + SPI_FLASH_TransferByte(uiAddr&0xff); + SPI_FLASH_CS_HIGH(); SPI_FLASH_WaitBusy(); } @@ -123,18 +123,18 @@ void SPI_FLASH_WaitBusy(void) SPI_FLASH_CS_LOW(); (void)SPI_FLASH_TransferByte(W25X_ReadStatusReg); do - { - uiStatusReg = SPI_FLASH_TransferByte(SPI_FLASH_DUMMY_BYTE); + { + uiStatusReg = SPI_FLASH_TransferByte(SPI_FLASH_DUMMY_BYTE); } while((uiStatusReg & 0x01) == 1); - SPI_FLASH_CS_HIGH(); + SPI_FLASH_CS_HIGH(); } void SPI_FLASH_WriteEnable(void) { SPI_FLASH_CS_LOW(); - (void)SPI_FLASH_TransferByte(W25X_WriteEnable); - SPI_FLASH_CS_HIGH(); + (void)SPI_FLASH_TransferByte(W25X_WriteEnable); + SPI_FLASH_CS_HIGH(); } void SPI_FLASH_ReadData(uint32_t uiAddr,uint8_t *readBuff,uint32_t numByteToRead) @@ -142,15 +142,15 @@ void SPI_FLASH_ReadData(uint32_t uiAddr,uint8_t *readBuff,uint32_t numByteToRead SPI_FLASH_CS_LOW(); (void)SPI_FLASH_TransferByte(W25X_ReadData); (void)SPI_FLASH_TransferByte((uiAddr>>16)&0xff); - (void)SPI_FLASH_TransferByte((uiAddr>>8)&0xff); - (void)SPI_FLASH_TransferByte(uiAddr&0xff); + (void)SPI_FLASH_TransferByte((uiAddr>>8)&0xff); + (void)SPI_FLASH_TransferByte(uiAddr&0xff); while(numByteToRead--) - { + { *readBuff = SPI_FLASH_TransferByte(SPI_FLASH_DUMMY_BYTE); readBuff++; } - SPI_FLASH_CS_HIGH(); + SPI_FLASH_CS_HIGH(); } void SPI_FLASH_WriteData(uint32_t uiAddr,uint8_t *writeBuff,uint32_t numByteToWrite) @@ -159,14 +159,14 @@ void SPI_FLASH_WriteData(uint32_t uiAddr,uint8_t *writeBuff,uint32_t numByteToWr SPI_FLASH_CS_LOW(); (void)SPI_FLASH_TransferByte(W25X_PageProgram); (void)SPI_FLASH_TransferByte((uiAddr>>16)&0xff); - (void)SPI_FLASH_TransferByte((uiAddr>>8)&0xff); - (void)SPI_FLASH_TransferByte(uiAddr&0xff); + (void)SPI_FLASH_TransferByte((uiAddr>>8)&0xff); + (void)SPI_FLASH_TransferByte(uiAddr&0xff); while(numByteToWrite--) - { + { (void)SPI_FLASH_TransferByte(*writeBuff); writeBuff++; } - SPI_FLASH_CS_HIGH(); + SPI_FLASH_CS_HIGH(); SPI_FLASH_WaitBusy(); } @@ -177,23 +177,23 @@ static uint32_t SPI_TIMEOUT_UserCallback(uint8_t errorCode) return 0; } -uint8_t SPI_FLASH_ReadStatusReg(void) -{ - uint8_t uiStatusRegVal = 0; - SPI_FLASH_CS_LOW(); - (void)SPI_FLASH_TransferByte(W25X_ReadStatusReg); - uiStatusRegVal = SPI_FLASH_TransferByte(SPI_FLASH_DUMMY_BYTE); - SPI_FLASH_CS_HIGH(); - return uiStatusRegVal; -} - -void SPI_FLASH_EraseChip(void) -{ +uint8_t SPI_FLASH_ReadStatusReg(void) +{ + uint8_t uiStatusRegVal = 0; + SPI_FLASH_CS_LOW(); + (void)SPI_FLASH_TransferByte(W25X_ReadStatusReg); + uiStatusRegVal = SPI_FLASH_TransferByte(SPI_FLASH_DUMMY_BYTE); + SPI_FLASH_CS_HIGH(); + return uiStatusRegVal; +} + +void SPI_FLASH_EraseChip(void) +{ SPI_FLASH_WriteEnable(); - SPI_FLASH_WaitBusy(); - SPI_FLASH_CS_LOW(); - (void)SPI_FLASH_TransferByte(W25X_ChipErase); - SPI_FLASH_CS_HIGH(); - SPI_FLASH_WaitBusy(); + SPI_FLASH_WaitBusy(); + SPI_FLASH_CS_LOW(); + (void)SPI_FLASH_TransferByte(W25X_ChipErase); + SPI_FLASH_CS_HIGH(); + SPI_FLASH_WaitBusy(); } diff --git a/Transplant/MiniDevCore/BSP/src/ssd1306_spi.c b/Transplant/MiniDevCore/BSP/src/ssd1306_spi.c index c48e207949b5bf9fd9ac37e532489299b269a08e..51d4bddb68de82e541d91ae7676b112e353a8938 100644 --- a/Transplant/MiniDevCore/BSP/src/ssd1306_spi.c +++ b/Transplant/MiniDevCore/BSP/src/ssd1306_spi.c @@ -1,37 +1,37 @@ #include "ssd1306_spi.h" -#define SPI_SSD1306_SPI SPI2 -#define SPI_SSD1306_SPI_APBxClock_FUN RCC_APB1PeriphClockCmd -#define SPI_SSD1306_SPI_CLK RCC_APB1Periph_SPI2 +#define SPI_SSD1306_SPI SPI2 +#define SPI_SSD1306_SPI_APBxClock_FUN RCC_APB1PeriphClockCmd +#define SPI_SSD1306_SPI_CLK RCC_APB1Periph_SPI2 -#define SPI_SSD1306_GPIO_APBxClock_FUN RCC_APB2PeriphClockCmd -#define SPI_SSD1306_GPIO_CLK RCC_APB2Periph_GPIOB -#define SPI_SSD1306_GPIO_PORT GPIOB +#define SPI_SSD1306_GPIO_APBxClock_FUN RCC_APB2PeriphClockCmd +#define SPI_SSD1306_GPIO_CLK RCC_APB2Periph_GPIOB +#define SPI_SSD1306_GPIO_PORT GPIOB //RST -#define SPI_SSD1306_RST_PIN GPIO_Pin_10 -#define SPI_SSD1306_RST_LOW() GPIO_ResetBits(SPI_SSD1306_GPIO_PORT, SPI_SSD1306_RST_PIN) -#define SPI_SSD1306_RST_HIGH() GPIO_SetBits(SPI_SSD1306_GPIO_PORT, SPI_SSD1306_RST_PIN) +#define SPI_SSD1306_RST_PIN GPIO_Pin_10 +#define SPI_SSD1306_RST_LOW() GPIO_ResetBits(SPI_SSD1306_GPIO_PORT, SPI_SSD1306_RST_PIN) +#define SPI_SSD1306_RST_HIGH() GPIO_SetBits(SPI_SSD1306_GPIO_PORT, SPI_SSD1306_RST_PIN) //DC -#define SPI_SSD1306_DC_PIN GPIO_Pin_11 -#define SPI_SSD1306_DC_LOW() GPIO_ResetBits(SPI_SSD1306_GPIO_PORT, SPI_SSD1306_DC_PIN) -#define SPI_SSD1306_DC_HIGH() GPIO_SetBits(SPI_SSD1306_GPIO_PORT, SPI_SSD1306_DC_PIN) -#define SPI_SSD1306_MODE_CMD() SPI_SSD1306_DC_LOW() -#define SPI_SSD1306_MODE_DAT() SPI_SSD1306_DC_HIGH() +#define SPI_SSD1306_DC_PIN GPIO_Pin_11 +#define SPI_SSD1306_DC_LOW() GPIO_ResetBits(SPI_SSD1306_GPIO_PORT, SPI_SSD1306_DC_PIN) +#define SPI_SSD1306_DC_HIGH() GPIO_SetBits(SPI_SSD1306_GPIO_PORT, SPI_SSD1306_DC_PIN) +#define SPI_SSD1306_MODE_CMD() SPI_SSD1306_DC_LOW() +#define SPI_SSD1306_MODE_DAT() SPI_SSD1306_DC_HIGH() //CS(NSS) -#define SPI_SSD1306_CS_PIN GPIO_Pin_12 -#define SPI_SSD1306_CS_LOW() GPIO_ResetBits(SPI_SSD1306_GPIO_PORT, SPI_SSD1306_CS_PIN) -#define SPI_SSD1306_CS_HIGH() GPIO_SetBits(SPI_SSD1306_GPIO_PORT, SPI_SSD1306_CS_PIN) +#define SPI_SSD1306_CS_PIN GPIO_Pin_12 +#define SPI_SSD1306_CS_LOW() GPIO_ResetBits(SPI_SSD1306_GPIO_PORT, SPI_SSD1306_CS_PIN) +#define SPI_SSD1306_CS_HIGH() GPIO_SetBits(SPI_SSD1306_GPIO_PORT, SPI_SSD1306_CS_PIN) //SCLK -#define SPI_SSD1306_SCLK_PIN GPIO_Pin_13 -#define SPI_SSD1306_SCLK_LOW() GPIO_ResetBits(SPI_SSD1306_GPIO_PORT, SPI_SSD1306_SCLK_PIN) -#define SPI_SSD1306_SCLK_HIGH() GPIO_SetBits(SPI_SSD1306_GPIO_PORT, SPI_SSD1306_SCLK_PIN) +#define SPI_SSD1306_SCLK_PIN GPIO_Pin_13 +#define SPI_SSD1306_SCLK_LOW() GPIO_ResetBits(SPI_SSD1306_GPIO_PORT, SPI_SSD1306_SCLK_PIN) +#define SPI_SSD1306_SCLK_HIGH() GPIO_SetBits(SPI_SSD1306_GPIO_PORT, SPI_SSD1306_SCLK_PIN) //MOSI -#define SPI_SSD1306_MOSI_PIN GPIO_Pin_15 -#define SPI_SSD1306_MOSI_LOW() GPIO_ResetBits(SPI_SSD1306_GPIO_PORT, SPI_SSD1306_MOSI_PIN) -#define SPI_SSD1306_MOSI_HIGH() GPIO_SetBits(SPI_SSD1306_GPIO_PORT, SPI_SSD1306_MOSI_PIN) +#define SPI_SSD1306_MOSI_PIN GPIO_Pin_15 +#define SPI_SSD1306_MOSI_LOW() GPIO_ResetBits(SPI_SSD1306_GPIO_PORT, SPI_SSD1306_MOSI_PIN) +#define SPI_SSD1306_MOSI_HIGH() GPIO_SetBits(SPI_SSD1306_GPIO_PORT, SPI_SSD1306_MOSI_PIN) -#define SPI_SSD1306_DUMMY_BYTE (0xFF) +#define SPI_SSD1306_DUMMY_BYTE (0xFF) static void SSD1306_InitializeGPIO(void); #ifndef SSD1306_SOFT_SPI @@ -40,249 +40,249 @@ static void SSD1306_InitializeSPI(void); static void SSD1306_WriteByte(uint8_t uiData); /*****************************************************************************/ -/** Function Name: SSD1306_InitializeGPIO. **/ -/** Purpose: Config and initialize GPIO. **/ -/** Params: None. **/ -/** Return: None. **/ -/** Limitation: None. **/ +/** Function Name: SSD1306_InitializeGPIO. **/ +/** Purpose: Config and initialize GPIO. **/ +/** Params: None. **/ +/** Return: None. **/ +/** Limitation: None. **/ /*****************************************************************************/ void SSD1306_InitializeGPIO(void) { - // Initialize data structure. - GPIO_InitTypeDef GPIO_InitStructure; - - // Initialize GPIO. - SPI_SSD1306_GPIO_APBxClock_FUN(SPI_SSD1306_GPIO_CLK, ENABLE); + // Initialize data structure. + GPIO_InitTypeDef GPIO_InitStructure; - // Enable GPIO. - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; + // Initialize GPIO. + SPI_SSD1306_GPIO_APBxClock_FUN(SPI_SSD1306_GPIO_CLK, ENABLE); + + // Enable GPIO. + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; #ifndef SSD1306_SOFT_SPI - GPIO_InitStructure.GPIO_Pin = SPI_SSD1306_SCLK_PIN|SPI_SSD1306_MOSI_PIN; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; - GPIO_Init(SPI_SSD1306_GPIO_PORT, &GPIO_InitStructure); + GPIO_InitStructure.GPIO_Pin = SPI_SSD1306_SCLK_PIN|SPI_SSD1306_MOSI_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; + GPIO_Init(SPI_SSD1306_GPIO_PORT, &GPIO_InitStructure); #endif #ifdef SSD1306_SOFT_SPI - GPIO_InitStructure.GPIO_Pin = SPI_SSD1306_RST_PIN|SPI_SSD1306_DC_PIN|SPI_SSD1306_CS_PIN|SPI_SSD1306_SCLK_PIN|SPI_SSD1306_MOSI_PIN; + GPIO_InitStructure.GPIO_Pin = SPI_SSD1306_RST_PIN|SPI_SSD1306_DC_PIN|SPI_SSD1306_CS_PIN|SPI_SSD1306_SCLK_PIN|SPI_SSD1306_MOSI_PIN; #else - GPIO_InitStructure.GPIO_Pin = SPI_SSD1306_RST_PIN|SPI_SSD1306_DC_PIN|SPI_SSD1306_CS_PIN; + GPIO_InitStructure.GPIO_Pin = SPI_SSD1306_RST_PIN|SPI_SSD1306_DC_PIN|SPI_SSD1306_CS_PIN; #endif - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; - GPIO_Init(SPI_SSD1306_GPIO_PORT, &GPIO_InitStructure); + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; + GPIO_Init(SPI_SSD1306_GPIO_PORT, &GPIO_InitStructure); } /*****************************************************************************/ -/** Function Name: SSD1306_InitializeSPI. **/ -/** Purpose: Initialize hardware SPI controler for OLED. **/ -/** Params: None. **/ -/** Return: None. **/ +/** Function Name: SSD1306_InitializeSPI. **/ +/** Purpose: Initialize hardware SPI controler for OLED. **/ +/** Params: None. **/ +/** Return: None. **/ /*****************************************************************************/ void SSD1306_InitializeSPI(void) { - // Initialize data structure. - SPI_InitTypeDef SPI_InitStructure; - - // Initialize GPIO. - SPI_SSD1306_SPI_APBxClock_FUN(SPI_SSD1306_SPI_CLK, ENABLE); - - // Config SPI control. - SPI_InitStructure.SPI_Direction = SPI_Direction_1Line_Tx; - SPI_InitStructure.SPI_Mode = SPI_Mode_Master; - SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; - SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low; - SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge; - SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; - SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2; - SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; - SPI_InitStructure.SPI_CRCPolynomial = 7; - SPI_Init(SPI_SSD1306_SPI, &SPI_InitStructure); + // Initialize data structure. + SPI_InitTypeDef SPI_InitStructure; + + // Initialize GPIO. + SPI_SSD1306_SPI_APBxClock_FUN(SPI_SSD1306_SPI_CLK, ENABLE); - SPI_Cmd(SPI_SSD1306_SPI, ENABLE); + // Config SPI control. + SPI_InitStructure.SPI_Direction = SPI_Direction_1Line_Tx; + SPI_InitStructure.SPI_Mode = SPI_Mode_Master; + SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; + SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low; + SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge; + SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; + SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2; + SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; + SPI_InitStructure.SPI_CRCPolynomial = 7; + SPI_Init(SPI_SSD1306_SPI, &SPI_InitStructure); + + SPI_Cmd(SPI_SSD1306_SPI, ENABLE); } /*****************************************************************************/ -/** Function Name: SSD1306_WriteByte. **/ -/** Purpose: Simulate SPI communication timing to write a byte **/ -/** to OLED controler. **/ -/** Params: **/ -/** @ uiByte: Byte will be write. **/ -/** Return: None. **/ -/** Limitation: None. **/ +/** Function Name: SSD1306_WriteByte. **/ +/** Purpose: Simulate SPI communication timing to write a byte **/ +/** to OLED controler. **/ +/** Params: **/ +/** @ uiByte: Byte will be write. **/ +/** Return: None. **/ +/** Limitation: None. **/ /*****************************************************************************/ void SSD1306_WriteByte(uint8_t uiByte) { #ifdef SSD1306_SOFT_SPI - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - uint16_t i; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + uint16_t i; #endif - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ #ifdef SSD1306_SOFT_SPI - for(i=0;i<8;i++) - { - if((uiByte << i) & 0x80) - { - SPI_SSD1306_MOSI_HIGH(); - } - else - { - SPI_SSD1306_MOSI_LOW(); - } - SPI_SSD1306_SCLK_LOW(); - SPI_SSD1306_SCLK_HIGH(); - } + for(i=0;i<8;i++) + { + if((uiByte << i) & 0x80) + { + SPI_SSD1306_MOSI_HIGH(); + } + else + { + SPI_SSD1306_MOSI_LOW(); + } + SPI_SSD1306_SCLK_LOW(); + SPI_SSD1306_SCLK_HIGH(); + } #else - while (SPI_I2S_GetFlagStatus(SPI_SSD1306_SPI, SPI_I2S_FLAG_TXE) == RESET); - SPI_I2S_SendData(SPI_SSD1306_SPI, uiByte); - while (SPI_I2S_GetFlagStatus(SPI_SSD1306_SPI, SPI_I2S_FLAG_TXE) == RESET); + while (SPI_I2S_GetFlagStatus(SPI_SSD1306_SPI, SPI_I2S_FLAG_TXE) == RESET); + SPI_I2S_SendData(SPI_SSD1306_SPI, uiByte); + while (SPI_I2S_GetFlagStatus(SPI_SSD1306_SPI, SPI_I2S_FLAG_TXE) == RESET); #endif } /*****************************************************************************/ -/* Function Name: SSD1306_WriteData. **/ -/* Purpose: Write a data byte to OLED coltroler. **/ -/* Resources: None. **/ -/* Params: **/ -/* @ uiData: One byte data will be write. **/ -/* Return: None. **/ -/* Limitation: None. **/ +/* Function Name: SSD1306_WriteData. **/ +/* Purpose: Write a data byte to OLED coltroler. **/ +/* Resources: None. **/ +/* Params: **/ +/* @ uiData: One byte data will be write. **/ +/* Return: None. **/ +/* Limitation: None. **/ /*****************************************************************************/ void SSD1306_WriteData(uint8_t uiData) { - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - SPI_SSD1306_MODE_DAT(); - SPI_SSD1306_CS_LOW(); - SSD1306_WriteByte(uiData); - SPI_SSD1306_CS_HIGH(); + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + SPI_SSD1306_MODE_DAT(); + SPI_SSD1306_CS_LOW(); + SSD1306_WriteByte(uiData); + SPI_SSD1306_CS_HIGH(); } /*****************************************************************************/ -/* Function Name: SSD1306_WriteCommand. **/ -/* Purpose: Write a command byte to OLED coltroler. **/ -/* Resources: None. **/ -/* Params: **/ -/* @ uiCommand: One byte command will be write. **/ -/* Return: None. **/ -/* Limitation: None. **/ +/* Function Name: SSD1306_WriteCommand. **/ +/* Purpose: Write a command byte to OLED coltroler. **/ +/* Resources: None. **/ +/* Params: **/ +/* @ uiCommand: One byte command will be write. **/ +/* Return: None. **/ +/* Limitation: None. **/ /*****************************************************************************/ void SSD1306_WriteCommand(uint8_t uiCommand) { - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - SPI_SSD1306_MODE_CMD(); - SPI_SSD1306_CS_LOW(); - SSD1306_WriteByte(uiCommand); - SPI_SSD1306_CS_HIGH(); + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + SPI_SSD1306_MODE_CMD(); + SPI_SSD1306_CS_LOW(); + SSD1306_WriteByte(uiCommand); + SPI_SSD1306_CS_HIGH(); } /*****************************************************************************/ -/* Function Name: SSD1306_SetPosition. **/ -/* Purpose: Set current position of page and colomn. **/ -/* Resources: None. **/ -/* Params: **/ -/* @ uiColumn: Position of column. **/ -/* @ uiPage: Position of page. **/ -/* Return: None. **/ -/* Limitation: None. **/ +/* Function Name: SSD1306_SetPosition. **/ +/* Purpose: Set current position of page and colomn. **/ +/* Resources: None. **/ +/* Params: **/ +/* @ uiColumn: Position of column. **/ +/* @ uiPage: Position of page. **/ +/* Return: None. **/ +/* Limitation: None. **/ /*****************************************************************************/ void SSD1306_SetPosition(uint8_t uiColumn, uint8_t uiPage) { - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - SSD1306_WriteCommand(0xB0 | uiPage); - SSD1306_WriteCommand(((uiColumn & 0xF0)>>4)|0x10); - SSD1306_WriteCommand((uiColumn & 0x0F)); + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + SSD1306_WriteCommand(0xB0 | uiPage); + SSD1306_WriteCommand(((uiColumn & 0xF0)>>4)|0x10); + SSD1306_WriteCommand((uiColumn & 0x0F)); } /*****************************************************************************/ -/* Function Name: SSD1306_Fill. **/ -/* Purpose: Fill screen. **/ -/* Resources: None. **/ -/* Params: **/ -/* @uiByte: Filled data for each display unit. **/ -/* Return: None. **/ -/* Limitation: None. **/ +/* Function Name: SSD1306_Fill. **/ +/* Purpose: Fill screen. **/ +/* Resources: None. **/ +/* Params: **/ +/* @uiByte: Filled data for each display unit. **/ +/* Return: None. **/ +/* Limitation: None. **/ /*****************************************************************************/ void SSD1306_Fill(uint8_t uiByte) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - uint8_t uiPage, uiColumn; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + uint8_t uiPage, uiColumn; - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - for(uiPage=0; uiPage<8; uiPage++) - { - SSD1306_WriteCommand(0xb0 | uiPage); - SSD1306_WriteCommand(0x00); - SSD1306_WriteCommand(0x10); - for(uiColumn=0; uiColumn<128; uiColumn++) - { - SSD1306_WriteData(uiByte); - } - } + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + for(uiPage=0; uiPage<8; uiPage++) + { + SSD1306_WriteCommand(0xb0 | uiPage); + SSD1306_WriteCommand(0x00); + SSD1306_WriteCommand(0x10); + for(uiColumn=0; uiColumn<128; uiColumn++) + { + SSD1306_WriteData(uiByte); + } + } } /*****************************************************************************/ -/** Function Name: SSD1306_Initialize **/ -/** Purpose: Run the device initialize sequence. **/ -/** Params: None. **/ -/** Return: None. **/ -/** Limitation: Initialize sequence must executed after power on 500ms. **/ +/** Function Name: SSD1306_Initialize **/ +/** Purpose: Run the device initialize sequence. **/ +/** Params: None. **/ +/** Return: None. **/ +/** Limitation: Initialize sequence must executed after power on 500ms. **/ /*****************************************************************************/ void SSD1306_Initialize(void) { - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ #ifndef SSD1306_SOFT_SPI - // Initialize SPI control. - SSD1306_InitializeSPI(); + // Initialize SPI control. + SSD1306_InitializeSPI(); #endif - // Initialize GPIO - SSD1306_InitializeGPIO(); - /* Clear reset singal. */ - SPI_SSD1306_RST_HIGH(); + // Initialize GPIO + SSD1306_InitializeGPIO(); + /* Clear reset singal. */ + SPI_SSD1306_RST_HIGH(); - SSD1306_WriteCommand(0xae); - SSD1306_WriteCommand(0xae);//--turn off oled panel - SSD1306_WriteCommand(0x00);//---set low column address - SSD1306_WriteCommand(0x10);//---set high column address - SSD1306_WriteCommand(0x40);//--set start line address Set Mapping RAM Display Start Line (0x00~0x3F) - SSD1306_WriteCommand(0x81);//--set contrast control register - SSD1306_WriteCommand(0xcf); // Set SEG Output Current Brightness - SSD1306_WriteCommand(0xa0);//--Set SEG/Column Mapping 0xa0,0xa1 - SSD1306_WriteCommand(0xc0);//Set COM/Row Scan Direction 0xc0,0xc8 - SSD1306_WriteCommand(0xa6);//--set normal display - SSD1306_WriteCommand(0xa8);//--set multiplex ratio(1 to 64) - SSD1306_WriteCommand(0x3f);//--1/64 duty - SSD1306_WriteCommand(0xd3);//-set display offset Shift Mapping RAM Counter (0x00~0x3F) - SSD1306_WriteCommand(0x00);//-not offset - SSD1306_WriteCommand(0xd5);//--set display clock divide ratio/oscillator frequency - SSD1306_WriteCommand(0x80);//--set divide ratio, Set Clock as 100 Frames/Sec - SSD1306_WriteCommand(0xd9);//--set pre-charge period - SSD1306_WriteCommand(0xf1);//Set Pre-Charge as 15 Clocks & Discharge as 1 Clock - SSD1306_WriteCommand(0xda);//--set com pins hardware configuration - SSD1306_WriteCommand(0x12); - SSD1306_WriteCommand(0xdb);//--set vcomh - SSD1306_WriteCommand(0x40);//Set VCOM Deselect Level - SSD1306_WriteCommand(0x20);//-Set Page Addressing Mode (0x00/0x01/0x02) - SSD1306_WriteCommand(0x02);// - SSD1306_WriteCommand(0x8d);//--set Charge Pump enable/disable - SSD1306_WriteCommand(0x14);//--set(0x10) disable - SSD1306_WriteCommand(0xa4);// Disable Entire Display On (0xa4/0xa5) - SSD1306_WriteCommand(0xa6);// Disable Inverse Display On (0xa6/a7) - SSD1306_WriteCommand(0xaf);//--turn on oled panel - SSD1306_Clear(); - SSD1306_SetPosition(0,0); + SSD1306_WriteCommand(0xae); + SSD1306_WriteCommand(0xae);//--turn off oled panel + SSD1306_WriteCommand(0x00);//---set low column address + SSD1306_WriteCommand(0x10);//---set high column address + SSD1306_WriteCommand(0x40);//--set start line address Set Mapping RAM Display Start Line (0x00~0x3F) + SSD1306_WriteCommand(0x81);//--set contrast control register + SSD1306_WriteCommand(0xcf); // Set SEG Output Current Brightness + SSD1306_WriteCommand(0xa0);//--Set SEG/Column Mapping 0xa0,0xa1 + SSD1306_WriteCommand(0xc0);//Set COM/Row Scan Direction 0xc0,0xc8 + SSD1306_WriteCommand(0xa6);//--set normal display + SSD1306_WriteCommand(0xa8);//--set multiplex ratio(1 to 64) + SSD1306_WriteCommand(0x3f);//--1/64 duty + SSD1306_WriteCommand(0xd3);//-set display offset Shift Mapping RAM Counter (0x00~0x3F) + SSD1306_WriteCommand(0x00);//-not offset + SSD1306_WriteCommand(0xd5);//--set display clock divide ratio/oscillator frequency + SSD1306_WriteCommand(0x80);//--set divide ratio, Set Clock as 100 Frames/Sec + SSD1306_WriteCommand(0xd9);//--set pre-charge period + SSD1306_WriteCommand(0xf1);//Set Pre-Charge as 15 Clocks & Discharge as 1 Clock + SSD1306_WriteCommand(0xda);//--set com pins hardware configuration + SSD1306_WriteCommand(0x12); + SSD1306_WriteCommand(0xdb);//--set vcomh + SSD1306_WriteCommand(0x40);//Set VCOM Deselect Level + SSD1306_WriteCommand(0x20);//-Set Page Addressing Mode (0x00/0x01/0x02) + SSD1306_WriteCommand(0x02);// + SSD1306_WriteCommand(0x8d);//--set Charge Pump enable/disable + SSD1306_WriteCommand(0x14);//--set(0x10) disable + SSD1306_WriteCommand(0xa4);// Disable Entire Display On (0xa4/0xa5) + SSD1306_WriteCommand(0xa6);// Disable Inverse Display On (0xa6/a7) + SSD1306_WriteCommand(0xaf);//--turn on oled panel + SSD1306_Clear(); + SSD1306_SetPosition(0,0); } diff --git a/Transplant/MiniDevCore/BSP/src/trigger_flags.c b/Transplant/MiniDevCore/BSP/src/trigger_flags.c index a8a5bd97d5fef0687effb9889cb28266656bc9a4..c821d357f85b204df86319c1a272a412e59d3391 100644 --- a/Transplant/MiniDevCore/BSP/src/trigger_flags.c +++ b/Transplant/MiniDevCore/BSP/src/trigger_flags.c @@ -1,84 +1,84 @@ #include "trigger_flags.h" #include -static bool __IO s_bBaseTimerTrigger = false; -static bool __IO s_bRTCTimerTrigger = false; -static USART_INPUT __IO s_stUsartInput = {0x00}; +static bool __IO s_bBaseTimerTrigger = false; +static bool __IO s_bRTCTimerTrigger = false; +static USART_INPUT __IO s_stUsartInput = {0x00}; void USARTReceiveProc(USART_INT_REASON eReason, uint8_t uiReceiveData) { - if(USART_INT_REASON_IDLE == eReason) - { - s_stUsartInput.bIsTriggered = true; - } - else if(USART_INT_REASON_REV == eReason) - { - if(true == s_stUsartInput.bHalfRev) - { - s_stUsartInput.unKeyValue.uiByte[0] = uiReceiveData; - s_stUsartInput.bIsTriggered = true; - } - else - { - s_stUsartInput.unKeyValue.uiByte[1] = uiReceiveData; - s_stUsartInput.bHalfRev = true; - } - } + if(USART_INT_REASON_IDLE == eReason) + { + s_stUsartInput.bIsTriggered = true; + } + else if(USART_INT_REASON_REV == eReason) + { + if(true == s_stUsartInput.bHalfRev) + { + s_stUsartInput.unKeyValue.uiByte[0] = uiReceiveData; + s_stUsartInput.bIsTriggered = true; + } + else + { + s_stUsartInput.unKeyValue.uiByte[1] = uiReceiveData; + s_stUsartInput.bHalfRev = true; + } + } } void KeyEventProc(uint16_t uiKeyCode, KEY_EVENT eEvent) { - if(KEY_EVENT_DOWN == eEvent) - { - printf("Key 0x%02X is down.", uiKeyCode); - printf("\r\n"); - } + if(KEY_EVENT_DOWN == eEvent) + { + printf("Key 0x%02X is down.", uiKeyCode); + printf("\r\n"); + } } void TimerInterruptProc(void) { - s_bBaseTimerTrigger = true; + s_bBaseTimerTrigger = true; } void RTCInterruptProc(uint32_t uiTimeStamp) { - s_bRTCTimerTrigger = true; + s_bRTCTimerTrigger = true; } bool BaseTimerIsTrigger(void) { - return s_bBaseTimerTrigger; + return s_bBaseTimerTrigger; } void BaseTimerTriggerReset(void) { - s_bBaseTimerTrigger = false; + s_bBaseTimerTrigger = false; } bool UsartIsReceived(void) { - return s_stUsartInput.bIsTriggered; + return s_stUsartInput.bIsTriggered; } uint16_t GetReceivedCode(void) { - return s_stUsartInput.unKeyValue.uiKeyCode; + return s_stUsartInput.unKeyValue.uiKeyCode; } void UsartTriggerReset(void) { - s_stUsartInput.bIsTriggered = false; - s_stUsartInput.bHalfRev = false; - s_stUsartInput.unKeyValue.uiKeyCode = 0; + s_stUsartInput.bIsTriggered = false; + s_stUsartInput.bHalfRev = false; + s_stUsartInput.unKeyValue.uiKeyCode = 0; } bool RTCTimerIsTrigger(void) { - return s_bRTCTimerTrigger; + return s_bRTCTimerTrigger; } void RTCTimerTriggerReset(void) { - s_bRTCTimerTrigger = false; + s_bRTCTimerTrigger = false; } diff --git a/Transplant/MiniDevCore/BSP/src/uc1604c_softspi.c b/Transplant/MiniDevCore/BSP/src/uc1604c_softspi.c index bcafb683bcb421ef30a199eb22136ce687438d92..59cf7a882a000353976a9f11699b353ecd583af0 100644 --- a/Transplant/MiniDevCore/BSP/src/uc1604c_softspi.c +++ b/Transplant/MiniDevCore/BSP/src/uc1604c_softspi.c @@ -3,40 +3,40 @@ #include #include -#define SPI_UC1604C_CTRL SPI2 -#define SPI_UC1604C_APBxClock_FUN RCC_APB1PeriphClockCmd -#define SPI_UC1604C_CLK RCC_APB1Periph_SPI2 +#define SPI_UC1604C_CTRL SPI2 +#define SPI_UC1604C_APBxClock_FUN RCC_APB1PeriphClockCmd +#define SPI_UC1604C_CLK RCC_APB1Periph_SPI2 -#define SPI_UC1604C_GPIO_APBxClock_FUN RCC_APB2PeriphClockCmd -#define SPI_UC1604C_GPIO_CLK RCC_APB2Periph_GPIOD -#define SPI_UC1604C_GPIO_PORT GPIOD +#define SPI_UC1604C_GPIO_APBxClock_FUN RCC_APB2PeriphClockCmd +#define SPI_UC1604C_GPIO_CLK RCC_APB2Periph_GPIOD +#define SPI_UC1604C_GPIO_PORT GPIOD //RST -#define SPI_UC1604C_RST_PIN GPIO_Pin_1 -#define SPI_UC1604C_RST_LOW() GPIO_ResetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_RST_PIN) -#define SPI_UC1604C_RST_HIGH() GPIO_SetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_RST_PIN) +#define SPI_UC1604C_RST_PIN GPIO_Pin_1 +#define SPI_UC1604C_RST_LOW() GPIO_ResetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_RST_PIN) +#define SPI_UC1604C_RST_HIGH() GPIO_SetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_RST_PIN) //DC -#define SPI_UC1604C_DC_PIN GPIO_Pin_0 -#define SPI_UC1604C_DC_LOW() GPIO_ResetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_DC_PIN) -#define SPI_UC1604C_DC_HIGH() GPIO_SetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_DC_PIN) -#define SPI_UC1604C_MODE_CMD() SPI_UC1604C_DC_LOW() -#define SPI_UC1604C_MODE_DAT() SPI_UC1604C_DC_HIGH() +#define SPI_UC1604C_DC_PIN GPIO_Pin_0 +#define SPI_UC1604C_DC_LOW() GPIO_ResetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_DC_PIN) +#define SPI_UC1604C_DC_HIGH() GPIO_SetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_DC_PIN) +#define SPI_UC1604C_MODE_CMD() SPI_UC1604C_DC_LOW() +#define SPI_UC1604C_MODE_DAT() SPI_UC1604C_DC_HIGH() //CS(NSS) -#define SPI_UC1604C_CS_PIN GPIO_Pin_2 -#define SPI_UC1604C_CS_LOW() GPIO_ResetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_CS_PIN) -#define SPI_UC1604C_CS_HIGH() GPIO_SetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_CS_PIN) -#define SPI_UC1604C_CS_ENABLE() SPI_UC1604C_CS_LOW() -#define SPI_UC1604C_CS_DISABLE() SPI_UC1604C_CS_HIGH() +#define SPI_UC1604C_CS_PIN GPIO_Pin_2 +#define SPI_UC1604C_CS_LOW() GPIO_ResetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_CS_PIN) +#define SPI_UC1604C_CS_HIGH() GPIO_SetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_CS_PIN) +#define SPI_UC1604C_CS_ENABLE() SPI_UC1604C_CS_LOW() +#define SPI_UC1604C_CS_DISABLE() SPI_UC1604C_CS_HIGH() //SCLK -#define SPI_UC1604C_SCLK_PIN GPIO_Pin_4 -#define SPI_UC1604C_SCLK_LOW() GPIO_ResetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_SCLK_PIN) -#define SPI_UC1604C_SCLK_HIGH() GPIO_SetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_SCLK_PIN) +#define SPI_UC1604C_SCLK_PIN GPIO_Pin_4 +#define SPI_UC1604C_SCLK_LOW() GPIO_ResetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_SCLK_PIN) +#define SPI_UC1604C_SCLK_HIGH() GPIO_SetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_SCLK_PIN) //MOSI -#define SPI_UC1604C_MOSI_PIN GPIO_Pin_3 -#define SPI_UC1604C_MOSI_LOW() GPIO_ResetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_MOSI_PIN) -#define SPI_UC1604C_MOSI_HIGH() GPIO_SetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_MOSI_PIN) +#define SPI_UC1604C_MOSI_PIN GPIO_Pin_3 +#define SPI_UC1604C_MOSI_LOW() GPIO_ResetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_MOSI_PIN) +#define SPI_UC1604C_MOSI_HIGH() GPIO_SetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_MOSI_PIN) static void UC1604C_InitializeGPIO(void); static void UC1604C_WriteByte(uint8_t uiData); @@ -44,176 +44,176 @@ static void UC1604C_WriteCommand(uint8_t uiCommand); void UC1604C_Delay(uint32_t uiDelay) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - uint32_t uiDelayTime; - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - while(uiDelay--) - { - uiDelayTime = 1000; - while(--uiDelayTime); - } + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + uint32_t uiDelayTime; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + while(uiDelay--) + { + uiDelayTime = 1000; + while(--uiDelayTime); + } } /*****************************************************************************/ -/** Function Name: UC1604C_InitializeGPIO. **/ -/** Purpose: Initialize GPIO for SPI Pin. **/ -/** Params: None. **/ -/** Return: None. **/ +/** Function Name: UC1604C_InitializeGPIO. **/ +/** Purpose: Initialize GPIO for SPI Pin. **/ +/** Params: None. **/ +/** Return: None. **/ /*****************************************************************************/ void UC1604C_InitializeGPIO(void) { - // Initialize data structure. - GPIO_InitTypeDef GPIO_InitStructure; - // Initialize GPIO. - SPI_UC1604C_GPIO_APBxClock_FUN(SPI_UC1604C_GPIO_CLK, ENABLE); - // Enable GPIO. - GPIO_InitStructure.GPIO_Pin = SPI_UC1604C_RST_PIN|SPI_UC1604C_DC_PIN|SPI_UC1604C_CS_PIN|SPI_UC1604C_SCLK_PIN|SPI_UC1604C_MOSI_PIN; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; - GPIO_Init(SPI_UC1604C_GPIO_PORT, &GPIO_InitStructure); - GPIO_SetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_DC_PIN|SPI_UC1604C_CS_PIN|SPI_UC1604C_SCLK_PIN|SPI_UC1604C_MOSI_PIN); - GPIO_ResetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_RST_PIN); + // Initialize data structure. + GPIO_InitTypeDef GPIO_InitStructure; + // Initialize GPIO. + SPI_UC1604C_GPIO_APBxClock_FUN(SPI_UC1604C_GPIO_CLK, ENABLE); + // Enable GPIO. + GPIO_InitStructure.GPIO_Pin = SPI_UC1604C_RST_PIN|SPI_UC1604C_DC_PIN|SPI_UC1604C_CS_PIN|SPI_UC1604C_SCLK_PIN|SPI_UC1604C_MOSI_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; + GPIO_Init(SPI_UC1604C_GPIO_PORT, &GPIO_InitStructure); + GPIO_SetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_DC_PIN|SPI_UC1604C_CS_PIN|SPI_UC1604C_SCLK_PIN|SPI_UC1604C_MOSI_PIN); + GPIO_ResetBits(SPI_UC1604C_GPIO_PORT, SPI_UC1604C_RST_PIN); } /*****************************************************************************/ -/** Function Name: UC1604C_WriteByte. **/ -/** Purpose: Simulate SPI communication timing to write a byte to **/ -/** LCD controller. **/ -/** Params: **/ -/** @ uiData: Byte will be write. **/ -/** Return: None. **/ +/** Function Name: UC1604C_WriteByte. **/ +/** Purpose: Simulate SPI communication timing to write a byte to **/ +/** LCD controller. **/ +/** Params: **/ +/** @ uiData: Byte will be write. **/ +/** Return: None. **/ /*****************************************************************************/ void UC1604C_WriteByte(uint8_t uiByte) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - uint16_t i; - uint8_t uiSendByte; - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - uiSendByte = uiByte; - SPI_UC1604C_CS_LOW(); - for(i=0;i<8;i++) - { - if(uiSendByte & 0x80) - { - SPI_UC1604C_MOSI_HIGH(); - } - else - { - SPI_UC1604C_MOSI_LOW(); - } - SPI_UC1604C_SCLK_LOW(); - SPI_UC1604C_SCLK_HIGH(); - - uiSendByte <<= 1; - } - SPI_UC1604C_CS_HIGH(); + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + uint16_t i; + uint8_t uiSendByte; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + uiSendByte = uiByte; + SPI_UC1604C_CS_LOW(); + for(i=0;i<8;i++) + { + if(uiSendByte & 0x80) + { + SPI_UC1604C_MOSI_HIGH(); + } + else + { + SPI_UC1604C_MOSI_LOW(); + } + SPI_UC1604C_SCLK_LOW(); + SPI_UC1604C_SCLK_HIGH(); + + uiSendByte <<= 1; + } + SPI_UC1604C_CS_HIGH(); } /*****************************************************************************/ -/** Function Name: UC1604C_WriteData. **/ -/** Purpose: Write a data byte to OLED coltroler. **/ -/** Resources: None. **/ -/** Params: **/ -/** @ uiData: One byte data will be write. **/ -/** Return: None. **/ +/** Function Name: UC1604C_WriteData. **/ +/** Purpose: Write a data byte to OLED coltroler. **/ +/** Resources: None. **/ +/** Params: **/ +/** @ uiData: One byte data will be write. **/ +/** Return: None. **/ /*****************************************************************************/ void UC1604C_WriteData(uint8_t uiData) { - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - SPI_UC1604C_MODE_DAT(); - UC1604C_WriteByte(uiData); + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + SPI_UC1604C_MODE_DAT(); + UC1604C_WriteByte(uiData); } /*****************************************************************************/ -/** Function Name: UC1604C_WriteCommand. **/ -/** Purpose: Write a command byte to OLED coltroler. **/ -/** Resources: None. **/ -/** Params: **/ -/** @ uiData: One byte command will be write. **/ -/** Return: None. **/ +/** Function Name: UC1604C_WriteCommand. **/ +/** Purpose: Write a command byte to OLED coltroler. **/ +/** Resources: None. **/ +/** Params: **/ +/** @ uiData: One byte command will be write. **/ +/** Return: None. **/ /*****************************************************************************/ void UC1604C_WriteCommand(uint8_t uiCommand) { - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - SPI_UC1604C_MODE_CMD(); - UC1604C_WriteByte(uiCommand); + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + SPI_UC1604C_MODE_CMD(); + UC1604C_WriteByte(uiCommand); } /*****************************************************************************/ -/** Function Name: UC1604C_SetPosition. **/ -/** Purpose: Set current position of page and colomn. **/ -/** Resources: None. **/ -/** Params: **/ -/** @ uiColumn: Position of column. **/ -/** @ uiPage: Position of page. **/ -/** Return: None. **/ +/** Function Name: UC1604C_SetPosition. **/ +/** Purpose: Set current position of page and colomn. **/ +/** Resources: None. **/ +/** Params: **/ +/** @ uiColumn: Position of column. **/ +/** @ uiPage: Position of page. **/ +/** Return: None. **/ /*****************************************************************************/ void UC1604C_SetPosition(uint8_t uiColumn, uint8_t uiPage) { - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - UC1604C_WriteCommand(0xB0 | uiPage); - UC1604C_WriteCommand(((uiColumn & 0xF0)>>4)|0x10); - UC1604C_WriteCommand((uiColumn & 0x0F)); + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + UC1604C_WriteCommand(0xB0 | uiPage); + UC1604C_WriteCommand(((uiColumn & 0xF0)>>4)|0x10); + UC1604C_WriteCommand((uiColumn & 0x0F)); } /*****************************************************************************/ -/** Function Name: UC1604C_Fill. **/ -/** Purpose: Fill screen. **/ -/** Params: **/ -/** @ uiByte: Filled data. **/ -/** Return: None. **/ +/** Function Name: UC1604C_Fill. **/ +/** Purpose: Fill screen. **/ +/** Params: **/ +/** @ uiByte: Filled data. **/ +/** Return: None. **/ /*****************************************************************************/ void UC1604C_Fill(uint8_t uiByte)//全屏填充 { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - uint8_t uiPage, uiColumn; - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - for(uiPage=0; uiPageSR;\ + uiReg = PORT->DR;\ + (void)uiReg;\ + }\ + if(USART_GetITStatus(PORT, USART_IT_RXNE) == SET)\ + {\ + if(NULL != PORT##_INIT_CALLBACK)\ + {\ + PORT##_INIT_CALLBACK(USART_INT_REASON_REV, USART_ReceiveData(PORT));\ + }\ + }\ + }\ -#define USART_REV_INT_SRV_DEFINE(PORT) void PORT##_IRQHandler(void)\ - {\ - uint8_t uiReg;\ - if(USART_GetITStatus(PORT, USART_IT_IDLE) == SET)\ - {\ - if(NULL != PORT##_INIT_CALLBACK)\ - {\ - PORT##_INIT_CALLBACK(USART_INT_REASON_IDLE, 0x00);\ - }\ - uiReg = PORT->SR;\ - uiReg = PORT->DR;\ - (void)uiReg;\ - }\ - if(USART_GetITStatus(PORT, USART_IT_RXNE) == SET)\ - {\ - if(NULL != PORT##_INIT_CALLBACK)\ - {\ - PORT##_INIT_CALLBACK(USART_INT_REASON_REV, USART_ReceiveData(PORT));\ - }\ - }\ - }\ - USART_REV_INT_CBPF_DEFINE(USART1, NULL); USART_REV_INT_CFG_DEFINE(USART1); USART_REV_INT_SRV_DEFINE(USART1); @@ -44,18 +44,18 @@ USART_REV_INT_SRV_DEFINE(USART2) void USART_Initialize(USART_TypeDef* pstUSARTx, uint32_t Baudrate) { - USART_InitTypeDef USART_InitStructure; - - USART_InitStructure.USART_BaudRate = Baudrate; - USART_InitStructure.USART_WordLength = USART_WordLength_8b; - USART_InitStructure.USART_StopBits = USART_StopBits_1; - USART_InitStructure.USART_Parity = USART_Parity_No; - USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; - USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; - USART_Init(pstUSARTx, &USART_InitStructure); + USART_InitTypeDef USART_InitStructure; + + USART_InitStructure.USART_BaudRate = Baudrate; + USART_InitStructure.USART_WordLength = USART_WordLength_8b; + USART_InitStructure.USART_StopBits = USART_StopBits_1; + USART_InitStructure.USART_Parity = USART_Parity_No; + USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; + USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; + USART_Init(pstUSARTx, &USART_InitStructure); - USART_Cmd(pstUSARTx, ENABLE); - USART_ClearFlag(pstUSARTx, USART_FLAG_TXE); + USART_Cmd(pstUSARTx, ENABLE); + USART_ClearFlag(pstUSARTx, USART_FLAG_TXE); } void USART_SendByte(USART_TypeDef* pstUSARTx, uint16_t uiByte) @@ -69,16 +69,16 @@ void USART_SendByte(USART_TypeDef* pstUSARTx, uint16_t uiByte) void USART_ActiveInterrupt(USART_TypeDef* pstUSARTx, bool bEnable) { - USART_Cmd(pstUSARTx, DISABLE); - if(true == bEnable) - { - USART_ITConfig(pstUSARTx, USART_IT_RXNE, ENABLE); - USART_ITConfig(pstUSARTx, USART_IT_IDLE, ENABLE); - } - else - { - USART_ITConfig(pstUSARTx, USART_IT_RXNE, DISABLE); - USART_ITConfig(pstUSARTx, USART_IT_IDLE, DISABLE); - } - USART_Cmd(pstUSARTx, ENABLE); + USART_Cmd(pstUSARTx, DISABLE); + if(true == bEnable) + { + USART_ITConfig(pstUSARTx, USART_IT_RXNE, ENABLE); + USART_ITConfig(pstUSARTx, USART_IT_IDLE, ENABLE); + } + else + { + USART_ITConfig(pstUSARTx, USART_IT_RXNE, DISABLE); + USART_ITConfig(pstUSARTx, USART_IT_IDLE, DISABLE); + } + USART_Cmd(pstUSARTx, ENABLE); } diff --git a/Transplant/MiniDevCore/BSP/src/usart_stdio.c b/Transplant/MiniDevCore/BSP/src/usart_stdio.c index de2122f1b55e4cb7e9008808f12417878591b736..0310751264aa8bfa1f494ad3ad96db1aa72ad9ec 100644 --- a/Transplant/MiniDevCore/BSP/src/usart_stdio.c +++ b/Transplant/MiniDevCore/BSP/src/usart_stdio.c @@ -2,12 +2,12 @@ #include "usart_stdio.h" #include "usart.h" -#define STDIO_USARTx USART1 -#define STDIO_USARTx_CLK_FUN RCC_APB2PeriphClockCmd -#define STDIO_USARTx_RCC RCC_APB2Periph_USART1 -#define STDIO_USARTx_PORT GPIOA -#define STDIO_USARTx_TXPin GPIO_Pin_9 -#define STDIO_USARTx_RXPin GPIO_Pin_10 +#define STDIO_USARTx USART1 +#define STDIO_USARTx_CLK_FUN RCC_APB2PeriphClockCmd +#define STDIO_USARTx_RCC RCC_APB2Periph_USART1 +#define STDIO_USARTx_PORT GPIOA +#define STDIO_USARTx_TXPin GPIO_Pin_9 +#define STDIO_USARTx_RXPin GPIO_Pin_10 #pragma import(__use_no_semihosting) @@ -16,36 +16,36 @@ FILE __stdin; static void Stdio_ConfigGPIO(void) { - // Initialize data structure. - GPIO_InitTypeDef GPIO_InitStructure; - // Enable RCC. - STDIO_USARTx_CLK_FUN(RCC_APB2Periph_GPIOA, ENABLE); - // Config TX GPIO. - GPIO_InitStructure.GPIO_Pin = STDIO_USARTx_TXPin; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; - GPIO_Init(STDIO_USARTx_PORT, &GPIO_InitStructure); - // Config RX GPIO. - GPIO_InitStructure.GPIO_Pin = STDIO_USARTx_RXPin; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; - GPIO_Init(STDIO_USARTx_PORT, &GPIO_InitStructure); + // Initialize data structure. + GPIO_InitTypeDef GPIO_InitStructure; + // Enable RCC. + STDIO_USARTx_CLK_FUN(RCC_APB2Periph_GPIOA, ENABLE); + // Config TX GPIO. + GPIO_InitStructure.GPIO_Pin = STDIO_USARTx_TXPin; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; + GPIO_Init(STDIO_USARTx_PORT, &GPIO_InitStructure); + // Config RX GPIO. + GPIO_InitStructure.GPIO_Pin = STDIO_USARTx_RXPin; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; + GPIO_Init(STDIO_USARTx_PORT, &GPIO_InitStructure); } void _sys_exit(int return_code) { - while(1) - { - /* Blank loop */ - } + while(1) + { + /* Blank loop */ + } } -int ferror(FILE *f) +int ferror(FILE *f) { - /* Your implementation of ferror */ - return EOF; + /* Your implementation of ferror */ + return EOF; } -void _ttywrch(int c) +void _ttywrch(int c) { /* Place your implementation of fputc here */ /* e.g. write a character to the USART */ @@ -54,7 +54,7 @@ void _ttywrch(int c) /* Loop until the end of transmission */ while (USART_GetFlagStatus(STDIO_USARTx, USART_FLAG_TC) == RESET) { - /* Blank loop */ + /* Blank loop */ } } @@ -66,13 +66,13 @@ void _ttywrch(int c) * Return : None *******************************************************************************/ int fputc(int ch, FILE *f) -{ - while(USART_GetFlagStatus(STDIO_USARTx,USART_FLAG_TC)==RESET) - { - /* Blank loop */ - } - USART_SendData(STDIO_USARTx,(uint8_t)ch); - return ch; +{ + while(USART_GetFlagStatus(STDIO_USARTx,USART_FLAG_TC)==RESET) + { + /* Blank loop */ + } + USART_SendData(STDIO_USARTx,(uint8_t)ch); + return ch; } /******************************************************************************* @@ -84,16 +84,16 @@ int fputc(int ch, FILE *f) *******************************************************************************/ int fgetc(FILE *f) { - uint16_t uiRtnValue; - /* Loop until received a char */ - while(!(USART_GetFlagStatus(STDIO_USARTx, USART_FLAG_RXNE) == SET)) - { - /* Blank loop */ - } - uiRtnValue = USART_ReceiveData(STDIO_USARTx); - - /* Read a character from the USART and RETURN */ - return (uiRtnValue); + uint16_t uiRtnValue; + /* Loop until received a char */ + while(!(USART_GetFlagStatus(STDIO_USARTx, USART_FLAG_RXNE) == SET)) + { + /* Blank loop */ + } + uiRtnValue = USART_ReceiveData(STDIO_USARTx); + + /* Read a character from the USART and RETURN */ + return (uiRtnValue); } /******************************************************************************* @@ -105,10 +105,10 @@ int fgetc(FILE *f) *******************************************************************************/ void USART_Stdio_Initialize(uint32_t Baudrate) { - /* Configure USART1 */ - STDIO_USARTx_CLK_FUN(STDIO_USARTx_RCC, ENABLE); - USART_Initialize(STDIO_USARTx, Baudrate); - /* Configure USART1 GPIO */ - Stdio_ConfigGPIO(); + /* Configure USART1 */ + STDIO_USARTx_CLK_FUN(STDIO_USARTx_RCC, ENABLE); + USART_Initialize(STDIO_USARTx, Baudrate); + /* Configure USART1 GPIO */ + Stdio_ConfigGPIO(); } diff --git a/Transplant/MiniDevCore/DemoProc/src/DemoProc.c b/Transplant/MiniDevCore/DemoProc/src/DemoProc.c index cd3a538dde93d120d32ccb0b2fc6ecbf032c9931..b9fa6cc00ef34e9da31f37c776ad70a246a54f5f 100644 --- a/Transplant/MiniDevCore/DemoProc/src/DemoProc.c +++ b/Transplant/MiniDevCore/DemoProc/src/DemoProc.c @@ -1,11 +1,11 @@ /*************************************************************************/ -/** Copyright. **/ -/** FileName: DemoProc.c **/ -/** Author: Polarix **/ -/** Description: User operation interface. **/ +/** Copyright. **/ +/** FileName: DemoProc.c **/ +/** Author: Polarix **/ +/** Description: User operation interface. **/ /*************************************************************************/ //=======================================================================// -//= Include files. =// +//= Include files. =// //=======================================================================// #include "DemoProc.h" @@ -23,187 +23,187 @@ #endif //=======================================================================// -//= Static variable declaration. =// +//= Static variable declaration. =// //=======================================================================// -SGUI_SCR_DEV g_stDeviceInterface; -HMI_SCREEN_OBJECT* g_arrpstScreenObjs[] = - { - &g_stHMIDemo_List, - &g_stHMIDemo_TextPaint, - &g_stHMIDemo_VariableBox, - &g_stHMIDemo_RealtimeGraph, - &g_stHMIDemo_Menu, - &g_stHMIDemo_Notice, - &g_stHMIDemo_BasicPaint - }; -HMI_ENGINE_OBJECT g_stDemoEngine; +SGUI_SCR_DEV g_stDeviceInterface; +HMI_SCREEN_OBJECT* g_arrpstScreenObjs[] = + { + &g_stHMIDemo_List, + &g_stHMIDemo_TextPaint, + &g_stHMIDemo_VariableBox, + &g_stHMIDemo_RealtimeGraph, + &g_stHMIDemo_Menu, + &g_stHMIDemo_Notice, + &g_stHMIDemo_BasicPaint + }; +HMI_ENGINE_OBJECT g_stDemoEngine; #ifndef _SIMPLE_GUI_IN_VIRTUAL_SDK_ -static unsigned int s_uiKeyValue; +static unsigned int s_uiKeyValue; #endif //=======================================================================// -//= Static function declare. =// +//= Static function declare. =// //=======================================================================// -static void KeyPressEventProc(void); -static void RTCEventProc(void); -static void SysTickTimerEventProc(void); +static void KeyPressEventProc(void); +static void RTCEventProc(void); +static void SysTickTimerEventProc(void); #ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ -static bool CheckEventFlag(ENV_FLAG_INDEX eIndex); +static bool CheckEventFlag(ENV_FLAG_INDEX eIndex); #endif // _SIMPLE_GUI_VIRTUAL_ENVIRONMENT_SIMULATOR_ //=======================================================================// -//= Function define. =// +//= Function define. =// //=======================================================================// /*****************************************************************************/ -/** Function Name: InitializeHMIEngineObj **/ -/** Purpose: Simple GUI HMI engine and interface demo process. **/ -/** Parameters: None. **/ -/** Return: HMI_ENGINE_RESULT. **/ -/** Notice: This function demonstrates how to use the interface and **/ +/** Function Name: InitializeHMIEngineObj **/ +/** Purpose: Simple GUI HMI engine and interface demo process. **/ +/** Parameters: None. **/ +/** Return: HMI_ENGINE_RESULT. **/ +/** Notice: This function demonstrates how to use the interface and **/ /** HMI engine of Simple GUI. **/ /*****************************************************************************/ HMI_ENGINE_RESULT InitializeHMIEngineObj(void) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - HMI_ENGINE_RESULT eProcessResult; - int iIndex; - - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - eProcessResult = HMI_RET_NORMAL; - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - /* Clear structure. */ - SGUI_SystemIF_MemorySet(&g_stDeviceInterface, 0x00, sizeof(SGUI_SCR_DEV)); - SGUI_SystemIF_MemorySet(&g_stDemoEngine, 0x00, sizeof(HMI_ENGINE_OBJECT)); + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + HMI_ENGINE_RESULT eProcessResult; + int iIndex; + + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + eProcessResult = HMI_RET_NORMAL; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + /* Clear structure. */ + SGUI_SystemIF_MemorySet(&g_stDeviceInterface, 0x00, sizeof(SGUI_SCR_DEV)); + SGUI_SystemIF_MemorySet(&g_stDemoEngine, 0x00, sizeof(HMI_ENGINE_OBJECT)); #ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ - /* Initialize display size. */ - g_stDeviceInterface.stSize.iWidth = 128; - g_stDeviceInterface.stSize.iHeight = 64; - /* Initialize interface object. */ - g_stDeviceInterface.fnSetPixel = SGUI_SDK_SetPixel; - g_stDeviceInterface.fnGetPixel = SGUI_SDK_GetPixel; - g_stDeviceInterface.fnClear = SGUI_SDK_ClearDisplay; - g_stDeviceInterface.fnSyncBuffer = SGUI_SDK_RefreshDisplay; + /* Initialize display size. */ + g_stDeviceInterface.stSize.iWidth = 128; + g_stDeviceInterface.stSize.iHeight = 64; + /* Initialize interface object. */ + g_stDeviceInterface.fnSetPixel = SGUI_SDK_SetPixel; + g_stDeviceInterface.fnGetPixel = SGUI_SDK_GetPixel; + g_stDeviceInterface.fnClear = SGUI_SDK_ClearDisplay; + g_stDeviceInterface.fnSyncBuffer = SGUI_SDK_RefreshDisplay; #else - /* Initialize display size. */ - g_stDeviceInterface.stSize.iWidth = 128; - g_stDeviceInterface.stSize.iHeight = 64; - /* Initialize interface object. */ - g_stDeviceInterface.fnSetPixel = OLED_SetPixel; - g_stDeviceInterface.fnGetPixel = OLED_GetPixel; - g_stDeviceInterface.fnClear = OLED_ClearDisplay; - g_stDeviceInterface.fnSyncBuffer = OLED_RefreshScreen; + /* Initialize display size. */ + g_stDeviceInterface.stSize.iWidth = 128; + g_stDeviceInterface.stSize.iHeight = 64; + /* Initialize interface object. */ + g_stDeviceInterface.fnSetPixel = OLED_SetPixel; + g_stDeviceInterface.fnGetPixel = OLED_GetPixel; + g_stDeviceInterface.fnClear = OLED_ClearDisplay; + g_stDeviceInterface.fnSyncBuffer = OLED_RefreshScreen; #endif - do - { - /* Prepare HMI engine object. */ - g_stDemoEngine.ScreenCount = sizeof(g_arrpstScreenObjs)/sizeof(*g_arrpstScreenObjs); - g_stDemoEngine.ScreenObjPtr = g_arrpstScreenObjs; - g_stDemoEngine.Interface = &g_stDeviceInterface; - - /* Initialize all screen object. */ - if(NULL != g_stDemoEngine.ScreenObjPtr) - { - for(iIndex=0; iIndexpstActions) - && (NULL != g_stDemoEngine.ScreenObjPtr[iIndex]->pstActions->Initialize) - ) - { - g_stDemoEngine.ScreenObjPtr[iIndex]->pstActions->Initialize(&g_stDeviceInterface); - g_stDemoEngine.ScreenObjPtr[iIndex]->pstPrevious = NULL; - } - } - } - else - { - - } - /* Active engine object. */ - eProcessResult = HMI_ActiveEngine(&g_stDemoEngine, HMI_SCREEN_ID_DEMO_LIST); - //eProcessResult = HMI_ActiveEngine(&g_stDemoEngine, HMI_SCREEN_ID_DEMO_ITEMS_BASE); - if(HMI_PROCESS_FAILED(eProcessResult)) - { - /* Active engine failed. */ - break; - } - /* Start engine process. */ - eProcessResult = HMI_StartEngine(NULL); - if(HMI_PROCESS_FAILED(eProcessResult)) - { - /* Start engine failed. */ - break; - } - }while(0); - - return eProcessResult; + do + { + /* Prepare HMI engine object. */ + g_stDemoEngine.ScreenCount = sizeof(g_arrpstScreenObjs)/sizeof(*g_arrpstScreenObjs); + g_stDemoEngine.ScreenObjPtr = g_arrpstScreenObjs; + g_stDemoEngine.Interface = &g_stDeviceInterface; + + /* Initialize all screen object. */ + if(NULL != g_stDemoEngine.ScreenObjPtr) + { + for(iIndex=0; iIndexpstActions) + && (NULL != g_stDemoEngine.ScreenObjPtr[iIndex]->pstActions->Initialize) + ) + { + g_stDemoEngine.ScreenObjPtr[iIndex]->pstActions->Initialize(&g_stDeviceInterface); + g_stDemoEngine.ScreenObjPtr[iIndex]->pstPrevious = NULL; + } + } + } + else + { + + } + /* Active engine object. */ + eProcessResult = HMI_ActiveEngine(&g_stDemoEngine, HMI_SCREEN_ID_DEMO_LIST); + //eProcessResult = HMI_ActiveEngine(&g_stDemoEngine, HMI_SCREEN_ID_DEMO_ITEMS_BASE); + if(HMI_PROCESS_FAILED(eProcessResult)) + { + /* Active engine failed. */ + break; + } + /* Start engine process. */ + eProcessResult = HMI_StartEngine(NULL); + if(HMI_PROCESS_FAILED(eProcessResult)) + { + /* Start engine failed. */ + break; + } + }while(0); + + return eProcessResult; } #ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ /*****************************************************************************/ -/** Function Name: CheckEventFlag **/ -/** Purpose: Check SimpleGUI virtual SDK event trigger flag and **/ -/** reset for next trigger and check. **/ -/** Parameters: **/ -/** @ eIndex[in]: Checked flag index. **/ -/** Return: true for event is trigger, false for not. **/ -/** Notice: This function only used in SimpleGUI virtual SDK **/ +/** Function Name: CheckEventFlag **/ +/** Purpose: Check SimpleGUI virtual SDK event trigger flag and **/ +/** reset for next trigger and check. **/ +/** Parameters: **/ +/** @ eIndex[in]: Checked flag index. **/ +/** Return: true for event is trigger, false for not. **/ +/** Notice: This function only used in SimpleGUI virtual SDK **/ /*****************************************************************************/ bool CheckEventFlag(ENV_FLAG_INDEX eIndex) { - /*----------------------------------*/ - /* Variable Declaration */ /*----------------------------------*/ - bool bReturn; + /* Variable Declaration */ + /*----------------------------------*/ + bool bReturn; - /*----------------------------------*/ - /* Process */ /*----------------------------------*/ - bReturn = SGUI_SDK_GetEventSyncFlag(eIndex); + /* Process */ + /*----------------------------------*/ + bReturn = SGUI_SDK_GetEventSyncFlag(eIndex); if(true == bReturn) - { - SGUI_SDK_SetEvnetSyncFlag(eIndex, false); - } + { + SGUI_SDK_SetEvnetSyncFlag(eIndex, false); + } - return bReturn; + return bReturn; } #endif // _SIMPLE_GUI_VIRTUAL_ENVIRONMENT_SIMULATOR_ /*****************************************************************************/ -/** Function Name: DemoMainProcess **/ -/** Purpose: It is a dummy main function for SimpleGUI Virtual SDK, **/ -/** or run demo process in demo process. **/ -/** Parameters: None. **/ -/** Return: Terminal code, seam as main function return code. **/ -/** Notice: None. **/ +/** Function Name: DemoMainProcess **/ +/** Purpose: It is a dummy main function for SimpleGUI Virtual SDK, **/ +/** or run demo process in demo process. **/ +/** Parameters: None. **/ +/** Return: Terminal code, seam as main function return code. **/ +/** Notice: None. **/ /*****************************************************************************/ void DemoMainProcess(void) { - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ // Initialize HMI Engine. InitializeHMIEngineObj(); /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ while(1) { // Check and process heart-beat timer event. if(true == SysTickTimerTriggered()) { - SysTickTimerEventProc(); + SysTickTimerEventProc(); } // Check and process key press event. if(true == UserEventTriggered()) @@ -219,235 +219,235 @@ void DemoMainProcess(void) } /*****************************************************************************/ -/** Function Name: KeyPressEventProc **/ -/** Purpose: Deal with user key process in demo process. **/ -/** Parameters: None. **/ -/** Return: None. **/ -/** Notice: The button is just abstract, and the message may come **/ -/** from a touch screen, a serial port, and so on. **/ +/** Function Name: KeyPressEventProc **/ +/** Purpose: Deal with user key process in demo process. **/ +/** Parameters: None. **/ +/** Return: None. **/ +/** Notice: The button is just abstract, and the message may come **/ +/** from a touch screen, a serial port, and so on. **/ /*****************************************************************************/ void KeyPressEventProc(void) { - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - KEY_PRESS_EVENT stEvent; - - /*----------------------------------*/ - /* Initialize */ - /*----------------------------------*/ - HMI_EVENT_INIT(stEvent); - - /*----------------------------------*/ - /* Process */ - /*----------------------------------*/ - stEvent.Head.iType = EVENT_TYPE_ACTION; - stEvent.Head.iID = EVENT_ID_KEY_PRESS; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + KEY_PRESS_EVENT stEvent; + + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + HMI_EVENT_INIT(stEvent); + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + stEvent.Head.iType = EVENT_TYPE_ACTION; + stEvent.Head.iID = EVENT_ID_KEY_PRESS; #ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ - stEvent.Data.uiKeyValue = SGUI_SDK_GetKeyEventData(); + stEvent.Data.uiKeyValue = SGUI_SDK_GetKeyEventData(); #else - stEvent.Data.uiKeyValue = s_uiKeyValue; + stEvent.Data.uiKeyValue = s_uiKeyValue; #endif - // Post key press event. - HMI_ProcessEvent((HMI_EVENT_BASE*)(&stEvent)); + // Post key press event. + HMI_ProcessEvent((HMI_EVENT_BASE*)(&stEvent)); } /*****************************************************************************/ -/** Function Name: SysTickTimerEventProc **/ -/** Purpose: Deal with heartbeat timer event in demo process. **/ -/** Parameters: None. **/ -/** Return: None. **/ -/** Notice: It is usually used to simulate ADC or other sensors. **/ +/** Function Name: SysTickTimerEventProc **/ +/** Purpose: Deal with heartbeat timer event in demo process. **/ +/** Parameters: None. **/ +/** Return: None. **/ +/** Notice: It is usually used to simulate ADC or other sensors. **/ /*****************************************************************************/ void SysTickTimerEventProc(void) { /*----------------------------------*/ - /* Variable Declaration */ + /* Variable Declaration */ /*----------------------------------*/ - DATA_EVENT stEvent; + DATA_EVENT stEvent; /*----------------------------------*/ - /* Initialize */ + /* Initialize */ /*----------------------------------*/ HMI_EVENT_INIT(stEvent); /*----------------------------------*/ - /* Process */ + /* Process */ /*----------------------------------*/ - stEvent.Head.iType = EVENT_TYPE_DATA; - stEvent.Head.iID = EVENT_ID_TIMER; + stEvent.Head.iType = EVENT_TYPE_DATA; + stEvent.Head.iID = EVENT_ID_TIMER; stEvent.Data.iValue = (rand() % 200)-100; // Post timer event. HMI_ProcessEvent((HMI_EVENT_BASE*)&stEvent); } /*****************************************************************************/ -/** Function Name: RTCEventProc **/ -/** Purpose: Deal with RTC timer event in demo process. **/ -/** Parameters: None. **/ -/** Return: None. **/ -/** Notice: It is usually used to simulate ADC or other sensors. **/ +/** Function Name: RTCEventProc **/ +/** Purpose: Deal with RTC timer event in demo process. **/ +/** Parameters: None. **/ +/** Return: None. **/ +/** Notice: It is usually used to simulate ADC or other sensors. **/ /*****************************************************************************/ void RTCEventProc(void) { /*----------------------------------*/ - /* Variable Declaration */ + /* Variable Declaration */ /*----------------------------------*/ - HMI_GENERAL_EVENT stEvent; + HMI_GENERAL_EVENT stEvent; /*----------------------------------*/ - /* Initialize */ + /* Initialize */ /*----------------------------------*/ HMI_EVENT_INIT(stEvent); /*----------------------------------*/ - /* Process */ + /* Process */ /*----------------------------------*/ - stEvent.Head.iType = EVENT_TYPE_DATA; - stEvent.Head.iID = EVENT_ID_RTC; + stEvent.Head.iType = EVENT_TYPE_DATA; + stEvent.Head.iID = EVENT_ID_RTC; // Post RTC update message to a screen. HMI_ProcessEvent((HMI_EVENT_BASE*)&stEvent); } /*****************************************************************************/ -/** Function Name: SysTickTimerTriggered **/ -/** Purpose: Check sys-tick timer interrupt is triggered. **/ -/** Parameters: None. **/ -/** Return: None. **/ -/** Notice: None. **/ +/** Function Name: SysTickTimerTriggered **/ +/** Purpose: Check sys-tick timer interrupt is triggered. **/ +/** Parameters: None. **/ +/** Return: None. **/ +/** Notice: None. **/ /*****************************************************************************/ bool SysTickTimerTriggered(void) { #ifndef _SIMPLE_GUI_IN_VIRTUAL_SDK_ - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - bool bIsTriggered; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + bool bIsTriggered; #endif - /*----------------------------------*/ - /* Process */ + /*----------------------------------*/ + /* Process */ /*----------------------------------*/ #ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ - return CheckEventFlag(ENV_FLAG_IDX_SDK_TIM_EVENT); + return CheckEventFlag(ENV_FLAG_IDX_SDK_TIM_EVENT); #else - // Dummy sys-tick Timer interrupt triggered process. - bIsTriggered = BaseTimerIsTrigger(); - if(true == bIsTriggered) - { - BaseTimerTriggerReset(); - } - - return bIsTriggered; + // Dummy sys-tick Timer interrupt triggered process. + bIsTriggered = BaseTimerIsTrigger(); + if(true == bIsTriggered) + { + BaseTimerTriggerReset(); + } + + return bIsTriggered; #endif } /*****************************************************************************/ -/** Function Name: RTCTimerTriggered **/ -/** Purpose: Check RTC timer interrupt is triggered. **/ -/** Parameters: None. **/ -/** Return: None. **/ -/** Notice: None. **/ +/** Function Name: RTCTimerTriggered **/ +/** Purpose: Check RTC timer interrupt is triggered. **/ +/** Parameters: None. **/ +/** Return: None. **/ +/** Notice: None. **/ /*****************************************************************************/ bool RTCTimerTriggered(void) { #ifndef _SIMPLE_GUI_IN_VIRTUAL_SDK_ - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - bool bIsTriggered; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + bool bIsTriggered; #endif - /*----------------------------------*/ - /* Process */ + /*----------------------------------*/ + /* Process */ /*----------------------------------*/ #ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ - return CheckEventFlag(ENV_FLAG_IDX_SDK_RTC_EVENT); + return CheckEventFlag(ENV_FLAG_IDX_SDK_RTC_EVENT); #else - // RTC interrupt triggered process. - bIsTriggered = RTCTimerIsTrigger(); - if(true == bIsTriggered) - { - RTCTimerTriggerReset(); - } - - return bIsTriggered; + // RTC interrupt triggered process. + bIsTriggered = RTCTimerIsTrigger(); + if(true == bIsTriggered) + { + RTCTimerTriggerReset(); + } + + return bIsTriggered; #endif } /*****************************************************************************/ -/** Function Name: UserEventTriggered **/ -/** Purpose: Check user event is triggered. **/ -/** Parameters: None. **/ -/** Return: None. **/ -/** Notice: None. **/ +/** Function Name: UserEventTriggered **/ +/** Purpose: Check user event is triggered. **/ +/** Parameters: None. **/ +/** Return: None. **/ +/** Notice: None. **/ /*****************************************************************************/ bool UserEventTriggered(void) { #ifndef _SIMPLE_GUI_IN_VIRTUAL_SDK_ - /*----------------------------------*/ - /* Variable Declaration */ - /*----------------------------------*/ - bool bIsTriggered; + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + bool bIsTriggered; #endif - /*----------------------------------*/ - /* Process */ + /*----------------------------------*/ + /* Process */ /*----------------------------------*/ #ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ - return CheckEventFlag(ENV_FLAG_IDX_SDK_KEY_EVENT); + return CheckEventFlag(ENV_FLAG_IDX_SDK_KEY_EVENT); #else - // User event triggered process. - bIsTriggered = UsartIsReceived(); - if(true == bIsTriggered) - { - s_uiKeyValue = GetReceivedCode(); - UsartTriggerReset(); - } - return bIsTriggered; + // User event triggered process. + bIsTriggered = UsartIsReceived(); + if(true == bIsTriggered) + { + s_uiKeyValue = GetReceivedCode(); + UsartTriggerReset(); + } + return bIsTriggered; #endif } /*****************************************************************************/ -/** Function Name: SysTickTimerEnable **/ -/** Purpose: Enable or disable sys-tick timer. **/ -/** Parameters: **/ -/** @ bEnable[in]: True for enable sys-tick timer, false for disable. **/ -/** Return: None. **/ -/** Notice: None. **/ +/** Function Name: SysTickTimerEnable **/ +/** Purpose: Enable or disable sys-tick timer. **/ +/** Parameters: **/ +/** @ bEnable[in]: True for enable sys-tick timer, false for disable. **/ +/** Return: None. **/ +/** Notice: None. **/ /*****************************************************************************/ void SysTickTimerEnable(bool bEnable) { - /*----------------------------------*/ - /* Process */ + /*----------------------------------*/ + /* Process */ /*----------------------------------*/ #ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ - (void)SGUI_SDK_ConfigHearBeatTimer(bEnable?DEMO_HEART_BEAT_INTERVAL_MS:0); + (void)SGUI_SDK_ConfigHearBeatTimer(bEnable?DEMO_HEART_BEAT_INTERVAL_MS:0); #else - // Add Dummy sys-tick timer interrupt enable change operation here. - BASE_TIMER_ActiveInterrupt(TIM3, bEnable); + // Add Dummy sys-tick timer interrupt enable change operation here. + BASE_TIMER_ActiveInterrupt(TIM3, bEnable); #endif } /*****************************************************************************/ -/** Function Name: RTCTimerEnable **/ -/** Purpose: Enable or disable RTC timer. **/ -/** Parameters: **/ -/** @ bEnable[in]: True for enable RTC timer, false for disable. **/ -/** Return: None. **/ -/** Notice: None. **/ +/** Function Name: RTCTimerEnable **/ +/** Purpose: Enable or disable RTC timer. **/ +/** Parameters: **/ +/** @ bEnable[in]: True for enable RTC timer, false for disable. **/ +/** Return: None. **/ +/** Notice: None. **/ /*****************************************************************************/ void RTCTimerEnable(bool bEnable) { - /*----------------------------------*/ - /* Process */ + /*----------------------------------*/ + /* Process */ /*----------------------------------*/ #ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_ - (void)SGUI_SDK_EnableRTCInterrupt(bEnable); + (void)SGUI_SDK_EnableRTCInterrupt(bEnable); #else - // Add RTC interrupt enable change operation here. - RTC_WaitForSynchro(); - RTC_ITConfig(RTC_IT_SEC, bEnable?ENABLE:DISABLE); - RTC_WaitForLastTask(); + // Add RTC interrupt enable change operation here. + RTC_WaitForSynchro(); + RTC_ITConfig(RTC_IT_SEC, bEnable?ENABLE:DISABLE); + RTC_WaitForLastTask(); #endif } diff --git a/Transplant/MiniDevCore/User/src/init.c b/Transplant/MiniDevCore/User/src/init.c index ac4ba39057308efe3ebeaaa8bd9f520cba801834..df156b7bb3e9d89f7198d99b12b59a085f694c93 100644 --- a/Transplant/MiniDevCore/User/src/init.c +++ b/Transplant/MiniDevCore/User/src/init.c @@ -2,23 +2,23 @@ void BSP_Initialize(void) { - /* Initialize usart 1 for stdio. */ - USART_Stdio_Initialize(115200); - USART1_ConfigReceiveInterrupt(USARTReceiveProc, 2, 2); - USART_ActiveInterrupt(USART1, true); - printf("Stand IO initialized.\r\n"); + /* Initialize usart 1 for stdio. */ + USART_Stdio_Initialize(115200); + USART1_ConfigReceiveInterrupt(USARTReceiveProc, 2, 2); + USART_ActiveInterrupt(USART1, true); + printf("Stand IO initialized.\r\n"); - RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE); - BASE_TIMER_Initialize(TIM3, 499, 7199); - TIM3_ConfigReceiveInterrupt(TimerInterruptProc, 2, 1); - BASE_TIMER_ActiveInterrupt(TIM3, true); - printf("General timer initialized.\r\n"); - - RTC_Initialize(); - RTC_ConfigReceiveInterrupt(RTCInterruptProc, 0, 0); - printf("RTC timer initialized.\r\n"); - - SCREEN_Initialize(); - SCREEN_ClearDisplay(); - printf("Screen device initialized.\r\n"); + RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE); + BASE_TIMER_Initialize(TIM3, 499, 7199); + TIM3_ConfigReceiveInterrupt(TimerInterruptProc, 2, 1); + BASE_TIMER_ActiveInterrupt(TIM3, true); + printf("General timer initialized.\r\n"); + + RTC_Initialize(); + RTC_ConfigReceiveInterrupt(RTCInterruptProc, 0, 0); + printf("RTC timer initialized.\r\n"); + + SCREEN_Initialize(); + SCREEN_ClearDisplay(); + printf("Screen device initialized.\r\n"); }