STemWin 532 with STM32F777 screen tearing

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

    • STemWin 532 with STM32F777 screen tearing

      Hello,

      I'm developing an UI project on custom board with STM32F777BI and WF70GTZAGDNG0 (800x480 TFT) using STemWin 532 library. Everything was going great and smooth
      until recently i added new file to the project (qwerty.c). What happened after adding this file is that the screen started tearing (I'm not sure if it is tearing or how to call it
      as the menu is mostly static, it is blinking every 1-5 seconds, seems like it tries to draw correct frame but moved by few pixels, but it happens too quickly to be sure what is drawn).
      To diagnose the problem, I stripped qwerty.c to the minimum and now it looks like this:

      C Source Code

      1. #include "UI_QwertyKeyPad.h"
      2. static GUI_QwertyKeyPad_t _qwertykeypad = {
      3. .active = 0,
      4. .state = QwertyKeyPad_None,
      5. .submenu = NULL,
      6. .max_char_nr = 0,
      7. .str = NULL,
      8. .accept_action = NULL,
      9. };
      10. GUI_SubMenu_t GUI_QwertyKeyPadMenu = {
      11. .items_nr = 35,
      12. .topbar_items_nr = 2,
      13. .default_return = NULL,
      14. .constructor = &GUI_QwertyKeyPad_InitMenu,
      15. };
      16. uint8_t func(void)
      17. {
      18. uint8_t i=1;
      19. return i;
      20. }
      Display All


      And now what is strange is that if I put func() anywhere in my code and qwerty.c compiles, the screen is tearing/blinking. If i remove func call, and
      compiler optimizes out the file from compilation as it has no reference, everything works perfectly. Now, my main loop looks like this:


      C Source Code

      1. void GUI_Thread(void const * argument)
      2. {
      3. _init_gui();
      4. // GUI background Task
      5. while(1)
      6. {
      7. GUI_WindowInvalid = _check_time_changed();
      8. _check_item_pressed();
      9. _check_context_switch();
      10. if(GUI_WindowInvalid)
      11. {
      12. _draw_gui();
      13. GUI_Exec();
      14. }
      15. osDelay(20);
      16. }
      17. }
      18. static void _init_gui(void)
      19. {
      20. buzzer_init();
      21. buzzer_on();
      22. buzzer_power(25); //max 100
      23. Beep();
      24. osDelay(30);
      25. Beep(); //just beep - why not?
      26. #ifdef BUZZER_TEST
      27. _buzzer_test();
      28. #endif
      29. // Create Touch screen Timer
      30. lcd_timer = osTimerCreate(osTimer(TS_Timer), osTimerPeriodic, (void *)0);
      31. // Start the TS Timer
      32. osTimerStart(lcd_timer, 50);
      33. // Create Panel Refresh Timer
      34. panel_timer = osTimerCreate(osTimer(Panel_Timer), osTimerPeriodic, (void *)0);
      35. // IO Self Test
      36. IOtest_timer = osTimerCreate(osTimer(IOtest_timer), osTimerPeriodic, (void *)0);
      37. // Clear LEDs
      38. LED_RUNNING(0);
      39. LED_ERROR(0);
      40. LED_READY(0);
      41. // Initialize logon module
      42. logon_log_first_user();
      43. // Initialize STemWin
      44. GUI_Init();
      45. GUI_SetBkColor(GUI_WHITE);
      46. GUI_Clear();
      47. GUI_EnableAlpha(ENABLE); //not realy used
      48. // Initialize the Touch screen
      49. TP_init();
      50. // Initialize dictionary
      51. dictionary = _set_dictionary();
      52. // Initialize top bar and main menu
      53. GUI_TopBar_init();
      54. GUI_Main_InitMenu();
      55. // Init runtime parameters
      56. _runtime_parameters_init();
      57. // Init redraw flag
      58. GUI_WindowInvalid = true;
      59. }
      60. static void _draw_gui(void)
      61. {
      62. int i;
      63. GUI_Item_t **bar_items = GUI_TopBar_Get();
      64. BSP_LCD_WaitForBufferSwitch();
      65. GUI_SetBkColor(GUI_DARKGRAY);
      66. GUI_Clear();
      67. for(i=0; i<GUI_TOPBAR_ITEMS_NR; i++)
      68. {
      69. _draw_item(bar_items[i]);
      70. }
      71. for(i=0; i<GUI_MAX_NR_OF_ITEMS; i++)
      72. {
      73. if(GUI_Items[i]==NULL) break;
      74. _draw_item(GUI_Items[i]);
      75. }
      76. BSP_LCD_SwitchBuffer();
      77. }
      78. static void _draw_item(GUI_Item_t *item)
      79. {
      80. int x,y;
      81. if(!item->is_active) return;
      82. GUI_RECT Rect = {item->x, item->y, item->x+item->x_size, item->y+item->y_size};
      83. if(item->color!=GUI_TRANSPARENT)
      84. {
      85. GUI_SetColor(item->color);
      86. GUI_FillRectEx(&Rect);
      87. }
      88. GUI_SetColor(item->icon_color);
      89. if(item->icon!=NULL)
      90. {
      91. Rect.x0 = item->x + item->icon_x;
      92. Rect.y0 = item->y + item->icon_y;
      93. GUI_DisplayIconInRect(item->icon, &Rect, item->icon_align, item->icon_x);
      94. }
      95. if(item->text!=NULL)
      96. {
      97. Rect.x0 = item->x + item->text_x;
      98. Rect.y0 = item->y + item->text_y;
      99. if(item->text_align&GUI_TA_RIGHT) Rect.x1 -= item->text_x;
      100. GUI_SetColor(item->text_color);
      101. GUI_SetTextMode(GUI_TM_TRANS); // text transparent mode
      102. if(item->text_font==NULL) item->text_font = GUI_DEFAULT_FONT_;
      103. GUI_SetFont(item->text_font);
      104. GUI_DispStringInRect(item->text, &Rect, item->text_align);
      105. }
      106. }
      Display All

      GUI_Thread is for now the only thread that is running in the project. I have simplified it to the maximum and still have no idea what is going on

      and how to fix it. I would very mach appreciate some help, or tip.


      Best Regards,
      Jakub Zdzioch