Playing around with emWin

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • Playing around with emWin

    I have build a small application with the gui maker and want to add now my own code.

    I have build a callback (line 170) and want there to display text but i don*t get it.


    Source Code

    1. /*********************************************************************
    2. * *
    3. * SEGGER Microcontroller GmbH & Co. KG *
    4. * Solutions for real time microcontroller applications *
    5. * *
    6. **********************************************************************
    7. * *
    8. * C-file generated by: *
    9. * *
    10. * GUI_Builder for emWin version 5.22 *
    11. * Compiled Jul 4 2013, 15:16:01 *
    12. * (c) 2013 Segger Microcontroller GmbH & Co. KG *
    13. * *
    14. **********************************************************************
    15. * *
    16. * Internet: www.segger.com Support: support@segger.com *
    17. * *
    18. **********************************************************************
    19. */
    20. // USER START (Optionally insert additional includes)
    21. // USER END
    22. #include "DIALOG.h"
    23. #include "GUI.h"
    24. #include "WM.h"
    25. #include "global_includes.h"
    26. /*********************************************************************
    27. *
    28. * Defines
    29. *
    30. **********************************************************************
    31. */
    32. #define ID_WINDOW_0 (GUI_ID_USER + 0x08)
    33. #define ID_BUTTON_0 (GUI_ID_USER + 0x1B)
    34. #define ID_TEXT_0 (GUI_ID_USER + 0x1C)
    35. #define ID_TEXT_1 (GUI_ID_USER + 0x1D)
    36. // USER START (Optionally insert additional defines)
    37. // USER END
    38. /*********************************************************************
    39. *
    40. * Static data
    41. *
    42. **********************************************************************
    43. */
    44. // USER START (Optionally insert additional static data)
    45. // USER END
    46. /*********************************************************************
    47. *
    48. * _aDialogCreate
    49. */
    50. extern WM_HWIN CreateFramewin(void);
    51. static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
    52. { WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 240, 320, 0, 0x0, 0 },
    53. { BUTTON_CreateIndirect, "Button", ID_BUTTON_0, 28, 267, 179, 37, 0, 0x0, 0 },
    54. { TEXT_CreateIndirect, "Text", ID_TEXT_0, 22, 40, 195, 29, 0, 0x64, 0 },
    55. { TEXT_CreateIndirect, "Text", ID_TEXT_1, 42, 67, 215, 33, 0, 0x64, 0 },
    56. // USER START (Optionally insert additional widgets)
    57. // USER END
    58. };
    59. /*********************************************************************
    60. *
    61. * Static code
    62. *
    63. **********************************************************************
    64. */
    65. // USER START (Optionally insert additional static code)
    66. // USER END
    67. /*********************************************************************
    68. *
    69. * _cbDialog
    70. */
    71. static void _cbDialog(WM_MESSAGE * pMsg) {
    72. WM_HWIN hItem;
    73. int NCode;
    74. int Id;
    75. // USER START (Optionally insert additional variables)
    76. // USER END
    77. switch (pMsg->MsgId) {
    78. case WM_INIT_DIALOG:
    79. //
    80. // Initialization of 'Window'
    81. //
    82. hItem = pMsg->hWin;
    83. WINDOW_SetBkColor(hItem, 0x00000080);
    84. //
    85. // Initialization of 'Button'
    86. //
    87. hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);
    88. BUTTON_SetText(hItem, "LED");
    89. BUTTON_SetFont(hItem, GUI_FONT_COMIC24B_ASCII);
    90. BUTTON_SetBkColor(hItem,BUTTON_CI_UNPRESSED,GUI_WHITE);
    91. //
    92. // Initialization of 'Text'
    93. //
    94. hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
    95. TEXT_SetTextColor(hItem, 0x00FF0000);
    96. TEXT_SetFont(hItem, GUI_FONT_24_ASCII);
    97. TEXT_SetText(hItem, "STM32F429I-DISCO");
    98. //
    99. // Initialization of 'Text'
    100. //
    101. hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
    102. TEXT_SetFont(hItem, GUI_FONT_24_ASCII);
    103. TEXT_SetText(hItem, "emWin Demo");
    104. TEXT_SetTextColor(hItem, 0x00FF0000);
    105. // USER START (Optionally insert additional code for further widget initialization)
    106. // USER END
    107. break;
    108. case WM_NOTIFY_PARENT:
    109. Id = WM_GetId(pMsg->hWinSrc);
    110. NCode = pMsg->Data.v;
    111. switch(Id) {
    112. case ID_BUTTON_0: // Notifications sent by 'Button'
    113. switch(NCode) {
    114. case WM_NOTIFICATION_CLICKED:
    115. // USER START (Optionally insert code for reacting on notification message)
    116. CreateFramewin();
    117. // USER END
    118. break;
    119. case WM_NOTIFICATION_RELEASED:
    120. // USER START (Optionally insert code for reacting on notification message)
    121. // USER END
    122. break;
    123. // USER START (Optionally insert additional code for further notification handling)
    124. // USER END
    125. }
    126. break;
    127. // USER START (Optionally insert additional code for further Ids)
    128. // USER END
    129. }
    130. break;
    131. // USER START (Optionally insert additional message handling)
    132. // USER END
    133. default:
    134. WM_DefaultProc(pMsg);
    135. break;
    136. }
    137. }
    138. /*********************************************************************
    139. *
    140. * Public code
    141. *
    142. **********************************************************************
    143. */
    144. /*********************************************************************
    145. *
    146. * CreateWindow
    147. */
    148. WM_HWIN CreateWindow(void);
    149. WM_HWIN CreateWindow(void) {
    150. WM_HWIN hWin;
    151. hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
    152. return hWin;
    153. }
    154. /*******************************************************************
    155. *
    156. * _Callback
    157. */
    158. void _callback () {
    159. STM_EVAL_LEDToggle(LED3);
    160. GUI_SetTextMode(GUI_TM_NORMAL);
    161. GUI_SetColor(GUI_YELLOW);
    162. GUI_SetFont(GUI_FONT_16B_ASCII);
    163. GUI_DispStringAt((char *)"Test", 50, 4);
    164. }
    165. // USER START (Optionally insert additional public code)
    166. // USER END
    167. /*************************** End of file ****************************/
    168. void MainTask(void)
    169. {
    170. WM_SetCreateFlags(WM_CF_MEMDEV | WM_CF_CONST_OUTLINE);
    171. GUI_Init();
    172. WM_MULTIBUF_Enable(1);
    173. WM_SetCallback(WM_HBKWIN, _callback);
    174. CreateWindow();
    175. while(1)
    176. {
    177. _callback ();
    178. GUI_Delay(100);
    179. }
    180. }
    181. // USER START (Optionally insert additional public code)
    182. // USER END
    183. /*************************** End of file ****************************/
    Display All



    would be nice to get a hint how to manage it.

    regards

    Jim
  • Hello Jim,

    For detailed information on how to create a callback function, please refer to the chapter "The Window Manager (WM)" in the emWin documentation. There are also many samples which make use of callback functions. Most of them are placed in the folder (Sample\Tutorial).

    When editing the GUIBuilder output, please note the following lines:

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

    Custom code should always be inserted between those lines.

    Best regards,
    Adrian
  • Hello Adrian,
    I managed now to display periodic changing values.
    I reduced the window size and place them in the free Space. That works but isn't fine for a uniform design.

    Some points about the GUI Builder.
    I miss a lot of things. It only build a basic structure. With no dependencies between windows.
    So it would be nice to build a complete application. Like place a Button in a Window that open a other window a.s.o..
    Also I miss drawing lines and rectangles, a Field to display formated values like floats, date and other normal used formats. Spin Boxes also should could be formated with decimal places.

    // USER START (Optionally insert additional public code)

    // USER END
    Yes it would be nice to have a part where to place periodic changing things.
    All I found is reacting touch inputs. 8)

    regards

    Jim
  • Hello Jim,

    You are right. After creating the dialog structure using the GUIBuilder, the actual application logic still needs to be implemented. Of course we are going to improve the GUIBuilder regularly, but most of the improvements which will be done in the near future will be related to single widgets.

    Best regards,
    Adrian
  • Hello Adrian,
    I rather wish that the GuiBuilder is developed faster. Every software engineer will be thankful if work is taken from him.

    Who needs video, picture viewers and things like that, to control a machine and equipment. I think this kind of applications are in first line target for which the Gui is intended or not? Windows like features are nice but no one will build a Laptop or Smartphone with emWin. A child learns how to crawl before it can run ;)

    Best regards,
    Jim
  • Hello Adrian,

    a adjustable Grid, group elements to move theme, settings for all possible settings at all elements would be nice.

    Also I like to have a Text field witch automatic updated when value is changed. So it would be easier to display time, date and values.

    regards

    Jim