STM32H743 LTDC, can't make sense of layers
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");
}