Description
What MCU/Processor/Board and compiler are you using?
I´m using ESP32 with Arduino IDE, lvgl library v7.8, lvgl examples v7.8
What do you experience?
I´m using 7" screen (SSD1963) which does work. I can so far compile just widget demo, but that it is OK for now.
I want to know how many FPS ESP32 can do with this screen, but FPS does not show up at the bottom. I changed lv_conf.h
to #define LV_USE_PERF_MONITOR 1
but that does not help.
Is there anything else which I should enable to make this work?
Code to reproduce
#include <lvgl.h>
#include <lv_examples.h>
#include <TFT_eSPI.h>
#include <XPT2046_Touchscreen.h> // ThingPulse library from Library Manager
#include <SPI.h>
TFT_eSPI tft = TFT_eSPI(); /* TFT instance */
#define CS_PIN 21
XPT2046_Touchscreen ts(CS_PIN); // Param 2 - NULL - No interrupts
//Define Touch-Parameters
#define TS_MINX 240
#define TS_MINY 315
#define TS_MAXX 4095
#define TS_MAXY 4095
#define XPT2046_HOR_RES 800
#define XPT2046_VER_RES 480
static lv_disp_buf_t disp_buf;
static lv_color_t buf[LV_HOR_RES_MAX * 10];
#if USE_LV_LOG != 0
/* Serial debugging */
void my_print(lv_log_level_t level, const char * file, uint32_t line, const char * dsc)
{
Serial.printf("%s@%d->%s\r\n", file, line, dsc);
Serial.flush();
}
#endif
/* 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);
tft.startWrite();
tft.setAddrWindow(area->x1, area->y1, w, h);
tft.pushColors(&color_p->full, w * h, true);
tft.endWrite();
lv_disp_flush_ready(disp);
}
bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data)
{
int16_t touchX, touchY;
bool touched = false;
//bool touched = touch.getXY(touchX, touchY); // bool TFT_eTouch<T>::getXY(int16_t& x, int16_t& y)
TS_Point p = ts.getPoint();
touchX = map(p.x, TS_MINX, TS_MAXX, 0, XPT2046_HOR_RES);
touchY = map(p.y, TS_MINY, TS_MAXY, 0, XPT2046_VER_RES);
//touchX = p.x;
//touchY = p.y;
// if ((touchX > 0) || (touchY > 0)) {
if (p.z > 1800) {
touched = true;
}
if (!touched)
{
data->state = LV_INDEV_STATE_REL;
return false;
}
else
{
data->state = LV_INDEV_STATE_PR;
/*Set the coordinates*/
data->point.x = touchX;
data->point.y = touchY;
Serial.print("Data X: ");
Serial.print(p.x);
Serial.print(", data Y: ");
Serial.println(p.y);
}
return false; /*Return `false` because we are not buffering and no more data to read*/
}
void setup()
{
Serial.begin(115200); /* prepare for possible serial debug */
Serial.println("Start of the setup..");
lv_init();
#if USE_LV_LOG != 0
lv_log_register_print_cb(my_print); /* register print function for debugging */
#endif
ts.begin();
ts.setRotation(2);
Serial.println("Touch started..");
tft.begin(); /* TFT init */
tft.setRotation(1); /* Landscape orientation */
Serial.println("LCD started..");
//uint16_t calData[5] = { 275, 3620, 264, 3532, 1 };
lv_disp_buf_init(&disp_buf, buf, NULL, LV_HOR_RES_MAX * 10);
/*Initialize the display*/
lv_disp_drv_t disp_drv;
lv_disp_drv_init(&disp_drv);
disp_drv.hor_res = XPT2046_HOR_RES;
disp_drv.ver_res = XPT2046_VER_RES;
disp_drv.flush_cb = my_disp_flush;
disp_drv.buffer = &disp_buf;
lv_disp_drv_register(&disp_drv);
/*Initialize the (dummy) input device driver*/
lv_indev_drv_t indev_drv;
lv_indev_drv_init(&indev_drv);
indev_drv.type = LV_INDEV_TYPE_POINTER;
indev_drv.read_cb = my_touchpad_read;
lv_indev_drv_register(&indev_drv);
/* Try an example from the lv_examples repository
https://github.com/lvgl/lv_examples */
lv_demo_widgets();
//lv_demo_music();
//lv_demo_printer();
//lv_demo_stress();
Serial.println("End of the setup..");
}
void loop()
{
//touch();
lv_tick_inc(10); // I had to add this to make my touchpad work
lv_task_handler(); /* let the GUI do its work */
delay(5);
}
Many thanks for answer .