You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when I use esp32-s3 and ili9431 tft with XPT2046, I found when I use initDMA(true),then use get touch pad: ftf.getouch.
the screen will have many lines ,if I touch it will refresh, but when I stop it will be like this photo
/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] = {414, 3414, 379, 3372, 1};
/Or try out a demo. Don't forget to enable the demos in lv_conf.h. E.g. LV_USE_DEMOS_WIDGETS/
// lv_demo_widgets();
// lv_demo_benchmark();
// lv_demo_keypad_encoder();
lv_demo_music();
// lv_demo_printer();
// lv_demo_stress();
}
void loop()
{
lv_timer_handler(); /* let the GUI do its work */
delay(5);
}
The text was updated successfully, but these errors were encountered:
when I use esp32-s3 and ili9431 tft with XPT2046, I found when I use initDMA(true),then use get touch pad: ftf.getouch.
the screen will have many lines ,if I touch it will refresh, but when I stop it will be like this photo
75453286731__30A8DFDF-F683-4E09-A2E6-49603CA89ED8.mov
IDE :PlatformIO
TFT_eSPI library version laster
code:
/Change to your screen resolution/
static const uint16_t screenWidth = 320;
static const uint16_t screenHeight = 240;
static lv_disp_draw_buf_t draw_buf_dsc; // Buffer Mode define
// static lv_disp_draw_buf_t draw_buf;
// static lv_color_t buf[ screenWidth * screenHeight / 10 ];
static lv_color_t buf_1[screenWidth * screenHeight / 2]; /A buffer for 2 rows/
static lv_color_t buf_2[screenWidth * screenHeight / 2]; /An other buffer for 2 rows/
TFT_eSPI tft = TFT_eSPI(screenHeight, screenWidth); /* TFT instance */
#if LV_USE_LOG != 0
/* Serial debugging */
void my_print(const char *buf)
{
Serial.printf(buf);
Serial.flush();
}
#endif
/* Display flushing */
void my_disp_flush(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p)
{
// tft.startWrite();
uint32_t w = (area->x2 - area->x1 + 1);
uint32_t h = (area->y2 - area->y1 + 1);
tft.setSwapBytes(true);
tft.pushImageDMA(area->x1, area->y1, w, h, (uint16_t *)&color_p->full);
// 此处不使用自带的显示刷新,改为DMA
// tft.setAddrWindow( area->x1, area->y1, w, h );
// tft.pushColors( ( uint16_t * )&color_p->full, w * h, true );
lv_disp_flush_ready(disp_drv);
}
/Read the touchpad/
void my_touchpad_read(lv_indev_drv_t *indev_drv, lv_indev_data_t *data)
{
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;
}
}
void setup()
{
lv_init();
tft.begin(); /* TFT init /
tft.initDMA(true); // 使能DMA并初始化
tft.setRotation(3); / Landscape orientation, flipped */
/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] = {414, 3414, 379, 3372, 1};
// tft.setTouch(calData);
// lv_disp_draw_buf_init(&draw_buf, buf, NULL, screenWidth * screenHeight / 10);
lv_disp_draw_buf_init(&draw_buf_dsc, buf_1, buf_2, screenWidth * screenHeight / 2); // TWO Buffer Mode, 2分屏
/Initialize the display/
static lv_disp_drv_t disp_drv;
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_dsc;
disp_drv.full_refresh = 1;
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;
indev_drv.read_cb = my_touchpad_read;
lv_indev_drv_register(&indev_drv);
/* Try an example. See all the examples
// lv_example_btn_1();
/Or try out a demo. Don't forget to enable the demos in lv_conf.h. E.g. LV_USE_DEMOS_WIDGETS/
// lv_demo_widgets();
// lv_demo_benchmark();
// lv_demo_keypad_encoder();
lv_demo_music();
// lv_demo_printer();
// lv_demo_stress();
}
void loop()
{
lv_timer_handler(); /* let the GUI do its work */
delay(5);
}
The text was updated successfully, but these errors were encountered: