Thursday, June 29th 2017, 9:22am UTC+2

You are not logged in.

  • Login
  • Register

rochi2211

Beginner

Date of registration: Jun 7th 2017

Posts: 9

1

Thursday, June 15th 2017, 12:14pm

Updating a value (TEXT STRING) within a DIALOGUE

I'm trying to update a constant value got from an hall sensor and converted with sprintf to be shown with a text widget. In which loop am I supposed to pass the updating string? Gui init Thread one?

SEGGER - Schoenen

Super Moderator

Date of registration: Aug 13th 2015

Posts: 309

2

Friday, June 16th 2017, 4:48pm

Hi,

Yes, update the text in the dialog within the same thread as it was created. If you have a TEXT widget within a dialog you can get the handle of the TEXT widget and set the text like shown below. Of course, the handle of the dialog must be known.

C/C++ Source code

1
2
hItem = WM_GetDialogItem(hDialog, ID_OF_TEXT_WIDGET);
TEXT_SetText(hItem, "New string");"


Regards,
Sven

rochi2211

Beginner

Date of registration: Jun 7th 2017

Posts: 9

3

Saturday, June 17th 2017, 7:40pm

Ok that's clear. I used an example ( dialog count) and it works. The problem now is another. I'm trying to stop that dialog and start another (swipelist dialog, which is the menu of this project). When i press the button, well after releasing the button I set a flag = 1 so that the code of mainscreen stops executing and then with GUI_EndDialog I close the dialog to start the swipelist. I can see swipelist on the screen but the program hangs. What route should I follow logically speaking? Virtual screens maybe? It's almost a week I'm looking for something that works but it seems to me that switching screens and having something in the loop doesn't kinda work togheter. Any help is appreciated, thank you!

SEGGER - Schoenen

Super Moderator

Date of registration: Aug 13th 2015

Posts: 309

4

Monday, June 19th 2017, 2:12pm

Hi,

Not sure what causes the crash. But, if you update a widget from a dialog periodically in a loop, please make sure the handle of the widget is valid. After GUI_EndDialog() with hDialog the lines below don't work any longer because hDilaog is invalid. Before using a handle which might get invalid you can also call WM_IsWindow() to check if the handle is valid.

Where does the application crashes?
What does the callstack say?

Regards,
Sven

rochi2211

Beginner

Date of registration: Jun 7th 2017

Posts: 9

5

Monday, June 19th 2017, 5:43pm

Can I use WM_IsWindow() as a flag if I'm understanding? By the way the crash consists in touchscreen being unresponsive so after GUI_enddialog I call my swipelist menu but I can't interact with it. As for the call stack I will check. I'm concerned if having "x" dialogs chained between them and every one with its loop (when needed) is possible. Let me know if You have any clue on that. Thank you.

rochi2211

Beginner

Date of registration: Jun 7th 2017

Posts: 9

6

Tuesday, June 20th 2017, 12:35pm

Attached call stack at thee moment of the crash and the code i'm using to execute the speedo and the menu.
rochi2211 has attached the following image:
  • Screenshot (14).png
rochi2211 has attached the following file:
  • HUD_1ST.zip (25.64 kB - 6 times downloaded - Last download: Yesterday, 10:16pm)