cancel
Showing results for 
Search instead for 
Did you mean: 

toughgfx change screen from button virtual function?

Rodo
Associate III

Hi all,

I want to change from firstScreen to secondScreen if there is some text displayed on the firstScreen. I found an old post (here) where the accepted answer says it is difficult right now and working on a better way ... that post is from 2019 though. Is there a newer/simpler way to change screen from code?

Thanks

2 REPLIES 2
JTP1
Lead

Hello

Not really. I would prefer method that just create all needed screen changes as interactions to some of your screen like:

JTP1_0-1688918844249.png

It doesn't even require any trigger. You can also define two different transitions for different directions to your screens, if needed,

TGFX will then generate needed functions for changing screens to frontend- base class (FrontendApplicationBase.cpp) and they can be called from any screen like:

application().gotoScreen2ScreenSlideTransitionEast();

Or from model-class for example like:

static_cast<FrontendApplication*>(Application::getInstance())->gotoScreen2ScreenSlideTransitionEast();

(add '#include <gui/common/FrontendApplication.hpp>' to model.cpp)

Other way is use actions like in your linked answer.

BR J.T

PS. Note that you can also set screen change for function of some button by setting trigger 'button is clicked'

INaee.1
Associate III

Hi ...

For screen changing in sequence or jumping to any screen , Interaction feature is used.

TouchGFX_Ineraction.jpg

I use 2 Interactions for each screen (accept first and last screens) as NEXT_SCREEN & PREVIOUS_SCREEN

For NEXT_SCREEN Interaction , below is example

TouchGFX_Ineraction_NEXT_SCREEN.jpg

For PREVIOUS_SCREEN Interaction , below is example

TouchGFX_Ineraction_PREVIOUS_SCREEN.jpg

Tip: To keep the codes uniforms for each screen transition , name the screens like , 

Screen_01 , Screen_02 , Screen_03 etc

for each ScreenViewBase.cpp , the transition will be added like below

TouchGFX_Transition_Handler.jpg

Now , need to code the keys read feature any one of followings

1. Simple GPIO keys without interrupt

2. SPI IO Expander Keys with interrupt

3. I2C IO Expander Keys with interrupt

I will show you 1 example > Simple GPIO keys without interrupt

keys.hpp

TouchGFX_Keys_hpp.jpg

keys.cpp

TouchGFX_Keys_cpp.jpg

TouchGFX_KeySampler_cpp.jpg

Following is one of my ongoing TouchGFX development with Samsung Tab3 10.1" , 1280x800 TFT 

WhatsApp Image 2023-08-02 at 10.43.54.jpg

In this experiment , I have 10 different screens .

attached are the files for first type : Simple GPIO keys without interrupt

Let me know , if more info required.

BR

I.N