2017-05-31 12:35:32 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/** Copyright. **/
|
|
|
|
/** FileName: HMI_Data.c **/
|
|
|
|
/** Author: Polarix **/
|
|
|
|
/** Version: 1.0.0.0 **/
|
|
|
|
/** Description: User operation interface. **/
|
|
|
|
/** History: **/
|
|
|
|
/** XuyYulin 2017/2/27 2.0.0.0 New create. **/
|
|
|
|
/** XuYulin 2017/2/27 1.0 build this moudle **/
|
|
|
|
/*************************************************************************/
|
|
|
|
//=======================================================================//
|
|
|
|
//= Include files. =//
|
|
|
|
//=======================================================================//
|
|
|
|
#include "HMI_Data.h"
|
2017-06-02 12:33:13 +00:00
|
|
|
#include "HMI_Demo01_Text.h"
|
|
|
|
#include "HMI_Demo02_List.h"
|
|
|
|
#include "HMI_Demo03_Notice1.h"
|
|
|
|
#include "HMI_Demo03_Notice2.h"
|
|
|
|
|
|
|
|
|
|
|
|
//=======================================================================//
|
|
|
|
//= User Macro definition. =//
|
|
|
|
//=======================================================================//
|
|
|
|
#define HMI_PRESSED_KEY_MAX (2)
|
|
|
|
|
|
|
|
//=======================================================================//
|
|
|
|
//= Data type definition. =//
|
|
|
|
//=======================================================================//
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
uint16_t Options;
|
|
|
|
uint16_t Keys[HMI_PRESSED_KEY_MAX];
|
|
|
|
}HMI_USER_KEY_ACTION;
|
2017-05-31 12:35:32 +00:00
|
|
|
|
|
|
|
//=======================================================================//
|
|
|
|
//= Static variable declaration. =//
|
|
|
|
//=======================================================================//
|
2017-06-02 12:33:13 +00:00
|
|
|
// Record count of screen.
|
2017-05-31 12:35:32 +00:00
|
|
|
static size_t uiScreenCount;
|
2017-06-02 12:33:13 +00:00
|
|
|
// Record the index of the currently active screen.
|
2017-05-31 12:35:32 +00:00
|
|
|
static size_t uiCurrentScreenIndex;
|
2017-06-02 12:33:13 +00:00
|
|
|
// Record the history of the screen follow-up.
|
2017-05-31 12:35:32 +00:00
|
|
|
static size_t uiScreenFollowUpHistory[HMI_GOBACK_HISTORY_SIZE_MAX];
|
2017-06-02 12:33:13 +00:00
|
|
|
static size_t uiScreenFollowUpHistoryCount;
|
2017-05-31 12:35:32 +00:00
|
|
|
|
|
|
|
static HMI_SCREEN* pstarrScreenDataArray[] = {
|
|
|
|
// Add HMI data here.
|
2017-06-02 12:33:13 +00:00
|
|
|
&g_stHMI_DemoText,
|
2017-05-31 12:35:32 +00:00
|
|
|
&g_stHMI_DemoList,
|
2017-06-02 12:33:13 +00:00
|
|
|
&g_stHMI_DemoRTCNotice,
|
|
|
|
&g_stHMI_DemoTextNotice
|
|
|
|
|
2017-05-31 12:35:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//=======================================================================//
|
|
|
|
//= Function implementation. =//
|
|
|
|
//=======================================================================//
|
|
|
|
/*****************************************************************************/
|
|
|
|
/** Function Name: HMI_ActionMap_Initialize **/
|
|
|
|
/** Purpose: Initialize screen follow-up data. **/
|
|
|
|
/** Resources: Screen data array and count variable. **/
|
|
|
|
/** Parameters: None. **/
|
|
|
|
/** Return: None. **/
|
|
|
|
/** Notice: This function must be called in action map initialize **/
|
|
|
|
/** process. **/
|
|
|
|
/*****************************************************************************/
|
|
|
|
void HMI_ScreenData_Initialize(void)
|
|
|
|
{
|
|
|
|
/*----------------------------------*/
|
|
|
|
/* Variable Declaration */
|
|
|
|
/*----------------------------------*/
|
|
|
|
size_t uiScreenIndex;
|
|
|
|
|
|
|
|
/*----------------------------------*/
|
|
|
|
/* Initialize */
|
|
|
|
/*----------------------------------*/
|
|
|
|
uiCurrentScreenIndex = 0;
|
|
|
|
uiScreenCount = sizeof(pstarrScreenDataArray)/sizeof(HMI_SCREEN*);
|
|
|
|
|
|
|
|
/*----------------------------------*/
|
|
|
|
/* Process */
|
|
|
|
/*----------------------------------*/
|
|
|
|
// Initialize each screen.
|
|
|
|
for(uiScreenIndex=0; uiScreenIndex<uiScreenCount; uiScreenIndex++)
|
|
|
|
{
|
|
|
|
if(NULL != pstarrScreenDataArray[uiScreenIndex])
|
|
|
|
{
|
2017-06-02 12:33:13 +00:00
|
|
|
pstarrScreenDataArray[uiScreenIndex]->ScreenID = uiScreenIndex;
|
|
|
|
if(NULL != pstarrScreenDataArray[uiScreenIndex]->Actions->Initialize)
|
2017-05-31 12:35:32 +00:00
|
|
|
{
|
|
|
|
// Run initialize process if existed.
|
2017-06-02 12:33:13 +00:00
|
|
|
pstarrScreenDataArray[uiScreenIndex]->Actions->Initialize();
|
2017-05-31 12:35:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-02 12:33:13 +00:00
|
|
|
uiScreenFollowUpHistoryCount = 0;
|
2017-05-31 12:35:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/** Function Name: Set current active screen data pointer. **/
|
|
|
|
/** Purpose: Set static screen data pointer to a new data structure. **/
|
|
|
|
/** Resources: Static global screen data pointer. **/
|
|
|
|
/** Parameters: **/
|
|
|
|
/** @uiScreenIndex: Screen data will be set. **/
|
|
|
|
/** Return: None. **/
|
|
|
|
/** Notice: None. **/
|
|
|
|
/*****************************************************************************/
|
|
|
|
void HMI_ScreenData_SetCurrentScreen(size_t uiScreenIndex)
|
|
|
|
{
|
|
|
|
uiCurrentScreenIndex = uiScreenIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/** Function Name: HMI_ScreenData_GetCurrentScreen. **/
|
|
|
|
/** Purpose: Get current screen data structure pointer which in **/
|
|
|
|
/** active. **/
|
|
|
|
/** Resources: Static global screen data pointer. **/
|
|
|
|
/** Parameters: None. **/
|
|
|
|
/** Return: Current in active screen data structure pointer. **/
|
|
|
|
/** Notice: None. **/
|
|
|
|
/*****************************************************************************/
|
|
|
|
HMI_SCREEN* HMI_ScreenData_GetCurrentScreen(void)
|
|
|
|
{
|
|
|
|
/*----------------------------------*/
|
|
|
|
/* Variable Declaration */
|
|
|
|
/*----------------------------------*/
|
|
|
|
HMI_SCREEN* pstCurrentScreen;
|
|
|
|
|
|
|
|
/*----------------------------------*/
|
|
|
|
/* Process */
|
|
|
|
/*----------------------------------*/
|
|
|
|
if(uiCurrentScreenIndex < uiScreenCount)
|
|
|
|
{
|
|
|
|
pstCurrentScreen = pstarrScreenDataArray[uiCurrentScreenIndex];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pstCurrentScreen = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return pstCurrentScreen;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/** Function Name: HMI_ScreenData_AddToHistory. **/
|
|
|
|
/** Purpose: Get current screen data structure pointer which in **/
|
|
|
|
/** active. **/
|
|
|
|
/** Resources: Static global screen data pointer. **/
|
|
|
|
/** Parameters: None. **/
|
|
|
|
/** Return: Current in active screen data structure pointer. **/
|
|
|
|
/** Notice: None. **/
|
|
|
|
/*****************************************************************************/
|
|
|
|
bool HMI_ScreenData_AddToHistory(size_t uiScreenIndex)
|
|
|
|
{
|
|
|
|
bool bProcessResult;
|
|
|
|
|
2017-06-02 12:33:13 +00:00
|
|
|
if(uiScreenFollowUpHistoryCount < HMI_GOBACK_HISTORY_SIZE_MAX)
|
2017-05-31 12:35:32 +00:00
|
|
|
{
|
2017-06-02 12:33:13 +00:00
|
|
|
uiScreenFollowUpHistory[uiScreenFollowUpHistoryCount] = uiScreenIndex;
|
|
|
|
uiScreenFollowUpHistoryCount++;
|
2017-05-31 12:35:32 +00:00
|
|
|
bProcessResult = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bProcessResult = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bProcessResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-06-02 12:33:13 +00:00
|
|
|
/** Function Name: HMI_ScreenData_GetFromHistory. **/
|
2017-05-31 12:35:32 +00:00
|
|
|
/** Purpose: Get current screen data structure pointer which in **/
|
|
|
|
/** active. **/
|
|
|
|
/** Resources: Static global screen data pointer. **/
|
|
|
|
/** Parameters: None. **/
|
|
|
|
/** Return: Current in active screen data structure pointer. **/
|
|
|
|
/** Notice: None. **/
|
|
|
|
/*****************************************************************************/
|
2017-06-02 12:33:13 +00:00
|
|
|
size_t HMI_ScreenData_GetLastHistory(void)
|
2017-05-31 12:35:32 +00:00
|
|
|
{
|
|
|
|
size_t uiScreenID;
|
2017-06-02 12:33:13 +00:00
|
|
|
if(uiScreenFollowUpHistoryCount > 0)
|
2017-05-31 12:35:32 +00:00
|
|
|
{
|
2017-06-02 12:33:13 +00:00
|
|
|
uiScreenFollowUpHistoryCount--;
|
|
|
|
uiScreenID = uiScreenFollowUpHistory[uiScreenFollowUpHistoryCount];
|
2017-05-31 12:35:32 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-06-02 12:33:13 +00:00
|
|
|
uiScreenID = HMI_SCREEN_START;
|
2017-05-31 12:35:32 +00:00
|
|
|
}
|
|
|
|
return uiScreenID;
|
|
|
|
}
|
|
|
|
|
2017-06-02 12:33:13 +00:00
|
|
|
void HMI_ScreenData_Memcpy(void* pDest, const void* pSrc, size_t uiSize)
|
|
|
|
{
|
|
|
|
memcpy(pDest, pSrc, uiSize);
|
|
|
|
}
|
2017-05-31 12:35:32 +00:00
|
|
|
|