Memory devices problem: screen direct drawing

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

  • Memory devices problem: screen direct drawing

    Hi,
    I'm new to emwin and I'm using STemwin on the STM32f429 discovery board.
    I need to migrate a old project on emwin and to do this I have to use memory devices and manually handle screen redraw.

    My problem is that if I use a memory device as drawing target I see that graphics are transferred directly to screen. And this before calling the GUI_MEMDEV_CopyToLCD() function.
    Is there something I miss?

    I started from the "hello-world" example for my board and I added the code of the layers transparency example modified with memory devices usage:

    C Source Code

    1. //memdev handles creation
    2. GUI_MEMDEV_Handle hMem0,hMem1;
    3. //just to be sure layes are visible
    4. GUI_SetLayerVisEx(0,1);
    5. GUI_SetLayerVisEx(1,1);
    6. //first memory device on layer 0: these operations are not shown
    7. //but only because there's opaque layer 1 covering them
    8. GUI_SelectLayer(0);
    9. hMem0 = GUI_MEMDEV_Create(0, 0, 200, 100);
    10. //memdev selection
    11. GUI_MEMDEV_Select(hMem0);
    12. GUI_Clear();
    13. GUI_SetColor(GUI_RED);
    14. GUI_FillRect(0, 0, 199, 33);
    15. GUI_SetColor(GUI_GREEN);
    16. GUI_FillRect(0, 34, 199, 66);
    17. GUI_SetColor(GUI_BLUE);
    18. GUI_FillRect(0, 67, 199, 99);
    19. //second memory device on layer 1: these operations are shown suddently
    20. GUI_SelectLayer(1);
    21. hMem1 = GUI_MEMDEV_Create(0, 0, 200, 100);
    22. GUI_MEMDEV_Select(hMem1);
    23. GUI_SetBkColor(GUI_WHITE);
    24. GUI_Clear();
    25. GUI_SetColor(GUI_BLACK);
    26. GUI_DispStringHCenterAt("Layer 1", 100, 4);
    27. GUI_SetColor(GUI_TRANSPARENT);
    28. GUI_FillCircle(100, 50, 35);
    29. GUI_FillRect(10, 10, 40, 90);
    30. GUI_FillRect(160, 10, 190, 90);
    31. //memory devices copy in respective layers: this is unuseful
    32. //because all is already drawn on layers
    33. //I would like to see result only after these two steps
    34. GUI_MEMDEV_CopyToLCD(hMem0);
    35. GUI_MEMDEV_CopyToLCD(hMem1);
    Display All


    Thank you for your help
  • Hi,
    I found that problem was related to failure of memory device creation.
    GUI_MEMDEV_Create returned zero that's the LCD selection.
    I encreased memory size moving GUI data to external RAM and now everything works fine.

    Thank you anyway
  • Hey Adrian,

    That is not so easy for me because I'm new with stm32 and emWin. Just trying to work with MEMDEV and no luck because of that problem.
    Maybe there is some article about how to setup memory? I can't find anything in STemWin manual. Thanks.
  • Hello,

    How to assign memory to emWin is explained in the chapter "Configuration" in the emWin user manual. At least this is the emWin part. You will have to refer to the documentation of your toolchain and hardware for information on how to place data on external RAM.

    Best regards,
    Adrian
  • hi dimky, sorry for delay.
    I'm using keil uVision compiler, If you also are using this compiler do as follows:
    open GUICONF.c file and modify GUI_NUMBYTES define as follows:
    I created a define to switch from internal to external RAM.
    you have first to understand what's first free place in your RAM. This will be GUI_BUFFER_ADDRESS. I placed this after 0X600000 bytes from RAM start (0xD0000000)
    then you have to increase GUI_NUMBYTES until your memory devices fits.

    C Source Code

    1. #define GUI_BUFFER_IN_EXT_RAM //comment this to run from internal RAM
    2. #define GUI_NUMBYTES ((1024) * 150) //was 1024*150
    3. #ifdef GUI_BUFFER_IN_EXT_RAM
    4. #define GUI_BUFFER_ADDRESS 0xD0600000 //is first free space after last buffer ending = Nlayers*LAYER_BYTES see LCD conf
    5. #endif


    Then, in same file modify void GUI_X_Config(void) function as follows:

    C Source Code

    1. void GUI_X_Config(void) {
    2. //
    3. // 32 bit aligned memory area
    4. //
    5. #ifdef GUI_BUFFER_IN_EXT_RAM
    6. static U32 aMemory[GUI_NUMBYTES / 4]__attribute__((at(GUI_BUFFER_ADDRESS)));
    7. #else
    8. static U32 aMemory[GUI_NUMBYTES / 4];
    9. #endif
    10. //
    11. // Assign memory to emWin
    12. //
    13. GUI_ALLOC_AssignMemory(aMemory, GUI_NUMBYTES);
    14. //
    15. // Set default font
    16. //
    17. GUI_SetDefaultFont(GUI_FONT_6X8);
    18. }
    Display All


    Hope it helps
  • Hi,

    I am new using emWin.
    I have the same board that FSPD, STM32F429 DISCOVERY and I am trying to use his code, the first one to implement MEMDEV and the second one to increase the memory available.


    My problem is that when I debug the execution, I can see that the first memdev is shown after execute the function GUI_MEMDEV_CopyToLCD(hMem0); but for the second memdev its drawing operations are shown with the execution of each line instead of wait to the function GUI_MEMDEV_CopyToLCD(hMem1);. How can I fix it?



    Another question I have, is related with the use of layers. I have used different layers without modifiying the variable GUI_NUM_LAYERS, but for this case I have had to. I have read the section 'MultiLayer' within the manual but I still don't know why I can use multilayers without initializing more than one layer.


    Thank you!
  • Hello again,

    I have solved the problem by deleting the memdev after using it. If I don't delete each memdev after using it, it is like I cannot create a new memdev.
    This solution includes that I have to copy each memdev before starting with the new one, and not as FSPD code where he copies both memdev after creating them.

    So, what can I do?

    Thanks.

    The post was edited 2 times, last by roldi ().

  • Hello Roldi,

    The problem is most likely related to a lack of memory. If there is not memory available the creation of a memory device will fail and the function GUI_MEMDEV_Create() will return 0.

    The most simple solution will be to increase the memory available for emWin. Take a look into the GUIConf.c and increase the size of the array used for allocating memory to emWin.

    Regarding the layer issue, not sure why it is working but I would recommend to configure multiple layers before using them ;)

    Regards,
    Sven
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.