cancel
Showing results for 
Search instead for 
Did you mean: 

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

scottSD
Senior III

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?

6 REPLIES 6
scottSD
Senior III

Anybody?

scottSD
Senior III

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
Senior III
Martin KJELDSEN
Chief III

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
}

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 ;) .

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