mirror of
https://gitee.com/Polarix/simplegui.git
synced 2025-06-17 21:47:52 +00:00
1.增加VirtualSDK的灰度显示支持
2.废弃SGUI_COLOR枚举,将SGUI_COLOR_TRANS调整至-1,SGUI_COLOR_FRGCLR弃用,SGUI_COLOR_BKGCLR保留转为宏定义 3.切换SGUI_COLOR为SGUI_INT16,使其能够保存256阶灰度的情况下同时支持负数的透明色 4.修复绘制圆形中的一些问题 5.调整基础绘图中与灰度显示不兼容的部分 6.修改基础绘图示例,增加灰度显示示例
This commit is contained in:
parent
39563bec4b
commit
3030207e10
@ -1,4 +1,4 @@
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/** Copyright. **/
|
||||
/** FileName: RTCNotice.c **/
|
||||
/** Author: Polarix **/
|
||||
@ -65,10 +65,17 @@ HMI_ENGINE_RESULT HMI_DemoBasic_RefreshScreen(SGUI_SCR_DEV* pstDeviceIF, const v
|
||||
/*----------------------------------*/
|
||||
/* Process */
|
||||
/*----------------------------------*/
|
||||
SGUI_Basic_DrawLine(pstDeviceIF, 0, 10, 96, 10, SGUI_COLOR_FRGCLR);
|
||||
SGUI_Basic_DrawRectangle(pstDeviceIF, 5, 5, 50, 50, SGUI_COLOR_FRGCLR, SGUI_COLOR_TRANS);
|
||||
SGUI_Basic_DrawCircle(pstDeviceIF, 32, 32, 20, SGUI_COLOR_FRGCLR, SGUI_COLOR_FRGCLR);
|
||||
SGUI_Basic_DrawCircle(pstDeviceIF, 96, 32, 20, SGUI_COLOR_FRGCLR, SGUI_COLOR_TRANS);
|
||||
SGUI_Basic_DrawRectangle(pstDeviceIF, 5, 16, 40, 40, SGUI_COLOR_FRGCLR, SGUI_COLOR_TRANS);
|
||||
SGUI_Basic_DrawCircle(pstDeviceIF, 30, 30, 12, SGUI_COLOR_FRGCLR, SGUI_COLOR_FRGCLR);
|
||||
SGUI_Basic_DrawCircle(pstDeviceIF, 96, 40, 20, SGUI_COLOR_FRGCLR, SGUI_COLOR_TRANS);
|
||||
|
||||
// GrayScale Demos
|
||||
SGUI_Basic_DrawLine(pstDeviceIF, 0, 2, 50, 2, 0x02);
|
||||
SGUI_Basic_DrawLine(pstDeviceIF, 0, 4, 60, 4, 0x04);
|
||||
SGUI_Basic_DrawLine(pstDeviceIF, 0, 6, 70, 6, 0x06);
|
||||
SGUI_Basic_DrawLine(pstDeviceIF, 0, 8, 80, 8, 0x08);
|
||||
SGUI_Basic_DrawLine(pstDeviceIF, 0, 10, 90, 10, 0x0B);
|
||||
SGUI_Basic_DrawLine(pstDeviceIF, 0, 12, 100, 12, 0x0E);
|
||||
return HMI_RET_NORMAL;
|
||||
}
|
||||
|
||||
|
@ -1,399 +1,401 @@
|
||||
/*************************************************************************/
|
||||
/** Copyright. **/
|
||||
/** FileName: DemoProc.c **/
|
||||
/** Author: Polarix **/
|
||||
/** Description: User operation interface. **/
|
||||
/*************************************************************************/
|
||||
//=======================================================================//
|
||||
//= Include files. =//
|
||||
//=======================================================================//
|
||||
#include "DemoProc.h"
|
||||
|
||||
#ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_
|
||||
#include "SDKInterface.h"
|
||||
#include "SGUI_FontResource.h"
|
||||
#else
|
||||
#include "screen.h"
|
||||
#include "usart.h"
|
||||
#include "rtc.h"
|
||||
#include "base_timer.h"
|
||||
#include "DemoActions.h"
|
||||
#include "trigger_flags.h"
|
||||
#include "keyboard.h"
|
||||
#endif
|
||||
|
||||
//=======================================================================//
|
||||
//= 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;
|
||||
|
||||
//=======================================================================//
|
||||
//= Static function declare. =//
|
||||
//=======================================================================//
|
||||
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);
|
||||
#endif //_SIMPLE_GUI_IN_VIRTUAL_SDK_
|
||||
|
||||
//=======================================================================//
|
||||
//= 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 **/
|
||||
/** 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));
|
||||
#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;
|
||||
#else
|
||||
#error Add screen device object initialize process here.
|
||||
#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; iIndex<g_stDemoEngine.ScreenCount; iIndex++)
|
||||
{
|
||||
if( (NULL != g_stDemoEngine.ScreenObjPtr[iIndex])
|
||||
&& (NULL != g_stDemoEngine.ScreenObjPtr[iIndex]->pstActions)
|
||||
&& (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 **/
|
||||
/*****************************************************************************/
|
||||
bool CheckEventFlag(ENV_FLAG_INDEX eIndex)
|
||||
{
|
||||
/*----------------------------------*/
|
||||
/* Variable Declaration */
|
||||
/*----------------------------------*/
|
||||
bool bReturn;
|
||||
|
||||
/*----------------------------------*/
|
||||
/* Process */
|
||||
/*----------------------------------*/
|
||||
bReturn = SGUI_SDK_GetEventSyncFlag(eIndex);
|
||||
|
||||
if(true == bReturn)
|
||||
{
|
||||
SGUI_SDK_SetEvnetSyncFlag(eIndex, false);
|
||||
}
|
||||
|
||||
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. **/
|
||||
/*****************************************************************************/
|
||||
void DemoMainProcess(void)
|
||||
{
|
||||
/*----------------------------------*/
|
||||
/* Initialize */
|
||||
/*----------------------------------*/
|
||||
// Initialize HMI Engine.
|
||||
InitializeHMIEngineObj();
|
||||
|
||||
/*----------------------------------*/
|
||||
/* Process */
|
||||
/*----------------------------------*/
|
||||
while(1)
|
||||
{
|
||||
// Check and process heart-beat timer event.
|
||||
if(true == SysTickTimerTriggered())
|
||||
{
|
||||
SysTickTimerEventProc();
|
||||
}
|
||||
// Check and process key press event.
|
||||
if(true == UserEventTriggered())
|
||||
{
|
||||
KeyPressEventProc();
|
||||
}
|
||||
// Check and process RTC event.
|
||||
if(true == RTCTimerTriggered())
|
||||
{
|
||||
RTCEventProc();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/** 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;
|
||||
#ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_
|
||||
stEvent.Data.uiKeyValue = SGUI_SDK_GetKeyEventData();
|
||||
#else
|
||||
#error Add key event data prepare process here.
|
||||
#endif
|
||||
// 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. **/
|
||||
/*****************************************************************************/
|
||||
void SysTickTimerEventProc(void)
|
||||
{
|
||||
/*----------------------------------*/
|
||||
/* Variable Declaration */
|
||||
/*----------------------------------*/
|
||||
DATA_EVENT stEvent;
|
||||
|
||||
/*----------------------------------*/
|
||||
/* Initialize */
|
||||
/*----------------------------------*/
|
||||
HMI_EVENT_INIT(stEvent);
|
||||
|
||||
/*----------------------------------*/
|
||||
/* Process */
|
||||
/*----------------------------------*/
|
||||
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. **/
|
||||
/*****************************************************************************/
|
||||
void RTCEventProc(void)
|
||||
{
|
||||
/*----------------------------------*/
|
||||
/* Variable Declaration */
|
||||
/*----------------------------------*/
|
||||
HMI_GENERAL_EVENT stEvent;
|
||||
|
||||
/*----------------------------------*/
|
||||
/* Initialize */
|
||||
/*----------------------------------*/
|
||||
HMI_EVENT_INIT(stEvent);
|
||||
|
||||
/*----------------------------------*/
|
||||
/* Process */
|
||||
/*----------------------------------*/
|
||||
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. **/
|
||||
/*****************************************************************************/
|
||||
bool SysTickTimerTriggered(void)
|
||||
{
|
||||
/*----------------------------------*/
|
||||
/* Process */
|
||||
/*----------------------------------*/
|
||||
#ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_
|
||||
return CheckEventFlag(ENV_FLAG_IDX_SDK_TIM_EVENT);
|
||||
#else
|
||||
#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. **/
|
||||
/*****************************************************************************/
|
||||
bool RTCTimerTriggered(void)
|
||||
{
|
||||
/*----------------------------------*/
|
||||
/* Process */
|
||||
/*----------------------------------*/
|
||||
#ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_
|
||||
return CheckEventFlag(ENV_FLAG_IDX_SDK_RTC_EVENT);
|
||||
#else
|
||||
#error Add RTC timer trigger process here.
|
||||
#endif
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/** Function Name: UserEventTriggered **/
|
||||
/** Purpose: Check user event is triggered. **/
|
||||
/** Parameters: None. **/
|
||||
/** Return: None. **/
|
||||
/** Notice: None. **/
|
||||
/*****************************************************************************/
|
||||
bool UserEventTriggered(void)
|
||||
{
|
||||
/*----------------------------------*/
|
||||
/* Process */
|
||||
/*----------------------------------*/
|
||||
#ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_
|
||||
return CheckEventFlag(ENV_FLAG_IDX_SDK_KEY_EVENT);
|
||||
#else
|
||||
#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. **/
|
||||
/*****************************************************************************/
|
||||
void SysTickTimerEnable(bool bEnable)
|
||||
{
|
||||
/*----------------------------------*/
|
||||
/* Process */
|
||||
/*----------------------------------*/
|
||||
#ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_
|
||||
(void)SGUI_SDK_ConfigHearBeatTimer(bEnable?DEMO_HEART_BEAT_INTERVAL_MS:0);
|
||||
#else
|
||||
#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. **/
|
||||
/*****************************************************************************/
|
||||
void RTCTimerEnable(bool bEnable)
|
||||
{
|
||||
|
||||
/*----------------------------------*/
|
||||
/* Process */
|
||||
/*----------------------------------*/
|
||||
#ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_
|
||||
(void)SGUI_SDK_EnableRTCInterrupt(bEnable);
|
||||
#else
|
||||
#error Add RTC timer enable/disable process here.
|
||||
#endif
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
/** Copyright. **/
|
||||
/** FileName: DemoProc.c **/
|
||||
/** Author: Polarix **/
|
||||
/** Description: User operation interface. **/
|
||||
/*************************************************************************/
|
||||
//=======================================================================//
|
||||
//= Include files. =//
|
||||
//=======================================================================//
|
||||
#include "DemoProc.h"
|
||||
|
||||
#ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_
|
||||
#include "Common.h"
|
||||
#include "SDKInterface.h"
|
||||
#include "SGUI_FontResource.h"
|
||||
#else
|
||||
#include "screen.h"
|
||||
#include "usart.h"
|
||||
#include "rtc.h"
|
||||
#include "base_timer.h"
|
||||
#include "DemoActions.h"
|
||||
#include "trigger_flags.h"
|
||||
#include "keyboard.h"
|
||||
#endif
|
||||
|
||||
//=======================================================================//
|
||||
//= 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;
|
||||
|
||||
//=======================================================================//
|
||||
//= Static function declare. =//
|
||||
//=======================================================================//
|
||||
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);
|
||||
#endif //_SIMPLE_GUI_IN_VIRTUAL_SDK_
|
||||
|
||||
//=======================================================================//
|
||||
//= 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 **/
|
||||
/** 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));
|
||||
#ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_
|
||||
/* Initialize display size. */
|
||||
g_stDeviceInterface.stSize.iWidth = PARAM_DEFAULT_PIXEL_NUM_H;
|
||||
g_stDeviceInterface.stSize.iHeight = PARAM_DEFAULT_PIXEL_NUM_V;
|
||||
g_stDeviceInterface.uiDepthBits = PARAM_DEFAULT_PIXEL_DEPTH;
|
||||
/* 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.
|
||||
#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; iIndex<g_stDemoEngine.ScreenCount; iIndex++)
|
||||
{
|
||||
if( (NULL != g_stDemoEngine.ScreenObjPtr[iIndex])
|
||||
&& (NULL != g_stDemoEngine.ScreenObjPtr[iIndex]->pstActions)
|
||||
&& (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 **/
|
||||
/*****************************************************************************/
|
||||
bool CheckEventFlag(ENV_FLAG_INDEX eIndex)
|
||||
{
|
||||
/*----------------------------------*/
|
||||
/* Variable Declaration */
|
||||
/*----------------------------------*/
|
||||
bool bReturn;
|
||||
|
||||
/*----------------------------------*/
|
||||
/* Process */
|
||||
/*----------------------------------*/
|
||||
bReturn = SGUI_SDK_GetEventSyncFlag(eIndex);
|
||||
|
||||
if(true == bReturn)
|
||||
{
|
||||
SGUI_SDK_SetEvnetSyncFlag(eIndex, false);
|
||||
}
|
||||
|
||||
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. **/
|
||||
/*****************************************************************************/
|
||||
void DemoMainProcess(void)
|
||||
{
|
||||
/*----------------------------------*/
|
||||
/* Initialize */
|
||||
/*----------------------------------*/
|
||||
// Initialize HMI Engine.
|
||||
InitializeHMIEngineObj();
|
||||
|
||||
/*----------------------------------*/
|
||||
/* Process */
|
||||
/*----------------------------------*/
|
||||
while(1)
|
||||
{
|
||||
// Check and process heart-beat timer event.
|
||||
if(true == SysTickTimerTriggered())
|
||||
{
|
||||
SysTickTimerEventProc();
|
||||
}
|
||||
// Check and process key press event.
|
||||
if(true == UserEventTriggered())
|
||||
{
|
||||
KeyPressEventProc();
|
||||
}
|
||||
// Check and process RTC event.
|
||||
if(true == RTCTimerTriggered())
|
||||
{
|
||||
RTCEventProc();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/** 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;
|
||||
#ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_
|
||||
stEvent.Data.uiKeyValue = SGUI_SDK_GetKeyEventData();
|
||||
#else
|
||||
#error Add key event data prepare process here.
|
||||
#endif
|
||||
// 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. **/
|
||||
/*****************************************************************************/
|
||||
void SysTickTimerEventProc(void)
|
||||
{
|
||||
/*----------------------------------*/
|
||||
/* Variable Declaration */
|
||||
/*----------------------------------*/
|
||||
DATA_EVENT stEvent;
|
||||
|
||||
/*----------------------------------*/
|
||||
/* Initialize */
|
||||
/*----------------------------------*/
|
||||
HMI_EVENT_INIT(stEvent);
|
||||
|
||||
/*----------------------------------*/
|
||||
/* Process */
|
||||
/*----------------------------------*/
|
||||
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. **/
|
||||
/*****************************************************************************/
|
||||
void RTCEventProc(void)
|
||||
{
|
||||
/*----------------------------------*/
|
||||
/* Variable Declaration */
|
||||
/*----------------------------------*/
|
||||
HMI_GENERAL_EVENT stEvent;
|
||||
|
||||
/*----------------------------------*/
|
||||
/* Initialize */
|
||||
/*----------------------------------*/
|
||||
HMI_EVENT_INIT(stEvent);
|
||||
|
||||
/*----------------------------------*/
|
||||
/* Process */
|
||||
/*----------------------------------*/
|
||||
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. **/
|
||||
/*****************************************************************************/
|
||||
bool SysTickTimerTriggered(void)
|
||||
{
|
||||
/*----------------------------------*/
|
||||
/* Process */
|
||||
/*----------------------------------*/
|
||||
#ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_
|
||||
return CheckEventFlag(ENV_FLAG_IDX_SDK_TIM_EVENT);
|
||||
#else
|
||||
#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. **/
|
||||
/*****************************************************************************/
|
||||
bool RTCTimerTriggered(void)
|
||||
{
|
||||
/*----------------------------------*/
|
||||
/* Process */
|
||||
/*----------------------------------*/
|
||||
#ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_
|
||||
return CheckEventFlag(ENV_FLAG_IDX_SDK_RTC_EVENT);
|
||||
#else
|
||||
#error Add RTC timer trigger process here.
|
||||
#endif
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/** Function Name: UserEventTriggered **/
|
||||
/** Purpose: Check user event is triggered. **/
|
||||
/** Parameters: None. **/
|
||||
/** Return: None. **/
|
||||
/** Notice: None. **/
|
||||
/*****************************************************************************/
|
||||
bool UserEventTriggered(void)
|
||||
{
|
||||
/*----------------------------------*/
|
||||
/* Process */
|
||||
/*----------------------------------*/
|
||||
#ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_
|
||||
return CheckEventFlag(ENV_FLAG_IDX_SDK_KEY_EVENT);
|
||||
#else
|
||||
#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. **/
|
||||
/*****************************************************************************/
|
||||
void SysTickTimerEnable(bool bEnable)
|
||||
{
|
||||
/*----------------------------------*/
|
||||
/* Process */
|
||||
/*----------------------------------*/
|
||||
#ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_
|
||||
(void)SGUI_SDK_ConfigHearBeatTimer(bEnable?DEMO_HEART_BEAT_INTERVAL_MS:0);
|
||||
#else
|
||||
#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. **/
|
||||
/*****************************************************************************/
|
||||
void RTCTimerEnable(bool bEnable)
|
||||
{
|
||||
|
||||
/*----------------------------------*/
|
||||
/* Process */
|
||||
/*----------------------------------*/
|
||||
#ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_
|
||||
(void)SGUI_SDK_EnableRTCInterrupt(bEnable);
|
||||
#else
|
||||
#error Add RTC timer enable/disable process here.
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -61,6 +61,15 @@ typedef SGUI_UINT32 SGUI_ROM_ADDRESS;
|
||||
#define SGUI_FALSE (0)
|
||||
#define SGUI_TRUE (!SGUI_FALSE)
|
||||
|
||||
#define SGUI_COLOR_TRANS (-1)
|
||||
/******
|
||||
* Deprecated!
|
||||
* Prepared to delete this guy!
|
||||
* DO NOT USE THIS MACRO ANY MORE!
|
||||
*/
|
||||
#define SGUI_COLOR_FRGCLR (0x0A)
|
||||
#define SGUI_COLOR_BKGCLR (0)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SGUI_INT iX;
|
||||
@ -87,12 +96,7 @@ typedef struct
|
||||
SGUI_INT iMax;
|
||||
}SGUI_RANGE;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SGUI_COLOR_BKGCLR = 0,
|
||||
SGUI_COLOR_FRGCLR = 1,
|
||||
SGUI_COLOR_TRANS = 2,
|
||||
}SGUI_COLOR;
|
||||
typedef SGUI_INT16 SGUI_COLOR ;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
@ -127,6 +131,8 @@ typedef struct
|
||||
{
|
||||
//Screen display area size in pixel.
|
||||
SGUI_AREA_SIZE stSize;
|
||||
// Screen display pixel depth in bit count(eg. 4(bits) means 16 grayscale)
|
||||
SGUI_UINT8 uiDepthBits;
|
||||
//Bitmap data buffer.
|
||||
SGUI_BYTE arrBmpDataBuffer[SGUI_BMP_DATA_BUFFER_SIZE];
|
||||
//Engine & device initialize function.
|
||||
|
@ -41,13 +41,9 @@ void SGUI_Basic_DrawPoint(SGUI_SCR_DEV* pstDeviceIF, SGUI_UINT uiCoordinateX, SG
|
||||
{
|
||||
/* Action function is unspecified, no actions. */
|
||||
}
|
||||
else if(SGUI_COLOR_FRGCLR == eColor)
|
||||
else
|
||||
{
|
||||
pstDeviceIF->fnSetPixel(uiCoordinateX, uiCoordinateY, 1);
|
||||
}
|
||||
else if(SGUI_COLOR_BKGCLR == eColor)
|
||||
{
|
||||
pstDeviceIF->fnSetPixel(uiCoordinateX, uiCoordinateY, 0);
|
||||
pstDeviceIF->fnSetPixel(uiCoordinateX,uiCoordinateY,eColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -68,13 +64,11 @@ SGUI_COLOR SGUI_Basic_GetPoint(SGUI_SCR_DEV* pstDeviceIF, SGUI_UINT uiCoordinate
|
||||
/* Variable Declaration */
|
||||
/*----------------------------------*/
|
||||
SGUI_COLOR eColor;
|
||||
SGUI_UINT uiPixValue;
|
||||
|
||||
/*----------------------------------*/
|
||||
/* Initialize */
|
||||
/*----------------------------------*/
|
||||
eColor = SGUI_COLOR_BKGCLR;
|
||||
uiPixValue = 0;
|
||||
|
||||
/*----------------------------------*/
|
||||
/* Process */
|
||||
@ -87,16 +81,8 @@ SGUI_COLOR SGUI_Basic_GetPoint(SGUI_SCR_DEV* pstDeviceIF, SGUI_UINT uiCoordinate
|
||||
}
|
||||
else
|
||||
{
|
||||
uiPixValue = pstDeviceIF->fnGetPixel(uiCoordinateX, uiCoordinateY);
|
||||
if(0 == uiPixValue)
|
||||
{
|
||||
eColor = SGUI_COLOR_BKGCLR;
|
||||
}
|
||||
else
|
||||
{
|
||||
eColor = SGUI_COLOR_FRGCLR;
|
||||
}
|
||||
}
|
||||
eColor = pstDeviceIF->fnGetPixel(uiCoordinateX, uiCoordinateY);
|
||||
}
|
||||
}
|
||||
|
||||
return eColor;
|
||||
@ -440,15 +426,16 @@ void SGUI_Basic_DrawCircle(SGUI_SCR_DEV* pstDeviceIF, SGUI_UINT uiCx, SGUI_UINT
|
||||
// Fill the circle
|
||||
if((uiRadius > 1) && (eFillColor != SGUI_COLOR_TRANS) && (uiPosXOffset_Old != uiPosXOffset))
|
||||
{
|
||||
|
||||
SGUI_Basic_DrawLine(pstDeviceIF, uiCx-uiPosXOffset, uiCy-uiYOffset+1, uiCx-uiPosXOffset, uiCy+uiYOffset-1, eFillColor);
|
||||
SGUI_Basic_DrawLine(pstDeviceIF, uiCx+uiPosXOffset, uiCy-uiYOffset+1, uiCx+uiPosXOffset, uiCy+uiYOffset-1, eFillColor);
|
||||
uiPosXOffset_Old = uiPosXOffset;
|
||||
}
|
||||
SGUI_Basic_DrawLine(pstDeviceIF, uiCx-uiYOffset, uiCy-uiPosXOffset+1, uiCx-uiYOffset, uiCy+uiPosXOffset-1, eFillColor);
|
||||
SGUI_Basic_DrawLine(pstDeviceIF, uiCx+uiYOffset, uiCy-uiPosXOffset+1, uiCx+uiYOffset, uiCy+uiPosXOffset-1, eFillColor);
|
||||
uiYOffset_Old = uiYOffset;
|
||||
|
||||
if ((uiRadius > 1) && (eFillColor != SGUI_COLOR_TRANS) && (uiYOffset_Old != uiYOffset))
|
||||
{
|
||||
SGUI_Basic_DrawLine(pstDeviceIF, uiCx-uiYOffset, uiCy-uiPosXOffset+1, uiCx-uiYOffset, uiCy+uiPosXOffset-1, eFillColor);
|
||||
SGUI_Basic_DrawLine(pstDeviceIF, uiCx+uiYOffset, uiCy-uiPosXOffset+1, uiCx+uiYOffset, uiCy+uiPosXOffset-1, eFillColor);
|
||||
uiYOffset_Old = uiYOffset;
|
||||
}
|
||||
// Draw edge.
|
||||
SGUI_Basic_DrawPoint(pstDeviceIF, uiCx+uiPosXOffset, uiCy+uiYOffset, eEdgeColor);
|
||||
SGUI_Basic_DrawPoint(pstDeviceIF, uiCx-uiPosXOffset, uiCy+uiYOffset, eEdgeColor);
|
||||
@ -490,6 +477,8 @@ void SGUI_Basic_ReverseBlockColor(SGUI_SCR_DEV* pstDeviceIF, SGUI_UINT uiStartX,
|
||||
/* Variable Declaration */
|
||||
/*----------------------------------*/
|
||||
SGUI_UINT i_W, i_H;
|
||||
SGUI_COLOR clsOriginColor;
|
||||
SGUI_UINT16 uiDepthTotal=1<<pstDeviceIF->uiDepthBits;
|
||||
|
||||
/*----------------------------------*/
|
||||
/* Process */
|
||||
@ -498,14 +487,8 @@ void SGUI_Basic_ReverseBlockColor(SGUI_SCR_DEV* pstDeviceIF, SGUI_UINT uiStartX,
|
||||
{
|
||||
for(i_H=0; i_H<uiHeight; i_H++)
|
||||
{
|
||||
if(SGUI_Basic_GetPoint(pstDeviceIF, uiStartX+i_W, uiStartY+i_H) == SGUI_COLOR_FRGCLR)
|
||||
{
|
||||
SGUI_Basic_DrawPoint(pstDeviceIF, uiStartX+i_W, uiStartY+i_H, SGUI_COLOR_BKGCLR);
|
||||
}
|
||||
else
|
||||
{
|
||||
SGUI_Basic_DrawPoint(pstDeviceIF, uiStartX+i_W, uiStartY+i_H, SGUI_COLOR_FRGCLR);
|
||||
}
|
||||
clsOriginColor=SGUI_Basic_GetPoint(pstDeviceIF, uiStartX+i_W, uiStartY+i_H);
|
||||
SGUI_Basic_DrawPoint(pstDeviceIF, uiStartX+i_W, uiStartY+i_H, uiDepthTotal-clsOriginColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
# SimpleGUI
|
||||
# Simple(Gray)GUI
|
||||
|
||||
---
|
||||
|
||||
**注意:当前项目正在经历从单色屏幕到灰度屏支持的变更,可能存在意想不到的Bug,如您需要在项目中使用SimpleGUI,请移步[SimpleGUI](https://gitee.com/Polarix/simplegui)官方仓库!**
|
||||
|
||||
#### 简介
|
||||
SimpleGUI是一款针对单色显示屏设计的GUI接口库。
|
||||
>
|
||||
|
@ -28,12 +28,20 @@
|
||||
#define LCD_COLOR_OBJ_PIX (0xFF258562)
|
||||
#define LCD_COLOR_OBJ_BKG (0xFF2BEEDE)
|
||||
#define LCD_COLOR_OBJ_GRID (0xFF38E3D0)
|
||||
// White LCD
|
||||
/*
|
||||
#define LCD_COLOR_OBJ_PIX (0xFFFFFFFF)
|
||||
#define LCD_COLOR_OBJ_BKG (0x00000000)
|
||||
#define LCD_COLOR_OBJ_GRID (0xFFCC1209)
|
||||
*/
|
||||
|
||||
#define PARAM_DEFAULT_PIXEL_NUM_H (128)
|
||||
#define PARAM_DEFAULT_PIXEL_NUM_V (64)
|
||||
#define PARAM_DEFAULT_PANEL_BORDER_WIDTH (8)
|
||||
#define PARAM_DEFAULT_PIXEL_WIDTH (3)
|
||||
#define PARAM_DEFAULT_PIXEL_HEIGHT (3)
|
||||
#define PARAM_DEFAULT_PIXEL_DEPTH_BITS (4)
|
||||
#define PARAM_DEFAULT_PIXEL_DEPTH (1<<PARAM_DEFAULT_PIXEL_DEPTH_BITS)
|
||||
#define PARAM_DEFAULT_GRID_ENABLE (true)
|
||||
#define PARAM_DEFAULT_GRID_DISABLE (false)
|
||||
|
||||
@ -42,15 +50,16 @@
|
||||
//=======================================================================//
|
||||
typedef struct
|
||||
{
|
||||
size_t HorizontalPixelNumber;
|
||||
size_t HorizontalPixelNumber;
|
||||
size_t VerticalPixelNumber;
|
||||
size_t PixelUnitWidth;
|
||||
size_t PixelUnitHeight;
|
||||
int PixelUnitDepth;
|
||||
size_t BorderWidth;
|
||||
bool EnableGrid;
|
||||
unsigned int PanelColor;
|
||||
unsigned int PixelColor;
|
||||
unsigned int GridColor;
|
||||
unsigned int PanelColor;
|
||||
unsigned int PixelColor;
|
||||
unsigned int GridColor;
|
||||
}PixelPanelParameter;
|
||||
|
||||
//=======================================================================//
|
||||
|
@ -27,5 +27,6 @@ void SetLCDPanelParameter(PixelPanelParameter* pstParameter)
|
||||
pstParameter->PanelColor = LCD_COLOR_OBJ_BKG;
|
||||
pstParameter->PixelColor = LCD_COLOR_OBJ_PIX;
|
||||
pstParameter->GridColor = LCD_COLOR_OBJ_GRID;
|
||||
pstParameter->PixelUnitDepth = PARAM_DEFAULT_PIXEL_DEPTH;
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,8 @@ class wxLCD: public wxLCDBase
|
||||
private:
|
||||
wxColour m_clsPixelHColour;
|
||||
wxColour m_clsPixelLColour;
|
||||
wxColour* m_clsPixelPalette;
|
||||
int m_iPixelDepth;
|
||||
|
||||
protected:
|
||||
|
||||
@ -29,6 +31,7 @@ class wxLCD: public wxLCDBase
|
||||
void CleanScreen(void);
|
||||
void SetPanelColour(const wxColour& clsPanelColour, bool bRefreshNow = true);
|
||||
void SetPixelColour(const wxColour& clsPixelColour, bool bRefreshNow = true);
|
||||
void SetPixelDepth(const int depth);
|
||||
|
||||
// Prepare to remove.
|
||||
void SetParameter(PixelPanelParameter* pstPanelParameter);
|
||||
|
@ -8,7 +8,8 @@
|
||||
//= Include files. =//
|
||||
//=======================================================================//
|
||||
#include "wxLCD.h"
|
||||
|
||||
#include "SGUI_Typedef.h"
|
||||
#include <math.h>
|
||||
//=======================================================================//
|
||||
//= Function define. =//
|
||||
//=======================================================================//
|
||||
@ -17,6 +18,7 @@ wxLCDBase(pclsParent, iWinID, clsPosition, clsSizeInPixel)
|
||||
{
|
||||
m_clsPixelLColour.Set(0x00000000);
|
||||
m_clsPixelHColour.Set(0x00000000);
|
||||
m_clsPixelPalette=NULL;
|
||||
}
|
||||
|
||||
wxLCD::~wxLCD(void)
|
||||
@ -56,32 +58,111 @@ void wxLCD::SetPixelColour(const wxColour& clsPixelColour, bool bRefreshNow)
|
||||
}
|
||||
}
|
||||
|
||||
void wxLCD::SetPixelDepth(const int depth)
|
||||
{
|
||||
this->m_iPixelDepth=depth;
|
||||
if(this->m_clsPixelPalette != NULL)
|
||||
{
|
||||
free(m_clsPixelPalette);
|
||||
m_clsPixelPalette=NULL;
|
||||
}
|
||||
// Generate a scaled Palette bettween the BackgroundColor and PixelColor
|
||||
m_clsPixelPalette = new wxColor[depth];
|
||||
unsigned char ucRH=this->m_clsPixelHColour.Red();
|
||||
unsigned char ucGH=this->m_clsPixelHColour.Green();
|
||||
unsigned char ucBH=this->m_clsPixelHColour.Blue();
|
||||
|
||||
unsigned char ucRL=m_clsPixelLColour.Red();
|
||||
unsigned char ucGL=m_clsPixelLColour.Green();
|
||||
unsigned char ucBL=m_clsPixelLColour.Blue();
|
||||
|
||||
double dbRDiff=(ucRH-ucRL)*1.0/depth;
|
||||
double dbGDiff=(ucGH-ucGL)*1.0/depth;
|
||||
double dbBDiff=(ucBH-ucBL)*1.0/depth;
|
||||
|
||||
double dbR=(int)ucRL*1.0;
|
||||
double dbG=(int)ucGL*1.0;
|
||||
double dbB=(int)ucBL*1.0;
|
||||
|
||||
for(int i=0; i<depth; i++)
|
||||
{
|
||||
dbR+=dbRDiff;
|
||||
dbG+=dbGDiff;
|
||||
dbB+=dbBDiff;
|
||||
m_clsPixelPalette[i]=wxColor((unsigned char)floor(dbR+0.5),(unsigned char)floor(dbG+0.5),(unsigned char)floor(dbB+0.5));
|
||||
}
|
||||
}
|
||||
int wxLCD::GetPixel(const int iX, const int iY)
|
||||
{
|
||||
int iReturn;
|
||||
int iReturn=-1;
|
||||
int iLeft=0;
|
||||
int iRight=m_iPixelDepth-1;
|
||||
int iMid=(iLeft+iRight)/2;
|
||||
wxColor clsLeftColor,clsRightColor;
|
||||
wxColor clsTargetColor=GetPixelUnitColor(iX, iY);
|
||||
wxColor clsMidColor;
|
||||
|
||||
if(WX_LCD_PIX_RGB(GetPixelUnitColor(iX, iY)) == WX_LCD_PIX_RGB(m_clsPixelHColour.GetRGBA()))
|
||||
while(iLeft<iRight)
|
||||
{
|
||||
iReturn = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
iReturn = 0;
|
||||
}
|
||||
|
||||
return iReturn;
|
||||
iMid=(iLeft+iRight)/2;
|
||||
clsLeftColor=m_clsPixelPalette[iLeft];
|
||||
clsMidColor=m_clsPixelPalette[iMid];
|
||||
clsRightColor=m_clsPixelPalette[iRight];
|
||||
// use Red to search
|
||||
if((clsLeftColor.Red()<=clsTargetColor.Red() && clsTargetColor.Red()<clsMidColor.Red()) ||
|
||||
(clsLeftColor.Red()>=clsTargetColor.Red() && clsTargetColor.Red()>clsMidColor.Red()))
|
||||
{
|
||||
iRight=iMid-1;
|
||||
continue;
|
||||
}
|
||||
else if((clsRightColor.Red()>=clsTargetColor.Red() && clsTargetColor.Red()>clsMidColor.Red())||
|
||||
(clsRightColor.Red()<=clsTargetColor.Red() && clsTargetColor.Red()<clsMidColor.Red()))
|
||||
{
|
||||
iLeft=iMid+1;
|
||||
continue;
|
||||
}
|
||||
// use Green to search
|
||||
if((clsLeftColor.Green()<=clsTargetColor.Green() && clsTargetColor.Green()<clsMidColor.Green()) ||
|
||||
(clsLeftColor.Green()>=clsTargetColor.Green() && clsTargetColor.Green()>clsMidColor.Green()))
|
||||
{
|
||||
iRight=iMid-1;
|
||||
continue;
|
||||
}
|
||||
else if((clsRightColor.Green()>=clsTargetColor.Green() && clsTargetColor.Green()>clsMidColor.Green())||
|
||||
(clsRightColor.Green()<=clsTargetColor.Green() && clsTargetColor.Green()<clsMidColor.Green()))
|
||||
{
|
||||
iLeft=iMid+1;
|
||||
continue;
|
||||
}
|
||||
// use Blue to search
|
||||
if((clsLeftColor.Blue()<=clsTargetColor.Blue() && clsTargetColor.Blue()<clsMidColor.Blue()) ||
|
||||
(clsLeftColor.Blue()>=clsTargetColor.Blue() && clsTargetColor.Blue()>clsMidColor.Blue()))
|
||||
{
|
||||
iRight=iMid-1;
|
||||
continue;
|
||||
}
|
||||
else if((clsRightColor.Blue()>=clsTargetColor.Blue() && clsTargetColor.Blue()>clsMidColor.Blue())||
|
||||
(clsRightColor.Blue()<=clsTargetColor.Blue() && clsTargetColor.Blue()<clsMidColor.Blue()))
|
||||
{
|
||||
iLeft=iMid+1;
|
||||
continue;
|
||||
}
|
||||
// iMid is the target color
|
||||
iReturn=iMid;
|
||||
break;
|
||||
}
|
||||
if(iReturn==-1 && iLeft==iRight)
|
||||
iReturn=iLeft;
|
||||
return iReturn;
|
||||
}
|
||||
|
||||
void wxLCD::SetPixel(const int iX, const int iY, const int iValue)
|
||||
{
|
||||
if(1 == iValue)
|
||||
{
|
||||
SetPixelUnitColor(iX, iY, m_clsPixelHColour);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetPixelUnitColor(iX, iY, m_clsPixelLColour);
|
||||
}
|
||||
int iCheckedValue;
|
||||
iCheckedValue = SGUI_MIN_OF(iValue,m_iPixelDepth-1);
|
||||
iCheckedValue = SGUI_MAX_OF(iCheckedValue,0);
|
||||
|
||||
SetPixelUnitColor(iX,iY,m_clsPixelPalette[iCheckedValue]);
|
||||
}
|
||||
|
||||
void wxLCD::CleanScreen(void)
|
||||
@ -101,6 +182,7 @@ void wxLCD::SetParameter(PixelPanelParameter* pstPanelParameter)
|
||||
SetPixelColour(wxColor(pstPanelParameter->PixelColor), false);
|
||||
SetPanelColour(wxColor(pstPanelParameter->PanelColor), false);
|
||||
SetGridColor(wxColor(pstPanelParameter->GridColor));
|
||||
SetPixelDepth(pstPanelParameter->PixelUnitDepth);
|
||||
|
||||
Layout();
|
||||
}
|
||||
|
@ -100,6 +100,9 @@
|
||||
<Unit filename="../../../DemoProc/src/Basic.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../../../DemoProc/src/Curve.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../../../DemoProc/src/DemoProc.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
|
Loading…
Reference in New Issue
Block a user