How to setup the lvgl library for Esp32-s3-WROOM-1 with TFT display 800*480

I have a similar problem.

I bought a 5" elecrow display and the files they sent as an example.

They use very old libraries, which is Arduino_GFX

And nothing compiles, I can’t do a basic HelloWord with LVGL and this card.

I read this forum thread carefully and still haven’t been able to find a solution.

Can anybody help me.

My board is a small variation of the problem you are experiencing.

image

image

The declared display is the ILI6122 and ILI5960

This code below is the example provided by the manufacturer.

But it’s useless because it doesn’t compile and uses very outdated libraries.


#include <lvgl.h>
#include <demos/lv_demos.h>
//UI
#include "ui.h"
static int first_flag = 0;
extern int zero_clean;
extern int goto_widget_flag;
extern int bar_flag;
extern lv_obj_t * ui_MENU;
extern lv_obj_t * ui_TOUCH;
extern lv_obj_t * ui_JIAOZHUN;
extern lv_obj_t * ui_Label2;
static lv_obj_t * ui_Label;//TOUCH interface label
static lv_obj_t * ui_Label3;//TOUCH interface label3
static lv_obj_t * ui_Labe2;//Menu interface progress bar label
static lv_obj_t * bar;//Menu interface progress bar
#include <SPI.h>
SPIClass& spi = SPI;
uint16_t touchCalibration_x0 = 300, touchCalibration_x1 = 3600, touchCalibration_y0 = 300, touchCalibration_y1 = 3600;
uint8_t  touchCalibration_rotate = 1, touchCalibration_invert_x = 2, touchCalibration_invert_y = 0;
static int val = 100;

static uint32_t screenWidth;
static uint32_t screenHeight;
static lv_disp_draw_buf_t draw_buf;
static lv_color_t disp_draw_buf[800 * 480 / 10];
static lv_disp_drv_t disp_drv;

#include <Ticker.h>          //Call the ticker. H Library
Ticker ticker1;
#include <Arduino_GFX_Library.h>
#define TFT_BL 2
#define GFX_BL DF_GFX_BL // default backlight pin, you may replace DF_GFX_BL to actual backlight pin

/* More dev device declaration: https://github.com/moononournation/Arduino_GFX/wiki/Dev-Device-Declaration */
#if defined(DISPLAY_DEV_KIT)
Arduino_GFX *lcd = create_default_Arduino_GFX();
#else /* !defined(DISPLAY_DEV_KIT) */

Arduino_ESP32RGBPanel *bus = new Arduino_ESP32RGBPanel(
  GFX_NOT_DEFINED /* CS */, GFX_NOT_DEFINED /* SCK */, GFX_NOT_DEFINED /* SDA */,
  40 /* DE */, 41 /* VSYNC */, 39 /* HSYNC */, 0 /* PCLK */,
  45 /* R0 */, 48 /* R1 */, 47 /* R2 */, 21 /* R3 */, 14 /* R4 */,
  5 /* G0 */, 6 /* G1 */, 7 /* G2 */, 15 /* G3 */, 16 /* G4 */, 4 /* G5 */,
  8 /* B0 */, 3 /* B1 */, 46 /* B2 */, 9 /* B3 */, 1 /* B4 */
);

Arduino_RPi_DPI_RGBPanel *lcd = new Arduino_RPi_DPI_RGBPanel(
  bus,
  800 /* width */, 0 /* hsync_polarity */, 210 /* hsync_front_porch */, 4 /* hsync_pulse_width */, 43 /* hsync_back_porch */,
  480 /* height */, 0 /* vsync_polarity */, 22 /* vsync_front_porch */, 4 /* vsync_pulse_width */, 12 /* vsync_back_porch */,
  1 /* pclk_active_neg */, 16000000 /* prefer_speed */, true /* auto_flush */);
#endif /* !defined(DISPLAY_DEV_KIT) */
#include "touch.h"
/* 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);

#if (LV_COLOR_16_SWAP != 0)
  lcd->draw16bitBeRGBBitmap(area->x1, area->y1, (uint16_t *)&color_p->full, w, h);
#else
  lcd->draw16bitRGBBitmap(area->x1, area->y1, (uint16_t *)&color_p->full, w, h);
#endif

  lv_disp_flush_ready(disp);
}

void my_touchpad_read(lv_indev_drv_t *indev_driver, lv_indev_data_t *data)
{
  if (touch_has_signal())
  {
    if (touch_touched())
    {
      data->state = LV_INDEV_STATE_PR;

      /*Set the coordinates*/
      data->point.x = touch_last_x;
      data->point.y = touch_last_y;
      Serial.print( "Data x :" );
      Serial.println( touch_last_x );

      Serial.print( "Data y :" );
      Serial.println( touch_last_y );
    }
    else if (touch_released())
    {
      data->state = LV_INDEV_STATE_REL;
    }
  }
  else
  {
    data->state = LV_INDEV_STATE_REL;
  }
}

uint16_t calData[5] = { 190, 3679, 382, 3335, 0 };
void callback1()  //Callback function
{
  if (bar_flag == 6)
  {
    if (val > 1)
    {
      val--;
      lv_bar_set_value(bar, val, LV_ANIM_OFF);
      lv_label_set_text_fmt(ui_Labe2, "%d %%", val);
    }
    else
    {
      lv_obj_clear_flag(ui_touch, LV_OBJ_FLAG_CLICKABLE);
      lv_label_set_text(ui_Labe2, "Loading");
      delay(150);
      val = 100;
      bar_flag = 0; //Stop progress bar sign
      goto_widget_flag = 1; //Enter the widget logo

    }
  }
}


void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600); // Init Display
#ifdef TFT_BL
  pinMode(TFT_BL, OUTPUT);
  digitalWrite(TFT_BL, LOW);
#endif
  lcd->begin();
  lcd->fillScreen(BLACK);
  lcd->setTextSize(2);
  delay(200);

  lv_init();
  touch_init();
  screenWidth = lcd->width();
  screenHeight = lcd->height();

  lv_disp_draw_buf_init(&draw_buf, disp_draw_buf, NULL, screenWidth * screenHeight / 10);
  //  lv_disp_draw_buf_init(&draw_buf, disp_draw_buf, NULL, 480 * 272 / 10);
  /* Initialize the display */
  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);
#ifdef TFT_BL
  digitalWrite(TFT_BL, HIGH);
#endif
  ui_init();//Boot UI
  while (1)
  {
    if (goto_widget_flag == 1)//Go to widget
    {
      if (ticker1.active() == true)
      {
        ticker1.detach();
      }
      goto_widget_flag = 0;
      delay(300);
      break;
    }

    if (goto_widget_flag == 3)//Go to the touch screen and close the progress bar thread first
    {
      bar_flag = 0; //Stop progress bar sign
      if (ticker1.active() == true)
      {
        ticker1.detach();
      }
      if (first_flag == 0 || first_flag == 1)
      {
        label_xy();
        first_flag = 2;
      }
      if (zero_clean == 1)
      {
        touch_last_x = 0;
        touch_last_y = 0;
        zero_clean = 0;
      }
      lv_label_set_text(ui_Label, "Touch Adjust:");
      lv_label_set_text_fmt(ui_Label3, "%d  %d", touch_last_x, touch_last_y); //Display touch information
    }

    if (goto_widget_flag == 4)//触摸界面返回到Menu界面,使进度条清零重启
    {
      val = 100;
      delay(100);
      ticker1.attach_ms(35, callback1);//每20ms调用callback1
      goto_widget_flag = 0;
    }

    if (goto_widget_flag == 5) //Trigger Calibration Signal
    {
      lv_scr_load_anim(ui_touch_calibrate, LV_SCR_LOAD_ANIM_NONE, 0, 0, false);
      lv_timer_handler();
      lv_timer_handler();
      delay(100);
      touch_calibrate();//Touch Calibration
      lv_scr_load_anim(ui_TOUCH, LV_SCR_LOAD_ANIM_NONE, 0, 0, false);
      lv_timer_handler();
      delay(100);
      goto_widget_flag = 3; //Access to the touch screen logo
      touch_last_x = 0;
      touch_last_y = 0;
    }

    if (bar_flag == 6)//Runs the progress bar once when you first boot into the Menu screen, then stops running after that
    {
      if (first_flag == 0)
      {
        lv_example_bar();
        ticker1.attach_ms(35, callback1);//每20ms调用callback1
        first_flag = 1;
      }
    }

    lv_timer_handler();
  }


  lcd->fillScreen(BLACK);
  lv_demo_widgets();//Main UI
  Serial.println( "Setup done" );

}

void loop() {
  // put your main code here, to run repeatedly:
  lv_timer_handler();
  delay(5);

}

//Touch Label Controls
void label_xy()
{
  ui_Label = lv_label_create(ui_TOUCH);
  lv_obj_enable_style_refresh(true);
  lv_obj_set_width(ui_Label, LV_SIZE_CONTENT);   /// 1
  lv_obj_set_height(ui_Label, LV_SIZE_CONTENT);    /// 1
  lv_obj_set_x(ui_Label, -55);
  lv_obj_set_y(ui_Label, -40);
  lv_obj_set_align(ui_Label, LV_ALIGN_CENTER);
  lv_obj_set_style_text_color(ui_Label, lv_color_hex(0xFF0000), LV_PART_MAIN | LV_STATE_DEFAULT);
  lv_obj_set_style_text_opa(ui_Label, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
  lv_obj_set_style_text_font(ui_Label, &lv_font_montserrat_24, LV_PART_MAIN | LV_STATE_DEFAULT);

  ui_Label3 = lv_label_create(ui_TOUCH);
  lv_obj_enable_style_refresh(true);
  lv_obj_set_width(ui_Label3, LV_SIZE_CONTENT);   /// 1
  lv_obj_set_height(ui_Label3, LV_SIZE_CONTENT);    /// 1
  lv_obj_set_x(ui_Label3, 85);
  lv_obj_set_y(ui_Label3, -40);
  lv_obj_set_align(ui_Label3, LV_ALIGN_CENTER);
  lv_obj_set_style_text_color(ui_Label3, lv_color_hex(0x00FF00), LV_PART_MAIN | LV_STATE_DEFAULT);
  lv_obj_set_style_text_opa(ui_Label3, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
  lv_obj_set_style_text_font(ui_Label3, &lv_font_montserrat_24, LV_PART_MAIN | LV_STATE_DEFAULT);

}


//Progress bar control
void lv_example_bar(void)
{
  //////////////////////////////
  bar = lv_bar_create(ui_MENU);
  lv_bar_set_value(bar, 0, LV_ANIM_OFF);
  lv_obj_set_width(bar, 480);
  lv_obj_set_height(bar, 25);
  lv_obj_set_x(bar, 0);
  lv_obj_set_y(bar, 175);
  lv_obj_set_align(bar, LV_ALIGN_CENTER);
  lv_obj_set_style_bg_img_src(bar, &ui_img_bar_800_01_png, LV_PART_MAIN | LV_STATE_DEFAULT);

  lv_obj_set_style_bg_img_src(bar, &ui_img_bar_800_02_png, LV_PART_INDICATOR | LV_STATE_DEFAULT);
  lv_obj_set_style_outline_color(bar, lv_color_hex(0x2D8812), LV_PART_INDICATOR | LV_STATE_DEFAULT);
  lv_obj_set_style_outline_opa(bar, 255, LV_PART_INDICATOR | LV_STATE_DEFAULT);
  //////////////////////
  ui_Labe2 = lv_label_create(bar);//Creating Tags
  lv_obj_set_style_text_color(ui_Labe2, lv_color_hex(0x09BEFB), LV_STATE_DEFAULT);
  lv_label_set_text(ui_Labe2, "0%");
  lv_obj_center(ui_Labe2);
}

#define Z_THRESHOLD 350 // Touch pressure threshold for validating touches
#define _RAWERR 20 // Deadband error allowed in successive position samples
void begin_touch_read_write(void) {
  digitalWrite(38, HIGH); // Just in case it has been left low
  spi.setFrequency(600000);
  digitalWrite(38, LOW);
}

void end_touch_read_write(void) {
  digitalWrite(38, HIGH); // Just in case it has been left low
  spi.setFrequency(600000);

}

uint16_t getTouchRawZ(void) {

  begin_touch_read_write();

  // Z sample request
  int16_t tz = 0xFFF;
  spi.transfer(0xb0);               // Start new Z1 conversion
  tz += spi.transfer16(0xc0) >> 3;  // Read Z1 and start Z2 conversion
  tz -= spi.transfer16(0x00) >> 3;  // Read Z2

  end_touch_read_write();

  return (uint16_t)tz;
}

uint8_t getTouchRaw(uint16_t *x, uint16_t *y) {
  uint16_t tmp;

  begin_touch_read_write();

  // Start YP sample request for x position, read 4 times and keep last sample
  spi.transfer(0xd0);                    // Start new YP conversion
  spi.transfer(0);                       // Read first 8 bits
  spi.transfer(0xd0);                    // Read last 8 bits and start new YP conversion
  spi.transfer(0);                       // Read first 8 bits
  spi.transfer(0xd0);                    // Read last 8 bits and start new YP conversion
  spi.transfer(0);                       // Read first 8 bits
  spi.transfer(0xd0);                    // Read last 8 bits and start new YP conversion

  tmp = spi.transfer(0);                   // Read first 8 bits
  tmp = tmp << 5;
  tmp |= 0x1f & (spi.transfer(0x90) >> 3); // Read last 8 bits and start new XP conversion

  *x = tmp;

  // Start XP sample request for y position, read 4 times and keep last sample
  spi.transfer(0);                       // Read first 8 bits
  spi.transfer(0x90);                    // Read last 8 bits and start new XP conversion
  spi.transfer(0);                       // Read first 8 bits
  spi.transfer(0x90);                    // Read last 8 bits and start new XP conversion
  spi.transfer(0);                       // Read first 8 bits
  spi.transfer(0x90);                    // Read last 8 bits and start new XP conversion

  tmp = spi.transfer(0);                 // Read first 8 bits
  tmp = tmp << 5;
  tmp |= 0x1f & (spi.transfer(0) >> 3);  // Read last 8 bits

  *y = tmp;

  end_touch_read_write();

  return true;
}

uint8_t validTouch(uint16_t *x, uint16_t *y, uint16_t threshold) {
  uint16_t x_tmp, y_tmp, x_tmp2, y_tmp2;

  // Wait until pressure stops increasing to debounce pressure
  uint16_t z1 = 1;
  uint16_t z2 = 0;
  while (z1 > z2)
  {
    z2 = z1;
    z1 = getTouchRawZ();
    delay(1);
    Serial.print("z1:");
    Serial.println(z1);
  }


  if (z1 <= threshold) return false;

  getTouchRaw(&x_tmp, &y_tmp);


  delay(1); // Small delay to the next sample
  if (getTouchRawZ() <= threshold) return false;

  delay(2); // Small delay to the next sample
  getTouchRaw(&x_tmp2, &y_tmp2);


  if (abs(x_tmp - x_tmp2) > _RAWERR) return false;
  if (abs(y_tmp - y_tmp2) > _RAWERR) return false;

  *x = x_tmp;
  *y = y_tmp;

  return true;
}

void calibrateTouch(uint16_t *parameters, uint32_t color_fg, uint32_t color_bg, uint8_t size) {
  int16_t values[] = {0, 0, 0, 0, 0, 0, 0, 0};
  uint16_t x_tmp, y_tmp;
  uint16_t _width = 800;
  uint16_t _height = 480;

  for (uint8_t i = 0; i < 4; i++) {
    lcd->fillRect(0, 0, size + 1, size + 1, color_bg);
    lcd->fillRect(0, _height - size - 1, size + 1, size + 1, color_bg);
    lcd->fillRect(_width - size - 1, 0, size + 1, size + 1, color_bg);
    lcd->fillRect(_width - size - 1, _height - size - 1, size + 1, size + 1, color_bg);

    if (i == 5) break; // used to clear the arrows

    switch (i) {
      case 0: // up left
        lcd->drawLine(0, 0, 0, size, color_fg);
        lcd->drawLine(0, 0, size, 0, color_fg);
        lcd->drawLine(0, 0, size , size, color_fg);
        break;
      case 1: // bot left
        lcd->drawLine(0, _height - size - 1, 0, _height - 1, color_fg);
        lcd->drawLine(0, _height - 1, size, _height - 1, color_fg);
        lcd->drawLine(size, _height - size - 1, 0, _height - 1 , color_fg);
        break;
      case 2: // up right
        lcd->drawLine(_width - size - 1, 0, _width - 1, 0, color_fg);
        lcd->drawLine(_width - size - 1, size, _width - 1, 0, color_fg);
        lcd->drawLine(_width - 1, size, _width - 1, 0, color_fg);
        break;
      case 3: // bot right
        lcd->drawLine(_width - size - 1, _height - size - 1, _width - 1, _height - 1, color_fg);
        lcd->drawLine(_width - 1, _height - 1 - size, _width - 1, _height - 1, color_fg);
        lcd->drawLine(_width - 1 - size, _height - 1, _width - 1, _height - 1, color_fg);
        break;
    }

    // user has to get the chance to release
    if (i > 0) delay(1000);

    for (uint8_t j = 0; j < 8; j++) {
      while (touch_has_signal())
      {
        if (touch_touched())
        {
          Serial.print( "Data x :" );
          Serial.println( touch_last_x );
          Serial.print( "Data y :" );
          Serial.println( touch_last_y );
          break;
        }
      }
    }
  }
}

void touch_calibrate()//screen calibration
{
  uint16_t calData[5];
  uint8_t calDataOK = 0;
  Serial.println("screen calibration");

  //校准
  Serial.println("Touch corners as directed");
  lv_timer_handler();
  calibrateTouch(calData, MAGENTA, BLACK, 17);
  Serial.println("calibrateTouch(calData, TFT_MAGENTA, TFT_BLACK, 15)");
  Serial.println(); Serial.println();
  Serial.println("// Use this calibration code in setup():.");
  Serial.print("uint16_t calData[5] = ");
  Serial.print("{ ");

  for (uint8_t i = 0; i < 5; i++)
  {
    Serial.print(calData[i]);
    if (i < 4) Serial.print(", ");
  }

  Serial.println(" };");


}

void setTouch(uint16_t *parameters) {
  touchCalibration_x0 = parameters[0];
  touchCalibration_x1 = parameters[1];
  touchCalibration_y0 = parameters[2];
  touchCalibration_y1 = parameters[3];

  if (touchCalibration_x0 == 0) touchCalibration_x0 = 1;
  if (touchCalibration_x1 == 0) touchCalibration_x1 = 1;
  if (touchCalibration_y0 == 0) touchCalibration_y0 = 1;
  if (touchCalibration_y1 == 0) touchCalibration_y1 = 1;

  touchCalibration_rotate = parameters[4] & 0x01;
  touchCalibration_invert_x = parameters[4] & 0x02;
  touchCalibration_invert_y = parameters[4] & 0x04;
}

Does anyone have an idea what could be happening?

Which path to follow?

@Xylopyrographer and @Yuri_Alves_Bordin

(Fala Youri me ajuda, por favor). Tamos de boa

After trying this code:

/*******************************************************************************
 * LVGL Widgets
 * This is a widgets demo for LVGL - Light and Versatile Graphics Library
 * import from: https://github.com/lvgl/lv_demos.git
 *
 * This was created from the project here 
 * https://www.makerfabs.com/sunton-esp32-s3-4-3-inch-ips-with-touch.html
 * 
 * Dependent libraries:
 * LVGL: https://github.com/lvgl/lvgl.git

 * Touch libraries:
 * FT6X36: https://github.com/strange-v/FT6X36.git
 * GT911: https://github.com/TAMCTec/gt911-arduino.git
 * XPT2046: https://github.com/PaulStoffregen/XPT2046_Touchscreen.git
 *
 * LVGL Configuration file:
 * Copy your_arduino_path/libraries/lvgl/lv_conf_template.h
 * to your_arduino_path/libraries/lv_conf.h
 * Then find and set:
 * #define LV_COLOR_DEPTH     16
 * #define LV_TICK_CUSTOM     1
 *
 * For SPI display set color swap can be faster, parallel screen don't set!
 * #define LV_COLOR_16_SWAP   1
 *
 * Optional: Show CPU usage and FPS count
 * #define LV_USE_PERF_MONITOR 1
 ******************************************************************************/
//#include "lv_demo_widgets.h"
//#include <Arduino.h>
#include <lvgl.h>
//#include <demos/lv_demos.h>
#include <Arduino_GFX_Library.h>
#include <esp_now.h>
#include <WiFi.h>
#include <ArduinoJson.h>

#define TFT_BL 2
#define GFX_BL DF_GFX_BL // default backlight pin, you may replace DF_GFX_BL to actual backlight pin
 
unsigned long previousMillis = 0;  
const long interval = 5000;

void Create_Screen1(void);
void Create_Screen2(void);
void Create_Screen3(void);
void button_event_cb(lv_event_t *event);

Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
    40 /* DE */, 41 /* VSYNC */, 39 /* HSYNC */, 0 /* PCLK */,
    45 /* R0 */, 48 /* R1 */, 47 /* R2 */, 21 /* R3 */, 14 /* R4 */,
    5 /* G0 */, 6 /* G1 */, 7 /* G2 */, 15 /* G3 */, 16 /* G4 */, 4 /* G5 */,
    8 /* B0 */, 3 /* B1 */, 46 /* B2 */, 9 /* B3 */, 1 /* B4 */,
    0 /* hsync_polarity */, 8 /* hsync_front_porch */, 4 /* hsync_pulse_width */, 8 /* hsync_back_porch */,
    0 /* vsync_polarity */, 8 /* vsync_front_porch */, 4 /* vsync_pulse_width */, 8 /* vsync_back_porch */,
    0 /* pclk_active_neg */, 13000000 /* prefer_speed */);
    
Arduino_RGB_Display *gfx = new Arduino_RGB_Display(
    800 /* width */, 480 /* height */, rgbpanel);

#include "touch.h"


void button_event_cb(lv_event_t *event);


/* Change to your screen resolution */
static uint32_t screenWidth;
static uint32_t screenHeight;
static lv_disp_draw_buf_t draw_buf;
static lv_color_t *disp_draw_buf;
static lv_disp_drv_t disp_drv;

/* 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);

#if (LV_COLOR_16_SWAP != 0)
  gfx->draw16bitBeRGBBitmap(area->x1, area->y1, (uint16_t *)&color_p->full, w, h);
#else
  gfx->draw16bitRGBBitmap(area->x1, area->y1, (uint16_t *)&color_p->full, w, h);
#endif

  lv_disp_flush_ready(disp);
}

void my_touchpad_read(lv_indev_drv_t *indev_driver, lv_indev_data_t *data)
{
  if (touch_has_signal())
  {
    if (touch_touched())
    {
      data->state = LV_INDEV_STATE_PR;
      /*Set the coordinates*/
      data->point.x = touch_last_x;
      data->point.y = touch_last_y;
    }
    else if (touch_released())
    {
      data->state = LV_INDEV_STATE_REL;
    }
  }
  else
  {
    data->state = LV_INDEV_STATE_REL;
  }
}

lv_obj_t *screen1;
lv_obj_t *screen2;
lv_obj_t *screen3;

void setup(){
        Serial.begin(115200);

          // Init touch device
          // Init Display
          gfx->begin();
          #ifdef TFT_BL
          pinMode(TFT_BL, OUTPUT);
          digitalWrite(TFT_BL, HIGH);
          #endif
          gfx->fillScreen(RED);
          delay(500);
          // gfx->fillScreen(GREEN);
          // delay(500);
          // gfx->fillScreen(RED);
          // delay(500);
          // gfx->fillScreen(GREEN);
          // delay(500);
          // gfx->fillScreen(RED);
          // delay(500);

          lv_init();
          delay(10);
          touch_init();

          screenWidth = gfx->width();
          screenHeight = gfx->height();

          #ifdef ESP32
          disp_draw_buf = (lv_color_t *)heap_caps_malloc(sizeof(lv_color_t) * screenWidth * screenHeight / 4, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
          #else
          disp_draw_buf = (lv_color_t *)malloc(sizeof(lv_color_t) * screenWidth * screenHeight / 4);
          #endif
          if (!disp_draw_buf)
          {
              printf("LVGL disp_draw_buf allocate failed!\n");
          }
          else
          {
          lv_disp_draw_buf_init(&draw_buf, disp_draw_buf, NULL, screenWidth * screenHeight / 4);

          /* Initialize the display */
          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);

          //******************************* MY CODE *******************************************
          //Dim the TFT backlight
          analogWrite(TFT_BL, 255 / 1.5); // values go from 0 to 255,

          //Three(3) Screen Example
          Create_Screen1();       //Create and load the first screen
          lv_scr_load(screen1);

          printf("Setup done\n");
        }
}

void loop(){
        lv_timer_handler(); /* let the GUI do its work */
        delay(5);

        unsigned long currentMillis = millis();
        if (currentMillis - previousMillis >= interval) {
          previousMillis = currentMillis;
          //espnow_senddata();
        }
}


//**********************  PROCEDURES  *************************************************
void Create_Screen1(void){
      screen1 = lv_obj_create(NULL);

      lv_obj_t * button1 = lv_btn_create(screen1);
      lv_obj_add_event_cb(button1, button_event_cb, LV_EVENT_CLICKED, NULL);
      lv_obj_set_size(button1, 170, 80);
      lv_obj_set_pos(button1, 32, 100);
      lv_obj_t * label1 = lv_label_create(button1);
      lv_label_set_text(label1, "Test");

      lv_obj_t * button2 = lv_btn_create(screen1);
      lv_obj_add_event_cb(button2, button_event_cb, LV_EVENT_CLICKED, NULL);
      lv_obj_set_size(button2, 170, 80);
      lv_obj_set_pos(button2, 249, 100);
      lv_obj_t * label2 = lv_label_create(button2);
      lv_label_set_text(label2, "Goto_Screen2");
}

void Create_Screen2(void){
      screen2 = lv_obj_create(NULL);

      lv_obj_t * button3 = lv_btn_create(screen2);
      lv_obj_add_event_cb(button3, button_event_cb, LV_EVENT_CLICKED, NULL);
      lv_obj_set_size(button3, 170, 80);
      lv_obj_set_pos(button3, 249, 100);
      lv_obj_t * label3 = lv_label_create(button3);
      lv_label_set_text(label3, "Goto_Screen3");
}

void Create_Screen3(void){
      screen3 = lv_obj_create(NULL);

      lv_obj_t * button4 = lv_btn_create(screen3);
      lv_obj_add_event_cb(button4, button_event_cb, LV_EVENT_CLICKED, NULL);
      lv_obj_set_size(button4, 170, 80);
      lv_obj_set_pos(button4, 249, 100);
      lv_obj_t * label4 = lv_label_create(button4);
      lv_label_set_text(label4, "Goto_Screen1");
}


void button_event_cb(lv_event_t *event){

        lv_obj_t *btn = lv_event_get_target(event);
        lv_obj_t * label = lv_obj_get_child(btn, 0);
        const char * text = lv_label_get_text(label);
        printf ("Button_Touched: %s \n", text);
        printf("[APP] Minimum memory: %s bytes\n", String(esp_get_minimum_free_heap_size()));

        if(strcmp(text, "Goto_Screen2") == 0) {
          printf ("Goto Screen: %s \n", text);

          printf ("Load Screen2:\n");
          Create_Screen2();
          lv_scr_load(screen2);

          printf("[APP] Free memory: %s bytes\n", String(esp_get_free_heap_size()));
          //printf ("Clean Screen1:\n");
          //lv_obj_clean(screen1);
          printf ("Delete Screen1:\n");
          lv_obj_del(screen1);
          printf("[APP] Free memory: %s bytes\n", String(esp_get_free_heap_size()));

        }
        if(strcmp(text, "Goto_Screen3") == 0) {
          printf ("Goto Screen: %s \n", text);

          printf ("Load Screen3:\n");
          Create_Screen3();
          lv_scr_load(screen3);

          printf("[APP] Free memory: %s bytes\n", String(esp_get_free_heap_size()));
          printf ("Delete Screen2:\n");
          lv_obj_del(screen2);
          printf("[APP] Free memory: %s bytes\n", String(esp_get_free_heap_size()));

        }
        if(strcmp(text, "Goto_Screen1") == 0) {
          printf ("Goto Screen: %s \n", text);

          printf ("Create Screen1:\n");
          Create_Screen1();
          lv_scr_load(screen1);

          printf("[APP] Free memory: %s bytes\n", String(esp_get_free_heap_size()));
          printf ("Delete Screen3:\n");
          lv_obj_del(screen3);
          printf("[APP] Free memory: %s bytes\n", String(esp_get_free_heap_size()));

        }
        else{
          return;
        }

}

I get this result:

I possess a Git repository housing an example for compiling LVGL with diverse board types. Adjusting pins, resolution, and Hsync/Vsync settings to match your screen allows for successful compilation. This project acts as a straightforward starting point that you can further develop for your specific needs.

(Claro que está tudo bem @allacmc , eu tive uns imprevistos aqui e esqueci de te responder e enviar o Código que você pediu, me perdoa por isso se você ainda precisar do Código eu ainda tenho ele)

For the basic PlatformIO project structure, refer to this link.

Additionally, there’s a project utilizing ESP-IDF and LVGL, designed for an easy start. It supports Resistive Touch, with LVGL touch indev and the actual Resistive Touch separated for individual use. Find the project here. The LCD Driver can be accessed here. To add new displays, create and configure a copy of the mentioned file.

Furthermore, the repository includes additional LVGL examples within PlatformIO, available here.

I solved!

Tanks!!

The code:

/*******************************************************************************
 * LVGL Widgets
 * This is a widgets demo for LVGL - Light and Versatile Graphics Library
 * import from: https://github.com/lvgl/lv_demos.git
 *
 * This was created from the project here 
 * https://www.makerfabs.com/sunton-esp32-s3-4-3-inch-ips-with-touch.html
 * 
 * Dependent libraries:
 * LVGL: https://github.com/lvgl/lvgl.git

 * Touch libraries:
 * FT6X36: https://github.com/strange-v/FT6X36.git
 * GT911: https://github.com/TAMCTec/gt911-arduino.git
 * XPT2046: https://github.com/PaulStoffregen/XPT2046_Touchscreen.git
 *
 * LVGL Configuration file:
 * Copy your_arduino_path/libraries/lvgl/lv_conf_template.h
 * to your_arduino_path/libraries/lv_conf.h
 * Then find and set:
 * #define LV_COLOR_DEPTH     16
 * #define LV_TICK_CUSTOM     1
 *
 * For SPI display set color swap can be faster, parallel screen don't set!
 * #define LV_COLOR_16_SWAP   1
 *
 * Optional: Show CPU usage and FPS count
 * #define LV_USE_PERF_MONITOR 1
 ******************************************************************************/
//#include "lv_demo_widgets.h"
//#include <Arduino.h>
#include <lvgl.h>
//#include <demos/lv_demos.h>
#include <Arduino_GFX_Library.h>
#include <esp_now.h>
#include <WiFi.h>
#include <ArduinoJson.h>

#define TFT_BL 2
#define GFX_BL DF_GFX_BL // default backlight pin, you may replace DF_GFX_BL to actual backlight pin
 
unsigned long previousMillis = 0;  
const long interval = 5000;

void Create_Screen1(void);
void Create_Screen2(void);
void Create_Screen3(void);
void button_event_cb(lv_event_t *event);

uint16_t touchCalibration_x0 = 300, touchCalibration_x1 = 3600, touchCalibration_y0 = 300, touchCalibration_y1 = 3600;
uint8_t  touchCalibration_rotate = 1, touchCalibration_invert_x = 2, touchCalibration_invert_y = 0;
static int val = 100;


Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
    40 /* DE */, 41 /* VSYNC */, 39 /* HSYNC */, 0 /* PCLK */,
    45 /* R0 */, 48 /* R1 */, 47 /* R2 */, 21 /* R3 */, 14 /* R4 */,
    5 /* G0 */, 6 /* G1 */, 7 /* G2 */, 15 /* G3 */, 16 /* G4 */, 4 /* G5 */,
    8 /* B0 */, 3 /* B1 */, 46 /* B2 */, 9 /* B3 */, 1 /* B4 */,

    0 /* hsync_polarity */, 210 /* hsync_front_porch */, 4 /* hsync_pulse_width */, 43 /* hsync_back_porch */,
    0 /* vsync_polarity */, 22 /* vsync_front_porch */, 4 /* vsync_pulse_width */, 12 /* vsync_back_porch */,
    0 /* pclk_active_neg */, 16000000 /* prefer_speed */);
    
Arduino_RGB_Display *gfx = new Arduino_RGB_Display(800 /* width */, 480 /* height */, rgbpanel);

#include "touch.h"


void button_event_cb(lv_event_t *event);


/* Change to your screen resolution */
static uint32_t screenWidth = 800;
static uint32_t screenHeight = 480;
static lv_disp_draw_buf_t draw_buf;
static lv_color_t *disp_draw_buf;
static lv_disp_drv_t disp_drv;

/* 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);
      #if (LV_COLOR_16_SWAP != 0)
        gfx->draw16bitBeRGBBitmap(area->x1, area->y1, (uint16_t *)&color_p->full, w, h);
      #else
        gfx->draw16bitRGBBitmap(area->x1, area->y1, (uint16_t *)&color_p->full, w, h);
      #endif

        lv_disp_flush_ready(disp);
}

void my_touchpad_read(lv_indev_drv_t *indev_driver, lv_indev_data_t *data){
      if (touch_has_signal())
      {
        if (touch_touched())
        {
          data->state = LV_INDEV_STATE_PR;
          /*Set the coordinates*/
          data->point.x = touch_last_x;
          data->point.y = touch_last_y;

          Serial.print( "Data x :" );
          Serial.println( touch_last_x );

          Serial.print( "Data y :" );
          Serial.println( touch_last_y );

        }
        else if (touch_released())
        {
          data->state = LV_INDEV_STATE_REL;
        }
      }
      else
      {
        data->state = LV_INDEV_STATE_REL;
      }
}

lv_obj_t *screen1;
lv_obj_t *screen2;
lv_obj_t *screen3;

void setup(){
        Serial.begin(115200);

          // Init touch device
          // Init Display
          gfx->begin();
          #ifdef TFT_BL
          pinMode(TFT_BL, OUTPUT);
          digitalWrite(TFT_BL, HIGH);
          #endif
          gfx->fillScreen(RED);
          delay(500);
          gfx->fillScreen(GREEN);
          delay(500);
          gfx->fillScreen(RED);
          delay(500);
          gfx->fillScreen(GREEN);
          delay(500);
          gfx->fillScreen(RED);
          delay(500);
          gfx->setCursor(10, 10);
          gfx->setTextColor(BLACK);
          gfx->println("Hello World!");
          delay(3000);
          lv_init();
          delay(10);
          touch_init();

          screenWidth = gfx->width();
          screenHeight = gfx->height();

          #ifdef ESP32
          disp_draw_buf = (lv_color_t *)heap_caps_malloc(sizeof(lv_color_t) * screenWidth * screenHeight / 4, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
          #else
          disp_draw_buf = (lv_color_t *)malloc(sizeof(lv_color_t) * screenWidth * screenHeight / 4);
          #endif
          if (!disp_draw_buf)
          {
              printf("LVGL disp_draw_buf allocate failed!\n");
          }
          else
          {
          lv_disp_draw_buf_init(&draw_buf, disp_draw_buf, NULL, screenWidth * screenHeight / 4);

          /* Initialize the display */
          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);

          //******************************* MY CODE *******************************************
          //Dim the TFT backlight
          analogWrite(TFT_BL, 255 / 1.5); // values go from 0 to 255,

          //Three(3) Screen Example
          Create_Screen1();       //Create and load the first screen
          lv_scr_load(screen1);

          printf("Setup done\n");
        }
}

void loop(){
        lv_timer_handler(); /* let the GUI do its work */
        delay(5);

        unsigned long currentMillis = millis();
        if (currentMillis - previousMillis >= interval) {
          previousMillis = currentMillis;
          //espnow_senddata();
        }
}


//**********************  PROCEDURES  *************************************************
void Create_Screen1(void){
      screen1 = lv_obj_create(NULL);

      lv_obj_t * button1 = lv_btn_create(screen1);
      lv_obj_add_event_cb(button1, button_event_cb, LV_EVENT_CLICKED, NULL);
      lv_obj_set_size(button1, 170, 80);
      lv_obj_set_pos(button1, 32, 100);
      lv_obj_t * label1 = lv_label_create(button1);
      lv_label_set_text(label1, "Test");

      lv_obj_t * button2 = lv_btn_create(screen1);
      lv_obj_add_event_cb(button2, button_event_cb, LV_EVENT_CLICKED, NULL);
      lv_obj_set_size(button2, 170, 80);
      lv_obj_set_pos(button2, 249, 100);
      lv_obj_t * label2 = lv_label_create(button2);
      lv_label_set_text(label2, "Goto_Screen2");
}

void Create_Screen2(void){
      screen2 = lv_obj_create(NULL);

      lv_obj_t * button3 = lv_btn_create(screen2);
      lv_obj_add_event_cb(button3, button_event_cb, LV_EVENT_CLICKED, NULL);
      lv_obj_set_size(button3, 170, 80);
      lv_obj_set_pos(button3, 249, 100);
      lv_obj_t * label3 = lv_label_create(button3);
      lv_label_set_text(label3, "Goto_Screen3");
}

void Create_Screen3(void){
      screen3 = lv_obj_create(NULL);

      lv_obj_t * button4 = lv_btn_create(screen3);
      lv_obj_add_event_cb(button4, button_event_cb, LV_EVENT_CLICKED, NULL);
      lv_obj_set_size(button4, 170, 80);
      lv_obj_set_pos(button4, 249, 100);
      lv_obj_t * label4 = lv_label_create(button4);
      lv_label_set_text(label4, "Goto_Screen1");
}


void button_event_cb(lv_event_t *event){

        lv_obj_t *btn = lv_event_get_target(event);
        lv_obj_t * label = lv_obj_get_child(btn, 0);
        const char * text = lv_label_get_text(label);
        printf ("Button_Touched: %s \n", text);
        printf("[APP] Minimum memory: %s bytes\n", String(esp_get_minimum_free_heap_size()));

        if(strcmp(text, "Goto_Screen2") == 0) {
          printf ("Goto Screen: %s \n", text);

          printf ("Load Screen2:\n");
          Create_Screen2();
          lv_scr_load(screen2);

          printf("[APP] Free memory: %s bytes\n", String(esp_get_free_heap_size()));
          //printf ("Clean Screen1:\n");
          //lv_obj_clean(screen1);
          printf ("Delete Screen1:\n");
          lv_obj_del(screen1);
          printf("[APP] Free memory: %s bytes\n", String(esp_get_free_heap_size()));

        }
        if(strcmp(text, "Goto_Screen3") == 0) {
          printf ("Goto Screen: %s \n", text);

          printf ("Load Screen3:\n");
          Create_Screen3();
          lv_scr_load(screen3);

          printf("[APP] Free memory: %s bytes\n", String(esp_get_free_heap_size()));
          printf ("Delete Screen2:\n");
          lv_obj_del(screen2);
          printf("[APP] Free memory: %s bytes\n", String(esp_get_free_heap_size()));

        }
        if(strcmp(text, "Goto_Screen1") == 0) {
          printf ("Goto Screen: %s \n", text);

          printf ("Create Screen1:\n");
          Create_Screen1();
          lv_scr_load(screen1);

          printf("[APP] Free memory: %s bytes\n", String(esp_get_free_heap_size()));
          printf ("Delete Screen3:\n");
          lv_obj_del(screen3);
          printf("[APP] Free memory: %s bytes\n", String(esp_get_free_heap_size()));

        }
        else{
          return;
        }

}

Now I need to get the capacitive touchscreen working.

1 Like

The Solved,
Display and Touch

The code:

/*******************************************************************************
 * LVGL Widgets
 * This is a widgets demo for LVGL - Light and Versatile Graphics Library
 * import from: https://github.com/lvgl/lv_demos.git
 *
 * This was created from the project here 
 * https://www.makerfabs.com/sunton-esp32-s3-4-3-inch-ips-with-touch.html
 * 
 * Dependent libraries:
 * LVGL: https://github.com/lvgl/lvgl.git

 * Touch libraries:
 * FT6X36: https://github.com/strange-v/FT6X36.git
 * GT911: https://github.com/TAMCTec/gt911-arduino.git
 * XPT2046: https://github.com/PaulStoffregen/XPT2046_Touchscreen.git
 *
 * LVGL Configuration file:
 * Copy your_arduino_path/libraries/lvgl/lv_conf_template.h
 * to your_arduino_path/libraries/lv_conf.h
 * Then find and set:
 * #define LV_COLOR_DEPTH     16
 * #define LV_TICK_CUSTOM     1
 *
 * For SPI display set color swap can be faster, parallel screen don't set!
 * #define LV_COLOR_16_SWAP   1
 *
 * Optional: Show CPU usage and FPS count
 * #define LV_USE_PERF_MONITOR 1
 ******************************************************************************/
//#include "lv_demo_widgets.h"
//#include <Arduino.h>
#include <lvgl.h>
//#include <demos/lv_demos.h>
#include <Arduino_GFX_Library.h>
#include <esp_now.h>
#include <WiFi.h>
#include <ArduinoJson.h>

#define TFT_BL 2
#define GFX_BL DF_GFX_BL // default backlight pin, you may replace DF_GFX_BL to actual backlight pin
 
unsigned long previousMillis = 0;  
const long interval = 5000;

void Create_Screen1(void);
void Create_Screen2(void);
void Create_Screen3(void);
void button_event_cb(lv_event_t *event);

uint16_t touchCalibration_x0 = 300, touchCalibration_x1 = 3600, touchCalibration_y0 = 300, touchCalibration_y1 = 3600;
uint8_t  touchCalibration_rotate = 1, touchCalibration_invert_x = 2, touchCalibration_invert_y = 0;
static int val = 100;


Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
    40 /* DE */, 41 /* VSYNC */, 39 /* HSYNC */, 0 /* PCLK */,
    45 /* R0 */, 48 /* R1 */, 47 /* R2 */, 21 /* R3 */, 14 /* R4 */,
    5 /* G0 */, 6 /* G1 */, 7 /* G2 */, 15 /* G3 */, 16 /* G4 */, 4 /* G5 */,
    8 /* B0 */, 3 /* B1 */, 46 /* B2 */, 9 /* B3 */, 1 /* B4 */,

    0 /* hsync_polarity */, 210 /* hsync_front_porch */, 4 /* hsync_pulse_width */, 43 /* hsync_back_porch */,
    0 /* vsync_polarity */, 22 /* vsync_front_porch */, 4 /* vsync_pulse_width */, 12 /* vsync_back_porch */,
    0 /* pclk_active_neg */, 16000000 /* prefer_speed */);
    
Arduino_RGB_Display *gfx = new Arduino_RGB_Display(800 /* width */, 480 /* height */, rgbpanel);

#include "touch.h"


void button_event_cb(lv_event_t *event);


/* Change to your screen resolution */
static uint32_t screenWidth = 800;
static uint32_t screenHeight = 480;
static lv_disp_draw_buf_t draw_buf;
static lv_color_t *disp_draw_buf;
static lv_disp_drv_t disp_drv;

/* 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);
      #if (LV_COLOR_16_SWAP != 0)
        gfx->draw16bitBeRGBBitmap(area->x1, area->y1, (uint16_t *)&color_p->full, w, h);
      #else
        gfx->draw16bitRGBBitmap(area->x1, area->y1, (uint16_t *)&color_p->full, w, h);
      #endif

        lv_disp_flush_ready(disp);
}

void my_touchpad_read(lv_indev_drv_t *indev_driver, lv_indev_data_t *data){
      if (touch_has_signal())
      {
        if (touch_touched())
        {
          data->state = LV_INDEV_STATE_PR;
          /*Set the coordinates*/
          data->point.x = touch_last_x;
          data->point.y = touch_last_y;

          Serial.print( "Data x :" );
          Serial.println( touch_last_x );

          Serial.print( "Data y :" );
          Serial.println( touch_last_y );

        }
        else if (touch_released())
        {
          data->state = LV_INDEV_STATE_REL;
        }
      }
      else
      {
        data->state = LV_INDEV_STATE_REL;
      }
}

lv_obj_t *screen1;
lv_obj_t *screen2;
lv_obj_t *screen3;

void setup(){
        Serial.begin(115200);

          // Init touch device
          // Init Display
          gfx->begin();
          #ifdef TFT_BL
          pinMode(TFT_BL, OUTPUT);
          digitalWrite(TFT_BL, HIGH);
          #endif
          gfx->fillScreen(RED);
          delay(500);
          gfx->fillScreen(GREEN);
          delay(500);
          gfx->fillScreen(RED);
          delay(500);
          gfx->fillScreen(GREEN);
          delay(500);
          gfx->fillScreen(RED);
          delay(500);
          gfx->setCursor(10, 10);
          gfx->setTextColor(BLACK);
          gfx->println("Hello World!");
          delay(3000);
          lv_init();
          delay(10);
          touch_init();

          screenWidth = gfx->width();
          screenHeight = gfx->height();

          #ifdef ESP32
          disp_draw_buf = (lv_color_t *)heap_caps_malloc(sizeof(lv_color_t) * screenWidth * screenHeight / 4, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
          #else
          disp_draw_buf = (lv_color_t *)malloc(sizeof(lv_color_t) * screenWidth * screenHeight / 4);
          #endif
          if (!disp_draw_buf)
          {
              printf("LVGL disp_draw_buf allocate failed!\n");
          }
          else
          {
          lv_disp_draw_buf_init(&draw_buf, disp_draw_buf, NULL, screenWidth * screenHeight / 4);

          /* Initialize the display */
          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);

          //******************************* MY CODE *******************************************
          //Dim the TFT backlight
          analogWrite(TFT_BL, 255 / 1.5); // values go from 0 to 255,

          //Three(3) Screen Example
          Create_Screen1();       //Create and load the first screen
          lv_scr_load(screen1);

          printf("Setup done\n");
        }
}

void loop(){
        lv_timer_handler(); /* let the GUI do its work */
        delay(5);

        unsigned long currentMillis = millis();
        if (currentMillis - previousMillis >= interval) {
          previousMillis = currentMillis;
          //espnow_senddata();
        }
}


//**********************  PROCEDURES  *************************************************
void Create_Screen1(void){
      screen1 = lv_obj_create(NULL);

      lv_obj_t * button1 = lv_btn_create(screen1);
      lv_obj_add_event_cb(button1, button_event_cb, LV_EVENT_CLICKED, NULL);
      lv_obj_set_size(button1, 170, 80);
      lv_obj_set_pos(button1, 32, 100);
      lv_obj_t * label1 = lv_label_create(button1);
      lv_label_set_text(label1, "Test");

      lv_obj_t * button2 = lv_btn_create(screen1);
      lv_obj_add_event_cb(button2, button_event_cb, LV_EVENT_CLICKED, NULL);
      lv_obj_set_size(button2, 170, 80);
      lv_obj_set_pos(button2, 249, 100);
      lv_obj_t * label2 = lv_label_create(button2);
      lv_label_set_text(label2, "Goto_Screen2");
}

void Create_Screen2(void){
      screen2 = lv_obj_create(NULL);

      lv_obj_t * button3 = lv_btn_create(screen2);
      lv_obj_add_event_cb(button3, button_event_cb, LV_EVENT_CLICKED, NULL);
      lv_obj_set_size(button3, 170, 80);
      lv_obj_set_pos(button3, 249, 100);
      lv_obj_t * label3 = lv_label_create(button3);
      lv_label_set_text(label3, "Goto_Screen3");
}

void Create_Screen3(void){
      screen3 = lv_obj_create(NULL);

      lv_obj_t * button4 = lv_btn_create(screen3);
      lv_obj_add_event_cb(button4, button_event_cb, LV_EVENT_CLICKED, NULL);
      lv_obj_set_size(button4, 170, 80);
      lv_obj_set_pos(button4, 249, 100);
      lv_obj_t * label4 = lv_label_create(button4);
      lv_label_set_text(label4, "Goto_Screen1");
}


void button_event_cb(lv_event_t *event){

        lv_obj_t *btn = lv_event_get_target(event);
        lv_obj_t * label = lv_obj_get_child(btn, 0);
        const char * text = lv_label_get_text(label);
        printf ("Button_Touched: %s \n", text);
        printf("[APP] Minimum memory: %s bytes\n", String(esp_get_minimum_free_heap_size()));

        if(strcmp(text, "Goto_Screen2") == 0) {
          printf ("Goto Screen: %s \n", text);

          printf ("Load Screen2:\n");
          Create_Screen2();
          lv_scr_load(screen2);

          printf("[APP] Free memory: %s bytes\n", String(esp_get_free_heap_size()));
          //printf ("Clean Screen1:\n");
          //lv_obj_clean(screen1);
          printf ("Delete Screen1:\n");
          lv_obj_del(screen1);
          printf("[APP] Free memory: %s bytes\n", String(esp_get_free_heap_size()));

        }
        if(strcmp(text, "Goto_Screen3") == 0) {
          printf ("Goto Screen: %s \n", text);

          printf ("Load Screen3:\n");
          Create_Screen3();
          lv_scr_load(screen3);

          printf("[APP] Free memory: %s bytes\n", String(esp_get_free_heap_size()));
          printf ("Delete Screen2:\n");
          lv_obj_del(screen2);
          printf("[APP] Free memory: %s bytes\n", String(esp_get_free_heap_size()));

        }
        if(strcmp(text, "Goto_Screen1") == 0) {
          printf ("Goto Screen: %s \n", text);

          printf ("Create Screen1:\n");
          Create_Screen1();
          lv_scr_load(screen1);

          printf("[APP] Free memory: %s bytes\n", String(esp_get_free_heap_size()));
          printf ("Delete Screen3:\n");
          lv_obj_del(screen3);
          printf("[APP] Free memory: %s bytes\n", String(esp_get_free_heap_size()));

        }
        else{
          return;
        }

}

and touch.h

/*******************************************************************************
 * Touch libraries:
 * FT6X36: https://github.com/strange-v/FT6X36.git
 * GT911: https://github.com/TAMCTec/gt911-arduino.git
 * XPT2046: https://github.com/PaulStoffregen/XPT2046_Touchscreen.git
 ******************************************************************************/

/* uncomment for FT6X36 */
// #define TOUCH_FT6X36
// #define TOUCH_FT6X36_SCL 38//19
// #define TOUCH_FT6X36_SDA 37//18
// #define TOUCH_FT6X36_INT 4//39
// #define TOUCH_SWAP_XY
// #define TOUCH_MAP_X1 800
// #define TOUCH_MAP_X2 0
// #define TOUCH_MAP_Y1 0
// #define TOUCH_MAP_Y2 480

/* uncomment for GT911 */
 #define TOUCH_GT911
 #define TOUCH_GT911_SCL 20//20
 #define TOUCH_GT911_SDA 19//19
 #define TOUCH_GT911_INT 10//-1
 #define TOUCH_GT911_RST 11
 
 //38
 #define TOUCH_GT911_ROTATION ROTATION_NORMAL
 #define TOUCH_MAP_X1 800//480
 #define TOUCH_MAP_X2 0
 #define TOUCH_MAP_Y1 480//272
 #define TOUCH_MAP_Y2 0

/* uncomment for XPT2046 */
// #define TOUCH_XPT2046
// #define TOUCH_XPT2046_SCK 12
// #define TOUCH_XPT2046_MISO 13
// #define TOUCH_XPT2046_MOSI 11
// #define TOUCH_XPT2046_CS 38
// #define TOUCH_XPT2046_INT 36
// #define TOUCH_XPT2046_ROTATION 0
// #define TOUCH_MAP_X1 4000
// #define TOUCH_MAP_X2 100
// #define TOUCH_MAP_Y1 100
// #define TOUCH_MAP_Y2 4000

int touch_last_x = 0, touch_last_y = 0;

#if defined(TOUCH_FT6X36)
#include <Wire.h>
#include <FT6X36.h>
FT6X36 ts(&Wire, TOUCH_FT6X36_INT);
bool touch_touched_flag = true, touch_released_flag = true;

#elif defined(TOUCH_GT911)
#include <Wire.h>
#include <TAMC_GT911.h>
TAMC_GT911 ts = TAMC_GT911(TOUCH_GT911_SDA, TOUCH_GT911_SCL, TOUCH_GT911_INT, TOUCH_GT911_RST, max(TOUCH_MAP_X1, TOUCH_MAP_X2), max(TOUCH_MAP_Y1, TOUCH_MAP_Y2));

#elif defined(TOUCH_XPT2046)
#include <XPT2046_Touchscreen.h>
#include <SPI.h>
XPT2046_Touchscreen ts(TOUCH_XPT2046_CS, TOUCH_XPT2046_INT);

#endif

#if defined(TOUCH_FT6X36)
void touch(TPoint p, TEvent e)
{
  if (e != TEvent::Tap && e != TEvent::DragStart && e != TEvent::DragMove && e != TEvent::DragEnd)
  {
    return;
  }
  // translation logic depends on screen rotation
#if defined(TOUCH_SWAP_XY)
  touch_last_x = map(p.y, TOUCH_MAP_X1, TOUCH_MAP_X2, 0, gfx->width());
  touch_last_y = map(p.x, TOUCH_MAP_Y1, TOUCH_MAP_Y2, 0, gfx->height());
#else
  touch_last_x = map(p.x, TOUCH_MAP_X1, TOUCH_MAP_X2, 0, gfx->width());
  touch_last_y = map(p.y, TOUCH_MAP_Y1, TOUCH_MAP_Y2, 0, gfx->height());
#endif
  switch (e)
  {
  case TEvent::Tap:
    Serial.println("Tap");
    touch_touched_flag = true;
    touch_released_flag = true;
    break;
  case TEvent::DragStart:
    Serial.println("DragStart");
    touch_touched_flag = true;
    break;
  case TEvent::DragMove:
    Serial.println("DragMove");
    touch_touched_flag = true;
    break;
  case TEvent::DragEnd:
    Serial.println("DragEnd");
    touch_released_flag = true;
    break;
  default:
    Serial.println("UNKNOWN");
    break;
  }
}
#endif

void touch_init()
{
#if defined(TOUCH_FT6X36)
  Wire.begin(TOUCH_FT6X36_SDA, TOUCH_FT6X36_SCL);
  ts.begin();
  ts.registerTouchHandler(touch);

#elif defined(TOUCH_GT911)
  Wire.begin(TOUCH_GT911_SDA, TOUCH_GT911_SCL);
  ts.begin();
  ts.setRotation(TOUCH_GT911_ROTATION);

#elif defined(TOUCH_XPT2046)
  SPI.begin(TOUCH_XPT2046_SCK, TOUCH_XPT2046_MISO, TOUCH_XPT2046_MOSI, TOUCH_XPT2046_CS);
  ts.begin();
  ts.setRotation(TOUCH_XPT2046_ROTATION);

#endif
}

bool touch_has_signal()
{
#if defined(TOUCH_FT6X36)
  ts.loop();
  return touch_touched_flag || touch_released_flag;

#elif defined(TOUCH_GT911)
  return true;

#elif defined(TOUCH_XPT2046)
  return ts.tirqTouched();

#else
  return false;
#endif
}

bool touch_touched()
{
#if defined(TOUCH_FT6X36)
  if (touch_touched_flag)
  {
    touch_touched_flag = false;
    return true;
  }
  else
  {
    return false;
  }

#elif defined(TOUCH_GT911)
  ts.read();
  if (ts.isTouched)
  {
#if defined(TOUCH_SWAP_XY)
    touch_last_x = map(ts.points[0].y, TOUCH_MAP_X1, TOUCH_MAP_X2, 0, gfx->width() - 1);
    touch_last_y = map(ts.points[0].x, TOUCH_MAP_Y1, TOUCH_MAP_Y2, 0, gfx->height() - 1);
#else
    touch_last_x = map(ts.points[0].x, TOUCH_MAP_X1, TOUCH_MAP_X2, 0, gfx->width() - 1);
    touch_last_y = map(ts.points[0].y, TOUCH_MAP_Y1, TOUCH_MAP_Y2, 0, gfx->height() - 1);
#endif
    return true;
  }
  else
  {
    return false;
  }

#elif defined(TOUCH_XPT2046)
  if (ts.touched())
  {
    TS_Point p = ts.getPoint();
#if defined(TOUCH_SWAP_XY)
    touch_last_x = map(p.y, TOUCH_MAP_X1, TOUCH_MAP_X2, 0, gfx->width() - 1);
    touch_last_y = map(p.x, TOUCH_MAP_Y1, TOUCH_MAP_Y2, 0, gfx->height() - 1);
#else
    touch_last_x = map(p.x, TOUCH_MAP_X1, TOUCH_MAP_X2, 0, gfx->width() - 1);
    touch_last_y = map(p.y, TOUCH_MAP_Y1, TOUCH_MAP_Y2, 0, gfx->height() - 1);
#endif
    return true;
  }
  else
  {
    return false;
  }

#else
  return false;
#endif
}

bool touch_released()
{
#if defined(TOUCH_FT6X36)
  if (touch_released_flag)
  {
    touch_released_flag = false;
    return true;
  }
  else
  {
    return false;
  }

#elif defined(TOUCH_GT911)
  return true;

#elif defined(TOUCH_XPT2046)
  return true;

#else
  return false;
#endif
}
2 Likes

I tried to compile your code … as it is … but i git too many errors. Please can you let me know what libraries and version I supposed to have ? to compile your code

Hi Alfonso. At the top of the .ino file the versions I used are listed:

// The values in this sketch work when using:
//  - Arduino IDE v 2.1.1
//  - arduino-esp32 core v2.0.11
//  - lvgl at version 8.3.7
//  - GFX Library for Arduino at version 1.3.7
//  - TAMC_GT911 at version 1.0.2

There are reports that this doesn’t work with LVGL v9, but I’ve not tried with that version.

Hope that’s enough to get it working for you.

1 Like

I’m going to try today … really appreciate your help

hello i am new for the ESP32 LCD 4.3 inch
link : ESP32 display-4.3 Inch HMI Display 480x272 RGB TFT LCD Touch Screen Compatible with Arduino/LVGL

i have seen the Youtube videos where then mentioned to use display driver : NV3047
but i dont know how to do it

pls help

Thanks in Advance !!!

Help for Sunton 8048S70 board

I bought the card in question, and I’m trying to load the program from your site

I followed your instructions correctly, but I can’t get this example to work.

I use Arduino IDE and as device board I use ESP32 S3 Device Module, is this correct?

I kindly ask you for your help.

Thank you

Best regards

Paul


DO I RECEIVE THESE ERRORS WHEN COMPILING ARDUINO?

In file included from c:\Users\paolo\Documents\Arduino\libraries\Arduino_GFX-master\src/Arduino_GFX_Library.h:4,
from C:\Users\paolo\Documents\Arduino\music_picture\music_picture.ino:1:
c:\Users\paolo\Documents\Arduino\libraries\Arduino_GFX-master\src/Arduino_DataBus.h:160:13: error: ‘i80_device_list’ has not been declared
160 | LIST_HEAD(i80_device_list, lcd_panel_io_i80_t)
| ^~~~~~~~~~~~~~~
c:\Users\paolo\Documents\Arduino\libraries\Arduino_GFX-master\src/Arduino_DataBus.h:160:3: error: ISO C++ forbids declaration of ‘LIST_HEAD’ with no type [-fpermissive]
160 | LIST_HEAD(i80_device_list, lcd_panel_io_i80_t)
| ^~~~~~~~~
c:\Users\paolo\Documents\Arduino\libraries\Arduino_GFX-master\src/Arduino_DataBus.h:160:48: error: expected ‘;’ at end of member declaration
160 | LIST_HEAD(i80_device_list, lcd_panel_io_i80_t)
| ^
| ;
c:\Users\paolo\Documents\Arduino\libraries\Arduino_GFX-master\src/Arduino_DataBus.h:161:3: error: ‘device_list’ does not name a type
161 | device_list; // Head of i80 device list
| ^~~~~~~~~~~
c:\Users\paolo\Documents\Arduino\libraries\Arduino_GFX-master\src/Arduino_DataBus.h:195:3: error: ISO C++ forbids declaration of ‘LIST_ENTRY’ with no type [-fpermissive]
195 | LIST_ENTRY(lcd_panel_io_i80_t)
| ^~~~~~~~~~
c:\Users\paolo\Documents\Arduino\libraries\Arduino_GFX-master\src/Arduino_DataBus.h:195:32: error: expected ‘;’ at end of member declaration
195 | LIST_ENTRY(lcd_panel_io_i80_t)
| ^
| ;
c:\Users\paolo\Documents\Arduino\libraries\Arduino_GFX-master\src/Arduino_DataBus.h:196:3: error: ‘device_list_entry’ does not name a type
196 | device_list_entry; // Entry of i80 device list
| ^~~~~~~~~~~~~~~~~
In file included from c:\Users\paolo\Documents\Arduino\libraries\Arduino_GFX-master\src/Arduino_GFX_Library.h:14:
c:\Users\paolo\Documents\Arduino\libraries\Arduino_GFX-master\src/databus/Arduino_ESP32RGBPanel.h:43:3: error: ‘esp_lcd_rgb_panel_frame_trans_done_cb_t’ does not name a type; did you mean ‘esp_lcd_panel_io_color_trans_done_cb_t’?
43 | esp_lcd_rgb_panel_frame_trans_done_cb_t on_frame_trans_done; // Callback, invoked after frame trans done
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| esp_lcd_panel_io_color_trans_done_cb_t

exit status 1

Compilation error: exit status 1

Hi
can you share the connection of ESP32S3-LCD?
and what driver do you need for the bare LCD setup?
thanks

I have a smilar board but with parallel 800x480px ST7262E43 display and ESP32S3 from www.waveshare.com esp32s3 lcd 4.3 800x480

But no success in making the display working display use The LCD controller is the ST7262E43, and the Touch controller is the GT911.

How to start, Do you have some good examples for Arduino IDE to start with… Thank you.

Need workin’ newest libs, and working demo to start from scratch.

Please give a link for this display on git, and post some examples here!

The display is beautiful but is hard to initialize.

Please help me… need to make some streamer and flac player/recorder, with an external audio DAC.

For anybody interested, I managed to get it working with the ESP-8048S050
, it’s also a S3-Wroom-1 with 5’ TFT 800x480, using the ST7262 display driver and GT911 touch driver.

To get it working, install the ESP32_Display_Panel by espressif, GFX For Arduino by Moon On Our Nation, TAMC_GT911 andd lvgl.

With the exception of lvgl whose version should be between lvgl (>= v8.3.9, < v9), the rest should be the latest available.

Then you will want to either edit the following files in the ESP32_Display_Panel library, or if you don’t want to, you can just add those files along with the .ino code and it will work just fine (that said, for safety I edit both and add to project).

Also you shoul check for you ESP32-S3 settings in tools, some vendors will tell you to set it to partition size of 4 with spiffs, but doing so will cause an “not enought mem buffer size” error, so set “Flash Size: 16MB” and “Partition Size: 16MB Flash (2MB APP/ 12.5 FATFS)”. That solved the buffer size problem for me.

I’m still trying to get the lvgl code to work, it keeps failing to upload the code.

Ps: Ther is some GUI based editors for the those ESP, one of those is Guiton Editor they are the company that makes the board I’m currently using, but the editor only is available in Chinese.
ESP_Panel_Board_Custom.h (20.0 KB)
ESP_Panel_Conf.h based on @Yuri_Alves_Bordin project config for the 8048S043C (3.9 KB)

1 Like

@EraseR1972 @lladam
Found a general solution for all boards. Altough not by using the latest libs, it works with LVGL 8.4.0, and is compatible with Guiton Editor and SquareLine Editor.

Check this library ESP32 Smart display by Rzeldent, it include EVERY SINGLE board of those, and I mean it. The only downside for some, is that it must be used with PlatformIO, and I don’t know if it can be used with ArduinoIDE. That said, I hope that helps!

link to my Repo with example code of using PlatformIO, lvgl@8.4.0, bodmer/TJpg_Decoder@1.1.0, SquareLine Studio


SquareLine/Guiton Settings





Ps:~hope my days of suffering to help somebody ;(っ °Д °;)っ~
Pss: Guiton is basically an chinese SquareLine Editor, but with all the “premium” and paid features unlocked for free, only requires login, and also has option to upload firmware directly (altought that one always fails to open COM port for me)
WutShrugGIF

Anyone curious about the product developed with this board.

It is a “Datalogger de Temperatura” or “Medidor de Temperatura”

The product page is: https://enervision.ind.br/produto/enervision-thermal-datalogger/

I made it work for DIYmalls 4,3" pouces ESP32-S3 Écran ESP32-8048S043C-I IPS TFT LCD Module ILI9485 capacitif tactile 800x480 ESP32-S3-WROOM-1 (DIYmalls 4,3" pouces ESP32-S3 Écran ESP32-8048S043C-I IPS TFT LCD Module ILI9485 capacitif tactile 800x480 ESP32-S3-WROOM-1 Carte de développement pour Arduino : Amazon.fr: Commerce, Industrie et Science)

Here is my esphome config:

esphome:
  name: home-display
  friendly_name: Home Display
  platformio_options:
    build_flags: "-DBOARD_HAS_PSRAM"
    board_build.arduino.memory_type: qio_opi
    board_build.flash_mode: dio
    board_upload.maximum_ram_size: 524288

esp32:
  board: esp32-s3-devkitc-1
  variant: esp32s3
  framework:
    type: esp-idf
    sdkconfig_options:
      CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240: y
      CONFIG_ESP32S3_DATA_CACHE_64KB: y
      CONFIG_SPIRAM_FETCH_INSTRUCTIONS: y
      CONFIG_SPIRAM_RODATA: y
# Enable Home Assistant API
api:
  encryption:
    key: !secret encryption_key

ota:
  - platform: esphome
    password: !secret ota_password

wifi:
  power_save_mode: none
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  reboot_timeout: 3min
  fast_connect: true
  output_power: 10

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "$device_name Fallback Hotspot"
    password: !secret fallback_wifi_password

captive_portal:


external_components:
  - source: github://pr#6363
    refresh: 10min
    components: [lvgl]

psram:
  mode: octal
  speed: 80MHz

# Enable logging
logger:
  level: DEBUG

i2c:
  sda: GPIO19
  scl: GPIO20
  scan: False #True
  id: bus_a

display:
  - platform: rpi_dpi_rgb
    id: my_display
    auto_clear_enabled: true
    update_interval: never
    color_order: RGB
    pclk_frequency: 16MHz
    dimensions:
      width: 800
      height: 480
    de_pin:
      number: 40
    hsync_pin:
      number: 39
      #ignore_strapping_warning: true
    vsync_pin:
      number: 41
      #ignore_strapping_warning: true
    pclk_pin: 42
    pclk_inverted: false
    hsync_back_porch: 8 #30
    hsync_front_porch: 8 #210 
    hsync_pulse_width: 4 #30
    vsync_back_porch: 8 #4
    vsync_front_porch: 8 #4
    vsync_pulse_width: 4 #4
    
    data_pins:
      red:
        - 45         #r3
        - 48         #r4
        - 47        #r5
        - 21        #r6
        - 14        #r7
      blue:
        - 8        #b3
        - 3        #b4
        - 46        #b5
        - 9        #b6
        - 1        #b7
      green:
        - 5        #g2
        - 6         #g3
        - 7        #g4
        - 15        #g5
        - 16        #g6
        - 4        #g7

font:
  - file: "gfonts://Roboto"
    id: chu_nano
    size: 12

touchscreen:
  platform: gt911
  id: my_touch
  reset_pin: GPIO38
  on_touch:
    - lambda: |-
          ESP_LOGI("cal", "x=%d, y=%d, x_raw=%d, y_raw=%0d",
              touch.x,
              touch.y,
              touch.x_raw,
              touch.y_raw
              );
output:
  - platform: ledc
    pin: 2
    id: gpio_backlight_pwm

# Define a monochromatic, dimmable light for the backlight
light:
  - platform: monochromatic
    output: gpio_backlight_pwm
    name: "Display Backlight"
    id: back_light
    restore_mode: ALWAYS_ON

lvgl:
  displays:
    - display_id: my_display
  buffer_size: 100% #25%
  touchscreens:
    - touchscreen_id: my_touch 

  theme:
    # label:
    #   text_font: my_font # set all your labels to use your custom defined font
    button:
      bg_color: 0x2F8CD8
      bg_grad_color: 0x005782
      bg_grad_dir: VER
      bg_opa: COVER
      border_color: 0x0077b3
      border_width: 1
      text_color: 0xFFFFFF
      pressed: # set some button colors to be different in pressed state
        bg_color: 0x006699
        bg_grad_color: 0x00334d
      checked: # set some button colors to be different in checked state
        bg_color: 0x1d5f96
        bg_grad_color: 0x03324A
        text_color: 0xfff300
    buttonmatrix:
      bg_opa: TRANSP
      border_color: 0x0077b3
      border_width: 0
      text_color: 0xFFFFFF
      pad_all: 0
      items: # set all your buttonmatrix buttons to use your custom defined styles and font
        bg_color: 0x2F8CD8
        bg_grad_color: 0x005782
        bg_grad_dir: VER
        bg_opa: COVER
        border_color: 0x0077b3
        border_width: 1
        text_color: 0xFFFFFF
        #text_font: my_font
        pressed:
          bg_color: 0x006699
          bg_grad_color: 0x00334d
        checked:
          bg_color: 0x1d5f96
          bg_grad_color: 0x03324A
          text_color: 0x005580
    switch:
      bg_color: 0xC0C0C0
      bg_grad_color: 0xb0b0b0
      bg_grad_dir: VER
      bg_opa: COVER
      checked:
        bg_color: 0x1d5f96
        bg_grad_color: 0x03324A
        bg_grad_dir: VER
        bg_opa: COVER
      knob:
        bg_color: 0xFFFFFF
        bg_grad_color: 0xC0C0C0
        bg_grad_dir: VER
        bg_opa: COVER
    slider:
      border_width: 1
      border_opa: 15%
      bg_color: 0xcccaca
      bg_opa: 15%
      indicator:
        bg_color: 0x1d5f96
        bg_grad_color: 0x03324A
        bg_grad_dir: VER
        bg_opa: COVER
      knob:
        bg_color: 0x2F8CD8
        bg_grad_color: 0x005782
        bg_grad_dir: VER
        bg_opa: COVER
        border_color: 0x0077b3
        border_width: 1
        text_color: 0xFFFFFF

  style_definitions:
    - id: header_footer
      bg_color: 0x2F8CD8
      bg_grad_color: 0x005782
      bg_grad_dir: VER
      bg_opa: COVER
      border_opa: TRANSP
      radius: 0
      pad_all: 0
      pad_row: 0
      pad_column: 0
      border_color: 0x0077b3
      text_color: 0xFFFFFF
      width: 100%
      height: 30

  top_layer:
    widgets:
      - buttonmatrix:
          align: bottom_mid
          styles: header_footer
          pad_all: 0
          outline_width: 0
          id: top_layer
          items:
            styles: header_footer
          rows:
            - buttons:
              - id: page_prev
                text: "\uF053"
                on_press:
                  then:
                    lvgl.page.previous:
              - id: page_home
                text: "\uF015"
                on_press:
                  then:
                    lvgl.page.show: main_page
              - id: page_next
                text: "\uF054"
                on_press:
                  then:
                    lvgl.page.next:
  pages:
    - id: main_page
      widgets:
        # Example toggle button with text:
        - button:
            x: 10
            y: 50
            width: 70
            height: 30
            id: btn_id
            checkable: true
            widgets:
              - label:
                  align: center
                  text: "Light"
            on_value:
              then:
                - logger.log:
                    format: "Button checked state: %d"
                    args: [ x ]
        - switch:
            x: 10
            y: 10
            id: switch_id
            on_value:
              then:
                - logger.log:
                    format: "Switch state: %d"
                    args: [ x ]
    
    - id: clock_page
      widgets:
        

        - obj: # Clock container
            height: 400 #size_content
            width: 800 #240
            align: CENTER
            pad_all: 0
            border_width: 0
            bg_color: 0xFFFFFF
            widgets:
              - meter: # Clock face
                  height: 400 #220
                  width: 400 #220
                  align: center
                  bg_opa: TRANSP
                  text_color: 0x000000
                  scales:
                    - ticks: # minutes scale
                        width: 1
                        count: 61
                        length: 10
                        color: 0x000000
                      range_from: 0
                      range_to: 60
                      angle_range: 360
                      rotation: 270
                      indicators:
                        - line:
                            id: minute_hand
                            width: 3
                            color: 0xa6a6a6
                            r_mod: -4
                            value: 0
                    - ticks: # hours scale
                        width: 1
                        count: 12
                        length: 1
                        major:
                          stride: 1
                          width: 4
                          length: 8
                          color: 0xC0C0C0
                          label_gap: 12
                      angle_range: 330
                      rotation: 300
                      range_from: 1
                      range_to: 12
                    - indicators:
                        - line:
                            id: hour_hand
                            width: 5
                            color: 0xa6a6a6
                            r_mod: -30
                            value: 0
                      angle_range: 360
                      rotation: 270
                      range_from: 0
                      range_to: 720

time:
  - platform: homeassistant
    id: time_comp

interval:
  - interval: 30s
    then:
      if:
        condition:
          time.has_time:
        then:
          - script.execute: time_update

script:
  - id: time_update
    then:
      - lvgl.indicator.update:
          id: minute_hand
          value: !lambda |-
            return id(time_comp).now().minute;
      - lvgl.indicator.update:
          id: hour_hand
          value: !lambda |-
            auto now = id(time_comp).now();
            return std::fmod(now.hour, 12) * 60 + now.minute;

Hope it helps :wink:

I have that board too ( Waveshare ESP32-S3 4.3inch Capacitive 5Point Touch Display Development Board, 800x480, 32Bit LX7 2-Core Processor, 240MHz, Support WiFi, Onboard Antenna, Suitable for ESPHome/Home Assistant Project) , here is my working config for esphome and lvgl :

esphome:
  name: home-display
  friendly_name: Home Display
  platformio_options:
    build_flags: "-DBOARD_HAS_PSRAM"
    board_build.arduino.memory_type: qio_opi
    board_build.flash_mode: dio
    board_upload.maximum_ram_size: 524288

esp32:
  board: esp32-s3-devkitc-1
  variant: esp32s3
  framework:
    type: esp-idf
    sdkconfig_options:
      CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240: y
      CONFIG_ESP32S3_DATA_CACHE_64KB: y
      CONFIG_SPIRAM_FETCH_INSTRUCTIONS: y
      CONFIG_SPIRAM_RODATA: y

# Enable Home Assistant API
api:
  encryption:
    key: !secret encryption_key

ota:
  - platform: esphome
    password: !secret ota_password

wifi:
  power_save_mode: none
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  reboot_timeout: 3min
  fast_connect: true
  output_power: 10

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "$device_name Fallback Hotspot"
    password: !secret fallback_wifi_password

captive_portal:


external_components:
  - source: github://pr#6363
    refresh: 10min
    components: [lvgl]

psram:
  mode: octal
  speed: 80MHz

# Enable logging
logger:
  level: DEBUG

i2c:
  sda: GPIO08
  scl: GPIO09
  scan: True
  id: bus_a

display:
  - platform: rpi_dpi_rgb
    id: my_display
    auto_clear_enabled: false
    update_interval: never
    color_order: RGB
    pclk_frequency: 14MHz
    dimensions:
      width: 800
      height: 480
    de_pin:
      number: 5
    hsync_pin:
      number: 46
      ignore_strapping_warning: true
    vsync_pin:
      number: 3
      ignore_strapping_warning: true
    pclk_pin: 7
    pclk_inverted: false
    hsync_back_porch: 10 #30
    hsync_front_porch: 20 #210 
    hsync_pulse_width: 10 #30
    vsync_back_porch: 10 #4
    vsync_front_porch: 10 #4
    vsync_pulse_width: 10 #4
    data_pins:
      red:
        - 1         #r3
        - 2         #r4
        - 42        #r5
        - 41        #r6
        - 40        #r7
      blue:
        - 14        #b3
        - 38        #b4
        - 18        #b5
        - 17        #b6
        - 10        #b7
      green:
        - 39        #g2
        - 0         #g3
        - 45        #g4
        - 48        #g5
        - 47        #g6
        - 21        #g7

font:
  - file: "gfonts://Roboto"
    id: chu_nano
    size: 12

touchscreen:
  platform: gt911
  id: my_touch
  interrupt_pin: GPIO4
  on_touch:
    - lambda: |-
          ESP_LOGI("cal", "x=%d, y=%d, x_raw=%d, y_raw=%0d",
              touch.x,
              touch.y,
              touch.x_raw,
              touch.y_raw
              );

lvgl:
  displays:
    - display_id: my_display
  buffer_size: 25%
  touchscreens:
    - touchscreen_id: my_touch 
  pages:
    - id: main_page
      widgets:
        # Example toggle button with text:
        - button:
            x: 10
            y: 50
            width: 70
            height: 30
            id: btn_id
            checkable: true
            widgets:
              - label:
                  align: center
                  text: "Light"
            on_value:
              then:
                - logger.log:
                    format: "Button checked state: %d"
                    args: [ x ]
        - switch:
            x: 10
            y: 10
            id: switch_id
            on_value:
              then:
                - logger.log:
                    format: "Switch state: %d"
                    args: [ x ]
    
    - id: clock_page
      widgets:
        

        - obj: # Clock container
            height: 400 #size_content
            width: 800 #240
            align: CENTER
            pad_all: 0
            border_width: 0
            bg_color: 0xFFFFFF
            widgets:
              - meter: # Clock face
                  height: 400 #220
                  width: 400 #220
                  align: center
                  bg_opa: TRANSP
                  text_color: 0x000000
                  scales:
                    - ticks: # minutes scale
                        width: 1
                        count: 61
                        length: 10
                        color: 0x000000
                      range_from: 0
                      range_to: 60
                      angle_range: 360
                      rotation: 270
                      indicators:
                        - line:
                            id: minute_hand
                            width: 3
                            color: 0xa6a6a6
                            r_mod: -4
                            value: 0
                    - ticks: # hours scale
                        width: 1
                        count: 12
                        length: 1
                        major:
                          stride: 1
                          width: 4
                          length: 8
                          color: 0xC0C0C0
                          label_gap: 12
                      angle_range: 330
                      rotation: 300
                      range_from: 1
                      range_to: 12
                    - indicators:
                        - line:
                            id: hour_hand
                            width: 5
                            color: 0xa6a6a6
                            r_mod: -30
                            value: 0
                      angle_range: 360
                      rotation: 270
                      range_from: 0
                      range_to: 720

time:
  - platform: homeassistant
    id: time_comp

interval:
  - interval: 30s
    then:
      if:
        condition:
          time.has_time:
        then:
          - script.execute: time_update

script:
  - id: time_update
    then:
      - lvgl.indicator.update:
          id: minute_hand
          value: !lambda |-
            return id(time_comp).now().minute;
      - lvgl.indicator.update:
          id: hour_hand
          value: !lambda |-
            auto now = id(time_comp).now();
            return std::fmod(now.hour, 12) * 60 + now.minute;

Hi Dataced,

I have a Waveshare ESP32-S3 7inch (800x480) capacitive touch control via I2C interface with 5-point touch, Xtensa® 32-bit LX7 dual-core processor, up to 240MHz.

The example “08_Drawcolorbar” in this demo library https://files.waveshare.com/wiki/esp32-s3-touch-lcd-7/esp32-s3-touch-lcd-7-demo.zip works. The display is therefore not broken, if I play with “Expander-> DigitalWrite (LCD_BL, Low); Delay (1000); Expander-> Digitalwrite (LCD_BL, High);” I also see the display back lighting on and going out.

But I don’t get it working in the LVGL environment such as that some buttons can produce with an HTTP post behind it.
I have experience with ESP8266 and the ESP01 together with OLED Displays, where I upload the code via Arduino IDE.
I have tried many example from this thread, YouTube examples, or other GitHub code, but I didn’t have any luck.

Can you help me (or someone else) on my way push a bit in the right direction. Thanks

#ESP32-S3-Touch-LCD-7

Hi Dirk2.0 , if I understand well you try to use LVGL with Arduino IDE ? not ESPHome ?

Yes that’s correct.

I only will make some tiles (buttons) with an HTTP-post request behind. (after this all works, I’ll figering out if I can change the colors of the tiles so I know the state)
I have installed Visual Studio Code with the extentions: ESP-IDF and PlatformIO IDE, because I read that I need that. And for making the GUI I installed EEZ Studio.

I can successfully upload the example “08_Drawcolorbar” to the ESP32 using Arduino IDE. And “i2s_recorder” from the esp-idf-v5.3.2 sample packedge build and flash with ESP-IDF ( esp-idf-v5.3.2/examples/peripherals/i2s/i2s_recorder ). I only had to change VSYNC, DE and PCLK (SDA and SCL I can’t found).
This works