cancel
Showing results for 
Search instead for 
Did you mean: 

Add a field and its setter to a built-in class.

robinbobin1979
Associate II

Hello!

I have a swipe container with 3 pages in my TouchGFX app, running on an STM32F469 Discovery Kit. Everything is working fine, but I need to carry out certain actions when a swipe is started / ended. The docs state there are no built-in triggers for touchgfx::SwipeContainter, so I decided to add my code to it.

But as soon as I add a field (GenericCallback) and this field's setter method to this class and invoke this method from my code, the UI becomes unresponsive. I guess the app just crashes.

What am I doing wrong?

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Alexandre RENOUX
Principal

Hello,

After investigating, I found that the fact that you declare and implement the function in the header file is the issue.

If you just declare in the SwipeContainer.hpp

void setAaa();
 
uint8_t aaa;

And then in the SwipeContainer.cpp, you initialize the aaa variable in the constructor

And finally you implement the setAaa() function

void SwipeContainer::setAaa()
{
  aaa = 10;
}

Also, as you changed the SwipeContainer.cpp, you should include it in your project to make sure the compiler refers to the modified file and not the one in the library.

The reason of this hardfault is still not completely clear but this is how the compilers compile the code and having this setter implemented in the header file is not something he likes even though it doesn't tell you so.

/Alexandre

View solution in original post

4 REPLIES 4
Alexandre RENOUX
Principal

Hello,

Could you enclose your UI in this thread ? I will try to have a look.

/Alexandre

robinbobin1979
Associate II

Alexandre,

Thanks for your response.

Unfortunately I can't post the exact UI, as it's a commercial project, so I created a new project in TouchGFXDesigner and deleted

.\Middlewares\ST\touchgfx\framework\tools\

.\Middlewares\ST\touchgfx\lib\

to keep the archive small. The app consists of a single screen with a swipe container, allowing to switch between two pages. I added a dummy variable and its setter to .\Middlewares\ST\touchgfx\framework\include\touchgfx\containers\SwipeContainer.hpp. The setter is invoked from .\TouchGFX\gui\src\main_screen\MainView.cpp line 12. The app crashes when you swipe to page two.

Thanks a lot for your help.

Alexandre RENOUX
Principal

Hello,

After investigating, I found that the fact that you declare and implement the function in the header file is the issue.

If you just declare in the SwipeContainer.hpp

void setAaa();
 
uint8_t aaa;

And then in the SwipeContainer.cpp, you initialize the aaa variable in the constructor

And finally you implement the setAaa() function

void SwipeContainer::setAaa()
{
  aaa = 10;
}

Also, as you changed the SwipeContainer.cpp, you should include it in your project to make sure the compiler refers to the modified file and not the one in the library.

The reason of this hardfault is still not completely clear but this is how the compilers compile the code and having this setter implemented in the header file is not something he likes even though it doesn't tell you so.

/Alexandre

Hello, Alexandre.

It worked like a charm, thanks a lot!