Skip to main content
PMath.4
Senior III
October 30, 2019
Solved

STM32H743 LTDC, can't make sense of layers

  • October 30, 2019
  • 3 replies
  • 1093 views

I'm being stupid but I've copied the various demos and tried every combination I can think off.

I want to have two layers that I can write to. If a pixel in layer 2 is set to zero then I want the pixel from layer 1 to show through otherwise I want the the layer 2 pixel to show as-is.

The overall LTDC set up is working to the extent in that if I set alpha for layer 2 to 100 then I can see images from both layers with the layer 2 information on top of layer 1 and the intensity of layer 1 reduced.

However, if I increase the alpha of layer 2 to 255 then layer 1 disappears completely rather than just the pixels that are non-blank in layer 2. If I set it to 0 then layer 2 doesn't show at all

Here is my layer set up. I've tried both variants of the blending factor

		 if(colours==16) pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_RGB565;
		 else pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_L8;
		 pLayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA;
		 pLayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA;
		 pLayerCfg.Backcolor.Blue = 0;
		 pLayerCfg.Backcolor.Green = 0;
		 pLayerCfg.Backcolor.Red = 0;
		 pLayerCfg.Alpha = 255;
		 pLayerCfg.Alpha0 = 0;
		 pLayerCfg.FBStartAdress = (uint32_t)WritePageAddress;
		 pLayerCfg.WindowX0 = 0;
		 pLayerCfg.WindowY0 = 0;
		 pLayerCfg.WindowX1 = x;
		 pLayerCfg.WindowY1 = y*yscale;
		 pLayerCfg.ImageWidth = x;
		 pLayerCfg.ImageHeight = y*yscale;
		 if(colours==16) pLayerCfg1.PixelFormat = LTDC_PIXEL_FORMAT_RGB565;
		 else pLayerCfg1.PixelFormat = LTDC_PIXEL_FORMAT_L8;
		 pLayerCfg1.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA;
		 pLayerCfg1.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA;
		 pLayerCfg1.Backcolor.Blue = 0;
		 pLayerCfg1.Backcolor.Green = 0;
		 pLayerCfg1.Backcolor.Red = 0;
		 pLayerCfg1.Alpha = 200;
		 pLayerCfg1.Alpha0 = 0;
		 pLayerCfg1.FBStartAdress = (uint32_t)LayerPageAddress;
		 pLayerCfg1.WindowX0 = 0;
		 pLayerCfg1.WindowY0 = 0;
		 pLayerCfg1.WindowX1 = x;
		 pLayerCfg1.WindowY1 = y*yscale;
		 pLayerCfg1.ImageWidth = x;
		 pLayerCfg1.ImageHeight = y*yscale;
if (HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg, 0) != HAL_OK)
{
	error("HAL_LTDC_ConfigLayer");
}
if (HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg1, 1) != HAL_OK)
{
	error("HAL_LTDC_ConfigLayer1");
}

This topic has been closed for replies.
Best answer by oleksandr.karbivsky

Hi. If you want set alpha for specific pixel use ARGB4444 pixel format instead RGB565.

3 replies

oleksandr.karbivsky
Senior II
October 31, 2019

Hi. If you want set alpha for specific pixel use ARGB4444 pixel format instead RGB565.

PMath.4
PMath.4Author
Senior III
November 1, 2019

Thanks - that was the clue I needed - I'm using ARGB1555 and it is working perfectly. Now the only problem I have is switching back to single layer mode. Even stopping and restarting LTDC (Deinit/Init) doesn't seem to clean up properly

waclawek.jan
Super User
November 1, 2019

> Hi. If you want set alpha for specific pixel use ARGB4444 pixel format instead RGB565.

Not necessarily, see the Color keying paragraph in the LTDC chapter in RM.

JW