Showing results for 
Search instead for 
Did you mean: 

Upgrading TouchGFX engine and external buttons

Associate III

This is an outstanding issue that's been there for a while but since it just got me again, I'm finally taking the time to post about it.  When using external buttons and the button controller, the implementation instructions have you edit the ToughGFXConfiguration.cpp file to add the custom button controller instance and pass that instance in the touchgfx_init() function.  That whole file is flagged as
* This file is generated by TouchGFX Generator x.x.x. Please, do not edit!

But, you need to edit it to use the button controller.  So, when you do the upgrade of the TouchGFX engine in CubeIDE, this file must get re-generated since it overwrites my edits which then I have to rely on memory to go fix.

It would be great if we could add USER CODE BEGIN and USE CODE END sections that Cube uses elsewhere.  Or implement virtual or weak functions we can override so this can be implemented without editing a generated file.




Hello @Jazman ,

I totally understand the difficulty, but I think you can add a button controller without changing TouchGFXConfiguration. There are a number of examples that indicate how to work with external buttons. You can find them under Demos -> Board Specific Demo tab.
Board Specific DemosBoard Specific Demos

You can just use one of them as inspiration for your development, especially STM32F769I-DISCO External Interrupt Line Demo can be a great help.
You can have your code for the Button, and then add them to TouchGFX from TouchGFXHAL.cpp, initialize() instead of TouchGFXConfiguration (By using setButtonController function). 


I hope this helps you

Mohammad MORADI
ST Software Developer | TouchGFX

I will take a look at that.  However, the documentation on the website clearly tells you to implement it in a completely different way (editing generated files)...  See "Other External Events" about halfway down...

Oh I see the problem. 
Yes, I am very sorry for the confusion that has been made here. We will update the documentation as soon as possible to reflect the correct method.
And, thanks a lot for pointing this out


Best regards,

Mohammad MORADI
ST Software Developer | TouchGFX