Waveshare 2.1inch ST7701S ESP-32S3 Arduino IDE

You are 100% correct about AI.

I had that in the back of my mind. It did help a little bit but yeah, there are a few nonsensical lines :disappointed:

The good new is… I managed to make it work :sweat:
Took me a few more ours of searching and trying different things.

I’m not 100% sure this is the correct code, but it seems to be working (at least for a basic hello world example)

Hopefully this will help someone else that come along:

EDIT: I deleted even more lines of code that weren’t doing anything at all.

LVGL_Driver.cpp

#include "indev/lv_indev.h"
#include "LVGL_Driver.h"

static uint8_t buf1[(LCD_WIDTH * LCD_HEIGHT / 10) * BYTE_PER_PIXEL + 500];
static uint8_t buf2[(LCD_WIDTH * LCD_HEIGHT / 10) * BYTE_PER_PIXEL + 500];

void flushDisplay(lv_display_t *disp, const lv_area_t *area, uint8_t *color_p) {
    LCD_addWindow(area->x1, area->y1, area->x2, area->y2, color_p);
    lv_display_flush_ready(disp);
}

void touchPadRead( lv_indev_t * indev_drv, lv_indev_data_t * data ) {
  Touch_Read_Data();

  // Display was pressed
  if (touch_data.points != 0x00) {
    data->point.x = touch_data.x;
    data->point.y = touch_data.y;
    data->state = LV_INDEV_STATE_PRESSED;

    printf("LVGL : X=%u Y=%u points=%d\r\n",  touch_data.x , touch_data.y,touch_data.points);
  } 
  // Display was released
  else { 
    data->state = LV_INDEV_STATE_RELEASED;
  }
  
  // Handle Gestures
  if (touch_data.gesture != NONE ) { }

  touch_data.x = 0;
  touch_data.y = 0;
  touch_data.points = 0;
  touch_data.gesture = NONE;
}

void initLVGL(void) {
  lv_init();
  lv_tick_set_cb(xTaskGetTickCount);
  
  lv_display_t *disp_drv = lv_display_create(LCD_WIDTH, LCD_HEIGHT);

  /* Initialize the draw buffer */
  lv_display_set_buffers(disp_drv, buf1, buf2, sizeof(buf1), LV_DISPLAY_RENDER_MODE_PARTIAL);

  /* Set the display resolution */
  lv_display_set_physical_resolution(disp_drv, LCD_HEIGHT, LCD_WIDTH);

  /* Set flush callback */
  lv_display_set_flush_cb(disp_drv, flushDisplay);

  /* Initialize the input device driver */
  lv_indev_t *indev = lv_indev_create();
  lv_indev_set_type(indev, LV_INDEV_TYPE_POINTER);
  lv_indev_set_read_cb(indev, touchPadRead);
}

void loopLVGL(void) {
  lv_timer_handler();

  vTaskDelay(pdMS_TO_TICKS(5));
}