Event and animation do not work at all

What do you want to achieve?

I want to have a splash screen with my logo on Screen1 then fade out to Screen2. Similar to this: Animation test for start screen - #3 by dronecz

What have you tried so far?

Screenshot or video

Others

  • SquareLine Studio version: 1.3.3
  • Operating system: Mac Monterey 12.7.1
  • Target hardware: WT32-SC01-PLUS

I am using Arduino IDE. Currently only the Screen1 shows without fade animations, and does not move to Screen2. Please give some idea how to go on what to debug and check, thank you!

You can create an event at Screen1 (the intended splash-screen) with Trigger ‘SCREEN_LOADED’ and action ‘CHANGE SCREEN’ with Screen2 as target (‘Screen To’), and additionally set ‘Delay’ in milliseconds to the time you want you splash-screen to appear for.

Yeah, that is what I did. And it works in the Squareline editor. I mean when i click to the ‘Play’ button, the splash screen appears then fades out to the Main screen, as it should. I exported the C files, and added to the Arduino then upload it to the WT32-SC01+ board. On the screen, only the Splash screen appears, and it does not move to the next screen.

See:

///////////////////// FUNCTIONS ////////////////////
void ui_event_Screen1( lv_event_t * e) {
    lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e);
if ( event_code == LV_EVENT_SCREEN_LOADED) {

      _ui_screen_change( &ui_Screen2, LV_SCR_LOAD_ANIM_FADE_ON, 250, 2000, &ui_Screen2_screen_init);
}
}
void ui_init( void )
{
lv_disp_t *dispp = lv_disp_get_default();
lv_theme_t *theme = lv_theme_default_init(dispp, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_RED), false, LV_FONT_DEFAULT);
lv_disp_set_theme(dispp, theme);
ui_Screen1_screen_init();
ui_Screen2_screen_init();
ui____initial_actions0 = lv_obj_create(NULL);
lv_disp_load_scr( ui_Screen1);
}
void ui_Screen1_screen_init(void)
{
ui_Screen1 = lv_obj_create(NULL);
lv_obj_clear_flag( ui_Screen1, LV_OBJ_FLAG_CLICKABLE | LV_OBJ_FLAG_SCROLLABLE );    /// Flags
lv_obj_set_style_bg_color(ui_Screen1, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT );
lv_obj_set_style_bg_opa(ui_Screen1, 255, LV_PART_MAIN| LV_STATE_DEFAULT);

ui_Image3 = lv_img_create(ui_Screen1);
lv_img_set_src(ui_Image3, &ui_img_sclogosmall_png);
lv_obj_set_width( ui_Image3, LV_SIZE_CONTENT);  /// 305
lv_obj_set_height( ui_Image3, LV_SIZE_CONTENT);   /// 227
lv_obj_set_align( ui_Image3, LV_ALIGN_CENTER );
lv_obj_add_flag( ui_Image3, LV_OBJ_FLAG_ADV_HITTEST );   /// Flags
lv_obj_clear_flag( ui_Image3, LV_OBJ_FLAG_SCROLLABLE );    /// Flags

//lv_obj_add_event_cb(ui_Image3, ui_event_Image3, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(ui_Screen1, ui_event_Screen1, LV_EVENT_ALL, NULL);

}

all these stuff are generated by Squareline Studio.

Rename topic to Im noob my event and animation…
Seems some code in your ino fail, and for fade you require edit lv_conf.h parameter

#define LV_COLOR_SCREEN_TRANSP 1


Hahaha… it is already set in lv_conf.h !

/*Enable features to draw on transparent background.
 *It's required if opa, and transform_* style properties are used.
 *Can be also used if the UI is above another layer, e.g. an OSD menu or video player.*/
#define LV_COLOR_SCREEN_TRANSP 1

@Marian_M I bet you just throwing ideas here, but you have no clue about the solution…

Then show your setup and loop code , generated code seems be ok.
And crystal ball say idea for zero info peaples check too

#define LV_TICK_CUSTOM 1

#define LV_TICK_CUSTOM 1

is also set. Maybe memory problems? When it tries to instantiate the next screen it runs out of RAM? That would be really sad from a WT32-SC01-plus… As I know it has 2MB of PSRAM

#include <Wire.h>
#define LGFX_USE_V1
#include <LovyanGFX.hpp>
#include <lvgl.h>
#include "ui.h"

static const int RXPin = 10, TXPin = 11, sclPin = 12, sdaPin = 13;

class LGFX : public lgfx::LGFX_Device {
  lgfx::Panel_ST7796 _panel_instance;
  lgfx::Bus_Parallel8 _bus_instance;
  lgfx::Light_PWM _light_instance;
  lgfx::Touch_FT5x06 _touch_instance;

public:
  LGFX(void) {
    {
      auto cfg = _bus_instance.config();
      cfg.freq_write = 40000000;
      cfg.pin_wr = 47;
      cfg.pin_rd = -1;
      cfg.pin_rs = 0;
      cfg.pin_d0 = 9;
      cfg.pin_d1 = 46;
      cfg.pin_d2 = 3;
      cfg.pin_d3 = 8;
      cfg.pin_d4 = 18;
      cfg.pin_d5 = 17;
      cfg.pin_d6 = 16;
      cfg.pin_d7 = 15;
      _bus_instance.config(cfg);
      _panel_instance.setBus(&_bus_instance);
    }

    {
      auto cfg = _panel_instance.config();
      cfg.pin_cs = -1;
      cfg.pin_rst = 4;
      cfg.pin_busy = -1;
      cfg.memory_width = 320;
      cfg.memory_height = 480;
      cfg.panel_width = 320;
      cfg.panel_height = 480;
      cfg.offset_x = 0;
      cfg.offset_y = 0;
      cfg.offset_rotation = 0;
      cfg.dummy_read_pixel = 8;
      cfg.dummy_read_bits = 1;
      cfg.readable = true;
      cfg.invert = true;
      cfg.rgb_order = false;
      cfg.dlen_16bit = false;
      cfg.bus_shared = false;

      _panel_instance.config(cfg);
    }

    {
      auto cfg = _light_instance.config();
      cfg.pin_bl = 45;
      cfg.invert = false;
      cfg.freq = 44100;
      cfg.pwm_channel = 7;

      _light_instance.config(cfg);
      _panel_instance.setLight(&_light_instance);
    }

    {
      auto cfg = _touch_instance.config();
      cfg.i2c_port = 1;
      cfg.i2c_addr = 0x38;
      cfg.pin_sda = 6;
      cfg.pin_scl = 5;
      cfg.freq = 400000;
      cfg.x_min = 0;
      cfg.x_max = 320;
      cfg.y_min = 0;
      cfg.y_max = 480;

      _touch_instance.config(cfg);
      _panel_instance.setTouch(&_touch_instance);
    }

    setPanel(&_panel_instance);
  }
};

static LGFX tft;

/*Change to your screen resolution*/
static const uint32_t screenWidth = 480;
static const uint32_t screenHeight = 320;
static lv_disp_draw_buf_t draw_buf;
static lv_color_t buf[screenWidth * 10];

/* Display flushing */
void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p) {
  uint32_t w = (area->x2 - area->x1 + 1);
  uint32_t h = (area->y2 - area->y1 + 1);

  tft.startWrite();
  tft.setAddrWindow(area->x1, area->y1, w, h);
  tft.writePixels((lgfx::rgb565_t *)&color_p->full, w * h);
  tft.endWrite();

  lv_disp_flush_ready(disp);
}

/*Read the touchpad*/
void my_touchpad_read(lv_indev_drv_t *indev_driver, lv_indev_data_t *data) {

  uint16_t x, y;
  if (tft.getTouch(&x, &y)) {
    data->state = LV_INDEV_STATE_PR;
    data->point.x = x;
    data->point.y = y;

  } else {
    data->state = LV_INDEV_STATE_REL;
  }
}

void setup() {
  Serial.begin(115200);
  initDisplay();
  lv_init();
  lv_disp_draw_buf_init(&draw_buf, buf, NULL, screenWidth * 10);

  /*Initialize the display*/
  static lv_disp_drv_t disp_drv;
  lv_disp_drv_init(&disp_drv);

  /*Change the following line to your display resolution*/
  disp_drv.hor_res = screenWidth;
  disp_drv.ver_res = screenHeight;
  disp_drv.flush_cb = my_disp_flush;
  disp_drv.draw_buf = &draw_buf;
  lv_disp_drv_register(&disp_drv);

  /*Initialize the (dummy) input device driver*/
  /*static lv_indev_drv_t indev_drv;
  lv_indev_drv_init(&indev_drv);
  indev_drv.type = LV_INDEV_TYPE_POINTER;
  indev_drv.read_cb = my_touchpad_read;
  lv_indev_drv_register(&indev_drv); */

  ui_init();
}

void loop() {
  lv_timer_handler();
  delay(5);
}

void initDisplay() {
  tft.begin();
  tft.setRotation(1);
  tft.setBrightness(255);
}

Seems all set ok and display load first flush. Now only debug helps. Have you serial monitor open ? Place in loop line for check it… for exampe

unsigned int looper5=0;
void loop() {
  lv_timer_handler(); /* let the GUI do its work */
  looper5++;
delay(5);
if(1 && (looper5%2000)==0)   {
  Serial.print(heap_caps_get_largest_free_block(MALLOC_CAP_8BIT));
  Serial.print(" loop run 2sec ");
  Serial.println(heap_caps_get_largest_free_block(MALLOC_CAP_DMA));
}

}

and memory is in lvconf limited to little part. PSRAM or more mem is only used by lvgl if you change conf to custom.

For me similar screen-switching freezes happened on different (Arduino-SDK and ESP-IDF related) boards when LV_MEM_CUSTOM wasn’t set in lv_conf.h. Setting it to 1 solved those weird memory-related problems, maybe this could help in your case too. It’s worth a try…

hey @Hermit, thank you so much for this. Setting this parameter to 1 solved the problem! Also, thank you @Marian_M for your suggestion, that will help me debugging in the future.