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:
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:
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
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
- #include "UI_QwertyKeyPad.h"
- static GUI_QwertyKeyPad_t _qwertykeypad = {
- .active = 0,
- .state = QwertyKeyPad_None,
- .submenu = NULL,
- .max_char_nr = 0,
- .str = NULL,
- .accept_action = NULL,
- };
- GUI_SubMenu_t GUI_QwertyKeyPadMenu = {
- .items_nr = 35,
- .topbar_items_nr = 2,
- .default_return = NULL,
- .constructor = &GUI_QwertyKeyPad_InitMenu,
- };
- uint8_t func(void)
- {
- uint8_t i=1;
- return i;
- }
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
- void GUI_Thread(void const * argument)
- {
- _init_gui();
- // GUI background Task
- while(1)
- {
- GUI_WindowInvalid = _check_time_changed();
- _check_item_pressed();
- _check_context_switch();
- if(GUI_WindowInvalid)
- {
- _draw_gui();
- GUI_Exec();
- }
- osDelay(20);
- }
- }
- static void _init_gui(void)
- {
- buzzer_init();
- buzzer_on();
- buzzer_power(25); //max 100
- Beep();
- osDelay(30);
- Beep(); //just beep - why not?
- #ifdef BUZZER_TEST
- _buzzer_test();
- #endif
- // Create Touch screen Timer
- lcd_timer = osTimerCreate(osTimer(TS_Timer), osTimerPeriodic, (void *)0);
- // Start the TS Timer
- osTimerStart(lcd_timer, 50);
- // Create Panel Refresh Timer
- panel_timer = osTimerCreate(osTimer(Panel_Timer), osTimerPeriodic, (void *)0);
- // IO Self Test
- IOtest_timer = osTimerCreate(osTimer(IOtest_timer), osTimerPeriodic, (void *)0);
- // Clear LEDs
- LED_RUNNING(0);
- LED_ERROR(0);
- LED_READY(0);
- // Initialize logon module
- logon_log_first_user();
- // Initialize STemWin
- GUI_Init();
- GUI_SetBkColor(GUI_WHITE);
- GUI_Clear();
- GUI_EnableAlpha(ENABLE); //not realy used
- // Initialize the Touch screen
- TP_init();
- // Initialize dictionary
- dictionary = _set_dictionary();
- // Initialize top bar and main menu
- GUI_TopBar_init();
- GUI_Main_InitMenu();
- // Init runtime parameters
- _runtime_parameters_init();
- // Init redraw flag
- GUI_WindowInvalid = true;
- }
- static void _draw_gui(void)
- {
- int i;
- GUI_Item_t **bar_items = GUI_TopBar_Get();
- BSP_LCD_WaitForBufferSwitch();
- GUI_SetBkColor(GUI_DARKGRAY);
- GUI_Clear();
- for(i=0; i<GUI_TOPBAR_ITEMS_NR; i++)
- {
- _draw_item(bar_items[i]);
- }
- for(i=0; i<GUI_MAX_NR_OF_ITEMS; i++)
- {
- if(GUI_Items[i]==NULL) break;
- _draw_item(GUI_Items[i]);
- }
- BSP_LCD_SwitchBuffer();
- }
- static void _draw_item(GUI_Item_t *item)
- {
- int x,y;
- if(!item->is_active) return;
- GUI_RECT Rect = {item->x, item->y, item->x+item->x_size, item->y+item->y_size};
- if(item->color!=GUI_TRANSPARENT)
- {
- GUI_SetColor(item->color);
- GUI_FillRectEx(&Rect);
- }
- GUI_SetColor(item->icon_color);
- if(item->icon!=NULL)
- {
- Rect.x0 = item->x + item->icon_x;
- Rect.y0 = item->y + item->icon_y;
- GUI_DisplayIconInRect(item->icon, &Rect, item->icon_align, item->icon_x);
- }
- if(item->text!=NULL)
- {
- Rect.x0 = item->x + item->text_x;
- Rect.y0 = item->y + item->text_y;
- if(item->text_align&GUI_TA_RIGHT) Rect.x1 -= item->text_x;
- GUI_SetColor(item->text_color);
- GUI_SetTextMode(GUI_TM_TRANS); // text transparent mode
- if(item->text_font==NULL) item->text_font = GUI_DEFAULT_FONT_;
- GUI_SetFont(item->text_font);
- GUI_DispStringInRect(item->text, &Rect, item->text_align);
- }
- }
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