Acoustic Feedback

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

  • Acoustic Feedback

    Hello,
    i have a touch screen and everything works very well with emwin. Now i want to give an acoustical feedback for the user, so he knows, when he hit a button, changed a page on a multipage, opened a dropdown... So everytime the user hit something wich causes a reaction, i want to have an acoustical signal.
    First thought was to write the beepFunction() (which causes the acoustical signal) in every callback function of my dialogues. But then, i would have to write it too often.
    Second thought was to write it in the callback functions of the widgets. But my emwin version is precompiled.
    Third thought was to use the function WM_ForEachDesc() in the main loop. But i didn't find out how to use it to find out, if there was an WM_NOTIFICATION_RELEASED in any window (or something like that).
    Is there a way to find out, if the user hit something which causes an reaction?
  • Hi,
    Second thought was to write it in the callback functions of the widgets. But my emwin version is precompiled.
    This is how I would do it. It doesn't matter if your library is precompiled. Please try the code below. I have overwritten the callback of the desktop window and react on the WM_NOTIFY_PARENT message from the button. This will also work with any other window/widget. Just overwrite the callback of the parent window and react on these messages.

    C Source Code

    1. #include "DIALOG.h"
    2. /*********************************************************************
    3. *
    4. * Static code
    5. *
    6. **********************************************************************
    7. */
    8. /*********************************************************************
    9. *
    10. * _cbBk
    11. */
    12. static void _cbBk(WM_MESSAGE * pMsg) {
    13. int NCode;
    14. int Id;
    15. switch (pMsg->MsgId) {
    16. case WM_PAINT:
    17. GUI_Clear();
    18. break;
    19. case WM_NOTIFY_PARENT:
    20. Id = WM_GetId(pMsg->hWinSrc);
    21. NCode = pMsg->Data.v;
    22. switch(Id) {
    23. case GUI_ID_BUTTON0: // Upper left button
    24. switch(NCode) {
    25. case WM_NOTIFICATION_CLICKED:
    26. break;
    27. case WM_NOTIFICATION_RELEASED:
    28. beepFunction();
    29. break;
    30. }
    31. }
    32. break;
    33. default:
    34. WM_DefaultProc(pMsg);
    35. break;
    36. }
    37. }
    38. /*********************************************************************
    39. *
    40. * Public code
    41. *
    42. **********************************************************************
    43. */
    44. /*********************************************************************
    45. *
    46. * MainTask
    47. */
    48. void MainTask(void) {
    49. WM_HWIN hButton;
    50. GUI_Init();
    51. WM_SetCallback(WM_HBKWIN, _cbBk);
    52. BUTTON_CreateAsChild(10, 10, 80, 20, WM_HBKWIN, GUI_ID_BUTTON0, WM_CF_SHOW);
    53. while (1) {
    54. GUI_Delay(100);
    55. }
    56. }
    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.