How to show dinamic variable

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

  • How to show dinamic variable

    Hi

    I'm using STemWin with STM32F429I Discovery board. I need show a variable on the Dialog. But I Don't know how to text a variable. Is there any example in this regard?

    Best Regards
    Thank you
  • Hi,

    There are several ways to display values. The easiest might just to call GUI_DispDec() and a value will appear on the screen.

    To display a value in a dialog simply react on WM_PAINT in the callback of the dialog and display the value.

    Attached is a quick example which shows both ways. You can switch by setting the define MEHTOD to either 0 or 1.

    Although, it is no dialog the way it works is the same aas with a dialog.

    EDIT: Forgot attachment.

    Regards
    Sven
    Files
    • DispValue.zip

      (686 Byte, downloaded 392 times, last: )
    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.
  • Thank you for the reply. I run your application. It works. I have one more question. I want to increase a number value when a button is pressed. I want to print this number value to a text. I wrote the following code in the pressed event of the button.

    PHP Source Code

    1. case WM_NOTIFY_PARENT:
    2. Id = WM_GetId(pMsg->hWinSrc);
    3. NCode = pMsg->Data.v;
    4. switch(Id) {
    5. case ID_BUTTON_0: // Notifications sent by 'Button'
    6. switch(NCode) {
    7. case WM_NOTIFICATION_CLICKED:
    8. // USER START (Optionally insert code for reacting on notification message)
    9. STM_EVAL_LEDToggle(LED4);
    10. datax++;
    11. sprintf(st,"Sayi=%ld",datax);
    12. hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
    13. TEXT_SetText(hItem, st);
    14. // USER END
    15. break;
    16. case WM_NOTIFICATION_RELEASED:
    17. // USER START (Optionally insert code for reacting on notification message)
    18. // USER END
    19. break;
    20. // USER START (Optionally insert additional code for further notification handling)
    21. // USER END
    22. } break;
    Display All


    This code is not working properly. When I press the button, the button appears on the text. Why does this happen?

    edit; Code was added

    The post was edited 3 times, last by FerhatYOL ().

  • Hi,

    nothing easier than that ;)

    Here is a short example how the text (value) of a TEXT widget gets changed on button press.

    Regards
    Sven
    Files
    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.
  • Hi

    Thanks for your answer. I get it now.


    What do I need to do to write a constantly changing value to the Edit Widget? But I do not understand how this constantly changing values are printed. (For example: ADC Value) No events on pressing any button. Is a timer required for this?
  • Hi,

    I have modified the example from my last post and added an EDIT widget. Within the super loop I use the handle of the EDIT widget to set a random value.

    In this example I use the function WM_GetDialogItem() with the handle of the parent dialog and the ID of the EDIT widget. It is also possible to store the handle of the EDIT widget in a static variable when within WM_INIT_DIALOG.

    Regards
    Sven
    Files
    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.