GUI_MEMDEV_create() problem

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

  • GUI_MEMDEV_create() problem

    Hello,
    To develop without flickering, I want to use GUI_MEMDEV_create() function. I get an error during creation of it. (return 0)

    To begin I used a demo code and It works very well. Layers are displayed only during the CopyToLCD functions.

    C Source Code

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


    Now I would like apply the same strategy to my screen (7": 800*480 pixels)
    hMem0 and hMem1 return 0. Memory are not created and all operations are shown before the CopyToLCD operation.

    C Source Code

    1. GUI_SelectLayer(0);
    2. hMem0 = GUI_MEMDEV_Create(0, 0, 800, 480);
    3. GUI_MEMDEV_Select(hMem0);
    4. GUI_Clear();
    5. GUI_SetColor(GUI_RED);
    6. GUI_FillRect(0, 0, 400, 240);
    7. GUI_SetColor(GUI_GREEN);
    8. GUI_FillRect(0, 240, 400, 480);
    9. GUI_SetColor(GUI_BLUE);
    10. GUI_FillRect(400, 0, 800, 240);
    11. GUI_SelectLayer(1);
    12. hMem1 = GUI_MEMDEV_Create(0, 0, 800, 480);
    13. GUI_MEMDEV_Select(hMem1);
    14. GUI_SetBkColor(GUI_WHITE);
    15. GUI_Clear();
    16. GUI_SetColor(GUI_DARKBLUE);
    17. GUI_DispStringHCenterAt("TEST Layer 1", 100, 4);
    18. GUI_SetColor(GUI_TRANSPARENT);
    19. GUI_AA_FillCircle(400, 240, 150);
    20. GUI_FillRect(180, 0, 220, 480);
    21. GUI_FillRect(580, 0, 620, 480);
    22. GUI_MEMDEV_CopyToLCD(hMem0);
    23. GUI_MEMDEV_CopyToLCD(hMem1);
    Display All



    Do you have an idea ? For information I use the STM32f429 discovery demo board.
    Must I increase the RAM data space ? How ?


    Thanks in advance.
  • Hello,

    Yes, the most likely reason for a creation function (in general) to return with 0 is lack of memory. Please try assigning more memory to emWin in the function GUI_X_Config() (GUIConf.c). Details about the memory requirements can be found in the chapter "Memory Devices" in the emWin user manual.

    Best regards,
    Adrian
  • Ok thank you ! It works !

    I post my source code compatible with IAR compiler:

    C Source Code

    1. #define GUI_NUMBYTES ( 2048 * 1024) // x KByte
    2. #pragma location=0xD0000000 //EXTRAM start
    3. static __no_init U32 HeapMem[1024 * 1024];
    4. #pragma location=0xD0200000 //EXTRAM GUI Conf
    5. static __no_init U32 extMem[GUI_NUMBYTES];
    6. U32* Get_ExtMemHeap (void)
    7. {
    8. return HeapMem;
    9. }
    10. void GUI_X_Config(void)
    11. {
    12. GUI_ALLOC_AssignMemory(extMem, GUI_NUMBYTES);
    13. }
    Display All