如何在ART-PI@STM32H750上运行TouchGFX
学习目标:
1、在ART-PI上运行RT-Thread
2、点亮正点原子4.3寸RGB屏
3、在ART-PI上运行TouchGFX
4、解决gt9147软件包死机的问题
提示:并未对RT-Thread和TouchGFX做深入研究,老鸟可以直接略过。
前言
过年放假在家,闲着无聊,撸一撸RT-Thread和TouchGFX,充充电。
提示:板子是在RT-Thread官方买的,最近芯片涨价,贵了30
屏是在TB买的(矿工电子)800x480/IPS/RGB兼容原子野火。
一、简介
RT-Thread简介。为什么想学他呢?主要是因为(Linux太难?)虽然现在我做的项目基本用裸机编程就可以满足了,但并不代表以后也够。
为什么不选FreeRTOS或UCOS呢?我看中RT-Thread主要是:国产、studio、软件包、GUI等一套生态。
二、步骤
1.创建工程
按照前人的经验https://blog.csdn.net/lzs940320/article/details/112368116,很快啊,啪的一下就建好了,然后烧录程序,然后就死机了。。。
按照https://blog.csdn.net/s2014201506/article/details/111084459的方法修改libraries\touchgfx_lib\TouchGFX\ target\STM32TouchController.cpp代码如下:
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
{
return false;
}
}
然后还是没用。。。
2.解决gt9147软件包死机的问题
经过我的反复调试,显示没有问题,加上触摸就会死机,看来问题是出在gt9147软件包上。看了眼打印出来是801X401X10,实际应该是800X400X5,难道问题在这里?
于是就修改了一下libraries\touchgfx_lib\TouchGFX\target\STM32TouchController.cpp
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);
if(info.range_x > 800)info.range_x = 800;
if(info.range_y > 480)info.range_y = 480;
if(info.point_num > 5)info.point_num = 5;
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;
}
这样就不会死机了(D2会一直闪烁)
现在触摸就正常了,GUI本身是480X272的,后面研究下咋改,留坑…
总结
以上就是今天要分享的内容,本文仅仅简单介绍如何在ART-PI上运行TouchGFX,记录了添加触摸芯片gt9147软件包后死机的解决办法。