cancel
Showing results for 
Search instead for 
Did you mean: 

Creating screen transition in FrontendApplication.cpp

JHarding
Senior

Hello, I am having some difficulty implementing a screen transition. I have followed along this thread, but it seems there are some underlying issues with MVPApplication that are not allowing a template arguments to deduced/substituted.

Versions:

TouchGFX 4.13.0

STM32CubeIDE 1.2.0

I have a screen transition that I created from within TouchGFX Designer that works perfectly fine, but it requires me to have a button that I don't actually need on the screen. I would like to create my own screen transition that I can use from code. So I used the TouchGFX Desginer generated code as a template, and then deleted the interaction in TouchGFX Designer once I had copied the code.

What I have so far...

If my FrontendApplication.cpp file I have added this code:

#include <mvp/MVPApplication.hpp>
#include <gui/datetime_screen/DateTimeView.hpp>
#include <gui/datetime_screen/DateTimePresenter.hpp>
 
void FrontendApplication::gotoDateTimeScreenSlideTransitionEast()
{
    transitionCallbackTwo = touchgfx::Callback<FrontendApplication>(this, &FrontendApplication::gotoDateTimeScreenSlideTransitionEastImpl);
    pendingScreenTransitionCallback = &transitionCallbackTwo;
}
 
void FrontendApplication::gotoDateTimeScreenSlideTransitionEastImpl()
{
    touchgfx::makeTransition<DateTimeView, DateTimePresenter, touchgfx::SlideTransition<EAST>, Model >(&currentScreen, &currentPresenter, frontendHeap, &currentTransition, &model);
}

Now when I compile the code I get the following errors:

In file included from ../TouchGFX/generated/gui_generated/include/gui_generated/common/FrontendApplicationBase.hpp:7:0,
                 from ../TouchGFX/gui/include/gui/common/FrontendApplication.hpp:4,
                 from ../TouchGFX/gui/src/common/FrontendApplication.cpp:1:
../Middlewares/ST/touchgfx/framework/include/mvp/MVPApplication.hpp:192:16: note: candidate: template<class ScreenType, class PresenterType, class TransType, class ModelType> PresenterType* touchgfx::makeTransition(touchgfx::Screen**, touchgfx::Presenter**, touchgfx::MVPHeap&, touchgfx::Transition**, ModelType*)
 PresenterType* makeTransition(Screen** currentScreen, Presenter** currentPresenter, MVPHeap& heap, Transition** currentTrans, ModelType* model)
                ^~~~~~~~~~~~~~
../Middlewares/ST/touchgfx/framework/include/mvp/MVPApplication.hpp:192:16: note:   template argument deduction/substitution failed:
../TouchGFX/gui/src/common/FrontendApplication.cpp:121:139: note:   cannot convert '((FrontendApplication*)this)->FrontendApplication::<anonymous>.FrontendApplicationBase::frontendHeap' (type 'FrontendHeap') to type 'touchgfx::MVPHeap&'
     touchgfx::makeTransition<DateTimeView, DateTimePresenter, touchgfx::SlideTransition<EAST>, Model >(&currentScreen, &currentPresenter, frontendHeap, &currentTransition, &model);
                                                                                                                                           ^~~~~~~~~~~~
make[1]: *** [TouchGFX/gui/src/common/subdir.mk:18: TouchGFX/gui/src/common/FrontendApplication.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [makefile:105: all] Error 2
"make -j all" terminated with exit code 2. Build might be incomplete.

2 REPLIES 2
AJT141
Associate III

Hello Jhard.17,

I'm going to answer tomorrow because i've already done that but my code is on my PC at my work office.

Regards,

AJT141

[EDIT] : so here is my anwser

Imagine you want to create a transition to go to s_resident_name screen.

You have to add this in "FrontendApplication.hpp" :

  • void gotoscreenResidentScreenNoTransition(); in public part of the class FrontendApplication
  • void gotoscreenResidentScreenNoTransitionImpl(); in protected part of the class FrontendApplication
  • touchgfx::Callback<FrontendApplication> own_transitionCallback; in protected part of the class FrontendApplication

You have to implement these functions in "FrontendApplication.hpp" :

void FrontendApplication::gotoscreenResidentScreenNoTransition()
{
    own_transitionCallback = touchgfx::Callback<FrontendApplication>(this, &FrontendApplication::gotoscreenResidentScreenNoTransitionImpl);
    pendingScreenTransitionCallback = &own_transitionCallback;
}
 
void FrontendApplication::gotoscreenResidentScreenNoTransitionImpl()
{
    touchgfx::makeTransition<s_resident_nameView, s_resident_namePresenter, touchgfx::NoTransition, Model >(&currentScreen, &currentPresenter, frontendHeap, &currentTransition, &model);
}

And you need to add the initialization of own_transitionCallback in FrontendApplication constructor :

FrontendApplication::FrontendApplication(Model& m, FrontendHeap& heap)
    : FrontendApplicationBase(m, heap), own_transitionCallback()
{
 
}

Now, if you want to switch to resident Screen you just have to call gotoscreenResidentScreenNoTransition like that :

application().gotoscreenCommunicationEstablishedScreenNoTransition();

 Did you forget to include that ?

#include <touchgfx/transitions/slideTransition.hpp>