How to Refresh Screen LVGL 8.3

REFRESHING LVGL SCREEN

Description

I am new to LVGL and i have bee working to understand it for almost a month and after creating a first code for a board that is ESP32-8048S043 using LVGL and Arduino_GFX librarys i have come trough using The capactive touch GT911 from that board and it worked using only it and Arduino GFX now i need to make the LVGL read that touch and use it on somes test buttons that i made so pls someone help me

What MCU/Processor/Board and compiler are you using?

i am using PlataformIO
board: ESP32-8048S043

What LVGL version are you using?

8.3

What do you want to achieve?

i want to achive making my buttons work (i am not sure if the problem is on the refreshing of the screen or on touching)

What have you tried so far?

i have tried muiltiple ways of testing the screen refresh like changing he color afer some time and nothing happend

Code to reproduce (MY code that the touch worked so from that its possible to get the)

#include <Arduino.h>
#include <Arduino_GFX_Library.h>
#include <Arduino_GFX.h>
#include <lvgl.h>
#include <TAMC_GT911.h>

/===================TouchConfig====================/
#define TOUCH_SDA 19
#define TOUCH_SCL 20
#define TOUCH_INT 18
#define TOUCH_RST 38

#define TOUCH_MAP_X1 800
#define TOUCH_MAP_X2 0
#define TOUCH_MAP_Y1 480
#define TOUCH_MAP_Y2 0

int touch_last_x = 0; // *1.65 for 800
int touch_last_y = 0; // *1.75 for 480
int touch_last_RightX = 0;
int touch_last_RightY = 0;

void Calibration() {
float multiplicadorX = 1.65;
float multiplicadorY = 1.75;
float multiplicadorNovoX;
float multiplicadorNovoY;

multiplicadorNovoX = (800 * multiplicadorX) / TOUCH_MAP_X1;
multiplicadorNovoY = (480 * multiplicadorY) / TOUCH_MAP_Y1;

touch_last_RightX = touch_last_x * multiplicadorNovoX;
touch_last_RightY  = touch_last_y * multiplicadorNovoY;

}

TAMC_GT911 ts = TAMC_GT911(TOUCH_SDA, TOUCH_SCL, TOUCH_INT, TOUCH_RST,
max(TOUCH_MAP_X1, TOUCH_MAP_X2), max(TOUCH_MAP_Y1, TOUCH_MAP_Y2));
/===================TouchConfig====================/

static lv_disp_draw_buf_t draw_buf;
static lv_disp_drv_t disp_drv;
static lv_color_t *disp_draw_buf;
static uint32_t screenWidth;
static uint32_t screenHeight;
static unsigned long last_ms;

#define GFX_BL DF_GFX_BL // default backlight pin, you may replace DF_GFX_BL to actual backlight pin
#define TFT_BL 2 // LED K

Arduino_ESP32RGBPanel rgbpanel = new Arduino_ESP32RGBPanel(
40 /
DE /, 41 / VSYNC /, 39 / HSYNC /, 42 / 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 /, 16000000 / prefer_speed */);
Arduino_RGB_Display gfx = new Arduino_RGB_Display(
800 /
width /, 480 / height */, rgbpanel);

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

gfx->draw16bitRGBBitmap(area->x1, area->y1, (uint16_t *)&color_p->full, w, h);

lv_disp_flush_ready(disp);
}

void touch_init()
{
Wire.begin(TOUCH_SDA, TOUCH_SCL);
ts.begin();
ts.setRotation(ROTATION_NORMAL);
}

bool touch_touched()
{
ts.read();
if (ts.isTouched)
{

    touch_last_x = map(ts.points[0].x, TOUCH_MAP_X1, TOUCH_MAP_X2, 0, 800 - 1);
    touch_last_y = map(ts.points[0].y, TOUCH_MAP_Y1, TOUCH_MAP_Y2, 0, 480 - 1);
    Calibration();

    return true;
}
else
{
    return false;
}

}

void TouchHandler(){
while (1)
{
if (touch_touched())
{
gfx->fillCircle(touch_last_RightX, touch_last_RightY, 1, GREEN);
}
delay(10);
}

Serial.println("Setup done");

}

void setup()
{
Serial.begin(115200);
Serial.println(“TAMC_GT911 Example: Ready”);
// Init Display
gfx->begin();
gfx->fillScreen(BLACK);

pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);

lv_init();
touch_init();
TouchHandler();

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

disp_draw_buf = (lv_color_t *)heap_caps_malloc(sizeof(lv_color_t) * screenWidth *32, MALLOC_CAP_32BIT);

if (!disp_draw_buf)

{
Serial.println(“LVGL disp_draw_buf allocate failed!”);
}
else
{
lv_disp_draw_buf_init(&draw_buf, disp_draw_buf, NULL, 800 * 32);

/* 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;
  lv_indev_drv_register(&indev_drv);

/* Create lvgl objs */

lv_obj_t *btn = lv_btn_create(lv_scr_act());
lv_obj_set_size(btn, 100, 50);
 lv_obj_align(btn, LV_ALIGN_CENTER, 0, 0);

lv_obj_t *label = lv_label_create(btn);
lv_label_set_text(label, "Botão Usando LVGL (V" GFX_STR(LVGL_VERSION_MAJOR) "." GFX_STR(LVGL_VERSION_MINOR) "." GFX_STR(LVGL_VERSION_PATCH) ")");
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);

Serial.println("Setup done");

}
}

void loop()
{
lv_timer_handler(); /* let the GUI do its work */
delay(5);
}
Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

/*You code here*/

Screenshot and/or video

not possible
If possible, add screenshots and/or videos about the current state.