How to create a Touchgfx project on ART-PI to realize touch (based on the punctual atom 4.3-inch RGB screen)

Directory

ART-PI creates Touchgfx project to realize touch

1. Create ART-PI project

2. Create a Touchgfx project

3. Add touch function

Four. Summary

ART-PI creates a Touchgfx project to realize touch

1. Create ART-PI project

1. Download the relevant chip package in RT-Thread Studio

2. Create ATR-PI project

3. Click Finish to automatically create the project.

2. Create a Touchgfx project

1. Enable related software, add touch chip

2. Configure IIC

The configuration is shown in the figure:

3. Enable Touchgfx related library 4. Save Related operations, the software will automatically add into the project, as follows:

5. First open DAM2D and CRC macro definition:

6. Open project properties to change C/C++ build settings

7. Compile and run, at this time there will be the following fatal error: touch.h: No such file or directory gt9147.c /touchgfx-test/packages/gt9147-v1.1.0/src line 22 C/C ++ problem like this An error is reported, this is because we have not enabled the touch device, open RT-Thread Settings, enable the touch device, save and exit.

Compile the project again, and you can find that there are no errors and no warnings.

8. Download the program into the board, the phenomenon is as follows (the touch function cannot be used, probably because of a crash):

3. Add touch function

1. Open the \packages\touchgfx2rtt-latest\TouchGFX\target\STM32TouchController.cpp file to modify the program (you can directly copy and replace it):

/**
  ***************************************************** *****************************
  * File Name: STM32TouchController.cpp
  ***************************************************** *****************************
  * @attention
  *
  * <h2><center> & amp;copy; 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 */

#include <STM32TouchController.hpp>
#include <rtthread.h>

#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\
");
        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 \
", 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 \
", info.range_x);
    rt_kprintf("range_y = %d \
", info. range_y);
    rt_kprintf("point_num = %d \
", info.point_num);

    rt_free(id);

    return 0;
}
#endif

void STM32TouchController::init()
{
    /**
     * Initialize touch controller and driver
     *
     */
#ifdef PKG_USING_GT9147
    gt9147_init();
#endif
}

bool STM32TouchController::sampleTouch(int32_t & amp; x, int32_t & amp; 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;
    }
}

/* USER CODE END STM32TouchController */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

The phenomenon of compiling and downloading is as follows (the touch function can be used normally):

2. Add and use different Touchgfx official domes (the recommended touchgfx version is 4.15.0, although using a newer version of touchfgx will automatically update the relevant software packages, but files will be missing during the compilation process, use the 4.15.0 version of touchgfxkeyi1 to reduce porting problems in the process)

Use the official routine:

3. Select the dome you need (do not take up too much space, otherwise the compilation will not pass after importing) add

Change according to your own needs and generate relevant code:

4. Open the art-pi project, update the software package, and then compile and download (the effect is shown in the figure):

4. Summary

I used a newer version of touchgfx to report a lot of mistakes during the transplantation process. I searched for solutions from many bloggers and found no relevant solutions. Later, I switched to the same version as touchgfx in the touch chip routine to solve related problems. Touch After the chip is added, it cannot be touched, please watch the solution of this blog:

(15 messages) One of RT-Thread study notes: How to run TouchGFX + punctual atomic RGB screen on ART-PI and solve the problem of gt9147 software package crash_Ye0522.’s blog-CSDN blog One of RT-Thread study notes: How to run TouchGFX + punctual atomic RGB screen on ART-PI and solve the problem of gt9147 software package crash_Ye0522.’s blog-CSDN blog (15 messages) RT-Thread study notes one: How to run TouchGFX on ART-PI + punctual atomic RGB screen and solve the problem of gt9147 software package crash_Ye0522.’s blog – CSDN blog (15 messages) RT-Thread study notes one: How to run TouchGFX on ART-PI + punctual atomic RGB screen and solve gt9147 The problem of software package crash_Ye0522.’s Blog-CSDN Blog

The above is what I shared. This article only briefly introduces how to run TouchGFX on ART-PI, and records the solution to the crash after creating a touchgfx project and adding the touch chip gt9147 software package, and related content that needs to be paid attention to during the process of transplanting dome.