Skip to main content
scottSD
Senior III
April 13, 2020
Question

Is there a way to add "User Code" areas to TouchGFX Generator files so user code is not over written by a CubeMX generation?

  • April 13, 2020
  • 4 replies
  • 1376 views

Currently, it appears that there are not "User Code" areas in TouchGFX target files which can be protected by a CubeMX generation.

This is possible throughout core/main.c and Hal drivers and it would be nice to have for TouchGFX Generator files as well.

This would be very useful, especially when adding dynamic bitmap cache to the registerBitmapDatabase() function call in TouchGFXConfiguration.cpp.

It is likely that it cannot be currently be done, but would it be possible to add to future releases?

This topic has been closed for replies.

4 replies

scottSD
scottSDAuthor
Senior III
April 16, 2020

Anybody?

scottSD
scottSDAuthor
Senior III
April 24, 2020

Not getting many answers these days.

I created a work around, but it is not very elegant. All it does is cause a compile error me when this file has been overwritten by a CubeMX Generate.

I would think that if adding dynamic bitmap cache is an option in the call to registerBitmapDatabase() there would be a better way to use this option than modifying code that will be overwritten whenever CubeMX is generated.

scottSD
scottSDAuthor
Senior III
June 26, 2020
Martin KJELDSEN
Principal III
June 29, 2020

Hi Scott,

The TouchGFXHAL.cpp file is one big user code section and you can do what you please here. We didn't want to plaster TouchGFXGeneratedHAL.cpp with user code sections like you see in main.c.

For instance, if you want something to be different in your TouchGFX setup simply write that in

void TouchGFXHAL::initialize()
{
 TouchGFXGeneratedHAL::initialize();
 
 //your own code here
}

scottSD
scottSDAuthor
Senior III
June 29, 2020

Thanks for the reply @Martin KJELDSEN​ .

I assume what you are saying is that I could write my own version of touchgfx_init() and call registerBitmapDatabase() here? These are currently generated and placed in "generated/TouchGFXConfiguration.cpp".

I will look into this. Right now, I have something working (as long as I remember to revert when CubeMX overwrites it when it generates ;) .

Martin KJELDSEN
Principal III
June 29, 2020

I'm saying that in TouchGFXHAL.cpp we implement all the functions from TouchGFXGeneratedHAL and call the super class functions - So they're ready to modify. For TouchGFXHAL::initialize() you can overwrite what is generated inside the TouchGFXGeneratedHAL::initialize() version

/Martin