硬件+软件平台说明

硬件部分:

  • 2.4寸TFT液晶屏 ,驱动为ST7789
  • 触摸屏,驱动为GT911
  • 主控:ESP32-S3-WROOM-1U

软件部分:

  • VS code + platformIO + arduino
  • LVGL 驱动
  • TFT驱动 (SPI)
  • 触摸屏驱动 (IIC)

关于platformio.ini文件内容

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:esp32-s3-devkitm-1]
platform = espressif32
board = esp32-s3-devkitm-1
framework = arduino
lib_ldf_mode = deep+
lib_deps = 
	bodmer/TFT_eSPI@^2.5.43
	lewisxhe/SensorLib@^0.1.4
	lvgl/lvgl@^8.3.11

问题:触摸屏测试代码有效,移植LVGL后无法响应触摸屏

解决方法1:

在lv_conf.h中,将“#define LV_TICK_CUSTOM 0” 置为1 。

#define LV_TICK_CUSTOM 1
#if LV_TICK_CUSTOM
    #define LV_TICK_CUSTOM_INCLUDE "Arduino.h"         /*Header for the system time function*/
    #define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis())    /*Expression evaluating to current system time in ms*/
    /*If using lvgl as ESP32 component*/
    // #define LV_TICK_CUSTOM_INCLUDE "esp_timer.h"
    // #define LV_TICK_CUSTOM_SYS_TIME_EXPR ((esp_timer_get_time() / 1000LL))
#endif   /*LV_TICK_CUSTOM*/

解决方法2:

在void loop() {}中 添加“lv_tick_inc(5);”


void loop()
{
    lv_timer_handler(); /* let the GUI do its work */   
    lv_tick_inc(5);//防止5毫秒过去 ,LVGL会失去时钟,触摸函数无响应
    delay( 5 );
}

总结

笔记仅为记录自研过程中遇到的问题。

最后感谢:
LittleVGL踩坑指南03:Arduino下显示和触摸驱动配置(TFT_eSPI)

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐