初级会员
- 积分
- 59
- 金钱
- 59
- 注册时间
- 2015-5-21
- 在线时间
- 15 小时
|
5金钱
[mw_shl_code=c,true]/*********************************************************************
* *
* SEGGER Microcontroller GmbH & Co. KG *
* Solutions for real time microcontroller applications *
* *
**********************************************************************
* *
* C-file generated by: *
* *
* GUI_Builder for emWin version 5.28 *
* Compiled Jan 30 2015, 16:41:06 *
* (c) 2015 Segger Microcontroller GmbH & Co. KG *
* *
**********************************************************************
* *
* Internet: www.segger.com Support: support@segger.com *
* *
**********************************************************************
*/
// USER START (Optionally insert additional includes)
// USER END
#include "DIALOG.h"
#include "ff.h"
#include "EmWinHZFont.h"
#include "malloc.h"
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
#define ID_WINDOW_0 (GUI_ID_USER + 0x00)
#define ID_TEXT_0 (GUI_ID_USER + 0x01)
#define ID_TEXT_1 (GUI_ID_USER + 0x02)
#define ID_TEXT_2 (GUI_ID_USER + 0x03)
#define ID_TEXT_3 (GUI_ID_USER + 0x04)
#define ID_TEXT_4 (GUI_ID_USER + 0x05)
#define ID_TEXT_5 (GUI_ID_USER + 0x06)
#define ID_TEXT_6 (GUI_ID_USER + 0x07)
#define ID_IMAGE_0 (GUI_ID_USER + 0x08)
#define ID_IMAGE_1 (GUI_ID_USER + 0x09)
#define ID_IMAGE_2 (GUI_ID_USER + 0x0A)
#define ID_BUTTON_0 (GUI_ID_USER + 0x0B)
#define ID_IMAGE_0_IMAGE_0 0x00
#define ID_IMAGE_1_IMAGE_0 0x01
#define ID_IMAGE_2_IMAGE_0 0x02
static FIL BMPFile;
u32 BMPFileSize;
static char *bmpbuffer;
RTC_TimeTypeDef RTC_TimeStruct;
RTC_DateTypeDef RTC_DateStruct;
// USER START (Optionally insert additional defines)
// USER END
/*********************************************************************
*
* _aDialogCreate
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
{ WINDOW_CreateIndirect, "Window_tim", ID_WINDOW_0, 0, 0, 800, 480, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "Text", ID_TEXT_0, 0, 0, 800, 30, 0, 0x64, 0 },
{ TEXT_CreateIndirect, "Text", ID_TEXT_1, 225, 130, 110, 40, 0, 0x64, 0 },
{ TEXT_CreateIndirect, "Text", ID_TEXT_2, 225, 230, 110, 40, 0, 0x64, 0 },
{ TEXT_CreateIndirect, "Text", ID_TEXT_3, 225, 330, 110, 40, 0, 0x64, 0 },
{ TEXT_CreateIndirect, "Text", ID_TEXT_4, 370, 130, 240, 40, 0, 0x64, 0 },
{ TEXT_CreateIndirect, "Text", ID_TEXT_5, 370, 230, 240, 40, 0, 0x64, 0 },
{ TEXT_CreateIndirect, "Text", ID_TEXT_6, 370, 330, 240, 40, 0, 0x64, 0 },
{ IMAGE_CreateIndirect, "Image", ID_IMAGE_0, 510, 130, 50, 50, 0, 0, 0 },
{ IMAGE_CreateIndirect, "Image", ID_IMAGE_1, 510, 230, 50, 50, 0, 0, 0 },
{ IMAGE_CreateIndirect, "Image", ID_IMAGE_2, 510, 330, 50, 50, 0, 0, 0 },
{ BUTTON_CreateIndirect, "Button", ID_BUTTON_0, 711, 452, 80, 24, 0, 0x0, 0 },
// USER START (Optionally insert additional widgets)
// USER END
};
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
//»ñè¡ÑÕé«»·í¼Ïñêy¾Y
//·μ»ØÖμ:0 3é1|£¬ÆäËû ꧰ü
static u8 GetColorLoopData(char* BMPFileName)
{
u16 bread;
char result;
#if SYSTEM_SUPPORT_OS
CPU_SR_ALLOC();
#endif
result=f_open(&BMPFile,(const TCHAR*)BMPFileName,FA_READ); //′ò¿aÎļt
//Îļt′ò¿a′íÎó»òÕßÎļtPNGMEMORYSIZE
if(result!=FR_OK) return 1;
BMPFileSize=BMPFile.fsize;
if(bmpbuffer==NULL) bmpbuffer=mymalloc(SRAMEX,BMPFile.fsize);
if(bmpbuffer==NULL) return 2;
#if SYSTEM_SUPPORT_OS
OS_CRITICAL_ENTER(); //áù½çÇø
#endif
result = f_read(&BMPFile,bmpbuffer,BMPFile.fsize,(UINT *)&bread);//¶áè¡êy¾Y
if(result != FR_OK) return 3;
#if SYSTEM_SUPPORT_OS
OS_CRITICAL_EXIT(); //íË3öáù½çÇø
#endif
f_close(&BMPFile);//1رÕÎļt
return 0;
}
/*********************************************************************
*
* _GetImageById
*/
static const void * _GetImageById(U32 Id, U32 * pSize)
{
const char* buffer;
switch (Id)
{
case ID_IMAGE_0_IMAGE_0:
if(GetColorLoopData("0:/PICTURE/BMP/oôÎü.bmp")==0)
buffer=(const void *)bmpbuffer;
else buffer=NULL;
*pSize=BMPFile.fsize;
return buffer;
case ID_IMAGE_1_IMAGE_0:
if(GetColorLoopData("0:/PICTURE/BMP/DÄìø.bmp")==0)
buffer=(const void *)bmpbuffer;
else buffer=NULL;
*pSize=BMPFile.fsize;
return buffer;
case ID_IMAGE_2_IMAGE_0:
if(GetColorLoopData("0:/PICTURE/BMP/ìåÎÂ.bmp")==0)
buffer=(const void *)bmpbuffer;
else buffer=NULL;
*pSize=BMPFile.fsize;
return buffer;
}
return NULL;
}
// USER START (Optionally insert additional static code)
// USER END
/*********************************************************************
*
* _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
const void * pData;
WM_HWIN hItem;
U32 FileSize;
int NCode;
int Id;
char buf[30];
// USER START (Optionally insert additional variables)
// USER END
switch (pMsg->MsgId) {
case WM_TIMER:
hItem = pMsg->hWin;
RTC_GetTime(RTC_Format_BIN,&RTC_TimeStruct);
RTC_GetDate(RTC_Format_BIN, &RTC_DateStruct);
sprintf((char*)buf," 20%02d-%02d-%02d %02d:%02d:%02d DÇÆú%d",RTC_DateStruct.RTC_Year,RTC_DateStruct.RTC_Month,
RTC_DateStruct.RTC_Date,RTC_TimeStruct.RTC_Hours,RTC_TimeStruct.RTC_Minutes,RTC_TimeStruct.RTC_Seconds,RTC_DateStruct.RTC_WeekDay);
TEXT_SetText(WM_GetDialogItem(hItem,ID_TEXT_0), (const char *)buf);
WM_RestartTimer(pMsg->Data.v, 1000);
break;
case WM_INIT_DIALOG:
//
// Initialization of 'Window_tim'
//
hItem = pMsg->hWin;
WINDOW_SetBkColor(hItem, 0x00FFFFFF);
//
// Initialization of 'Text'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
TEXT_SetFont(hItem, &GUI_FontHZ24);
RTC_GetTime(RTC_Format_BIN,&RTC_TimeStruct);
RTC_GetDate(RTC_Format_BIN, &RTC_DateStruct);
sprintf((char*)buf," 20%02d-%02d-%02d %02d:%02d:%02d DÇÆú%d",RTC_DateStruct.RTC_Year,RTC_DateStruct.RTC_Month,
RTC_DateStruct.RTC_Date,RTC_TimeStruct.RTC_Hours,RTC_TimeStruct.RTC_Minutes,RTC_TimeStruct.RTC_Seconds,RTC_DateStruct.RTC_WeekDay);
TEXT_SetText(hItem, (const char *)buf);
TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER);
TEXT_SetTextColor(hItem, 0x00000000);
//
// Initialization of 'Text'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
TEXT_SetFont(hItem, &GUI_FontHZ32);
TEXT_SetText(hItem, "oôÎü");
TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER);
TEXT_SetTextColor(hItem, 0x00000000);
//
// Initialization of 'Text'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_2);
TEXT_SetFont(hItem, &GUI_FontHZ32);
TEXT_SetText(hItem, "DÄìø");
TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER);
TEXT_SetTextColor(hItem, 0x00000000);
//
// Initialization of 'Text'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_3);
TEXT_SetFont(hItem, &GUI_FontHZ32);
TEXT_SetText(hItem, "ìåÎÂ");
TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER);
TEXT_SetTextColor(hItem, 0x00000000);
//
// Initialization of 'Text'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_4);
TEXT_SetFont(hItem, GUI_FONT_32_ASCII);
TEXT_SetText(hItem, "Text");
TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER);
TEXT_SetTextColor(hItem, 0x00000000);
//
// Initialization of 'Text'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_5);
TEXT_SetFont(hItem, GUI_FONT_32_ASCII);
TEXT_SetText(hItem, "Text");
TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER);
TEXT_SetTextColor(hItem, 0x00000000);
//
// Initialization of 'Text'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_6);
TEXT_SetFont(hItem, GUI_FONT_32_ASCII);
TEXT_SetText(hItem, "Text");
TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER);
TEXT_SetTextColor(hItem, 0x00000000);
//
// Initialization of 'Image'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_0);
pData = _GetImageById(ID_IMAGE_0_IMAGE_0,&FileSize);
IMAGE_SetBMP(hItem, pData, FileSize);
//
// Initialization of 'Image'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_1);
pData = _GetImageById(ID_IMAGE_1_IMAGE_0,&FileSize);
IMAGE_SetBMP(hItem, pData, FileSize);
// //
// // Initialization of 'Image'
// //
// hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_2);
// pData = _GetImageById(ID_IMAGE_2_IMAGE_0,&FileSize);
// IMAGE_SetBMP(hItem, pData, FileSize);
//
// Initialization of 'Button'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);
BUTTON_SetFont(hItem, &GUI_FontHZ24);
BUTTON_SetText(hItem, "·μ»Ø");
// USER START (Optionally insert additional code for further widget initialization)
// USER END
break;
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch(Id) {
case ID_BUTTON_0: // Notifications sent by 'Button'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
hItem=pMsg->hWin;
WM_DeleteWindow(hItem);
break;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
// USER START (Optionally insert additional code for further Ids)
// USER END
}
break;
// USER START (Optionally insert additional message handling)
// USER END
default:
WM_DefaultProc(pMsg);
break;
}
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* CreateWindow_tim
*/
WM_HWIN CreateWindow_tim(void);
WM_HWIN CreateWindow_tim(void) {
WM_HWIN hWin;
WM_SetCreateFlags(WM_CF_MEMDEV);
hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
WM_CreateTimer(WM_GetClientWindow(hWin), 0, 1000, 0);
return hWin;
}
// USER START (Optionally insert additional public code)
// USER END
/*************************** End of file ****************************/
[/mw_shl_code]
|
|