初级会员
积分 178
金钱 178
注册时间 2013-11-19
在线时间 22 小时
5 金钱
/*******************************************************************
*
* static code
*
********************************************************************
*/
/*******************************************************************
*
* _cbBkWindow
*/
static void _cbBkWindow(WM_MESSAGE* pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
GUI_ClearRect(0, 50, 319, 239);
default:
WM_DefaultProc(pMsg);
}
}
/*******************************************************************
*
* _cbWindow
*/
static void _cbWindow(WM_MESSAGE* pMsg) {
GUI_RECT Rect;
switch (pMsg->MsgId) {
case WM_PAINT:
WM_GetInsideRect(&Rect);
GUI_SetBkColor(GUI_RED);
GUI_SetColor(GUI_YELLOW);
GUI_ClearRectEx(&Rect);
GUI_DrawRectEx(&Rect);
GUI_SetColor(GUI_BLACK);
GUI_SetFont(&GUI_Font8x16);
GUI_DispStringHCenterAt("Foreground window", 75, 40);
break;
default:
WM_DefaultProc(pMsg);
}
}
/*******************************************************************
*
* _MoveWindow
*/
static void _MoveWindow(const char* pText) {
WM_HWIN hWnd;
int i;
/* Create foreground window */
hWnd = WM_CreateWindow(10, 50, 150, 100, WM_CF_SHOW, _cbWindow, 0);
GUI_Delay(500);
/* Move foreground window */
for (i = 0; i < 40; i++) {
WM_MoveWindow(hWnd, 2, 2);
GUI_Delay(10);
}
/* Show text before deleting window if we have one */
if (pText) {
GUI_DispStringAt(pText, 5, 50);
GUI_Delay(2500);
}
/* Delete foreground window */
WM_DeleteWindow(hWnd);
WM_Invalidate(WM_HBKWIN);
GUI_Exec();
}
/*******************************************************************
*
* _DemoRedraw
*/
static void _DemoRedraw(void) {
WM_CALLBACK* _cbOldBk;
GUI_SetBkColor(GUI_BLACK);
GUI_Clear();
GUI_SetColor(GUI_WHITE);
GUI_SetFont(&GUI_Font24_ASCII);
GUI_DispStringHCenterAt("WM_Redraw - Sample", 160, 5);
GUI_SetFont(&GUI_Font8x16);
while(1) {
/* Move a window over background */
_MoveWindow("Background has not been redrawn");
/* Clear background */
GUI_ClearRect(0, 50, 319, 239);
GUI_Delay(1000);
/* Set callback for background window */
_cbOldBk = WM_SetCallback(WM_HBKWIN, _cbBkWindow);
/* Move a window over background */
_MoveWindow("Background has been redrawn");
/* Delete callback for Background window */
WM_SetCallback(WM_HBKWIN, _cbOldBk);
}
}
int main(void)
{
SystemInit();
delay_init(72); //???±??????
NVIC_Configuration();
uart_init(9600);
LED_Init();
KEY_Init();
GUI_Init();
GUI_SetBkColor(GUI_BLACK);
GUI_Clear();
LED1=0;
_DemoRedraw();
//LED1=0;
while(1)
{
delay_ms(800);
LED0 = !LED0;
}
}
以上是 码源里提供的例程,相信大家都试验过。。。。。我的问题是……当把例程拷贝到自己的工程里,编译通过以后,。。。在自己的液晶屏上只显示如图所示的东西。。。感觉不太对。。。而且,根本没有进入主函数的WHILE循环(因为LED0不闪)。。。LED1是用来做测试的。。当在_DemoRedraw()这个函数上面时,LED1亮。 当在_DemoRedraw();下面时候, LED1不亮。。。。所以,我觉得函数在_DemoRedraw()里面没有跳出………………
请问,(1)究竟是什么原因呢???
(2)如果看到的大侠,心情不错,能不能帮忙解释一下,这个例程究竟是怎么执行,并利用回调的(小弟,现在对回调的概念很模糊)……祝大侠今晚有艳遇……这是每个工科男的心思……哎
我来回答