yuiij 发表于 2016-2-12 01:02:17

emWin GUIBuilder做的一个界面在F429I-DISCO上不显示

本帖最后由 yuiij 于 2016-2-12 01:04 编辑

用的是STM32Cube_FW_F4_V1.11.0\Projects\STM32F429I-Discovery\Applications\STemWin\STemWin_HelloWorld这个例程,把builder生成的.c文件加入了工程,然后用生成的一个函数---CreateWindow();替换了MainTask()函数里的代码。编译通过后,下载到板子里,黑屏。调了好长时间,就是什么都不显示。。下面是Builder生成的代码:/*********************************************************************
*                                                                  *
*                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.comSupport: support@segger.com       *
*                                                                  *
**********************************************************************
*/

// USER START (Optionally insert additional includes)
// USER END

#include "DIALOG.h"

/*********************************************************************
*
*       Defines
*
**********************************************************************
*/
#define ID_WINDOW_0 (GUI_ID_USER + 0x06)
#define ID_BUTTON_0 (GUI_ID_USER + 0x07)
#define ID_BUTTON_1 (GUI_ID_USER + 0x08)


// 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[] = {
{ WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 240, 320, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Button", ID_BUTTON_0, 78, 136, 80, 20, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Button", ID_BUTTON_1, 68, 69, 80, 20, 0, 0x0, 0 },
// USER START (Optionally insert additional widgets)
// USER END
};

/*********************************************************************
*
*       Static code
*
**********************************************************************
*/

// USER START (Optionally insert additional static code)
// USER END

/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
int NCode;
int Id;
// USER START (Optionally insert additional variables)
// USER END

switch (pMsg->MsgId) {
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
      break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_BUTTON_1: // 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
      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
*/
WM_HWIN CreateWindow(void);
WM_HWIN CreateWindow(void) {
WM_HWIN hWin;

hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
return hWin;
}

// USER START (Optionally insert additional public code)
// USER END

/*************************** End of file ****************************/

mark0668 发表于 2016-2-12 23:10:38

void MainTask(void) {
GUI_Clear();
GUI_SetFont(&GUI_Font20_1);
//GUI_DispStringAt("Hello world!", (LCD_GetXSize()-100)/2, (LCD_GetYSize()-20)/2);
CreateWindows();
        while(1){
                GUI_Delay(10);
        }
}


复制以上代码即可运行,是因为你没有对界面进行刷新.

feiting94 发表于 2016-2-12 09:10:24

MainTask() 函数不能删掉的, 你的 主函数应该调用的是 MainTask();
然后MainTask() 改为调用 CreateWindow()

yuiij 发表于 2016-2-12 09:53:54

feiting94 发表于 2016-2-12 09:10
MainTask() 函数不能删掉的, 你的 主函数应该调用的是 MainTask();
然后MainTask() 改为调用 CreateWindow ...

是的,我没动main函数里的代码,就是把Create Window放在MainTask里调用的。

zcl201207 发表于 2016-2-12 23:09:31

:):):):):)

modu8888 发表于 2017-9-27 09:06:39

请问楼主:我没有用操作系统,在main.c中先声明,再调用,也出不来啊。

声明:
extern WM_HWIN CreateFramewin(void);

调用:
        CreateFramewin();

modu8888 发表于 2017-9-27 12:23:01

搞清楚了。原来需要在主循环中添加GUI_Delay(M)。据说目的是运行GUI_Exec()。
页: [1]
查看完整版本: emWin GUIBuilder做的一个界面在F429I-DISCO上不显示