Description - loads of compile errors, been on this 2 weeks.
What MCU/Processor/Board and compiler are you using? ESP32 Arduino IDE 2.3.2
LVGL v9
To show a simple UI on the Elecrow HMI esp32 touch screen
Used the Arduino example code
Code to reproduce
#include <lvgl.h>
#include <TFT_eSPI.h>
// //********************************************************************************************
// // add these includes and any others .h files that have been generated fms
// #include “actions.h”
// #include “eez-flow.h”
// #include “fonts.h”
// #include “images.h”
// #include “screens.h”
// #include “structs.h”
// #include “styles.h”
// #include “ui.h”
// #include “vars.h”
// //********************************************************************************************
/Set to your screen resolution/
#define TFT_HOR_RES 480
#define TFT_VER_RES 320
/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 / 10 * (LV_COLOR_DEPTH / 8))
TFT_eSPI tft = TFT_eSPI(TFT_HOR_RES, TFT_VER_RES); /* TFT instance */
/Set the touchscreen calibration data,
the actual data for your display can be acquired using
the Generic → Touch_calibrate example from the TFT_eSPI library/
uint16_t calData[5] = { 311, 3570, 279, 3466, 7 }; // use the touch calibrate in tft_espi examples //fms
#if LV_USE_LOG != 0
void my_print(lv_log_level_t level, const char *buf) {
LV_UNUSED(level);
Serial.println(buf);
Serial.flush();
}
#endif
/* LVGL calls it when a rendered image needs to copied to the display*/
/* Display flushing /
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);
if (tft.getStartCount() == 0)
{ // Processing if not yet started
tft.startWrite();
}
tft.pushImageDMA( area->x1
, area->y1
, area->x2 - area->x1 + 1
, area->y2 - area->y1 + 1
,(uint16_t*) data);
lv_display_flush_ready(display);
}
/Read the touchpad/
void my_touchpad_read(lv_indev_drv_t *indev_drv, lv_indev_data_t *data) {
static uint16_t touchX, touchY;
bool touched = tft.getTouch(&touchX, &touchY, 600);
if (!touched) {
data->state = LV_INDEV_STATE_REL;
} else {
data->state = LV_INDEV_STATE_PR;
/*Set the coordinates*/
data->point.x = touchX;
data->point.y = touchY;
// Serial.print( "Data x " ); //fms
// Serial.println( touchX );
// Serial.print( "Data y " );
// Serial.println( touchY );
}
}
//lv_indev_t *indev; //Touchscreen input device
uint8_t *draw_buf; //draw_buf is allocated on heap otherwise the static area is too big on ESP32 at compile
uint32_t lastTick = 0; //Used to track the tick timer
void setup() {
//Some basic info on the Serial console
String LVGL_Arduino = "LVGL demo ";
LVGL_Arduino += String(‘V’) + lv_version_major() + “.” + lv_version_minor() + “.” + lv_version_patch();
Serial.begin(115200);
Serial.println(LVGL_Arduino);
//Initialise the touchscreen
tft.begin(); /* TFT init */
tft.fillScreen(TFT_BLACK);
delay(300);
tft.setTouch(calData);
//Backlight Pins
pinMode(27, OUTPUT);
digitalWrite(27, HIGH); // make sure tft is backlit
tft.setRotation(1); /* Landscape orientation, flipped fms was 3*/
//Initialise LVGL GUI
lv_init();
draw_buf = new uint8_t[DRAW_BUF_SIZE];
lv_display_t *disp;
disp = lv_tft_espi_create(TFT_HOR_RES, TFT_VER_RES, draw_buf, DRAW_BUF_SIZE);
//Initialize the XPT2046 input device driver
indev = lv_indev_create();
lv_indev_set_type(indev, LV_INDEV_TYPE_POINTER);
lv_indev_set_read_cb(indev, my_disp_flush);
//Done
Serial.println(“LVGL Setup done”);
//Integrate EEZ Studio GUI
ui_init();
}
void loop() {
lv_tick_inc(millis() - lastTick); //Update the tick timer. Tick is new for LVGL 9
lastTick = millis();
lv_timer_handler(); //Update the UI
ui_tick();
//delay(5);
}
The code block(s) should be formatted like:
/*You code here*/
Screenshot and/or video
If possible, add screenshots and/or videos about the current state.