I'm trying to drive a 128x160 SPI TFT screen using LVGL with the Xiao ESP32C3.

First of all, I’m a complete beginner in this topic. :innocent:

My hardware setup:

  • Xiao ESP32C3, I’m coding in C using the Arduino IDE.
  • 1.8" 128x160 SPI TFT display module with built-in SD card (ST7735 driver).

I’m trying to drive the screen with the ESP32. I initially tried to get help from AI models, but I couldn’t get it to work. I wasn’t able to compile the code, and I kept getting errors. I had previously used the screen successfully with the Adafruit_GFX library, but I couldn’t make it work with LVGL.

I installed the LVGL Arduino library.
After that, I made some changes in the lvgl_config_template.h file and renamed it to lvgl_config.h.
I also modified the TFT’s User_Setup file, since I needed to define the connection pins between the screen and the ESP32.

At first, I was working with LVGL v8, but then I realized that the version I was using was v9. I learned that the code structure changes between versions, so I started over with v9. Still, I couldn’t get any output on the screen—not even with v8 or v9. I couldn’t even compile the code properly.

I have conversations with AI models about this topic, and I can share them if needed—they’re in Turkish.

The screen shows some text already, but I just want to use a few symbols (like Wi-Fi, temperature, SD card icons, etc.). I don’t know where to begin. The GFX library works for me, but it’s not enough.

LVGL feels too advanced for me, especially since my screen is small and not a touchscreen. Still, I want to use it because it helps with icons and looks great visually. I’d really appreciate your help.

I tried reading and following the getting started guide, but I couldn’t make it work either.

Hello, can you share your code sample that already works on Adafruit_GFX?
Also, share the errors you get when compiling with LVGL.

Below is a reference of how your code should look with LVGL implemented

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 160
#define LV_BUFFER_SIZE (SCREEN_WIDTH * SCREEN_HEIGHT / 10)

uint8_t lv_buffer[LV_BUFFER_SIZE];

void my_disp_flush(lv_display_t *display, const lv_area_t *area, unsigned char *data)
{
    uint32_t w = lv_area_get_width(area);
    uint32_t h = lv_area_get_height(area);
    lv_draw_sw_rgb565_swap(data, w * h);
    tft.drawRGBBitmap(area->x1, area->y1, (uint16_t *)data, w, h);
    lv_display_flush_ready(display); /* tell lvgl that flushing is done */
}

static uint32_t my_tick(void)
{
  return millis();
}

void setup()
{
    // initialize Adafruit_GFX


    lv_init();

    lv_tick_set_cb(my_tick);

    static lv_display_t *lv_display = lv_display_create(SCREEN_WIDTH, SCREEN_HEIGHT);
    lv_display_set_color_format(lv_display, LV_COLOR_FORMAT_RGB565);
    lv_display_set_flush_cb(lv_display, my_disp_flush);
    lv_display_set_buffers(lv_display, lv_buffer, NULL, LV_BUFFER_SIZE, LV_DISPLAY_RENDER_MODE_PARTIAL);

    lv_obj_t *label1 = lv_label_create(lv_scr_act());
    lv_obj_set_align(label1, LV_ALIGN_CENTER);
    lv_label_set_text(label1, "Hello world");
}

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