新手上路
- 积分
- 27
- 金钱
- 27
- 注册时间
- 2022-5-27
- 在线时间
- 12 小时
|
1金钱
/*********************************************************************
* *
* SEGGER Microcontroller GmbH & Co. KG *
* Solutions for real time microcontroller applications *
* *
**********************************************************************
* *
* C-file generated by: *
* *
* GUI_Builder for emWin version 5.26 *
* Compiled Aug 18 2014, 17:12:05 *
* (c) 2014 Segger Microcontroller GmbH & Co. KG *
* *
**********************************************************************
* *
* Internet: www.segger.com Support: support@segger.com *
* *
**********************************************************************
*/
// USER START (Optionally insert additional includes)
// USER END
#include "DIALOG.h"
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
#define ID_FRAMEWIN_0 (GUI_ID_USER + 0x00)
#define ID_PROGBAR_0 (GUI_ID_USER + 0x01)
#define ID_SLIDER_0 (GUI_ID_USER + 0x02)
// USER START (Optionally insert additional defines)
// USER END
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
// USER START (Optionally insert additional static data)
// USER END
/*********************************************************************
*
* _aDialogCreate
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
{ FRAMEWIN_CreateIndirect, "Framewin", ID_FRAMEWIN_0, 0, 0, 1024, 600, 0, 0x0, 0 },
{ PROGBAR_CreateIndirect, "Progbar", ID_PROGBAR_0, 757, 8, 80, 20, 0, 0x0, 0 },
// { SLIDER_CreateIndirect, "Slider", ID_SLIDER_0, 191, 203, 364, 57, 0, 0x0, 0 },
// USER START (Optionally insert additional widgets)
// USER END
};
// USER START (Optionally insert additional static code)
// USER END
//int a[] = {1,5,10,15,20,25,30,40,50,100};
int Value_Bat;
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
// USER START (Optionally insert additional public code)
// USER END
/*********************************************************************
*
* _SetFont
*/
/*
static void _SetFont(WM_HWIN hDlg) {
WM_HWIN hItem;
hItem = WM_GetDialogItem(hDlg, ID_PROGBAR_0);
PROGBAR_SetValue(hItem,Value_Bat);
PROGBAR_SetBarColor(hItem, 1, GUI_WHITE);
if (Value_Bat <= 20)
{
PROGBAR_SetBarColor(hItem, 0, GUI_RED);
}
else
{
PROGBAR_SetBarColor(hItem, 0, GUI_GREEN);
}
}
*/
/*********************************************************************
*
* _cbBkWindow
*/
static void _cbBkWindow(WM_MESSAGE* pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
GUI_SetBkColor(GUI_BLUE);
GUI_Clear();
GUI_SetColor(GUI_WHITE);
GUI_SetFont(&GUI_Font24_ASCII);
// SLIDER_CreateEx(191, 203, 364, 57, 0, 0x0, 0, ID_SLIDER_0);
// SLIDER_SetRange(WM_GetDialogItem(pMsg->hWin, ID_SLIDER_0),0,9);
// SLIDER_SetNumTicks(WM_GetDialogItem(pMsg->hWin, ID_SLIDER_0),1);
default:
WM_DefaultProc(pMsg);
}
}
/*********************************************************************
*
* _cbCallback
*/
static void _cbCallback(WM_MESSAGE* pMsg) {
unsigned i;
int NCode, Id;
WM_HWIN hDlg, hItem;
hDlg = pMsg->hWin;
switch (pMsg->MsgId) {
case WM_INIT_DIALOG:
// hItem = WM_GetDialogItem(hDlg, ID_SLIDER_0);
// SLIDER_SetRange(hItem, 0, 9);
// SLIDER_SetNumTicks(hItem, 10);
break;
case WM_TIMER:
hItem = WM_GetDialogItem(pMsg->hWin, ID_PROGBAR_0);
Value_Bat++;
if (Value_Bat == 100)
{
Value_Bat = 0;
PROGBAR_SetValue(hItem, Value_Bat);
}
else
{
PROGBAR_SetValue(hItem, Value_Bat);
if (Value_Bat <= 20)
{
PROGBAR_SetBarColor(hItem, 0, GUI_RED);
}
else
{
PROGBAR_SetBarColor(hItem, 0, GUI_GREEN);
}
}
WM_RestartTimer(pMsg->Data.v, 1000);
break;
default:
WM_DefaultProc(pMsg);
}
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* MainTask
*/
void MainTask(void) {
WM_HWIN hDlgFrame;
WM_HTIMER htimer;
GUI_Init();
WM_SetCallback(WM_HBKWIN, _cbBkWindow);
WM_SetCreateFlags(WM_CF_MEMDEV); /* Use memory devices on all windows to avoid flicker */
hDlgFrame = 0;
while (1) {
if (!WM_IsWindow(hDlgFrame))
{
hDlgFrame = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbCallback, WM_HBKWIN, 0, 0);
}
htimer = WM_CreateTimer(WM_GetClientWindow(hDlgFrame), 0, 1000, 0);
GUI_Delay(100);
}
}
/*************************** End of file ****************************/
设置参数不变情况下,使用定时器触发 越运行越快
|
|