2017-06-05 13:01:34 +00:00
|
|
|
|
/*************************************************************************/
|
2017-05-31 12:35:32 +00:00
|
|
|
|
/** Copyright. **/
|
2017-10-11 10:59:56 +00:00
|
|
|
|
/** FileName: RTCNotice.c **/
|
2017-05-31 12:35:32 +00:00
|
|
|
|
/** Author: Polarix **/
|
|
|
|
|
/** Version: 1.0.0.0 **/
|
2017-06-07 13:50:51 +00:00
|
|
|
|
/** Description: HMI demo for notice box interface and refresh screen. **/
|
2017-05-31 12:35:32 +00:00
|
|
|
|
/*************************************************************************/
|
|
|
|
|
//=======================================================================//
|
|
|
|
|
//= Include files. =//
|
|
|
|
|
//=======================================================================//
|
2017-10-08 16:03:05 +00:00
|
|
|
|
#include "DemoProc.h"
|
|
|
|
|
#include "HMI_Engine.h"
|
2017-08-02 14:24:26 +00:00
|
|
|
|
#include "SGUI_Notice.h"
|
|
|
|
|
#include "SGUI_Common.h"
|
2017-10-11 10:59:56 +00:00
|
|
|
|
|
|
|
|
|
//=======================================================================//
|
|
|
|
|
//= User Macro definition. =//
|
|
|
|
|
//=======================================================================//
|
|
|
|
|
#define NOTICE_RTC_BUFFER_SIZE (64)
|
2017-05-31 12:35:32 +00:00
|
|
|
|
|
|
|
|
|
//=======================================================================//
|
|
|
|
|
//= Static function declaration. =//
|
|
|
|
|
//=======================================================================//
|
2019-01-11 14:03:38 +00:00
|
|
|
|
static HMI_ENGINE_RESULT HMI_DemoRTCNotice_Prepare(SGUI_SCR_DEV* pstIFObj, const void* pstParameters);
|
|
|
|
|
static HMI_ENGINE_RESULT HMI_DemoRTCNotice_RefreshScreen(SGUI_SCR_DEV* pstIFObj, const void* pstParameters);
|
2019-03-06 13:44:21 +00:00
|
|
|
|
static HMI_ENGINE_RESULT HMI_DemoRTCNotice_ProcessEvent(SGUI_SCR_DEV* pstIFObj, const HMI_EVENT_BASE* pstEvent, SGUI_INT* piActionID);
|
|
|
|
|
static HMI_ENGINE_RESULT HMI_DemoRTCNotice_PostProcess(SGUI_SCR_DEV* pstIFObj, HMI_ENGINE_RESULT eProcResult, SGUI_INT iActionID);
|
2017-05-31 12:35:32 +00:00
|
|
|
|
|
|
|
|
|
//=======================================================================//
|
|
|
|
|
//= Static variable declaration. =//
|
|
|
|
|
//=======================================================================//
|
2017-10-11 10:59:56 +00:00
|
|
|
|
static char s_szRTCNoticeText[NOTICE_RTC_BUFFER_SIZE+1] = {0x00};
|
2019-03-06 13:44:21 +00:00
|
|
|
|
HMI_SCREEN_ACTION s_stDemoRTCNoticeActions = { NULL,
|
2017-10-11 10:59:56 +00:00
|
|
|
|
HMI_DemoRTCNotice_Prepare,
|
|
|
|
|
HMI_DemoRTCNotice_RefreshScreen,
|
|
|
|
|
HMI_DemoRTCNotice_ProcessEvent,
|
|
|
|
|
HMI_DemoRTCNotice_PostProcess
|
|
|
|
|
};
|
2017-05-31 12:35:32 +00:00
|
|
|
|
//=======================================================================//
|
|
|
|
|
//= Global variable declaration. =//
|
|
|
|
|
//=======================================================================//
|
2017-10-11 10:59:56 +00:00
|
|
|
|
HMI_SCREEN_OBJECT g_stHMIDemo_RTCNotice = { HMI_SCREEN_ID_DEMO_RTC_NOTICE,
|
|
|
|
|
&s_stDemoRTCNoticeActions
|
2017-06-02 12:33:13 +00:00
|
|
|
|
};
|
2017-05-31 12:35:32 +00:00
|
|
|
|
|
|
|
|
|
//=======================================================================//
|
2017-12-27 12:03:30 +00:00
|
|
|
|
//= Function define. =//
|
2017-05-31 12:35:32 +00:00
|
|
|
|
//=======================================================================//
|
2019-01-11 14:03:38 +00:00
|
|
|
|
HMI_ENGINE_RESULT HMI_DemoRTCNotice_Prepare(SGUI_SCR_DEV* pstIFObj, const void* pstParameters)
|
2017-06-07 13:50:51 +00:00
|
|
|
|
{
|
2019-04-30 14:13:12 +00:00
|
|
|
|
RTCTimerEnable(true);
|
2019-03-06 13:44:21 +00:00
|
|
|
|
SGUI_SystemIF_MemorySet(s_szRTCNoticeText, 0x00, sizeof(SGUI_CHAR)*(NOTICE_RTC_BUFFER_SIZE+1));
|
2018-12-11 13:49:24 +00:00
|
|
|
|
HMI_DemoRTCNotice_RefreshScreen(pstIFObj, NULL);
|
2017-10-08 16:03:05 +00:00
|
|
|
|
return HMI_RET_NORMAL;
|
2017-05-31 12:35:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-11 14:03:38 +00:00
|
|
|
|
HMI_ENGINE_RESULT HMI_DemoRTCNotice_RefreshScreen(SGUI_SCR_DEV* pstIFObj, const void* pstParameters)
|
2017-06-02 12:33:13 +00:00
|
|
|
|
{
|
2017-07-31 13:29:09 +00:00
|
|
|
|
/*----------------------------------*/
|
|
|
|
|
/* Variable Declaration */
|
|
|
|
|
/*----------------------------------*/
|
2017-08-02 14:24:26 +00:00
|
|
|
|
SGUI_TIME stRTCTime;
|
2017-07-31 13:29:09 +00:00
|
|
|
|
|
|
|
|
|
/*----------------------------------*/
|
|
|
|
|
/* Process */
|
|
|
|
|
/*----------------------------------*/
|
2019-01-11 14:03:38 +00:00
|
|
|
|
SGUI_SystemIF_GetNowTime(&stRTCTime);
|
2018-01-15 15:46:46 +00:00
|
|
|
|
sprintf(s_szRTCNoticeText, DEMO_RTC_NOTICE_TEXT_FMT,
|
2017-07-31 13:29:09 +00:00
|
|
|
|
stRTCTime.Year, stRTCTime.Month, stRTCTime.Day,
|
|
|
|
|
stRTCTime.Hour, stRTCTime.Minute, stRTCTime.Second);
|
2019-04-30 14:13:12 +00:00
|
|
|
|
SGUI_Notice_Repaint(pstIFObj, s_szRTCNoticeText, SGUI_FONT_SIZE_H12, 0, SGUI_ICON_INFORMATION);
|
2017-10-08 16:03:05 +00:00
|
|
|
|
return HMI_RET_NORMAL;
|
2017-06-02 12:33:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-03-06 13:44:21 +00:00
|
|
|
|
HMI_ENGINE_RESULT HMI_DemoRTCNotice_ProcessEvent(SGUI_SCR_DEV* pstIFObj, const HMI_EVENT_BASE* pstEvent, SGUI_INT* piActionID)
|
2017-05-31 12:35:32 +00:00
|
|
|
|
{
|
|
|
|
|
/*----------------------------------*/
|
|
|
|
|
/* Variable Declaration */
|
|
|
|
|
/*----------------------------------*/
|
2017-10-11 10:59:56 +00:00
|
|
|
|
HMI_ENGINE_RESULT eProcessResult;
|
2019-01-09 12:33:11 +00:00
|
|
|
|
SGUI_TIME stRTCTime;
|
|
|
|
|
SGUI_UINT16 uiKeyValue;
|
2019-03-06 13:44:21 +00:00
|
|
|
|
KEY_PRESS_EVENT* pstKeyEvent;
|
|
|
|
|
SGUI_INT iProcessAction;
|
2017-05-31 12:35:32 +00:00
|
|
|
|
|
|
|
|
|
/*----------------------------------*/
|
|
|
|
|
/* Initialize */
|
|
|
|
|
/*----------------------------------*/
|
2017-10-11 10:59:56 +00:00
|
|
|
|
eProcessResult = HMI_RET_NORMAL;
|
2019-03-06 13:44:21 +00:00
|
|
|
|
iProcessAction = HMI_DEMO_PROC_NO_ACT;
|
2017-05-31 12:35:32 +00:00
|
|
|
|
|
|
|
|
|
/*----------------------------------*/
|
|
|
|
|
/* Process */
|
|
|
|
|
/*----------------------------------*/
|
2017-10-11 10:59:56 +00:00
|
|
|
|
if(NULL != pstEvent)
|
2017-06-02 12:33:13 +00:00
|
|
|
|
{
|
2019-03-06 13:44:21 +00:00
|
|
|
|
if(EVENT_TYPE_ACTION == pstEvent->iType)
|
2017-10-11 10:59:56 +00:00
|
|
|
|
{
|
2019-01-26 15:12:10 +00:00
|
|
|
|
if(EVENT_ID_KEY_PRESS == pstEvent->iID)
|
2017-10-11 10:59:56 +00:00
|
|
|
|
{
|
2019-01-26 15:12:10 +00:00
|
|
|
|
pstKeyEvent = (KEY_PRESS_EVENT*)pstEvent;
|
|
|
|
|
uiKeyValue = KEY_CODE_VALUE(pstKeyEvent->Data.uiKeyValue);
|
2019-01-09 12:33:11 +00:00
|
|
|
|
switch(uiKeyValue)
|
2017-10-11 10:59:56 +00:00
|
|
|
|
{
|
|
|
|
|
case KEY_VALUE_ENTER:
|
|
|
|
|
case KEY_VALUE_ESC:
|
|
|
|
|
{
|
2019-03-06 13:44:21 +00:00
|
|
|
|
iProcessAction = HMI_DEMO_PROC_CANCEL;
|
2017-10-11 10:59:56 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-01-26 15:12:10 +00:00
|
|
|
|
}
|
2019-03-06 13:44:21 +00:00
|
|
|
|
else if(EVENT_TYPE_DATA == pstEvent->iType)
|
2019-01-26 15:12:10 +00:00
|
|
|
|
{
|
|
|
|
|
if(EVENT_ID_RTC == pstEvent->iID)
|
2017-10-11 10:59:56 +00:00
|
|
|
|
{
|
2019-01-11 14:03:38 +00:00
|
|
|
|
SGUI_SystemIF_GetNowTime(&stRTCTime);
|
2019-01-09 12:33:11 +00:00
|
|
|
|
sprintf(s_szRTCNoticeText, DEMO_RTC_NOTICE_TEXT_FMT,
|
|
|
|
|
stRTCTime.Year, stRTCTime.Month, stRTCTime.Day,
|
|
|
|
|
stRTCTime.Hour, stRTCTime.Minute, stRTCTime.Second);
|
2019-04-30 14:13:12 +00:00
|
|
|
|
SGUI_Notice_Repaint(pstIFObj, s_szRTCNoticeText, SGUI_FONT_SIZE_H12, 0, SGUI_ICON_INFORMATION);
|
2017-10-11 10:59:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-06-02 12:33:13 +00:00
|
|
|
|
}
|
2019-03-06 13:44:21 +00:00
|
|
|
|
if(NULL != piActionID)
|
2017-06-02 12:33:13 +00:00
|
|
|
|
{
|
2019-03-06 13:44:21 +00:00
|
|
|
|
*piActionID = iProcessAction;
|
2017-06-02 12:33:13 +00:00
|
|
|
|
}
|
2017-10-11 10:59:56 +00:00
|
|
|
|
|
|
|
|
|
return eProcessResult;
|
2017-05-31 12:35:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-03-06 13:44:21 +00:00
|
|
|
|
HMI_ENGINE_RESULT HMI_DemoRTCNotice_PostProcess(SGUI_SCR_DEV* pstIFObj, HMI_ENGINE_RESULT eProcResult, SGUI_INT iActionID)
|
2017-05-31 12:35:32 +00:00
|
|
|
|
{
|
2019-03-06 13:44:21 +00:00
|
|
|
|
if(HMI_PROCESS_SUCCESSFUL(eProcResult))
|
2017-06-02 12:33:13 +00:00
|
|
|
|
{
|
2019-03-06 13:44:21 +00:00
|
|
|
|
if(HMI_DEMO_PROC_CANCEL == iActionID)
|
|
|
|
|
{
|
2019-04-30 14:13:12 +00:00
|
|
|
|
RTCTimerEnable(false);
|
2019-03-06 13:44:21 +00:00
|
|
|
|
HMI_GoBack(NULL);
|
|
|
|
|
}
|
2017-06-02 12:33:13 +00:00
|
|
|
|
}
|
2019-03-06 13:44:21 +00:00
|
|
|
|
|
2017-10-08 16:03:05 +00:00
|
|
|
|
return HMI_RET_NORMAL;
|
2017-05-31 12:35:32 +00:00
|
|
|
|
}
|
|
|
|
|
|