Button example show only white blank screen

Description

I try to run lv_example_get_started_1 example which is an example that create button widget but when compile and run, it does not show anything onscreen, only white blank screen.

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

MCU : NUCLEO-F446ZE
Display : RVT70AQFFWN00 800x480 px communicate via SPI
Compiler : arm gcc with makefile generated by stm32cubemx

What do you want to achieve?

I want to be able to display widgets.

What have you tried so far?

I tried to test my flush display method and it works fine so i’m not sure why in ex_disp_flush() it does not work.

Code to reproduce

This is my flush display callback function

static void ex_disp_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t * color_p)

{

    SEGGER_RTT_printf(0U, "ex_disp_flush() entered.\r\n");



    int32_t x1 = area->x1;

    int32_t x2 = area->x2;

    int32_t y1 = area->y1;

    int32_t y2 = area->y2;

    /*Return if the area is out the screen*/



    if(x2 < 0) return;

    if(y2 < 0) return;

    if(x1 > TFT_HOR_RES - 1) return;

    if(y1 > TFT_VER_RES - 1) return;



    /*Truncate the area to the screen*/

    int32_t act_x1 = x1 < 0 ? 0 : x1;

    int32_t act_y1 = y1 < 0 ? 0 : y1;

    int32_t act_x2 = x2 > TFT_HOR_RES - 1 ? TFT_HOR_RES - 1 : x2;

    int32_t act_y2 = y2 > TFT_VER_RES - 1 ? TFT_VER_RES - 1 : y2;



    SEGGER_RTT_printf(0U, "act_x1 value is %d.\r\n", act_x1);

    SEGGER_RTT_printf(0U, "act_y1 value is %d.\r\n", act_y1);

    SEGGER_RTT_printf(0U, "act_x2 value is %d.\r\n", act_x2);

    SEGGER_RTT_printf(0U, "act_y2 value is %d.\r\n", act_y2);



    uint8_t red_color = color_p->ch.red;

    uint8_t green_color = color_p->ch.green;

    uint8_t blue_color = color_p->ch.blue;



    // When first started, clear display and set line width

    if (act_y2 == 0) {

      App_WrDl_Buffer(phost, CLEAR(1, 1, 1));

      App_WrDl_Buffer(phost, LINE_WIDTH(1*16));

      App_WrDl_Buffer(phost, BEGIN(RECTS));

    }



    App_WrDl_Buffer(phost, COLOR_RGB(red_color, green_color, blue_color));

    App_WrDl_Buffer(phost, VERTEX2F(act_x1*16,act_y1*16));

    App_WrDl_Buffer(phost, VERTEX2F(act_x2*16,act_y2*16));

    

    // If this is final display row, swap frame to display data.

    if (act_y2 == 479) {

      App_WrDl_Buffer(phost, END());

      App_WrDl_Buffer(phost,DISPLAY());

      App_Flush_DL_Buffer(phost);

      Gpu_Hal_DLSwap(phost,DLSWAP_FRAME);

      lv_disp_flush_ready(drv);

      SEGGER_RTT_printf(0U, "Finish transmitting all data.\r\n");

    }



    lv_disp_flush_ready(drv);

    SEGGER_RTT_printf(0U, "ex_disp_flush() completed.\r\n");

}

My tft_init function

void tft_init(void)

{

  /* LCD Initialization */

  phost = &host;

  /* Init HW Hal */

  App_Common_Init(&host);

  App_Show_Logo(&host);

  

  // Test flush screen method

  App_WrDl_Buffer(phost, CLEAR(1, 1, 1));

  App_WrDl_Buffer(phost, LINE_WIDTH(1*16));

  App_WrDl_Buffer(phost, BEGIN(RECTS));

  App_WrDl_Buffer(phost, COLOR_RGB(0, 255, 0));

  for (uint16_t i = 0; i < 480; i++) {

    App_WrDl_Buffer(phost, COLOR_RGB(i, 255-i, 0));

    App_WrDl_Buffer(phost, VERTEX2F(0*16,i*16));

    App_WrDl_Buffer(phost, VERTEX2F((i+100)*16,i*16));

  }

  App_WrDl_Buffer(phost, END());

  App_WrDl_Buffer(phost,DISPLAY());

  App_Flush_DL_Buffer(phost);

  Gpu_Hal_DLSwap(phost,DLSWAP_FRAME);

  SEGGER_RTT_printf(0U, "Test screen success\r\n");

  HAL_Delay(5000);



  /*-----------------------------

	* Create a buffer for drawing

	*----------------------------*/



   /* LittlevGL requires a buffer where it draws the objects. The buffer's has to be greater than 1 display row*/



	static lv_disp_draw_buf_t disp_buf_1;

	static lv_color_t buf1_1[TFT_HOR_RES];

	lv_disp_draw_buf_init(&disp_buf_1, buf1_1, NULL, TFT_HOR_RES);   /*Initialize the display buffer*/





	/*-----------------------------------

	* Register the display in LittlevGL

	*----------------------------------*/



	lv_disp_drv_init(&disp_drv);                    /*Basic initialization*/



	/*Set up the functions to access to your display*/



	/*Set the resolution of the display*/

	disp_drv.hor_res = 800;

	disp_drv.ver_res = 480;



	/*Used to copy the buffer's content to the display*/

	disp_drv.flush_cb = ex_disp_flush;



	/*Set a display buffer*/

	disp_drv.draw_buf = &disp_buf_1;





	/*Finally register the driver*/

	our_disp = lv_disp_drv_register(&disp_drv);

}

and my main function with lv_example_get_started_1()

void lv_example_get_started_1(void)

{

  lv_obj_t * btn = lv_btn_create(lv_scr_act());     /*Add a button the current screen*/

  lv_obj_set_pos(btn, 10, 10);                            /*Set its position*/

  lv_obj_set_size(btn, 80, 48);                          /*Set its size*/



  lv_obj_t * label = lv_label_create(btn);          /*Add a label to the button*/

  lv_label_set_text(label, "Button");                     /*Set the labels text*/

  lv_obj_center(label);

}

/* USER CODE END 0 */



/**

  * @brief  The application entry point.

  * @retval int

  */

int main(void)

{

  /* USER CODE BEGIN 1 */



  /* USER CODE END 1 */



  /* MCU Configuration--------------------------------------------------------*/



  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */

  HAL_Init();



  /* USER CODE BEGIN Init */



  /* USER CODE END Init */



  /* Configure the system clock */

  SystemClock_Config();



  /* USER CODE BEGIN SysInit */



  /* USER CODE END SysInit */



  /* Initialize all configured peripherals */

  MX_GPIO_Init();

  MX_SPI1_Init();

  MX_USART3_UART_Init();

  MX_USB_OTG_FS_PCD_Init();

  /* USER CODE BEGIN 2 */

  HAL_GPIO_WritePin(LD1_GPIO_Port, LD1_Pin, GPIO_PIN_SET);

  HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_SET);

  HAL_GPIO_WritePin(LD3_GPIO_Port, LD3_Pin, GPIO_PIN_SET);



  lv_init();

  tft_init();

  lv_example_get_started_1();



  /* USER CODE END 2 */



  /* Infinite loop */

  /* USER CODE BEGIN WHILE */

  while (1)

  {

    /* USER CODE END WHILE */



    /* USER CODE BEGIN 3 */

    HAL_Delay(5);

    lv_task_handler();

  }

  /* USER CODE END 3 */

}

This is my full project link in gitlab: NUCLEO-F446ZE-Sandbox / f446ze-lvgl-test · GitLab

Screenshot and/or video

Here is my display when i test with my flush display method


but when trying to display widget, i get all white screen.

Interesting changes happen if i change

lv_obj_set_pos(btn, 10, 10);                            /*Set its position*/

to

lv_obj_set_pos(btn, 0, 10);                            /*Set its position*/

in lv_example_get_started_1(void) function. Then my display does not show white blank screen anymore.


But it is still incorrect.

Hello mate,
I have the exact same issue with blue line when I try to display button. Can you share where was the problem and what did you do to fix it?