EDIT_SetValue does not return

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

  • EDIT_SetValue does not return

    Hello,

    I am using the emwin library as part of a bigger embedded application. I am experiencing a bit strange behavior:
    I am using the EDIT_Widgets to visualize some data (like current temperature, etc).

    My dialog looks like the following

    C Source Code

    1. static void _cbDialog(WM_MESSAGE * pMsg) {
    2. WM_HWIN hItem;
    3. float fDummy;
    4. fDummy = -999999999.567;
    5. switch (pMsg->MsgId) {
    6. case WM_INIT_DIALOG:
    7. vInitDialog(pMsg);
    8. break
    9. case SOME_OTHER_EVENT:
    10. vUpdateActualSetpoints( pMsg);
    11. break
    12. ...
    13. }
    14. static void vInitDialog(WM_MESSAGE * pMsg){
    15. WM_HWIN hItem;
    16. hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_6);
    17. WIDGET_SetEffect(hItem, &WIDGET_Effect_None );
    18. EDIT_SetFloatMode(hItem, 30, 10, 50, 2, GUI_EDIT_SUPPRESS_LEADING_ZEROES);
    19. }
    20. static void vUpdateActualSetpoints(WM_MESSAGE * pMsg)
    21. {
    22. WM_HWIN hItem;
    23. float fDummy;
    24. hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_6);
    25. fDummy = -999999999.567;
    26. EDIT_SetFloatValue( hItem, fDummy );
    27. }
    Display All

    This is a very simplified example. My problem is here, that the function "EDIT_SetFloatValue( hItem, fDummy );" in line 28 does not return. Since this functions hols a mutex in my application, it blocks every functionality that needs that mutex.

    However, if I insert "EDIT_SetFloatValue(hItem, 0);" after line 20, the program works and the function "EDIT_SetFloatValue" inside my "vUpdateActualSetpoints" does return. Also, if I change the value in line 27 to be between 10 and 50 it returns.

    Is this behaviour known and intended? Is there a way to make sure, the emWin functions do always return?
  • Hi,

    I gave it a try but on my end it is working as expected.
    If I try to set a value of -999999999.567 it shows 10 as configured.

    Which version of emWin are you using?

    Here is the application I have used for testing:

    C Source Code

    1. /*********************************************************************
    2. *
    3. * Defines
    4. *
    5. **********************************************************************
    6. */
    7. #define ID_WINDOW_0 (GUI_ID_USER + 0x00)
    8. #define ID_EDIT_0 (GUI_ID_USER + 0x01)
    9. #define ID_BUTTON_0 (GUI_ID_USER + 0x02)
    10. /*********************************************************************
    11. *
    12. * Static data
    13. *
    14. **********************************************************************
    15. */
    16. /*********************************************************************
    17. *
    18. * _aDialogCreate
    19. */
    20. static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
    21. { WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 320, 240, 0, 0x0, 0 },
    22. { EDIT_CreateIndirect, "Edit", ID_EDIT_0, 87, 101, 137, 47, 0, 0x64, 0 },
    23. { BUTTON_CreateIndirect, "Set Value", ID_BUTTON_0, 50, 45, 80, 20, 0, 0x0, 0 },
    24. };
    25. /*********************************************************************
    26. *
    27. * Static code
    28. *
    29. **********************************************************************
    30. */
    31. /*********************************************************************
    32. *
    33. * _cbDialog
    34. */
    35. static void _cbDialog(WM_MESSAGE * pMsg) {
    36. WM_HWIN hItem;
    37. int NCode;
    38. int Id;
    39. float Value;
    40. switch (pMsg->MsgId) {
    41. case WM_INIT_DIALOG:
    42. //
    43. // Initialization of 'Edit'
    44. //
    45. hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);
    46. WIDGET_SetEffect(hItem, &WIDGET_Effect_None );
    47. EDIT_SetText(hItem, "123");
    48. EDIT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
    49. EDIT_SetFont(hItem, GUI_FONT_20_1);
    50. EDIT_SetFloatMode(hItem, 30, 10, 50, 2, GUI_EDIT_SUPPRESS_LEADING_ZEROES);
    51. break;
    52. case WM_NOTIFY_PARENT:
    53. Id = WM_GetId(pMsg->hWinSrc);
    54. NCode = pMsg->Data.v;
    55. switch(Id) {
    56. case ID_BUTTON_0: // Notifications sent by 'Set Value'
    57. switch(NCode) {
    58. case WM_NOTIFICATION_RELEASED:
    59. hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);
    60. Value = -999999999.567f;
    61. EDIT_SetFloatValue(hItem, Value);
    62. break;
    63. }
    64. break;
    65. }
    66. break;
    67. default:
    68. WM_DefaultProc(pMsg);
    69. break;
    70. }
    71. }
    72. /*********************************************************************
    73. *
    74. * MainTask
    75. */
    76. void MainTask(void) {
    77. WM_HWIN hWin;
    78. GUI_Init();
    79. GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
    80. while (1) {
    81. GUI_Delay(100);
    82. }
    83. }
    Display All


    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.