Updating a value (TEXT STRING) within a DIALOGUE

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • 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?
  • 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 Source Code

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


    Regards,
    Sven
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • 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!
  • 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
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • 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.