2020-05-21 08:20 AM
I'm having an issue regarding switching screen.
in My GUI, i have Screen one and Screen two,
1- in screen one i set an interaction for changing the current screen (to screen two) by hardware button and i generated the code correctly and i found the next API
//Handles when a key is pressed
void Screen1ViewBase::handleKeyEvent(uint8_t key)
{
if(0 == key)
{
application().gotoScreen2CoverTransitionEast();
}
}
2- i used this handleKeyEvent(0) (in certain event) , in the screen1 view, but i didn't succeed to switch the screen2.
3- after debugging , i found that i actually go to the screen two setupScreen, the screen doesn't appear on the lcd.
Q: i want how ask how to use handleKeyEvent() properly ? do i use it in the screen view or the presenter or the model?
2020-05-22 06:50 AM
Hello,
You can use handleKeyEvent() in your ScreenView.
Are you sure the code that handles the hardware button is correctly implemented ? Retrieving correctly the GPIO state for instance.
You might find some useful information there : https://support.touchgfx.com/docs/development/ui-development/touchgfx-engine-features/backend-communication
and https://support.touchgfx.com/docs/development/board-bring-up/example-gpio#touchgfx-hal-development and https://support.touchgfx.com/docs/development/board-bring-up/how-to/10-physical-buttons
Can you provide more code like your screen2View.cpp ?
/Alexandre
2020-05-22 05:33 PM
HI Alexandre,
regarding the hardware button, yes have tested the function of the the button and it works fine for different task.
-----------------------------------------------------------------------
1- Screen1View.cpp
Screen1View::HomeView()
{
}
void Screen1View::setupScreen()
{
Screen1ViewBase::setupScreen();
}
void Screen1View::tearDownScreen()
{
Screen1ViewBase::tearDownScreen();
}
void Screen1View::UpdateNavigation()
{
if(KEY_enumGetKeyStatus(KEY_EncoderSW) == KEY_PRESSED)
{
Screen1ViewBase::handleKeyEvent(0);
}
}
-----------------------------------------------------------------------
2- Screen2View.cpp
Screen2View::MyInforationView()
{
}
void Screen2View::setupScreen()
{
Screen2ViewBase::setupScreen();
}
void Screen2View::tearDownScreen()
{
Screen2ViewBase::tearDownScreen();
}
-----------------------------------------------------------------------
3- after debugging i found that the execution go to ( Screen2View::setupScreen() ), but screen2 doesn't appear on the lcd.
4- i have tested to use touch button to change screen from screen1 to screen2 and it was working fine but when i add the hw button feature i didn't succeed to do the same by the hw button
2020-05-25 03:24 AM
Hello,
I don't understand why you implemented handleKeyEvent in Screen1ViewBase. You should never write code in this file as it is generated code from Designer.
Again I suggest you to look at the examples that you will find on this link: https://support.touchgfx.com/docs/development/ui-development/touchgfx-engine-features/backend-communication
Also, when you call application().gotoScreen2CoverTransitionEast(), is this function generated in FrontApplicationBase.cpp (I think it is but just in case) ?
Btw, there is a button called "</>" when you are typing your message on the forum. This allows to add code so that it is easier to read it.
Finally, what board are you using ? Could you provide the code of your project ?
/Alexandre
2020-05-25 01:36 PM
HI,
regarding handleKeyEvent implementation, i using touchgfx designer and i just added the required interaction for the HW button to change the from screen1 to screen2. after i generated the code by the touchgfx designer. So, i didn't implement the handleKeyEvent . i just found it in Screen1ViewBase.
i'm using STM32F769I-DISCO board.
regarding the "application().gotoScreen2CoverTransitionEast()" implementation in FrontApplicationBase.cp, i will review it to make sure.
and i need know to which part of my code/project you want me to provide?
2020-05-26 01:53 AM
Hello,
"i need know to which part of my code/project you want me to provide?"
Could you provide all the code that is related to your HW button implementation (even the generated code like the one in Screen1ViewBase.cpp and .hpp) ?
/Alexandre
2020-05-28 06:35 PM
Hi Alexandre,
with your help and after debugging, i found the problem and the required solution
But before describing the problem and the required solution, i wanted to say that i found two ways to use HW button to change/switch the screen
1) Using KeySampler.cpp and Buttons.cpp modules generated by touchgfx
2) Calling handleKeyEvent() in ScreenView
The problem and the required solution
2020-05-29 03:46 AM
Hello,
Thank you for this explanation. I'm glad you found a solution and can move forward from now on.
Regarding the screen transitions, what transition did you try ? If it's the Slide transition then it might be normal. In fact, to be able to use the slide transition you need to allocate a certain amount of memory for this, otherwise it will never perform the animation and will automatically switch to the next screen.
To do so, you need to specify the start address in TouchGFXGeneratedHAL.cpp file as a parameter of the following function call:
setFrameBufferStartAddresses((void*)0xC0000000, (void*)0xC003FC00, (void*)0); //Third parameter corresponds to the buffer for the slide transition
Hope this will help,
/Alexandre