Multiple horizontal lines when running lvgl

Description

Recently, I have been working on adding lvgl on the board stm32l4r9i discovery. I used STM32CubeIDE with the assist of BSP folder from STM32Cube_FW_L4_V1.14.0. Currently, I can add lvgl into my project and create buttons on the screen. Without lvgl, i can draw different shapes with function from STM32l4r9i_discovery_lcd.c.

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

STM32l4r9i discovery

What do you experience?

Although i can create buttons on the screen. there are multiple lines appearing on the screen to. these line does not appear when i use example from BSP (when lvgl is not used).
I don’t if the flush function causes this lines or something else relating to background and foreground.

What do you expect?

i want to have a smooth buttons without lines accross them.

Code to reproduce

this is the code of my display driver.
https://github.com/HuyTyskland/LittlevGL_backupFile/blob/master/display.c

Use the ```c and ``` tags to format your code:

#include "lv_conf.h"
#include "display.h"
#include "lvgl/src/lv_hal/lv_hal.h"
#include "lvgl/lvgl.h"

#include "display.h"
#include "stm32l4xx_hal.h"
#include "stm32l4xx_hal_ltdc.h"
#include "stm32l4xx_hal_dma2d.h"
#include "stm32l4xx_hal_dsi.h"
#include "stm32l4xx_hal_rcc.h"
#include "stm32l4xx_hal_gfxmmu.h"

#include "stm32l4r9i_discovery.h"
#include "stm32l4r9i_discovery_lcd.h"
#include "stm32l4r9i_discovery_psram.h"

#define LAYER0_ADDRESS               GFXMMU_VIRTUAL_BUFFER0_BASE
#define ActiveLayer 				 LTDC_ACTIVE_LAYER_BACKGROUND
//**************STATIC PROTOTYPES**************

/* For LittlevGL */
static void my_flush_cb(lv_disp_drv_t *drv, const lv_area_t *area,
		lv_color_t *color_p);
//static uint32_t ChangeColorFormat(lv_color_t *color_p);
/* LCD */
//static void putpixel(int x, int y, lv_color_t *color_p);
/* RAM */
//static void CopyBuffer(const uint32_t *pSrc, uint32_t *pDst, uint16_t x, uint16_t y, uint16_t xsize, uint16_t ysize);
static void CopyBuffer(uint32_t *pSrc, uint32_t *pDst, uint16_t x, uint16_t y, uint16_t xsize, uint16_t ysize);
// ************STATIC VARIABLES***************

extern LTDC_HandleTypeDef hltdc_discovery;
//static DMA2D_HandleTypeDef hdma2d;
extern DSI_HandleTypeDef hdsi_discovery;
DSI_VidCfgTypeDef hdsivideo_handle;
DSI_PLLInitTypeDef dsiPllInit;
//static RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;

static uint32_t *my_fb = (uint32_t*)LAYER0_ADDRESS;
static DMA2D_HandleTypeDef   hdma2d_discovery;
// ************ GLOBAL FUNCTION *************

// ********* initialize the display ***********

void tft_init(void) {
	/* Deactivate speculative/cache access to first FMC Bank to save FMC bandwidth */
	FMC_Bank1_R->BTCR[0] = 0x000030D2;
	BSP_PSRAM_Init();
	BSP_LCD_Init();
	BSP_LCD_SelectLayer(0);

	/* Send Display on DCS command to display */
	  HAL_DSI_ShortWrite(&hdsi_discovery,
	                     0,
	                     DSI_DCS_SHORT_PKT_WRITE_P0,
	                     DSI_SET_DISPLAY_ON,
	                     0x0);
	BSP_LCD_Refresh();

	static lv_disp_buf_t disp_buf;
	static lv_color_t buf1[390 * 10];
//	static lv_color_t buf2[390 * 10];
	lv_disp_buf_init(&disp_buf, buf1, NULL, LV_HOR_RES_MAX * 10);

	lv_disp_drv_t disp_drv;                 /*A variable to hold the drivers. Can be local variable*/
	lv_disp_drv_init(&disp_drv);            /*Basic initialization*/
	disp_drv.buffer = &disp_buf;            /*Set an initialized buffer*/
	disp_drv.flush_cb = my_flush_cb;
	//lv_disp_t * disp;/*Set a flush callback to draw to the display*/
	lv_disp_drv_register(&disp_drv); /*Register the driver and save the created display objects*/
}

static void my_flush_cb(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p) {
	CopyBuffer((uint32_t*) color_p, my_fb, area->x1, area->y1, lv_area_get_width(area), lv_area_get_height(area));
	BSP_LCD_Refresh();
	lv_disp_flush_ready(drv);
}

/**
  * @brief  Copy an input RGB888 buffer to output RGB888 with output offset
  * @param  pSrc: Pointer to source buffer
  * @param  pDst: Output color
  * @param  x: Start x position
  * @param  y: Start y position
  * @param  xsize: width
  * @param  ysize: height
  * @param  ColorMode: Input color mode
  * @retval None
  */

static void CopyBuffer(uint32_t *pSrc, uint32_t *pDst, uint16_t x, uint16_t y, uint16_t xsize, uint16_t ysize)
{
  uint32_t destination = (uint32_t)pDst + (y * 768 + x) * 4;
  uint32_t source      = (uint32_t)pSrc;

  hdma2d_discovery.Instance = DMA2D;

  /*##-1- Configure the DMA2D Mode, Color Mode and output offset #############*/
  hdma2d_discovery.Init.Mode           = DMA2D_M2M;
  hdma2d_discovery.Init.ColorMode      = DMA2D_OUTPUT_ARGB8888;
  hdma2d_discovery.Init.OutputOffset   = 1024 - xsize;
  hdma2d_discovery.Init.AlphaInverted  = DMA2D_REGULAR_ALPHA;  /* No Output Alpha Inversion */
  hdma2d_discovery.Init.RedBlueSwap    = DMA2D_RB_REGULAR;     /* No Output Red & Blue swap */
  hdma2d_discovery.Init.BytesSwap      = DMA2D_BYTES_REGULAR;  /* Regular output byte order */
  hdma2d_discovery.Init.LineOffsetMode = DMA2D_LOM_PIXELS;     /* Pixel mode                */

  /*##-2- Foreground Configuration ###########################################*/
  hdma2d_discovery.LayerCfg[1].InputColorMode = DMA2D_INPUT_ARGB8888;
  hdma2d_discovery.LayerCfg[1].InputOffset    = 0;
  hdma2d_discovery.LayerCfg[1].AlphaMode      = DMA2D_NO_MODIF_ALPHA;
  hdma2d_discovery.LayerCfg[1].InputAlpha     = 0xFF;                /* Not used */
  hdma2d_discovery.LayerCfg[1].RedBlueSwap    = DMA2D_RB_SWAP; //DMA2D_RB_REGULAR;    /* No ForeGround Red/Blue swap */
  hdma2d_discovery.LayerCfg[1].AlphaInverted  = DMA2D_REGULAR_ALPHA; /* No ForeGround Alpha inversion */

  /* DMA2D Initialization */
  if(HAL_DMA2D_Init(&hdma2d_discovery) == HAL_OK)
  {
    if(HAL_DMA2D_ConfigLayer(&hdma2d_discovery, 1) == HAL_OK)
    {
      if (HAL_DMA2D_Start(&hdma2d_discovery, source, destination, xsize, ysize) == HAL_OK)
      {
        /* Polling For DMA transfer */
        HAL_DMA2D_PollForTransfer(&hdma2d_discovery, 10);
      }
    }
  }
}
/*You code here*/

Screenshot and/or video

2020-02-12.png

Thank you, Huy.

the problem of horizontal stribes has been solved