How to plot variables in a gui ?

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

  • How to plot variables in a gui ?

    Hi, I have a question, I used the GUI Builder to build a small GUI for my Nucleo. The GUI is working fine and i want to plot some variables in the GUI. I use a TEXT_Widget and a special callback function to change the Widget for my purpose.
    I use the following function _cbText, but this widget stays always frozen. I searched a bit in the manual and I found only a very bad workaround, I use this code

    C Source Code

    1. case WM_NOTIFICATION_RELEASED:
    2. // USER START (Optionally insert code for reacting on notification message)
    3. WM_InvalidateWindow(WM_GetDialogItem(pMsg->hWin, ID_TEXT_0));
    4. // USER END
    5. break;

    to trigger the refresh of the text widget when an event occurs .
    Could someone help me to fix it and to have real-time data of the variables ?

    C Source Code

    1. static void _cbText(WM_MESSAGE * pMsg) {
    2. GUI_RECT Rect;
    3. GUI_COLOR ColorFrame;
    4. GUI_COLOR Color;
    5. GUI_COLOR ColorText;
    6. GUI_CONST_STORAGE GUI_FONT * pFont23;
    7. GUI_CONST_STORAGE GUI_FONT * pFont32;
    8. switch (pMsg->MsgId) {
    9. case WM_PAINT:
    10. GUI_Clear();
    11. Color = DARK_BLUE;
    12. ColorText = GUI_WHITE;
    13. ColorFrame = GUI_WHITE;
    14. pFont23 = pFont23p;
    15. pFont32 = pFont32p;
    16. //
    17. // Draw thin frame around the button
    18. //
    19. WM_GetClientRectEx(pMsg->hWin, &Rect);
    20. GUI_SetColor(ColorFrame);
    21. GUI_FillRectEx(&Rect);
    22. GUI_SetColor(Color);
    23. //
    24. // Resize drawing rect
    25. //
    26. Rect.x0 += 1;
    27. Rect.x1 -= 1;
    28. Rect.y1 -= 1;
    29. //
    30. // Draw rest of the button
    31. //
    32. GUI_AA_FillRoundedRectEx(&Rect, 3);
    33. //
    34. // Draw Text
    35. //
    36. GUI_SetFont(&GUI_Font16_ASCII);
    37. GUI_SetColor(ColorText);
    38. GUI_SetTextAlign(GUI_TA_LEFT | GUI_TA_VCENTER);
    39. GUI_GotoXY(Rect.x0, Rect.y0+20);
    40. GUI_DispString("On/Off");
    41. GUI_GotoXY(Rect.x0+80, Rect.y0+20);
    42. GUI_DispDecSpace(stateOfProgram, 1);
    43. GUI_GotoXY(Rect.x0, Rect.y0+40);
    44. GUI_DispString("Man/Auto");
    45. GUI_GotoXY(Rect.x0+80, Rect.y0+40);
    46. GUI_DispDecSpace(selectProgram, 2);
    47. GUI_GotoXY(Rect.x0, Rect.y0+60);
    48. GUI_DispString("PID_H");
    49. GUI_GotoXY(Rect.x0+80, Rect.y0+60);
    50. GUI_DispDecSpace(inputValue_Htng, 2);
    51. GUI_GotoXY(Rect.x0, Rect.y0+80);
    52. GUI_DispString("PID_C");
    53. GUI_GotoXY(Rect.x0+80, Rect.y0+80);
    54. GUI_DispDecSpace(inputValue_Coolg, 2);
    55. GUI_GotoXY(Rect.x0, Rect.y0+100);
    56. GUI_DispString("Temp.");
    57. GUI_GotoXY(Rect.x0+80, Rect.y0+100);
    58. GUI_DispDecSpace(Temperature, 2);
    59. GUI_GotoXY(Rect.x0, Rect.y0+120);
    60. GUI_DispString("Time");
    61. GUI_GotoXY(Rect.x0+80, Rect.y0+120);
    62. GUI_DispDecSpace(SOLLtemperature, 2);
    63. //
    64. // Display temperature with a bigger font
    65. //
    66. int Index = ((SOLLtemperature - MIN_TEMPERATURE) * (GUI_COUNTOF(_aGradient) - 1)) / (MAX_TEMPERATURE - MIN_TEMPERATURE);
    67. Color = _aGradient[Index];
    68. // GUI_SetColor(Color);
    69. //GUI_SetBkColor(Color);
    70. //GUI_Clear();
    71. //GUI_SetColor(GUI_WHITE);
    72. /*GUI_SetFont(pFont32);
    73. GUI_SetTextAlign(GUI_TA_RIGHT | GUI_TA_VCENTER);
    74. GUI_GotoXY(Rect.x1 - 20, Rect.y1 / 2);
    75. GUI_DispDecSpace(SOLLtemperature, 2);
    76. GUI_DispString("�C");*/
    77. break;
    78. default:
    79. TEXT_Callback(pMsg); // The original callback
    80. break;
    81. }
    82. }
    Display All
  • Hi,

    Using 'WM_InvalidateWindow(WM_GetDialogItem(pMsg->hWin, ID_TEXT_0))' is the proper way if you have display all variables in on text widget. But this is not how the TEXt widget should be used.

    You should split it into multiple text widgets. Some are just used as a label (like On/Off or Man/Auto) which always stay the same. Other are getting updated (like the values).

    Unfortunately, it is not possible to display a value directly with the TEXT widget. You have t convert the value into a string and then set it to the TEXT widget.
    You could also use mix of TEXT widgets and drawing the values with GUI_DispDecSpace().

    Attached is an exsample how you could do this. Another advantage of using multiple TEXT widgets is that you will redraw only a small part of the screen if a value gets changed.

    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.