How to port display function with LDTC controller?


What MCU/Processor/Board and compiler are you using?

I use waveshare’s STM32F746 core board and 7inch Capacitive Touch LCD(F).
Keil MDK 5.24.

What do you want to achieve?

Port the disp_flush function with LTDC controller.

What have you tried so far?

I referenced the lv_port_stm32f746_disco_sw4stm32 project, but it was unsuccessful.

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
    /*The most simple case (but also the slowest) to put all pixels to the screen one-by-one*/


	Copy_Buffer((const uint32_t *)color_p, my_fb, area->x1, area->y1, lv_area_get_width(area), lv_area_get_height(area));

    /* IMPORTANT!!!
     * Inform the graphics library that you are ready with the flushing*/

	uint32_t x_address = (hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress) + 2*(BSP_LCD_GetXSize()*y + x);
	uint32_t source      = (uint32_t)pSrc;
	/* Register to memory mode with ARGB8888 as color Mode */ 
  hDma2dHandler.Init.Mode         = DMA2D_R2M;
  if(hLtdcHandler.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_RGB565)
  { /* RGB565 format */ 
    hDma2dHandler.Init.ColorMode    = DMA2D_RGB565;
  { /* ARGB8888 format */
    hDma2dHandler.Init.ColorMode    = DMA2D_ARGB8888;
  hDma2dHandler.Init.OutputOffset = BSP_LCD_GetXSize() - xSize;      
  hDma2dHandler.Instance = DMA2D;
  /* DMA2D Initialization */
  if(HAL_DMA2D_Init(&hDma2dHandler) == HAL_OK) 
    if(HAL_DMA2D_ConfigLayer(&hDma2dHandler, ActiveLayer) == HAL_OK) 
      if (HAL_DMA2D_Start(&hDma2dHandler, source, x_address, xSize, ySize) == HAL_OK)
        /* Polling For DMA transfer */  
        HAL_DMA2D_PollForTransfer(&hDma2dHandler, 10);

Screenshot and/or video

I’m not sure if something is missing, but it looks like the objects are all created, but the colors are not quite right.I use the demo example.


Are you sure color depth of you display and the driver’s settings are match? (RGB565 or RGB888)

I solved this problem with a very inefficient method,but it works for me.(issus #1403)

    int32_t x;
    int32_t y;
    for(y = area->y1; y <= area->y2; y++) {
        for(x = area->x1; x <= area->x2; x++) {
            /* Put a pixel to the display. For example: */
            /* put_px(x, y, *color_p)*/
            BSP_LCD_PutPixel(x, y, color_p->full);

Thanks for your help.:blush:

Have a nice day!

What is your LTDC pixel format?
The demo application from Waveshare found here have used RGB565 format.

I am use RGB565 format.