Skip to main content
VLau
Associate III
May 11, 2021
Solved

No reaction to touch

  • May 11, 2021
  • 7 replies
  • 1982 views

Hey!

I took the working project that is generated by TouchGFX Designer as a reference and made a new project on the DISCOVERY-F469 board.

I made UI with two screens. Screen1 has a button to jump to screen 2 and an animated image.

After flashing the board I can see my Screen1 with correctly running animation. The problem is that UI button isn't working.

While debugging I checked the following:

What can be wrong?

Thanks!

This topic has been closed for replies.
Best answer by Romain DIELEMAN

Hi @VLau​ ,

​

Could you try this ? Works on my side, I based it on your code, the main difference was that I added the ft6x06_ReadID() calls, and instead of doing everything in init() and sampleTouch() I added extra steps to make sure the program had time to extract and use the right information (if that makes sense :grinning_face_with_sweat:).

In STM32TouchController.cpp:

/**
 ******************************************************************************
 * 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>
 
// #include <ft6x06.h>
#include "../Components/ft6x06/ft6x06.h"
 
#define TS_I2C_ADDRESS ((uint16_t)0x54) //0x54 or 0x70
#define TS_I2C_ADDRESS_A02 ((uint16_t)0x70)
#define TS_SWAP_NONE ((uint8_t) 0x01)
#define TS_SWAP_X ((uint8_t) 0x02)
#define TS_SWAP_Y ((uint8_t) 0x04)
#define TS_SWAP_XY ((uint8_t) 0x08)
#define SIZE_X	800
#define SIZE_Y	480
 
 
static uint8_t ts_orientation;
static uint8_t I2C_Address = 0;
bool ts_initialized = false;
bool isTouchDetected = false;
uint16_t tmp = 0, tempoX = 0, tempoY = 0;
 
 
bool STM32TouchController::TS_init()
{
 
 ft6x06_Init(0);
 
 ft6x06_ReadID(TS_I2C_ADDRESS_A02);
 ft6x06_ReadID(TS_I2C_ADDRESS);
 
 I2C_Address = TS_I2C_ADDRESS_A02; 
	
 ft6x06_Reset(I2C_Address);
	ft6x06_TS_Start(I2C_Address);
 
 return true;
}
 
void STM32TouchController::init()
{
 /**
 * Initialize touch controller and driver
 *
 */
 if (SIZE_X < SIZE_Y)
 {
 ts_orientation = TS_SWAP_NONE;
 }
 else
 {
 ts_orientation = TS_SWAP_XY | TS_SWAP_Y;
 } 
 
 if (TS_init())
 {
 ts_initialized = true;
 }
 
}
 
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);
 *
 */
 if (ts_initialized)
 {
 // TS_StateTypeDef TS_State;
 isTouchDetected = TS_getCoordinates();
 if (isTouchDetected)
 {
 x = tempoX;
 y = tempoY;
 return true;
 }
 }
 return false;
}
 
bool STM32TouchController::TS_getCoordinates()
{
 
 if (ft6x06_TS_DetectTouch(I2C_Address))
 {
 ft6x06_TS_GetXY(I2C_Address, &tempoX, &tempoY);
 
 if (ts_orientation & TS_SWAP_XY)
 {
 tmp = tempoX;
 tempoX = tempoY;
 tempoY = tmp;
 }
 if (ts_orientation & TS_SWAP_X)
 {
 tempoX = FT_6206_MAX_WIDTH - 1 - tempoX;
 }
 if (ts_orientation & TS_SWAP_Y)
 {
 tempoY = FT_6206_MAX_HEIGHT - 1 - tempoY;
 }
 
 return true;
 }
 return false;
 
}
 
/* USER CODE END STM32TouchController */

and in STM32TouchController.hpp just add the two functions TS_init() and TS_getCoordinates() I added

class STM32TouchController : public touchgfx::TouchController
{
public:
 
 STM32TouchController() {}
 
 /**
 * @fn virtual void STM32TouchController::init() = 0;
 *
 * @brief Initializes touch controller.
 *
 * Initializes touch controller.
 */
 virtual void init();
 
 /**
 * @fn virtual bool STM32TouchController::sampleTouch(int32_t& x, int32_t& y) = 0;
 *
 * @brief Checks whether the touch screen is being touched, and if so, what coordinates.
 *
 * Checks whether the touch screen is being touched, and if so, what coordinates.
 *
 * @param [out] x The x position of the touch
 * @param [out] y The y position of the touch
 *
 * @return True if a touch has been detected, otherwise false.
 */
 virtual bool sampleTouch(int32_t& x, int32_t& y);
 
 bool TS_init();
 bool TS_getCoordinates();
 
 private:
 
 
 
};

Hope this helps (and also works on your side),

/Romain

​

​

7 replies

Romain DIELEMAN
ST Employee
May 11, 2021

Hi,

Do you see the images of the button change when you press it ? Do other animations work (like an animated image) ? Just to make sure the tick is working. What is the animationEndedCallbackHandler you are talking about in Screen1ViewBase (it usually is in widget classes with animations) ? Are you sure it is linked to your button in your case ?

/Romain

VLau
VLauAuthor
Associate III
May 11, 2021

Thanks for quick response!

Button image is not changing with press, while animation "runs" as expected.

"AnimationEndedCallbackHandler" I took from "Animated Image Example" from TGFX Designer UI templates. There an interaction added: Animation is done -> execute C++ code -> animation.startAnimation(!animation.isReverse(), false, true);

Another interaction on my Screen 1 is: Button Clicked -> Change Screen -> Screen 2.

In TGFX Designer generated project UI buttons work as expected, In CubeMX generated project not.

In case here's CubeMX TouchGFX config: Single Buffer, Address allocated framebuffer, 800x480, no OS. Display-related and TGFX-related code were more or less copied from working project. However since animation is working I think that part is probably fine.

Romain DIELEMAN
ST Employee
May 12, 2021

I'm a bit confused by what you said concerning the "Designer generated project works, but not the STM32CubeMX generated project". Do you mean the application template available in TouchGFX Designer compared to your custom project started from STM32CubeMX?

I first had my doubts about running without an OS but if the other animations work then it is not a tick issue. Could you share how you configured STM32TouchController.cpp and TouchGFXConfiguration.cpp ? Is it exactly like in the application template ?

/Romain