How to switch screen using user code when a certain flag becomes true.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-10-16 9:50 AM
I have gone through the methods that are gui generated when change screen transition is done through the designer. I have also gone through the previously asked question how to implement switchscreen() in touchgfx. However, sadly I don't understand exactly how to fulfill my requirement. I want to carry out transition whenever a certain boolean variable becomes true. The variable becomes true after response from the hardware. Please guide me on how to implement this. I shall be thankful.
Solved! Go to Solution.
- Labels:
-
TouchGFX
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-10-17 2:26 AM
Some code for checking things in Model::tick where GUIEvent is the name of the message queue, ControlMessage is a struct that contains a message code and a value
typedef struct
{
uint16_t messageCode;
int16_t messageValue;
} ControlMessage;
...
void Model::tick()
{
...
osEvent event = osMessageGet(GUIevent, 0); // Get GUIevent immediately
if (event.status == osEventMessage)
{
// handle event
ControlMessage* message = (ControlMessage*)event.value.p;
switch (message->messageCode)
{
case MESSAGE_TYPE1:
//go to type 1 screen
break;
case MESSAGE_TYPE2:
//go to type 2 screen
break;
...
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-10-16 11:43 PM
Hi,
If you're looking to change screens based on some hardware input you'd typically send this through an OS message queue to the gui task and handle the message in your model on every tick - THEN do your transition. Please check out the "integrating hardware and ui" sticky - I did a webinar on this very topic last year. Then you can use the goto... code that you've found here on the forum to make the transition.
/Martin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-10-16 11:44 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-10-17 2:26 AM
Some code for checking things in Model::tick where GUIEvent is the name of the message queue, ControlMessage is a struct that contains a message code and a value
typedef struct
{
uint16_t messageCode;
int16_t messageValue;
} ControlMessage;
...
void Model::tick()
{
...
osEvent event = osMessageGet(GUIevent, 0); // Get GUIevent immediately
if (event.status == osEventMessage)
{
// handle event
ControlMessage* message = (ControlMessage*)event.value.p;
switch (message->messageCode)
{
case MESSAGE_TYPE1:
//go to type 1 screen
break;
case MESSAGE_TYPE2:
//go to type 2 screen
break;
...
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-10-17 4:45 AM
I am actually not understanding how to make the transition with user code.
I saw the methods generated by the designer when you do transition using the designer. Now if I don't want to use designer for transition, should I leave the GUI generated methods as well and override them or delete the gui interaction and write my own function. Also in which class should I write the goto custom function.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-10-17 4:49 AM
There was a similar question recently, so i figured you might have seen it. Here it is:
https://community.st.com/s/question/0D50X0000BTdnsASQR/how-can-i-change-screen-in-software
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-10-17 5:09 AM
Thanks. Going through it right now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-10-19 1:19 AM
@Martin KJELDSEN​ I am sorry, I tried but not able to understand how to implement.
- In my Frontendapplication.hpp and .cpp files, I have defined custom transition functions.
- In my MainView, I have defined a custom function that calls static_cast<FrontendApplication*>(Application::getInstance())->gotoScreen2();
The problems are
- The compiler gives error that covertransition is not a member of touchgfx (I am not able to understand which Library I am missing.
- Is my above mentioned approach correct? Apart from the error being thrown?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-10-20 1:18 PM
Done with it. Thankyou so much for the help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-10-21 2:04 AM
Glad you solved it! :)
