cancel
Showing results for 
Search instead for 
Did you mean: 

Where did the touch driver code go?

vince
Associate III

I’ve updated to IDE 1.2.1 and GFX 4.13. After a HARD uphill struggle, I finally figured out how to get a screen running on a 746 Discovery board. I can’t find how to enable the touch controller, though. In the previous software, this functionality was generated in a cpp file in the TouchGFX folder. That file contains nothing but comments now, with no code to initialize or service touch events. How do we get the touch function going? We need some clear example code or instruction. (And may I vent a bit here? This release can not possibly have been regression tested. I’ve done this long enough to recognize a train wreck when I see one. ST “broke the build�?, and left their base to suffer the consequences. It is inexcusable.)

29 REPLIES 29

The problem for me was that this code simply wasn't in the file. I guess the reason for this is that I've taken the custom approach? My STM32TouchController.cpp generated by the designer in my video example was empty - well it was there, but it didn't contain more than comments. I can see that the code you've just posted is maybe less reliant on repository code and hooks directly to the touch driver

I'm not sure we're on the same page.

All of the application templates (pre v3 or v3) have code written inside the TouchController class that goes with the AT. It is written by hand and wont' get overwritten since it's user code.

I'm not sure why yours would be empty - It's not "generated" by the designer, it's extracted from the AT. The only reason i can think of that yours would be empty, with comments, is if you've somehow copied it from somewhere else and overwritten it (commented TouchController code smells like CubeMX 5.4)

/Martin

Martin -- We are very close to the root issue now. I, too, have been able to generate that same code from Designer by selecting the template. All good on that end. The issue has always been in coming from the other direction, i.e., from the board support package on the Cube side, which probably falls outside of your scope, so I understand if this must ultimately be deferred to another group to address. However, note that when you select the Disco board on a new Cube IDE project, the engine no longer generates the driver as before, as though we had simply selected a bare micro, and not the entire dev board (which condition would be expected, and even desirable in that case). Now: that could still be okay, if we could easily import your Designer-created project into the Cube IDE. Can you step me through how, exactly, this is done? I have found that Designer **always** renames my project to the template name, regardless of what I call the project, creating a mismatch between folder/project/ioc file structure than Cube cannot deal with on an import. I believe it is not supposed to do this, but the configurations tab does not allow changing it once the project is created. I tried creatively naming the project to "match" the template name at the start, and changing names manually after generation, and editing the contents of the ioc file, etc., etc., but every "fix" just creates a long new list of errors when I try to build the imported project in the IDE. If you are importing and building your Designer code, that is the part I very much want to learn how to do. It will close the loop on this complete system. Thanks

I just tried generating a new project on a blank machine - designer 4.13.0 and cubeIDE 1.2.0. I'm using the same method as in my video.

When I open the .part designer file and generate code I get the full TouchGFX project. This is the contents of the TouchController.cpp file:

/**
  ******************************************************************************
  * File Name          : STM32TouchController.cpp
  ******************************************************************************
  * @attention
  *
  * <h2><center>&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>
 
void STM32TouchController::init()
{
    /**
     * Initialize touch controller and driver
     *
     */
}
 
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);
     *
     */
    return false;
}
 
/* USER CODE END STM32TouchController */
 
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

The copyright says 2020 - but that could be coincidental..

Your TouchController will always be empty if you use the Generator. It prepares your TouchGFX HAL using whatever it can from CubeMX AND offers you the scaffold (empty classes) to complete the rest (STM32TouchController, GPIO.cpp, OSWrapper.cpp if you selected custom, etc).

/Martin

The only time you'll ever get a manually coded STM32TouchController.cpp file is if you've created the application through the Designer (New application, select AT aka "we coded everything for you", Select UI - go)

/Martin

Martin -- We are very close to the root issue now. I, too, have been able to generate that same code from Designer by selecting the template. All good on that end. The issue has always been in coming from the other direction, i.e., from the board support package on the Cube side, which probably falls outside of your scope, so I understand if this must ultimately be deferred to another group to address. However, note that when you select the Disco board on a new Cube IDE project, the engine no longer generates the driver as before, as though we had simply selected a bare micro, and not the entire dev board (which condition would be expected, and even desirable in that case). Now: that could still be okay, if we could easily import your Designer-created project into the Cube IDE. Can you step me through how, exactly, this is done? I have found that Designer **always** renames my project to the template name, regardless of what I call the project, creating a mismatch between folder/project/ioc file structure than Cube cannot deal with on an import. I believe it is not supposed to do this, but the configurations tab does not allow changing it once the project is created. I tried creatively naming the project to "match" the template name at the start, and changing names manually after generation, and editing the contents of the ioc file, etc., etc., but every "fix" just creates a long new list of errors when I try to build the imported project in the IDE. If you are importing and building your Designer code, that is the part I very much want to learn how to do. It will close the loop on this complete system. Thanks

It was never supposed to - The way it is now is the intended functionality.

* Don't use CubeMX/CubeIDE to give you complete board support

* Do use TouchGFX Designer, through application templates, to give you complete board support to Run TouchGFX applications on concrete boards.

I'll have to get more concrete tomorrow

/Martin

I get it now 🙂

using this custom approach gives much more space for configuration - of course the designer don't know which touch screen I have chosen to use. makes perfect sense!

we're just used to be carried by the hand here :D

Horay! 🙂