


等待项目创建完成










选择三项,然后点击应用并关闭




#define LCD_WIDTH 1024
#define LCD_HEIGHT 600
#define LCD_BITS_PER_PIXEL 24
#define LCD_BUF_SIZE (LCD_WIDTH * LCD_HEIGHT * LCD_BITS_PER_PIXEL / 8)
#define LCD_PIXEL_FORMAT RTGRAPHIC_PIXEL_FORMAT_RGB888
#define LCD_HSYNC_WIDTH 20
#define LCD_VSYNC_HEIGHT 3
#define LCD_HBP 140
#define LCD_VBP 20
#define LCD_HFP 160
#define LCD_VFP 12


双击这个文件



../packages/ft5426-latest/src/ft5426.c:77:12: error: unknown type name 'uint16_t'将uint16_t改为rt_uint16_t

undefined reference to touchgfx::paint::rgb888::lineFromColor(unsigned char*, unsigned int, unsigned long, unsigned char)'`D:\RT-ThreadStudio\workspace\ART\libraries\touchgfx_lib\Middlewares\ST\touchgfx\lib\core\cortex_m7\gcc\libtouchgfx-float-abi-hard.a(PainterRGB888.o): In function `touchgfx::PainterRGB888::paint(unsigned char*, short, short, short, short, unsigned char) const':
(.text._ZNK8touchgfx13PainterRGB8885paintEPhssssh+0x18): undefined reference to `touchgfx::paint::rgb888::lineFromColor(unsigned char*, unsigned int, unsigned long, unsigned char)'
D:\RT-ThreadStudio\workspace\ART\libraries\touchgfx_lib\Middlewares\ST\touchgfx\lib\core\cortex_m7\gcc\libtouchgfx-float-abi-hard.a(PainterRGB888.o): In function `touchgfx::PainterRGB888::tearDown() const':
(.text._ZNK8touchgfx13PainterRGB8888tearDownEv+0x0): undefined reference to `touchgfx::paint::rgb888::tearDown()'

PainterRGB888.cpp添加构建

PainterRGB888.hpp中添加头文件#include
#include




#ifdef PKG_USING_FT5426
#include "ft5426.h"
int rt_hw_ft5426_port(void)
{
struct rt_touch_config config;
config.dev_name = "i2c1";
rt_hw_ft5426_init("ft5426", &config);
return 0;
}
INIT_ENV_EXPORT(rt_hw_ft5426_port);
#endif
STM32TouchController.cpp下面是整个文件
/**
******************************************************************************
* File Name : STM32TouchController.cpp
******************************************************************************
* @attention
*
* © Copyright (c) 2020 STMicroelectronics.
* All rights reserved.
*
* 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 */
#include
#include
#ifdef PKG_USING_GT9147
#include "gt9147.h"
static rt_device_t dev = RT_NULL;
static struct rt_touch_data *read_data = NULL;
static struct rt_touch_info info;
int gt9147_init(void)
{
void *id;
dev = rt_device_find("gt");
if (dev == RT_NULL)
{
rt_kprintf("can't find device gt\n");
return -1;
}
if (rt_device_open(dev, RT_DEVICE_FLAG_INT_RX) != RT_EOK)
{
rt_kprintf("open device failed!");
return -1;
}
read_data = (struct rt_touch_data *)rt_malloc(sizeof(struct rt_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);
return 0;
}
#endif
#ifdef PKG_USING_FT5426
#ifdef __cplusplus
extern "C"{
#endif
#include "ft5426.h"
#include "touch.h"
#ifdef __cplusplus
}
#endif
static rt_device_t dev = RT_NULL;
static struct rt_touch_data *read_data = NULL;
static struct rt_touch_info info;
int ft5426_init(void)
{
void *id;
// //same init include sample_touchgfx.c
// struct rt_touch_config cfg;
// cfg.dev_name = "i2c1";
// rt_hw_ft5426_init("ft5426", &cfg);
dev = rt_device_find("ft5426");
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 = (struct rt_touch_data *)rt_malloc(sizeof(struct rt_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);
return 0;
}
#endif
void STM32TouchController::init()
{
/**
* Initialize touch controller and driver
*
*/
#ifdef PKG_USING_GT9147
gt9147_init();
#endif
#ifdef PKG_USING_FT5426
ft5426_init();
#endif
}
bool STM32TouchController::sampleTouch(int32_t& x, int32_t& y)
{
/**
* By default sampleTouch returns false,
* return true if a touch has been detected, otherwise false.
*
* Coordinates are passed to the caller by reference by x and y.
*
* This function is called by the TouchGFX framework.
* By default sampleTouch is called every tick, this can be adjusted by HAL::setTouchSampleRate(int8_t);
*
*/
#ifdef PKG_USING_GT9147
rt_device_read(dev, 0, read_data, info.point_num);
if (read_data[0].event == RT_TOUCH_EVENT_DOWN || read_data[0].event == RT_TOUCH_EVENT_MOVE)
{
x = 800 - read_data[0].x_coordinate;
y = 480 - read_data[0].y_coordinate;
return true;
}
else
#endif
#ifdef PKG_USING_FT5426
rt_device_read(dev, 0, read_data, info.point_num);
if (read_data[0].event == RT_TOUCH_EVENT_DOWN || read_data[0].event == RT_TOUCH_EVENT_MOVE)
{
y = read_data[0].x_coordinate;
x = read_data[0].y_coordinate;
//rt_kprintf("down x: %03d y: %03d\n", x, y);
return true;
}
else
#endif
{
return false;
}
}
/* USER CODE END STM32TouchController */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/