Thursday, June 29th 2017, 9:20am UTC+2

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

Manfred

Beginner

Date of registration: Apr 26th 2017

Posts: 7

1

Friday, May 19th 2017, 12:56pm

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?

SEGGER - Schoenen

Super Moderator

Date of registration: Aug 13th 2015

Posts: 309

2

Thursday, June 1st 2017, 4:47pm

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

Manfred

Beginner

Date of registration: Apr 26th 2017

Posts: 7

3

Friday, June 2nd 2017, 1:10pm

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!

SEGGER - Schoenen

Super Moderator

Date of registration: Aug 13th 2015

Posts: 309

4

Tuesday, June 6th 2017, 4:39pm

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/C++ Source code

1
2
3
4
5
6
7
8
9
10
  GUI_MEMDEV_Handle hMemDraw;
  GUI_MEMDEV_Handle hMemOld;

  GUI_Init();
  hMemDraw = GUI_MEMDEV_Create(0, 0, 10, 10);
  hMemOld = GUI_MEMDEV_Select(hMemDraw);
  //
  // .. Draw something
  //
  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