Migrate lv_port_stm32f429_disco to V9

, ,

Description

I want code, created and checked with lv_port_pc_vscode , be able to run on a 32F429IDISCOVERY Board for Demonstration purpose. Problem is: the example lv_port_stm32f429_disco is built with V8 but the vscode Simulator is using V9, so i tried to migrate the Discovery-code to V9.

I’m able to build the modified STM32CubeIDE Project now, but the Display is showing strange content, see Screenshots, and i don’t know what there may be wrong?

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

STM32F429DISCO
STM32CubeIDE 1.18.1

What do you want to achieve?

Be able to use same code for vscode simulator and stm32f429 discovery

What have you tried so far?

i’ve read all v8 to v9 migration infos and examples i found

Code to reproduce

  • switch lvgl subrepo from project lv_port_stm32f429_disco to release/v9.2
  • define Symbol LV_LVGL_H_INCLUDE_SIMPLE and change any remaining #include “lvgl/lvgl.h” error line into #include “lvgl.h”
  • replaced the existing lvgl_conf.h with new template from V9

In File tft.c, change the following 3 functions:

/**
 * Initialize your display here
 */
void tft_init(void)
{
    #define BUF_SIZE (TFT_HOR_RES * 60)
	static lv_color_t disp_buf1[BUF_SIZE];
	static lv_color_t disp_buf2[BUF_SIZE];

#if TFT_EXT_FB != 0
	SDRAM_Init();
#endif
	LCD_Config();
	DMA_Config();

	disp = lv_display_create(TFT_HOR_RES, TFT_VER_RES);
    lv_display_set_flush_cb(disp, tft_flush);
    lv_display_set_buffers(disp, disp_buf1, disp_buf2, sizeof(lv_color_t)*BUF_SIZE, LV_DISPLAY_RENDER_MODE_PARTIAL);

}

/**
 * Flush a color buffer
 * @param x1 left coordinate of the rectangle
 * @param x2 right coordinate of the rectangle
 * @param y1 top coordinate of the rectangle
 * @param y2 bottom coordinate of the rectangle
 * @param color_p pointer to an array of colors
 */

static void tft_flush(lv_display_t * disp, const lv_area_t * area, uint8_t * px_map)
{
	/*Return if the area is out the screen*/
	if(area->x2 < 0) return;
	if(area->y2 < 0) return;
	if(area->x1 > TFT_HOR_RES - 1) return;
	if(area->y1 > TFT_VER_RES - 1) return;

	/*Truncate the area to the screen*/
	int32_t act_x1 = area->x1 < 0 ? 0 : area->x1;
	int32_t act_y1 = area->y1 < 0 ? 0 : area->y1;
	int32_t act_x2 = area->x2 > TFT_HOR_RES - 1 ? TFT_HOR_RES - 1 : area->x2;
	int32_t act_y2 = area->y2 > TFT_VER_RES - 1 ? TFT_VER_RES - 1 : area->y2;

	x1_flush = act_x1;
	y1_flush = act_y1;
	x2_flush = act_x2;
	y2_fill = act_y2;
	y_fill_act = act_y1;
	buf_to_flush = (const lv_color_t * )px_map;

	  /*##-7- Start the DMA transfer using the interrupt mode #*/
	  /* Configure the source, destination and buffer size DMA fields and Start DMA Stream transfer */
	  /* Enable All the DMA interrupts */
	HAL_StatusTypeDef err;
	err = HAL_DMA_Start_IT(&DmaHandle,(uint32_t)buf_to_flush, (uint32_t)&my_fb[y_fill_act * TFT_HOR_RES + x1_flush],
			  (x2_flush - x1_flush + 1));
	if(err != HAL_OK)
	{
		while(1);	/*Halt on error*/
	}
}

/**
  * @brief  DMA conversion complete callback
  * @note   This function is executed when the transfer complete interrupt
  *         is generated
  * @retval None
  */
static void DMA_TransferComplete(DMA_HandleTypeDef *han)
{
	y_fill_act ++;

	if(y_fill_act > y2_fill) {
		  lv_disp_flush_ready(&disp_drv);
	} else {
	  buf_to_flush += x2_flush - x1_flush + 1;
	  /*##-7- Start the DMA transfer using the interrupt mode ####################*/
	  /* Configure the source, destination and buffer size DMA fields and Start DMA Stream transfer */
	  /* Enable All the DMA interrupts */
	  if(HAL_DMA_Start_IT(han,(uint32_t)buf_to_flush, (uint32_t)&my_fb[y_fill_act * TFT_HOR_RES + x1_flush],
						  (x2_flush - x1_flush + 1)) != HAL_OK)
	  {
	    while(1);	/*Halt on error*/
	  }
	}
}

In File touchpad.c, change the following function:

/**
 * Initialize your input devices here
 */
void touchpad_init(void)
{
  stmpe811_Init(TS_I2C_ADDRESS);
  stmpe811_TS_Start(TS_I2C_ADDRESS);

  indev = lv_indev_create();
  lv_indev_set_type(indev, LV_INDEV_TYPE_POINTER);
  lv_indev_set_read_cb(indev, touchpad_read);
}

In File touchpad.c, change the following function-parameters to(no code change…):

static void touchpad_read(lv_indev_t * indev, lv_indev_data_t * data)

Screenshot and/or video

So it seems as the lv_demo_widgets is running(sort of) but i don’t understand why the Screen is looking so wrong?
Does i need to change something on the LTDC setup? From my point of view, LTDC functionallity should still be the same for V9?

The vs code simulator works also with previous lvgl versions. You just have to download the correct one!