STemwin hangs (due to lack of ram?)

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

    • STemwin hangs (due to lack of ram?)

      Hi.

      I want to use multi page on a 480*320 lcd.
      so edited a demo of multipage... but with FRAMEWIN_AddMinButton() after two (or more\less) times minimize and reopening the window emwin hangs (?) and stops working!

      this is my code:

      C Source Code

      1. #include "main.h"
      2. #include <stdlib.h>
      3. #include "GUI.h"
      4. #include "MULTIPAGE.h"
      5. #include <stdio.h>
      6. #include "fatfs.h"
      7. #define ID_BUTTON_0 (GUI_ID_USER + 0x06)
      8. #define ID_BUTTON_1 (GUI_ID_USER + 0x07)
      9. extern FATFS myFATFS;
      10. extern FIL myFILE;
      11. extern int size;
      12. uint8_t shomar, shomarconfirm = 0;
      13. uint16_t CNTold = 0;
      14. char chr[20];
      15. WM_HWIN hItemtext;
      16. void _DemoMultiPage(void);
      17. static const GUI_WIDGET_CREATE_INFO _aDialogCreate3[] = {
      18. { WINDOW_CreateIndirect, "Dialog 3", 0, 0, 0, 190, 280, FRAMEWIN_CF_MOVEABLE },
      19. { RADIO_CreateIndirect, "", GUI_ID_RADIO0, 5, 30, 0, 0, 0, 3},
      20. { TEXT_CreateIndirect, "Option 1", GUI_ID_TEXT0, 25, 30, 50, 15, TEXT_CF_LEFT },
      21. { TEXT_CreateIndirect, "Option 2", GUI_ID_TEXT1, 25, 50, 50, 15, TEXT_CF_LEFT },
      22. { TEXT_CreateIndirect, "Option 3", GUI_ID_TEXT2, 25, 70, 50, 15, TEXT_CF_LEFT },
      23. { TEXT_CreateIndirect, "Dialog 3", 0, 5, 10, 50, 20, TEXT_CF_LEFT }
      24. };
      25. static const GUI_WIDGET_CREATE_INFO _aDialogCreate4[] = {
      26. { WINDOW_CreateIndirect, "Dialog 4", 0, 0, 0, 190, 280, FRAMEWIN_CF_MOVEABLE },
      27. { MULTIEDIT_CreateIndirect, "Text", GUI_ID_MULTIEDIT0, 5, 30, 180, 100 },
      28. { BUTTON_CreateIndirect, "+1", ID_BUTTON_0, 10, 170, 80, 80, 0, 0x0, 0 },
      29. { BUTTON_CreateIndirect, "-1", ID_BUTTON_1, 100, 170, 80, 80, 0, 0x0, 0 },
      30. { TEXT_CreateIndirect, "Dialog 4", 0, 5, 10, 50, 20, TEXT_CF_LEFT }
      31. };
      32. static void _cbDialog3(WM_MESSAGE * pMsg) {
      33. WM_HWIN hDlg;
      34. hDlg = pMsg->hWin;
      35. switch (pMsg->MsgId) {
      36. default:
      37. WM_DefaultProc(pMsg);
      38. }
      39. }
      40. /*********************************************************************
      41. *
      42. * _cbDialog4
      43. */
      44. static void _cbDialog4(WM_MESSAGE * pMsg) {
      45. int NCode;
      46. int Id;
      47. WM_HWIN hDlg, hItem;
      48. hDlg = pMsg->hWin;
      49. switch (pMsg->MsgId) {
      50. case WM_INIT_DIALOG:
      51. hItemtext = WM_GetDialogItem(hDlg, GUI_ID_MULTIEDIT0);
      52. MULTIEDIT_SetText(hItemtext, "MULTIEDIT widget");
      53. MULTIEDIT_SetInsertMode(hItemtext, 1);
      54. break;
      55. case WM_NOTIFY_PARENT:
      56. Id = WM_GetId(pMsg->hWinSrc);
      57. NCode = pMsg->Data.v;
      58. switch(Id) {
      59. case ID_BUTTON_0: // Notifications sent by 'Button'
      60. switch(NCode) {
      61. case WM_NOTIFICATION_CLICKED:
      62. // USER START (Optionally insert code for reacting on notification message)
      63. // USER END
      64. break;
      65. case WM_NOTIFICATION_RELEASED:
      66. // USER START (Optionally insert code for reacting on notification message)
      67. shomar++;
      68. // USER END
      69. break;
      70. // USER START (Optionally insert additional code for further notification handling)
      71. // USER END
      72. }
      73. break;
      74. case ID_BUTTON_1: // Notifications sent by 'Button'
      75. switch(NCode) {
      76. case WM_NOTIFICATION_CLICKED:
      77. // USER START (Optionally insert code for reacting on notification message)
      78. // USER END
      79. break;
      80. case WM_NOTIFICATION_RELEASED:
      81. // USER START (Optionally insert code for reacting on notification message)
      82. shomar--;
      83. // USER END
      84. break;
      85. // USER START (Optionally insert additional code for further notification handling)
      86. // USER END
      87. }
      88. break;
      89. // USER START (Optionally insert additional code for further Ids)
      90. // USER END
      91. }
      92. break;
      93. default:
      94. WM_DefaultProc(pMsg);
      95. }
      96. }
      97. /*********************************************************************
      98. *
      99. * _cbBkWindow
      100. *
      101. * Purpose:
      102. * Callback routine of the background window, shows the sample title and draws the background
      103. */
      104. static void _cbBkWindow(WM_MESSAGE* pMsg) {
      105. switch (pMsg->MsgId) {
      106. case WM_PAINT:
      107. f_mount(&myFATFS, SDPath, 1);
      108. f_open(&myFILE, "asuka2.bmp", FA_READ);
      109. size = f_size(&myFILE);
      110. GUI_BMP_DrawEx(APP_GetData, &myFILE, 0, 0);
      111. f_close(&myFILE);
      112. //GUI_Clear();
      113. //GUI_SetColor(GUI_WHITE);
      114. //GUI_SetFont(GUI_FONT_20B_ASCII);
      115. //GUI_DispStringHCenterAt("WIDGET_Multipage - Sample", 160, 5);
      116. break;
      117. default:
      118. WM_DefaultProc(pMsg);
      119. }
      120. }
      121. /*********************************************************************
      122. *
      123. * _cbFrameWin
      124. *
      125. * Purpose:
      126. * Callback routine of the frame window behind the MULTIPAGE widget
      127. */
      128. static void _cbFrameWin(WM_MESSAGE* pMsg) {
      129. switch (pMsg->MsgId) {
      130. case WM_PAINT:
      131. GUI_Clear();
      132. GUI_SetColor(GUI_WHITE);
      133. GUI_SetFont(&GUI_Font24_ASCII);
      134. //GUI_DispStringHCenterAt("WIDGET_Multipage - Sample", 160, 5);
      135. break;
      136. default:
      137. WM_DefaultProc(pMsg);
      138. }
      139. }
      140. /*********************************************************************
      141. *
      142. * _DemoMultiPage
      143. *
      144. * Purpose:
      145. * Demonstrates the use of a multipage widget
      146. */
      147. void _DemoMultiPage(void) {
      148. WM_HWIN hMultiPage, hFrameWin, hDialog;
      149. /* Enable use of memory devices */
      150. WM_SetCreateFlags(WM_CF_MEMDEV);
      151. WM_EnableMemdev(WM_HBKWIN);
      152. WM_SetCallback(WM_HBKWIN, &_cbBkWindow); /* Use own callback routine for background window */
      153. /* Create the frame window */
      154. hFrameWin = FRAMEWIN_Create("FrameWindow", &_cbFrameWin, WM_CF_SHOW, 140, 10, 200, 300);
      155. //FRAMEWIN_SetClientColor(hFrameWin, GUI_GREEN);
      156. FRAMEWIN_SetActive(hFrameWin, 1);
      157. FRAMEWIN_AddMinButton(hFrameWin, FRAMEWIN_BUTTON_RIGHT, 0);
      158. //FRAMEWIN_SetMoveable(hFrameWin, 1);
      159. /* Create the MULTIPAGE widget */
      160. hMultiPage = MULTIPAGE_CreateEx(0, 0, 190, 280, WM_GetClientWindow(hFrameWin), WM_CF_SHOW, 0, 0);
      161. GUI_COUNTOF(_aDialogCreate3),
      162. &_cbDialog3, WM_UNATTACHED, 0, 0);
      163. MULTIPAGE_AddPage(hMultiPage, hDialog, "Page 3");
      164. GUI_Delay(10);
      165. hDialog = GUI_CreateDialogBox(_aDialogCreate4,
      166. GUI_COUNTOF(_aDialogCreate4),
      167. &_cbDialog4, WM_UNATTACHED, 0, 0);
      168. MULTIPAGE_AddPage(hMultiPage, hDialog, "Home");
      169. while (1) {
      170. GUI_Exec();
      171. sprintf(chr, "%d", shomar);
      172. MULTIEDIT_SetText(hItemtext, chr);
      173. }
      174. }
      175. void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
      176. {
      177. if(GPIO_Pin == RE_Flag_Pin)
      178. {
      179. if((TIM9->CNT - CNTold) > 100 & shomarconfirm == 0)
      180. {
      181. shomar++;
      182. shomarconfirm = 1;
      183. }
      184. else shomarconfirm = 0;
      185. CNTold = TIM9->CNT;
      186. }
      187. if(GPIO_Pin == RE_EXT_Pin)
      188. {
      189. if((TIM9->CNT - CNTold) > 100 & shomarconfirm == 0)
      190. {
      191. shomar--;
      192. shomarconfirm = 1;
      193. }
      194. else shomarconfirm = 0;
      195. CNTold = TIM9->CNT;
      196. }
      197. }
      Display All
      in line 119 I defined a bmp for background (with size of 480*320). by removing this line everything goes OK!

      my MCU has 132 KB of RAM.. if I use an MCU with 190 or 260 KB of RAM the problem can be solved? is there any solution?


      thanks.
      Sora.