LISTWHEEL: how to reduce the snap positioning time?

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

    • LISTWHEEL: how to reduce the snap positioning time?

      Hi, I am using the LISTWHEEL widget and I am very happy with it.
      Just recently I wanted to further improve the widget behaviour, and I was wondering if there was any way so set the snap positioning speed:
      • let's suppose you are moving the LISTWHEEL using your finger on a capacitive touch screen
      • when you release the touch, the LISTWHEEL decelerates and moves towards the next snap position
      • sometimes, depending upon the LISTWHEEL position and speed at the moment of the release, the positioning to the next snap position is slow and it lasts a couple of seconds
      • this happens typically when you move slowly the LISTWHEEL then you release it when you're far away from the next snap position
      • I tried to reduce the positioning time changing the timer period, the speed, the deceleration but without success
      • my question is: is there any way to get the LISTWHEEL to move fast to next snap position once it gets released from the touch?
      Best regards

      Michele Sponchiado
    • New

      Hi,

      I gave it a try and tried to reproduce the issue. But on my end it is working fine. I couldn't reproduce the slow movement to a snap position.

      I know that we made some changes to the motion module of emWin in the past.

      Which version of emWin are you using?
      Try to get acces to the latest possible.

      EDIT:
      Here is the application I used for testing:

      C Source Code

      1. #include "DIALOG.h"
      2. /*********************************************************************
      3. *
      4. * Externals
      5. *
      6. **********************************************************************
      7. */
      8. /*********************************************************************
      9. *
      10. * Defines
      11. *
      12. **********************************************************************
      13. */
      14. #define ID_WINDOW_0 (GUI_ID_USER + 0x00)
      15. #define ID_LISTWHEEL_0 (GUI_ID_USER + 0x01)
      16. /*********************************************************************
      17. *
      18. * Static data
      19. *
      20. **********************************************************************
      21. */
      22. /*********************************************************************
      23. *
      24. * _aDialogCreate
      25. */
      26. static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
      27. { WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 480, 272, 0, 0x0, 0 },
      28. { LISTWHEEL_CreateIndirect, "Listwheel", ID_LISTWHEEL_0, 150, 11, 180, 250, 0, 0x0, 0 },
      29. };
      30. /*********************************************************************
      31. *
      32. * Static code
      33. *
      34. **********************************************************************
      35. */
      36. static int _OwnerDraw(const WIDGET_ITEM_DRAW_INFO * pItem) {
      37. int yPos;
      38. int xPos;
      39. switch (pItem->Cmd) {
      40. case WIDGET_ITEM_DRAW_BACKGROUND:
      41. LISTWHEEL_OwnerDraw(pItem);
      42. GUI_SetColor(GUI_DARKGRAY);
      43. GUI_DrawLine(pItem->x0, pItem->y0, pItem->x1, pItem->y0);
      44. return 0;
      45. case WIDGET_ITEM_DRAW_OVERLAY:
      46. yPos = (WM_GetWindowSizeY(pItem->hWin) - LISTWHEEL_GetLineHeight(pItem->hWin)) / 2;
      47. xPos = WM_GetWindowSizeX(pItem->hWin) - 1;
      48. GUI_SetColor(GUI_RED);
      49. GUI_DrawLine(0, yPos, xPos, yPos);
      50. yPos += LISTWHEEL_GetLineHeight(pItem->hWin);
      51. GUI_DrawLine(0, yPos, xPos, yPos);
      52. return 0;
      53. default:
      54. return LISTWHEEL_OwnerDraw(pItem);
      55. }
      56. }
      57. /*********************************************************************
      58. *
      59. * _cbDialog
      60. */
      61. static void _cbDialog(WM_MESSAGE * pMsg) {
      62. WM_HWIN hItem;
      63. int NCode;
      64. int Id;
      65. switch (pMsg->MsgId) {
      66. case WM_INIT_DIALOG:
      67. //
      68. // Initialization of 'Listwheel'
      69. //
      70. hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTWHEEL_0);
      71. LISTWHEEL_AddString(hItem, "String 0");
      72. LISTWHEEL_AddString(hItem, "String 1");
      73. LISTWHEEL_AddString(hItem, "String 2");
      74. LISTWHEEL_AddString(hItem, "String 3");
      75. LISTWHEEL_AddString(hItem, "String 4");
      76. LISTWHEEL_AddString(hItem, "String 5");
      77. LISTWHEEL_AddString(hItem, "String 6");
      78. LISTWHEEL_AddString(hItem, "String 7");
      79. LISTWHEEL_AddString(hItem, "String 8");
      80. LISTWHEEL_AddString(hItem, "String 9");
      81. LISTWHEEL_AddString(hItem, "String 10");
      82. LISTWHEEL_AddString(hItem, "String 11");
      83. LISTWHEEL_AddString(hItem, "String 12");
      84. LISTWHEEL_AddString(hItem, "String 13");
      85. LISTWHEEL_AddString(hItem, "String 14");
      86. LISTWHEEL_AddString(hItem, "String 15");
      87. LISTWHEEL_AddString(hItem, "String 67");
      88. LISTWHEEL_AddString(hItem, "String 17");
      89. LISTWHEEL_AddString(hItem, "String 18");
      90. LISTWHEEL_AddString(hItem, "String 19");
      91. LISTWHEEL_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
      92. LISTWHEEL_SetSnapPosition(hItem, WM_GetWindowSizeY(hItem) / 2 - 20);
      93. LISTWHEEL_SetFont(hItem, &GUI_Font20_1);
      94. LISTWHEEL_SetLineHeight(hItem, 40);
      95. LISTWHEEL_SetOwnerDraw(hItem, _OwnerDraw);
      96. break;
      97. case WM_NOTIFY_PARENT:
      98. Id = WM_GetId(pMsg->hWinSrc);
      99. NCode = pMsg->Data.v;
      100. switch(Id) {
      101. case ID_LISTWHEEL_0: // Notifications sent by 'Listwheel'
      102. switch(NCode) {
      103. case WM_NOTIFICATION_CLICKED:
      104. break;
      105. case WM_NOTIFICATION_RELEASED:
      106. break;
      107. case WM_NOTIFICATION_SEL_CHANGED:
      108. break;
      109. }
      110. break;
      111. }
      112. break;
      113. default:
      114. WM_DefaultProc(pMsg);
      115. break;
      116. }
      117. }
      118. /*********************************************************************
      119. *
      120. * _cbBk
      121. */
      122. static void _cbBk(WM_MESSAGE * pMsg) {
      123. switch (pMsg->MsgId) {
      124. case WM_PAINT:
      125. GUI_SetBkColor(GUI_BLACK);
      126. GUI_Clear();
      127. break;
      128. default:
      129. WM_DefaultProc(pMsg);
      130. break;
      131. }
      132. }
      133. /*********************************************************************
      134. *
      135. * Public code
      136. *
      137. **********************************************************************
      138. */
      139. /*********************************************************************
      140. *
      141. * MainTask
      142. */
      143. void MainTask(void) {
      144. GUI_Init();
      145. WM_SetCallback(WM_HBKWIN, _cbBk);
      146. GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
      147. while (1) {
      148. GUI_Delay(100);
      149. }
      150. }
      151. /*************************** End of file ****************************/
      Display All



      Regards,
      Sven
    • New

      Hi, Sven!
      Many thanks for your reply!
      I'm currently using emWin 5.30c on NXP LPC4357.
      Currently I am out of office, but I'll surely try your code.

      I am using a legacy library where I can find these settings:
      LISTWHEEL_SetDeceleration(p->hWheel, 20);
      LISTWHEEL_SetTimerPeriod(p->hWheel, 80);

      Maybe they could have some part in this problem? BTW, I already tried changing them with no results.

      BR
      Michele

      The post was edited 1 time, last by michele_sponchiado: typo ().