I’m trying to integrate LVGL with ESP32 C3 to create a GUI for my project using a TFT(320*240) display and the TFT_eSPI library. However, when I run the code, the screen just turns on and off (approx twice a second) with scrap pixels being displayed. I used EEZ Studio for drawing the GUI and an LVGL with EEZ flow project.
I checked that the display and connections are correct and working by running the lv_demo_benchmark and it works fine. I have also tried to create a screen from just an LVGL project without the EEZ flow and it worked too. I dont know if i am missing something in my code but i will include it below.
Thank you.
#include <lvgl.h>
#include <TFT_eSPI.h>
#include <demos/lv_demos.h>
#include "src/ui/screens.h"
#define TFT_HOR_RES 320
#define TFT_VER_RES 240
/*LVGL draw into this buffer, 1/10 screen size usually works well. The size is in bytes*/
#define DRAW_BUF_SIZE (TFT_HOR_RES * TFT_VER_RES / 5 * (LV_COLOR_DEPTH / 8))
uint32_t draw_buf[DRAW_BUF_SIZE / 4];
void setup()
{
String LVGL_Arduino = "Hello Arduino! ";
LVGL_Arduino += String('V') + lv_version_major() + "." + lv_version_minor() + "." +
lv_version_patch();
Serial.begin( 115200 );
Serial.println( LVGL_Arduino );
lv_init();
/*Set a tick source so that LVGL will know how much time elapsed. */
lv_tick_set_cb(millis);
lv_display_t * disp = lv_tft_espi_create(TFT_HOR_RES, TFT_VER_RES, draw_buf, sizeof(draw_buf));
create_screen_controll_screen();
//lv_demo_benchmark();
}
void loop()
{
lv_task_handler(); /* let the GUI do its work */
delay(5); /* let this time pass */
}
noor aldine is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.