How to prevent custom code from being overwritten after file export

Is there a way to mark code segments to prevent overwriting it after subsequent code generation?
Am I missing something?

I suggest adding code after ui_init(); I usually create ui_ext.c/h files with a ui_ext_init() function like this:

//Call this instead of ui_init
void ui_ext_init(void)
{
   ui_init();
  //Custom code here

}

Yes that works as a work around, but it would be nice if we had code injection at some point. Thank you.

1 Like

I Agree with Amine:
Maybe tags like in STMCubeIde (from ST Microelectronics) placed in init, screen & event functions could be a solution:
xxx function () {
// BEGIN USER CODE ENTER FUNCTION
…some user code not modified when exporting ui
// END USER CODE ENTER FUNCTION
…SLS generated code
// BEGIN USER CODE LEAVE FUNCTION
…some user code not modified when exporting ui
// END USER CODE LEAVE FUNCTION
}

Actually that’s we wanted to avoid as it can be error prone, inflexible and difficult to merge.

What is the real life example in which you needed to edit ui.c?

1 Like