MultiLayer problem

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

  • MultiLayer problem


    I'm working on STM32F4 Controller. The LTDC harware module supports two hardware layers. Hence I want to use emWIn MultiLayer support to create two hardware layer. First I created one layer and everything works fine. I can draw Bitmaps and so on. After I tried to create the second layer which seems to be fine. When I call LCD_GetNumLayers() I got two layers which should be fine. But when I want to draw one Bitmap or anything else in the the first layer (layer index 0) it isn't visible on the display. Only the draw operations in the second layer (layer index 1) are visible. Even if I try the GUI_SetLayerVisEx(0) function. Does anyone have an idea?
  • Hi,

    Per default the layers are not transparent. This means that if you have two layers the first one (index 0) is completely covered by the second layer.

    You could hide second layer:

    GUI_SetLayerVisEx(1, 0);

    Reduce its size and/or position:

    GUI_SetLayerSizeEx(1, xSize, ySize);
    GUI_SetLayerPosEx(1, xPos, yPos),

    Make it transparent:

    GUI_SetLayerAlphaEx(1, AlphaValue);

    Each of these functions will make the first layer (which lays behind the second one) somehow visible.

  • Dear Schoenen,

    it works fine, thank you very much for your support!
    But know I'm trying to use Multilayer and Memory Devices combined. But I have a problem about that. As explanation I used an example of emWin manual (chapter 25.2.2).
    I edited the source code as follows:

    static GUI_MEMDEV_Handle hMemBG = GUI_MEMDEV_CreateFixed32(0,0, 480,272 );
    static GUI_MEMDEV_Handle hMemFG = GUI_MEMDEV_CreateFixed32(0,0, 480,272 );

    GUI_FillCircle(100, 50, 49);

    for (int i = 0; i < 100; i++) {
    U32 Alpha;
    Alpha = (i * 255 / 100) << 24;
    GUI_SetColor(GUI_YELLOW | Alpha);
    GUI_DrawHLine(i, 100 - i, 100 + i);



    My intention is to draw something in one Memory device and something else in the second Memory Device. After then I want to draw the contents in two different layers. I guess, using the GUI_MEMDEV_CopyToLCD() function after selecting the layer, the content of the Memory Device will be copied in the frame buffer of the selected layer. But when I execute this source code nothing is visible on the display. In Addition I'm calling GUI_Exec() cyclic, of course. Do you have any ideas?

    Thanks a lot!
  • Hi,

    Try to add


    before selecting layer 0.

    Didn't tested it. But at the first glance I would says it helps.

    After selecting a memory device you should always deselect it. The most save way is something like this:

    C Source Code

    1. GUI_MEMDEV_Handle hMemDraw;
    2. GUI_MEMDEV_Handle hMemOld;
    3. GUI_Init();
    4. hMemDraw = GUI_MEMDEV_Create(0, 0, 10, 10);
    5. hMemOld = GUI_MEMDEV_Select(hMemDraw);
    6. //
    7. // .. Draw something
    8. //
    9. GUI_MEMDEV_Select(hMemOld);

    This makes sure that you always re-select the device which was selected before hMemDraw. Above it doesn't makes that much sense, but in combination with the window manager and automatic use of memory devices this is really helpful. Otherwise you might mess up the devices and some drawings end up where they don't belong.