emWin 1024x600 redraw problem

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

  • emWin 1024x600 redraw problem

    Hello,
    I'm using stemwin 5.26 on cortex m4 with freertos. my display is 1024 x 600. I started to implement some simple windows, but I see that refresh of the window causes a visible frame corruption. I made and attached a small video to explain clearly the issue. I do not know where the issue is located.

    Here code snippets of what I have in the program.

    Thanks for help
    Best Regards

    C Source Code

    1. main()
    2. {
    3. /*** [.....] ****/
    4. /* Initialize GUI */
    5. GUI_Init();
    6. osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 128);
    7. defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);
    8. osThreadDef(GUI_Thread, GUIThread, osPriorityLow, 0, 20 * configMINIMAL_STACK_SIZE);
    9. osThreadCreate(osThread(GUI_Thread), NULL);
    10. /* Start scheduler */
    11. osKernelStart();
    12. }
    13. /**************************************************************************************/
    14. static void GUIThread(void const * argument)
    15. {
    16. GUI_SelectLayer(1);
    17. GUI_SetColor (GUI_YELLOW);
    18. GUI_FillRect(600,300,1024,600);
    19. GUI_SetColor (GUI_BLUE);
    20. GUI_FillRect(20,10,500,500);
    21. k_InitMenu();
    22. while(1)
    23. {
    24. LED_Toggle(LED1);
    25. LED_Toggle(LED2);
    26. GUI_Delay(100);
    27. }
    28. }
    29. /**************************************************************************************/
    30. void k_InitMenu(void)
    31. {
    32. WM_SetCallback(WM_HBKWIN, _cbBk);
    33. GUI_SelectLayer(1);
    34. WM_CreateWindowAsChild(0, 0, 1000, 25, WM_HBKWIN, WM_CF_SHOW | WM_CF_HASTRANS | WM_CF_MEMDEV, _cbStatus, 0);
    35. }
    36. /*******************************************************************************/
    37. static void _cbStatus(WM_MESSAGE * pMsg)
    38. { int xSize, ySize;
    39. static uint8_t TempStr[50];
    40. static WM_HTIMER hTimerTime;
    41. static uint8_t tmp;
    42. static uint8_t bmp_res2;
    43. RTC_TimeTypeDef RTC_Time;
    44. RTC_DateTypeDef RTC_DateStructure;
    45. uint8_t sec, min, hour, day, month;
    46. uint16_t year;
    47. WM_HWIN hWin;
    48. hWin = pMsg->hWin;
    49. switch (pMsg->MsgId)
    50. {
    51. case WM_CREATE:
    52. hTimerTime = WM_CreateTimer(hWin, ID_TIMER_TIME, 1000, 0);
    53. break;
    54. case WM_DELETE:
    55. WM_DeleteTimer(hTimerTime);
    56. break;
    57. case WM_TIMER:
    58. if( WM_GetTimerId(pMsg->Data.v) == ID_TIMER_TIME)
    59. {
    60. WM_InvalidateWindow(pMsg->hWin);
    61. WM_RestartTimer(pMsg->Data.v, 1000);
    62. }
    63. break;
    64. case WM_PAINT:
    65. xSize = WM_GetWindowSizeX(hWin);
    66. ySize = WM_GetWindowSizeY(hWin);
    67. /* Draw background */
    68. GUI_Clear();
    69. GUI_SetColor(0x008d00);
    70. GUI_FillRect(0, 0, xSize , ySize - 3);
    71. GUI_SetColor(0x808080);
    72. GUI_DrawHLine(ySize - 2, 0, xSize );
    73. GUI_SetColor(0x404040);
    74. GUI_DrawHLine(ySize - 1, 0, xSize );
    75. /* Draw time & Date */
    76. GUI_SetTextMode(GUI_TM_TRANS);
    77. GUI_SetColor(GUI_WHITE);
    78. GUI_SetFont(GUI_FONT_13B_ASCII);
    79. k_GetTime(&RTC_Time);
    80. sec = RTC_Time.Seconds;
    81. min = RTC_Time.Minutes;
    82. hour = RTC_Time.Hours;
    83. k_GetDate(&RTC_DateStructure);
    84. sprintf((char *)TempStr, "%02d:%02d:%02d", hour , min, sec);
    85. GUI_DispStringAt((char *)TempStr, xSize - 70, 4);
    86. year = RTC_DateStructure.Year + 2014;
    87. month = RTC_DateStructure.Month;
    88. day = RTC_DateStructure.Date;
    89. if((day > 0) && (day <= 31) && (month > 0)&& (month <= 12) && (year >= 1900))
    90. {sprintf((char *)TempStr, "%02d, %s, %04d", day , strMonth[month-1], year);}
    91. else
    92. {sprintf((char *)TempStr, "01, January, 2014");}
    93. GUI_DispStringHCenterAt((char *)TempStr, xSize / 2, 4);
    94. GUI_DispStringAt( (char *)TempStr, 50, 4);
    95. break;
    96. default:
    97. WM_DefaultProc(pMsg);
    98. break;
    99. }
    100. }
    Display All
    Files
    • IMG_1091.zip

      (767.28 kB, downloaded 469 times, last: )
  • Hello,

    I am not sure what might cause this behavior. Have you tried doing this with layer 0? I see your example just uses layer 1. Also does the function _cbBk() draw the background in any way? If you just want to fill the background with a solid color, you do not have to set a callback function for that. Calling the function WM_SetDesktopColor() would be sufficient, but please note that both ways need to be done for all layers, since each layer has its own desktop window.

    Best regards,
    Adrian
  • Hello Adrian,
    I placed all in layer 0 (substituting GUI_SelectLayer(1) with GUI_SelectLayer(0) in the same code posted before) and the result is a black screen. Nothing on the screen. I cannot understand why.
    Here the background callback function

    C Source Code

    1. static void _cbBk(WM_MESSAGE * pMsg)
    2. {
    3. switch (pMsg->MsgId)
    4. {
    5. default:
    6. WM_DefaultProc(pMsg);
    7. break;
    8. }
    9. }
  • Adrian,

    I tried with only one layer (#define GUI_NUM_LAYERS 1) instead of 2 and the display seems to work well (i can see what I draw and the refresh problem is not present)
    Where the second layer can cause the problem?

    Best Regards
  • Hello,

    Please note that your function _cbBk() does not react to the WM_PAINT message and therefor does not draw anything.

    Also please refer to the section 24.2.5 "MultiLayer support" -> "Using MultiLayer support" -> "Configuring MultiLayer support" in the emWin user manual to verify your configuration.

    Best regards,
    Adrian
  • Adrian,
    I picked the _cbBK() function from a working demo, so I figured out that it wasn't interfering with my fw.
    I decreased the peripheral clock from 32 MHz to 20 MHz and the frame corruption is not visible anymore. I have to say that now I can see a little refresh on the display especially with large images. I cannot figure out why.

    Best Regards