diff --git a/DemoProc/src/RealtimeGraph.c b/DemoProc/src/RealtimeGraph.c index 415a4b9..77997cc 100644 --- a/DemoProc/src/RealtimeGraph.c +++ b/DemoProc/src/RealtimeGraph.c @@ -70,7 +70,6 @@ HMI_ENGINE_RESULT HMI_DemoRealGraph_ProcessEvent(HMI_EVENT_TYPE eEventType, cons HMI_ENGINE_RESULT eProcessResult; SGUI_INT iNewValue; SGUI_UINT16* parrKeyValue; - static SGUI_UINT uiTimer = 3; /*----------------------------------*/ /* Initialize */ @@ -101,17 +100,9 @@ HMI_ENGINE_RESULT HMI_DemoRealGraph_ProcessEvent(HMI_EVENT_TYPE eEventType, cons } case HMI_ENGINE_ACTION_ON_TIMER: { - if(uiTimer > 0) - { - uiTimer--; - } - else - { - uiTimer = 5; - iNewValue = *((SGUI_INT*)pstEvent->Data); - SGUI_RealtimeGraph_AppendValue(&s_stRealtimeGraph, iNewValue); - HMI_DemoRealGraph_RefreshScreen(NULL); - } + iNewValue = *((SGUI_INT*)pstEvent->Data); + SGUI_RealtimeGraph_AppendValue(&s_stRealtimeGraph, iNewValue); + HMI_DemoRealGraph_RefreshScreen(NULL); break; } default: diff --git a/DemoProc/src/ScrollingText.c b/DemoProc/src/ScrollingText.c index 51a2265..439ef6b 100644 --- a/DemoProc/src/ScrollingText.c +++ b/DemoProc/src/ScrollingText.c @@ -133,7 +133,6 @@ HMI_ENGINE_RESULT HMI_DemoScrollingText_ProcessEvent(HMI_EVENT_TYPE eEventType, /* Variable Declaration */ /*----------------------------------*/ HMI_ENGINE_RESULT eProcessResult; - static SGUI_UINT uiTimer = 1; SGUI_UINT16* parrKeyValue; /*----------------------------------*/ @@ -164,24 +163,16 @@ HMI_ENGINE_RESULT HMI_DemoScrollingText_ProcessEvent(HMI_EVENT_TYPE eEventType, break; } case HMI_ENGINE_ACTION_ON_TIMER: - { - if(uiTimer > 0) + { + //SGUI_Frame_DrawFullScreenFrame(&s_stTextFrame); + SGUI_Text_DrawMultipleLinesText(s_szDemoText, SGUI_FONT_SIZE_H12, &s_stTextDisplayArea, s_iTextOffset, SGUI_DRAW_NORMAL); + if(s_iTextOffset + s_iTextHeight == 0) { - uiTimer--; + s_iTextOffset = HMI_TEXT_DEMO_FRAME_TEXT_HEIGHT; } else - { - SGUI_Frame_DrawFullScreenFrame(&s_stTextFrame); - SGUI_Text_DrawMultipleLinesText(s_szDemoText, SGUI_FONT_SIZE_H12, &s_stTextDisplayArea, s_iTextOffset, SGUI_DRAW_NORMAL); - if(s_iTextOffset + s_iTextHeight == 0) - { - s_iTextOffset = HMI_TEXT_DEMO_FRAME_TEXT_HEIGHT; - } - else - { - s_iTextOffset--; - } - uiTimer = 1; + { + s_iTextOffset--; } eProcessResult = HMI_RET_NOACTION; break; diff --git a/DemoProject/STM32F1/System/inc/UsartKey.h b/DemoProject/STM32F1/Demo/inc/DemoActions.h similarity index 58% rename from DemoProject/STM32F1/System/inc/UsartKey.h rename to DemoProject/STM32F1/Demo/inc/DemoActions.h index bc58c0b..ba6e2df 100644 --- a/DemoProject/STM32F1/System/inc/UsartKey.h +++ b/DemoProject/STM32F1/Demo/inc/DemoActions.h @@ -1,20 +1,26 @@ -#ifndef __INCLUDE_USART_KEY_H__ -#define __INCLUDE_USART_KEY_H__ +#ifndef __INCLUDE_DEMOACTIONS_H__ +#define __INCLUDE_DEMOACTIONS_H__ -// Key value definition. -#define KEY_VALUE_TAB (0x01) -#define KEY_VALUE_ENTER (0x02) -#define KEY_VALUE_ESC (0x03) -#define KEY_VALUE_SPACE (0x04) -#define KEY_VALUE_LEFT (0x05) -#define KEY_VALUE_UP (0x06) -#define KEY_VALUE_RIGHT (0x07) -#define KEY_VALUE_DOWN (0x08) - -// User option flag value define -#define KEY_OPTION_NONE (0x00) -#define KEY_OPTION_CTRL (0x10) -#define KEY_OPTION_ALT (0x20) +#include + +#define KEY_NONE (0x00) +// Key value definition. +#define KEY_VALUE_TAB (0x01) +#define KEY_VALUE_ENTER (0x02) +#define KEY_VALUE_ESC (0x03) +#define KEY_VALUE_SPACE (0x04) +#define KEY_VALUE_LEFT (0x05) +#define KEY_VALUE_UP (0x06) +#define KEY_VALUE_RIGHT (0x07) +#define KEY_VALUE_DOWN (0x08) + +// User option flag value define +#define KEY_OPTION_CTRL (0x10) +#define KEY_OPTION_ALT (0x20) #define KEY_OPTION_SHIFT (0x40) -#endif /* __INCLUDE_USART_KEY_H__ */ +void DemoAction_InitializeUsart1(void); +void DemoAction_TimerEvent(void); +void DemoAction_UsartReceiveEvent(uint8_t cbReceiveByte); + +#endif /* __INCLUDE_DEMOACTIONS_H__ */ diff --git a/DemoProject/STM32F1/Demo/inc/DemoResource_GB2312.h b/DemoProject/STM32F1/Demo/inc/DemoResource_GB2312.h index ca2fd25..49b1f4e 100644 --- a/DemoProject/STM32F1/Demo/inc/DemoResource_GB2312.h +++ b/DemoProject/STM32F1/Demo/inc/DemoResource_GB2312.h @@ -8,7 +8,7 @@ 使用方法以及运作机理,在演示过程中,您可以通过串口发送特定字节模拟键盘\ 输入与SimpleGUI演示工程进行交互,以实现与模拟器中类似的效果。每字节高\ 四位为控制键码,低四位为主键码。\n\ - 使用串口发送0x02开始演示,串口配置为115200/N/8/1。"\ + 使用串口发送0x04开始演示,串口配置为115200/N/8/1。"\ ) /* Screen 2: List*/ diff --git a/DemoProject/STM32F1/Demo/src/DemoActions.c b/DemoProject/STM32F1/Demo/src/DemoActions.c new file mode 100644 index 0000000..1f4672c --- /dev/null +++ b/DemoProject/STM32F1/Demo/src/DemoActions.c @@ -0,0 +1,99 @@ +#include "stm32f10x_usart.h" +#include "stm32f10x_rcc.h" +#include "DemoActions.h" +#include "DemoProc.h" +#include "HMI_Engine.h" +#include "SGUI_Basic.h" +#include "GPIO.h" +#include "Usart.h" + +SGUI_INT s_GraphDemoData[72] = { +// 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, + 4, 9, 13, 17, 21, 25, 29, 32, 35, 38, 41, 43, 45, 47, 48, 49, 50, 50, + +// 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180, + 50, 49, 48, 47, 45, 43, 41, 38, 35, 32, 29, 25, 21, 17, 13, 9, 4, 0, + +// 185, 190, 195, 200, 205, 210, 215, 220, 225, 230, 235, 240, 245, 250, 255, 260, 265, 270, + -4, -9, -13, -17, -21, -25, -29, -32, -35, -38, -41, -43, -45, -47, -48, -49, -50, -50, + +// 275, 280, 285, 290, 295, 300, 305, 310, 315, 320, 325, 330, 335, 340, 345, 350, 355, 360, + -50, -49, -48, -47, -45, -43, -41, -38, -35, -32, -29, -25, -21, -17, -13, -9, -4, 0 +}; + +GPIO_OBJECT_STRUCT astUSART1GPIO[] = +{ + {RCC_APB2Periph_GPIOA, GPIOA, GPIO_Pin_9, GPIO_Mode_AF_PP, GPIO_Speed_2MHz, GPIO_STATE_HIGH}, + {RCC_APB2Periph_GPIOA, GPIOA, GPIO_Pin_10, GPIO_Mode_IN_FLOATING, GPIO_Speed_2MHz, GPIO_STATE_HIGH}, +}; + + +void DemoAction_InitializeUsart1(void) +{ + NVIC_InitTypeDef NVIC_InitStructure; + + /* Configure USART1 GPIO */ + GPIO_Initialize(astUSART1GPIO, 2); + + /* Configure Usart1 interrupt. */ + NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=2 ;//鎶㈠崰浼樺厛绾3 + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2; //瀛愪紭鍏堢骇3 + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQ閫氶亾浣胯兘 + NVIC_Init(&NVIC_InitStructure); + + /* Configure USART1 controller */ + RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); //Enable USART device clock. + USART_Config(USART1, 115200, true); //Initialize USART and enable USART interrupt. +} + + +void DemoAction_TimerEvent(void) +{ + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + HMI_EVENT stEvent; + static SGUI_INT iDemoGraphDataIndex = 0; + + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + stEvent.Action = HMI_ENGINE_ACTION_ON_TIMER; + stEvent.Data = NULL; + + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + stEvent.Data = (SGUI_BYTE*)(&s_GraphDemoData[iDemoGraphDataIndex]); + iDemoGraphDataIndex++; + iDemoGraphDataIndex = iDemoGraphDataIndex % 72; + // Post timer event. + EventProcess(HMI_ENGINE_EVENT_ACTION, &stEvent); + SGUI_Basic_RefreshDisplay(); +} + +void DemoAction_UsartReceiveEvent(uint8_t cbReceiveByte) +{ + /*----------------------------------*/ + /* Variable Declaration */ + /*----------------------------------*/ + SGUI_UINT16 arruiPressedKey[HMI_EVENT_KEY_VALUE_LENGTH_MAX]; + HMI_EVENT stEvent; + + /*----------------------------------*/ + /* Initialize */ + /*----------------------------------*/ + arruiPressedKey[0] = KEY_NONE; + stEvent.Action = HMI_ENGINE_ACTION_KEY_PRESS; + arruiPressedKey[0] = cbReceiveByte & 0xF0; + arruiPressedKey[1] = cbReceiveByte & 0x0F; + stEvent.Data = (SGUI_BYTE*)arruiPressedKey; + /*----------------------------------*/ + /* Process */ + /*----------------------------------*/ + // Call demo process. + EventProcess(HMI_ENGINE_EVENT_ACTION, &stEvent); + SGUI_Basic_RefreshDisplay(); +} + diff --git a/DemoProject/STM32F1/Projects/EmBitz/Project.ebp b/DemoProject/STM32F1/Projects/EmBitz/Project.ebp index 3df88c5..55bb95f 100644 --- a/DemoProject/STM32F1/Projects/EmBitz/Project.ebp +++ b/DemoProject/STM32F1/Projects/EmBitz/Project.ebp @@ -117,7 +117,11 @@ + + + @@ -238,7 +242,6 @@ - @@ -272,7 +275,6 @@ -