ART-PI(RTThread)+TouchGFX+正点原子7寸屏开发

📅 2026/8/21 15:08:48
ART-PI(RTThread)+TouchGFX+正点原子7寸屏开发
ART-PI(RTThread)+TouchGFX+正点原子7寸屏开发硬件及软件组成新建ART-PI模板工程配置TouchGFX配置显示驱动配置触摸驱动硬件及软件组成睿德赛ART-PI开发板正点原子ATK-MD0700R-1024600-IPS液晶显示屏(7寸)RTThread Studio软件TouchGFXDesigner-4.15.0软件(可不下载)新建ART-PI模板工程在RT-Thread_Source_Code中安装源码包在Chip_Support_Packages中安装芯片包在Board_Support_Package中安装ART-PI开发板的板级支持包文件-新建-RT-Thread项目-基于开发板(工程名自行定义)点击项目-构建项目,下载程序到ART-PI开发板,此时应有板载LED灯闪烁配置TouchGFX打开RT-Thread Settings加载TouchGFX库使能C++特性支持(因touchGFX基于C++编写)项目-属性(配置支持C++的编译,否则编译程序会报错)配置显示驱动使能SDRAM和LCD函数功能打开DMA2D传输和CRC校验宏定义(STM32H7图形加速)根据所用屏幕的参数信息修改LCD配置文件(IPS和TN屏时序是我个人查网上得到的)右键-打开方式-文本编辑器,修改TouchGFX的应用模板信息为24位色深,分辨率1024*600(即对应所用屏幕)至此下载程序,屏幕应能显示例程,但触摸无效配置触摸驱动使能软件模拟I2C(屏幕触摸芯片使用I2C通信)使能I2C总线及引脚修改STM32的触摸控制器驱动(含FT5426、GT9147、GT911)将以下代码覆盖STM32TouchController.cpp的文件内容/** ****************************************************************************** * File Name : STM32TouchController.cpp ****************************************************************************** * @attention * * h2centercopy; Copyright (c) 2020 STMicroelectronics. * All rights reserved./center/h2 * * This software component is licensed by ST under Ultimate Liberty license * SLA0044, the "License"; You may not use this file except in compliance with * the License. You may obtain a copy of the License at: * www.st.com/SLA0044 * ****************************************************************************** *//* USER CODE BEGIN STM32TouchController */#includeSTM32TouchController.hpp#includertthread.h#include"touch.h"#ifdefPKG_USING_FT5426#include"ft5426.h"staticrt_device_tdev=RT_NULL;staticstructrt_touch_data*read_data=NULL;staticstructrt_touch_infoinfo;intft5426_init(void){void*id;dev=rt_device_find("gt");if(dev==RT_NULL){rt_kprintf("can't find device ft5426\n");return-1;}if(rt_device_open(dev,RT_DEVICE_FLAG_RDONLY)!=RT_EOK){rt_kprintf("open device failed!");return-1;}read_data=(structrt_touch_data*)rt_malloc(sizeof(structrt_touch_data)*info.point_num);id=rt_malloc(sizeof(rt_uint8_t)*8);rt_device_control(dev,RT_TOUCH_CTRL_GET_ID,id);rt_uint8_t*read_id=(rt_uint8_t*)id;rt_kprintf("id = %c %c %c %c \n",read_id[0],read_id[1],read_id[2],read_id[3]);rt_device_control(dev,RT_TOUCH_CTRL_GET_INFO,info);rt_kprintf("range_x = %d \n",info.range_x);rt_kprintf("range_y = %d \n",info.range_y);rt_kprintf("point_num = %d \n",info.point_num);rt_free(id);return0;}#