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?
Not really. I would prefer method that just create all needed screen changes as interactions to some of your screen like:
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:
Or from model-class for example like:
(add '#include <gui/common/FrontendApplication.hpp>' to model.cpp)
Other way is use actions like in your linked answer.
PS. Note that you can also set screen change for function of some button by setting trigger 'button is clicked'
For screen changing in sequence or jumping to any screen , Interaction feature is used.
I use 2 Interactions for each screen (accept first and last screens) as NEXT_SCREEN & PREVIOUS_SCREEN
For NEXT_SCREEN Interaction , below is example
For PREVIOUS_SCREEN Interaction , below is example
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
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
Following is one of my ongoing TouchGFX development with Samsung Tab3 10.1" , 1280x800 TFT
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.