MultiLayer problem

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

  • MultiLayer problem

    Hello,

    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.

    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.
  • 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_MEMDEV_Select(hMemBG);
    GUI_SetColor(GUI_BLUE);
    GUI_FillCircle(100, 50, 49);

    GUI_MEMDEV_Select(hMemFG);
    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);
    }

    GUI_SelectLayer(0);
    GUI_MEMDEV_CopyToLCD(hMemBG);

    GUI_SelectLayer(1);
    GUI_SetBkColor(GUI_TRANSPARENT);
    GUI_MEMDEV_CopyToLCD(hMemFG);


    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

    GUI_MEMDEV_Select(0);

    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.

    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.