Simultaneous motion

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

    • Simultaneous motion

      Hello,

      I'd like to get a simultaneous motion of two simple windows.

      Here is a short sample.

      C Source Code: Main.c

      1. #include "DIALOG.h"
      2. WM_HWIN hWin1, hWin2;
      3. BUTTON_Handle hButton1, hButton2, hButton3;
      4. void _cbBk(WM_MESSAGE * pMsg) {
      5. switch (pMsg->MsgId) {
      6. case WM_PAINT:
      7. GUI_SetBkColor(GUI_LIGHTGRAY);
      8. GUI_Clear();
      9. break;
      10. case WM_NOTIFY_PARENT:
      11. if (pMsg->Data.v == WM_NOTIFICATION_RELEASED) {
      12. if ((pMsg->hWinSrc == hButton1) || (pMsg->hWinSrc == hButton2))
      13. WM_MOTION_SetMovement(pMsg->hWinSrc == hButton1 ? hWin1 : hWin2, GUI_COORD_X, 100, 170);
      14. else {
      15. WM_MOTION_Enable(0);
      16. WM_SetWindowPos(hWin1, 100, 60, 40, 40);
      17. WM_SetWindowPos(hWin2, 100, 140, 40, 40);
      18. WM_MOTION_Enable(1);
      19. }
      20. }
      21. break;
      22. default:
      23. WM_DefaultProc(pMsg);
      24. break;
      25. }
      26. }
      27. void _cbWin(WM_MESSAGE * pMsg) {
      28. GUI_COLOR Col;
      29. switch (pMsg->MsgId) {
      30. case WM_PAINT:
      31. if (pMsg->hWin == hWin1)
      32. Col = GUI_RED;
      33. else
      34. Col = GUI_BLUE;
      35. GUI_SetColor(Col);
      36. GUI_AA_FillCircle(20, 20, 18);
      37. break;
      38. default:
      39. WM_DefaultProc(pMsg);
      40. break;
      41. }
      42. }
      43. void MainTask(void) {
      44. GUI_Init();
      45. WM_MULTIBUF_Enable(1);
      46. WM_SetSize(WM_HBKWIN, 320, 240);
      47. WM_SetCallback(WM_HBKWIN, _cbBk);
      48. hButton1 = BUTTON_CreateEx(10, 70, 80, 20, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_BUTTON0);
      49. BUTTON_SetText(hButton1, "Move ->");
      50. hButton2 = BUTTON_CreateEx(10, 150, 80, 20, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_BUTTON1);
      51. BUTTON_SetText(hButton2, "Move ->");
      52. hButton3 = BUTTON_CreateEx(10, 10, 80, 20, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_BUTTON2);
      53. BUTTON_SetText(hButton3, "Reset");
      54. hWin1 = WM_CreateWindow(100, 60, 40, 40, WM_CF_SHOW | WM_CF_HASTRANS, _cbWin, 0);
      55. hWin2 = WM_CreateWindow(100, 140, 40, 40, WM_CF_SHOW | WM_CF_HASTRANS, _cbWin, 0);
      56. WM_MOTION_Enable(1);
      57. while (1) {
      58. GUI_Delay(50);
      59. }
      60. }
      Display All
      Just two simple "circle windows" with buttons to give them a motion. And a button to stop motion and reset windows to initial position.

      When clicking one of the "moving buttons" corresponded window starts moving.

      But if we click another button when one window is moving then another window starts moving and first window immediately stops.

      Is there a way to avoid stopping and give completely independent motion to windows precisely using motion (not e. g. animation objects)?

      Thank you.
    • Hi,

      please try to use the animation module of emWin instead of the motion support.

      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.