ESP32-8048S070 7inch display - PlatformIO - problem with flickering

I bought ESP32-8048S070 7inch and as a first step I wanted to use Arduino framework to make it running (My goal is to use ESP-IDF + LVGL - but this is next step). To do it I configured PlatformIO in VSC and I created a simple project that compiles without any problems. I used some Get-started examples from LVGL page - it works, but…

I have a big problem with flickering. Sometimes it’s more visible, sometimes less. I see that the biggest problem is just after programming the board.

What do you want to achieve?

No flickering.

What have you tried so far?

  • Power Supply - it’s not the problem.
  • Buffer created with static and dynamic allocation.

Code to reproduce

#include <Arduino.h>
#include "Arduino_GFX_Library.h"
#include <lvgl.h>

Arduino_ESP32RGBPanel *bus = new Arduino_ESP32RGBPanel(
  41, 40, 39, 42,
  14, 21, 47, 48, 45,
  9, 46, 3, 8, 16, 1,
  15, 7, 6, 5, 4,
  0, 210, 30, 16,   //0, 8, 2, 43,
  0, 22, 13, 10,   //0, 8, 2, 12,
  1, 9000000
);

Arduino_GFX *gfx = new Arduino_RGB_Display(
  800, 480, bus
);

void my_disp_flush( lv_display_t *disp, const lv_area_t *area, uint8_t * px_map)
{
    uint32_t w = lv_area_get_width(area);
    uint32_t h = lv_area_get_height(area);

    gfx->draw16bitRGBBitmap(area->x1, area->y1, (uint16_t *)px_map, w, h);

    lv_disp_flush_ready(disp);
}

uint32_t mtick()
{
    return millis();
}

#define TFT_HOR_RES   800
#define TFT_VER_RES   480

#define DRAW_BUF_SIZE (TFT_HOR_RES * TFT_VER_RES / 4)
static uint32_t draw_buf[DRAW_BUF_SIZE / 4];
// uint32_t * draw_buf;

static lv_display_t * disp;

void setup()
{
  gfx->begin();
  gfx->fillScreen(BLACK);
  delay(1000);
  
  pinMode(2, OUTPUT);
  digitalWrite(2, HIGH);
  delay(1000);

  Serial.begin(115200);

  lv_init();

  lv_tick_set_cb(mtick);

  disp = lv_display_create(gfx->width(), gfx->height());
  lv_display_set_flush_cb(disp, my_disp_flush);
  lv_display_set_buffers(disp, draw_buf, NULL, DRAW_BUF_SIZE, LV_DISPLAY_RENDER_MODE_PARTIAL);

  // draw_buf = (uint32_t *)heap_caps_malloc(DRAW_BUF_SIZE, MALLOC_CAP_INTERNAL | MALLOC_CAP_32BIT);
  lv_display_set_buffers(disp, draw_buf, NULL, DRAW_BUF_SIZE, LV_DISPLAY_RENDER_MODE_PARTIAL);

  /*Change the active screen's background color*/
  lv_obj_set_style_bg_color(lv_screen_active(), lv_color_hex(0x003a57), LV_PART_MAIN);
  // lv_obj_set_style_bg_color(lv_screen_active(), lv_color_hex(0xffffff), LV_PART_MAIN);
  // lv_obj_set_style_bg_color(lv_screen_active(), lv_color_hex(0), LV_PART_MAIN);

  /*Create a white label, set its text and align it to the center*/
  lv_obj_t * label = lv_label_create(lv_screen_active());
  lv_label_set_text(label, "Hello world");
  // lv_obj_set_style_text_color(lv_screen_active(), lv_color_hex(0), LV_PART_MAIN);
  lv_obj_set_style_text_color(lv_screen_active(), lv_color_hex(0x00ff00), LV_PART_MAIN);
  lv_obj_set_style_text_font(label, &lv_font_montserrat_20, 0);
  lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);

  lv_obj_t * btn = lv_button_create(lv_screen_active());     /*Add a button the current screen*/
  lv_obj_set_pos(btn, 10, 10);                            /*Set its position*/
  lv_obj_set_size(btn, 120, 50);                          /*Set its size*/
  // lv_obj_add_event_cb(btn, btn_event_cb, LV_EVENT_ALL, NULL);           /*Assign a callback to the button*/

  lv_obj_t * label2 = lv_label_create(btn);          /*Add a label to the button*/
  lv_label_set_text(label2, "Button");                     /*Set the labels text*/
  lv_obj_center(label2);

  static lv_style_t style;
  lv_style_init(&style);

  lv_style_set_arc_color(&style, lv_palette_main(LV_PALETTE_RED));
  lv_style_set_arc_width(&style, 4);

  lv_obj_t * obj = lv_arc_create(lv_screen_active());
  lv_obj_add_style(obj, &style, 0);
  lv_obj_set_pos(obj, 200, 10);
}

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

platformie.ini file

[env:esp32-s3-devkitc-1]
platform = espressif32
board = esp32-s3-devkitc-1
framework = arduino
monitor_speed = 115200
board_build.f_cpu = 240000000L
board_build.f_flash = 80000000L
board_build.arduino.memory_type = qio_opi
board_build.flash_mode = qio
board_build.psram_type = opi
board_upload.flash_size = 16MB
board_upload.maximum_size = 16777216
board_build.partitions = default_16MB.csv
board_build.extra_flags = 
	-DBOARD_HAS_PSRAM
	-DPSRAM_CLK=80000000
lib_deps = 
	moononournation/GFX Library for Arduino@1.6.0
	lvgl/lvgl@^9.3.0

Screenshot and/or video

Video on YouTube - recorded also in slow-motion. It shows the problem.

Environment