2015-07-01 02:00 PM
Hello,
I'm facing with very strange problem using STemWin library. I don't know if this is problem on my side, on STemWin (ST) side or directly from Segger, so I'm asking here first. What's my idea. I have a graph with (for now) one curve on it and I'm trying to update it every 100ms. On STM32F429-Discovery using driver provided from ST I see flickering and my idea is that LCD shows LTDC layer 2, but EMWIN draws everything on layer1 on LCD which is hidden. Then, after each emwin operation is done, I would copy content from layer1 (EMWIN drawing layer) to layer2 (user visible layer) to avoid flickering. It works what I wanna do, but no in a way I wanna do. My idea is, to copy layers only if there were pending tasks done with emwin using GUI_Exec function. According to the emWin documentation, GUI_Exec returns 1 if there were tasks to do. So when GUI_Exec() returns non-zero value, I would then also copy layer1 to layer2. But here is problem with GUI_Exec function. This function returns non-zero value only FIRST time when I call it. I call it first time after I set my graph. Each next time, function successfully does its job with updating everything, but it does not return non-zero value anymore so I can't know if there were pending tasks done to copy layers. Has this something to do with ST's implementation or is this Segger related problem? PS: STemWin 5.26 is in use without any Cube software. On version 5.22 I got the same behavior. Below is my example how I use this:GUI_Init();
/* Create graph through all LCD screen */
hGraph = GRAPH_CreateEx(0, 0, 320, 240, 0, WM_CF_SHOW, 0, GUI_ID_GRAPH0);
/* Set grids and border */
GRAPH_SetGridVis(hGraph, 1);
GRAPH_SetBorder(hGraph, 25, 5, 5, 5);
/* Create a curve for graph */
hData = GRAPH_DATA_YT_Create(GUI_DARKGREEN, 500, 0, 20);
/* Attach curve to graph */
GRAPH_AttachData(hGraph, hData);
/* Create scale for graph */
hScale = GRAPH_SCALE_Create(3, GUI_TA_LEFT, GRAPH_SCALE_CF_VERTICAL, 25);
/* Attach it to graph */
GRAPH_AttachScale(hGraph, hScale);
/* Update EMWIN GUI = do pending tasks */
/* This works, function returns non-zero, because it has some job to do */
/* And it is called first time in this project */
GUI_Exec();
/* Add manual data for testing if graph works */
GRAPH_DATA_YT_AddValue(hData, 100 + 60 * sin((float)2 * (float)5 * (float)3.14 * (float)15 / (float)255));
GRAPH_DATA_YT_AddValue(hData, 100 + 60 * sin((float)2 * (float)5 * (float)3.14 * (float)15 / (float)255));
GRAPH_DATA_YT_AddValue(hData, 100 + 60 * sin((float)2 * (float)5 * (float)3.14 * (float)15 / (float)255));
GRAPH_DATA_YT_AddValue(hData, 100 + 60 * sin((float)2 * (float)5 * (float)3.14 * (float)15 / (float)255));
GRAPH_DATA_YT_AddValue(hData, 100 + 60 * sin((float)2 * (float)5 * (float)3.14 * (float)15 / (float)255));
GRAPH_DATA_YT_AddValue(hData, 100 + 60 * sin((float)2 * (float)5 * (float)3.14 * (float)15 / (float)255));
/* Change layers for LTDC, show layer 2 on LCD */
TM_ILI9341_ChangeLayers();
while
(1) {
/* Here is my problem */
/* Check for pending tasks */
/* Here is function called second time and it does all pending jobs successfully */
/* Writes 6 points to graph as set some lines above */
/* But it does not return non-zero value anymore, it always returns zero value meaning no job to do anymore */
if
(GUI_Exec() > 0) {
/* Toggle LED, confirm that GUI_Exec returns non-zero value */
/* This never happens, LEDs are always zero */
TM_DISCO_LedToggle(LED_ALL);
/* Do some job if windows are updated */
/* Copy layer 1 (EMWIN drawing layer) to user-visible layer 2 to avoid flickering when fast updating graphs */
TM_ILI9341_Layer1To2();
}
/* Every 100 ms add new value to graph */
if
(TM_DELAY_Time() > 100) {
/* Reset time */
TM_DELAY_SetTime(0);
/* Add new fake values to graph */
GRAPH_DATA_YT_AddValue(hData, 100 + 60 * sin((float)2 * (float)5 * (float)3.14 * (float)15 / (float)255));
GRAPH_DATA_YT_AddValue(hData, 100);
}
}
#f429-discovery #stm32 #stemwin
2015-07-02 07:32 AM
Hi,
I faced the same problem with the example under STM32F429I-Discovery\Examples\LTDC\LTDC_Display_2Layers.To resolve it, update ''HAL_LTDC_SetWindowPosition'' as following:
Replace ''hltdc->Instance->SRCR = LTDC_SRCR_IMR;''by
''hltdc->Instance->SRCR = LTDC_SRCR_VBR;'' The issue is also reported to ST team. I hope that the proposal solve your problem. Regards
2015-07-02 08:43 AM
Hi,
I won't try your solution because:1. Problem is related to the STemWin because GUI_Exec does not return non-zero value even if there are jobs to be done,2. I said I don't use HAL drivers. Only STD + coding directly in registers.