Trying to use the fade in function but doesn't work

Important: posts that do not use this template will be ignored or closed.

Before posting

  • Get familiar with Markdown to format and structure your post
  • Be sure to update lvgl from the latest version from the master branch.
  • Be sure you have checked the relevant part of the documentation. We will not respond in detail to posts where you haven’t read the relevant documentation.
  • If applicable use the Simulator to eliminate hardware related issues.

Delete this section if you read and applied the mentioned points.

Description

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

ESP32, 2.8 TFT Display ILI9341 , Arduino IDE

What LVGL version are you using?

Version 7.1

What do you want to achieve?

I want to make a scenario of fading in and out a label

What have you tried so far?

i’ve tried to implement the lv_obj_fade_in() function but it doesn’t work

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:

  lv_obj_t * Lora_label = lv_label_create(lv_scr_act(), NULL);
  lv_label_set_text(Lora_label, "LoRA");
  lv_obj_add_style(Lora_label, LV_OBJ_PART_MAIN, &bootstyle);
  lv_obj_align(Lora_label, NULL, LV_ALIGN_CENTER, -26, 0);
  lv_obj_fade_in(Lora_label,1000,0);

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

Hi @Ryan_Gania,

Do you have LV_USE_ANIMATION enabled in your lv_conf.h file?

If you do and it still doesn’t work could you share the bootstyle initialisation code please…

Kind Regards,

Pete

Resolved this problem by putting the label on a page object then apply the lv_obj_fade_in to the page object. The lv_obj_fade_in doesn’t seem to work with labels

  static lv_style_t bootbgstyle;
  lv_style_init(&bootbgstyle);
  lv_style_set_bg_opa(&bootbgstyle, LV_STATE_DEFAULT, LV_OPA_TRANSP);
  lv_style_set_border_opa(&bootbgstyle, LV_STATE_DEFAULT, LV_OPA_0);

  lv_obj_t * bootpage = lv_page_create(lv_scr_act(), NULL);
  lv_obj_set_size(bootpage, 240, 70);
  lv_obj_align(bootpage, NULL, LV_ALIGN_CENTER, 0, 0);
  lv_page_set_scrlbar_mode(bootpage, LV_SCRLBAR_MODE_HIDE);
  lv_obj_add_style(bootpage, LV_OBJ_PART_MAIN, &bootbgstyle);
            
  LV_FONT_DECLARE(unbutton);
  static lv_style_t bootstyle;
  lv_style_init(&bootstyle);
  lv_style_set_text_font(&bootstyle, LV_STATE_DEFAULT, &unbutton);
  

  lv_obj_t * Lora_label = lv_label_create(bootpage, NULL);
  lv_label_set_recolor(Lora_label, true);
  lv_label_set_text(Lora_label, "#FFFFFF LoRA#");
  lv_obj_add_style(Lora_label, LV_OBJ_PART_MAIN, &bootstyle);
  lv_obj_align(Lora_label, NULL, LV_ALIGN_CENTER, -26, 0);

  lv_obj_t * AIS_label = lv_label_create(bootpage, NULL);
  lv_label_set_recolor(AIS_label, true);
  lv_label_set_text(AIS_label, "#FF0000 AIS#");
  lv_obj_add_style(AIS_label, LV_OBJ_PART_MAIN, &bootstyle);
  lv_obj_align(AIS_label, NULL, LV_ALIGN_CENTER, 50, 0);
  lv_obj_fade_in(bootpage,1000,0);

Right now I’m trying to combined this bootup logo with my main menu. Any suggestion to do this?

Hi @Ryan_Gania,

I would have your boot logo in a function, add a delay at the end of your code above for how long you want it to display for, add code in the function after the delay to delete the objects used for the boot logo and have the function call your main menu code which I would also put in a separate function. Then at startup just call your boot logo function and it will then start the menu for you.

Hope that helps…

Kind Regards,

Pete

I add delay between functions but at boot the screen doesn’t display anything then right after the delay ends the screen display the mainmenu() function.

  start_boot();
  delay(3000);
  mainmenu();

Hi @Ryan_Gania,

Please try this:

  start_boot();
  for( int i=0; i < 600; i++ ){
      lv_task_handler();  
      delay(5);
  }     
  mainmenu();

Kind Regards,

Pete

1 Like

This works amazing! Thank you very much!

1 Like

You are welcome!

Please can you mark the post as the solution, Thank you.

Kind Regards,

Pete