Touchscreen stops responding after ~65 seconds

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

    • Touchscreen stops responding after ~65 seconds

      After porting a project from the IAR environment to the Atollic Studio environment, I have run into an odd problem that I'd like to solicit your advice.
      When the project starts, the touch screen works fine, with the IRQ calling GUI_TOUCH_StoreStateEx() with new coordinates and evrything works fine (I receive the correct button press messages). After about 65 seconds (I've timed this many times), the touch IRQ continues to call the GUI_TOUCH_StoreStateEx() function with new coordinates, but I get no messages from the STemwin system saying a button has been pressed. This is the same code (mostly) that worked before. Any ideas?

      The only reason I ask here is because I don't know what happens internally in the STemWIn library that would cause this issue. I am running FreeRTOS, and the scheduler is still running, as are the timer IRQs.

      Thanks,
      Lee
    • After a little more checking, I found that if I bring up a dialog box with an OK and Cancel button, and then just let it sit for a minute, the first message I get when I press either OK or Cancel is WM_PID_STATE_CHANGED, followed by WM_TOUCH and WM_MOUSEOVER_END. The dialog box remains displayed (no WM_DELETE). Then I press the Cancel button and get WM_NOTIFY_PARENT, WM_NOTIFY_PARENT, WM_NOTIFY_CHILD_HAS_FOCUS, WM_NOTIFY_CHILD_HAS_FOCUS, WM_TOUCH_CHILD, WM_NOTIFY_PARENT, WM_TOUCH_CHILD, WM_NOTIFY_PARENT, WM_PRE_PAINT, WM_PAINT, WM_POST_PAINT, WM_TOUCH_CHILD, or something similar, but the dialog box still remains visible.


      It appears that after the WM_PID_STATE_CHANGED is sent I no longer have control. This message does not occur if the dialog box is OK'd or Canceled within the first ~65 seconds.


      I also don't know why I am getting the WM_MOUSEOVER_END message - I have GUI_SUPPORT_MOUSE set to 0.


      Lee
    • Hi Sven,
      Not sure what you mean about a short example. Do you want me to post the project as a zip file? I have cut it down considerably, but it still compiles out to a 234K image. It includes FreeRtos and a number of ST libraries for SDRAM, touch screen, etc.

      Two things. 1) The same source code (the full one), works when compiled with the IAR compiler. 2) It seems that I get both CLICK and RELEASE notifications during the first 65 seconds or so, but after that, only CLICK (along with some other accompanying TOUCH, GOT_FOCUS, SEL_CHANGED, etc), never RELEASE.

      I realize this is probably not your library causing the issue, but I am hoping you may have some suggestions on how to narrow the issue down further. Except for the compiler, everything is pretty much the same.

      Regards,
      Lee
    • k_TouchUpdate() is called in a timer IRQ every 100ms or so.

      C Source Code

      1. void k_TouchUpdate(void)
      2. {
      3. GUI_PID_STATE TS_State;
      4. static TS_StateTypeDef prev_state;
      5. __IO TS_StateTypeDef ts;
      6. uint16_t xDiff, yDiff;
      7. BSP_TS_GetState((TS_StateTypeDef *)&ts);
      8. TS_State.Pressed = ts.TouchDetected;
      9. xDiff = (prev_state.X > ts.X) ? (prev_state.X - ts.X) : (ts.X - prev_state.X);
      10. yDiff = (prev_state.Y > ts.Y) ? (prev_state.Y - ts.Y) : (ts.Y - prev_state.Y);
      11. if ((prev_state.TouchDetected != ts.TouchDetected ) ||
      12. (xDiff > 3 ) || (yDiff > 3))
      13. {
      14. prev_state.TouchDetected = ts.TouchDetected;
      15. if ((ts.X != 0) && (ts.Y != 0))
      16. {
      17. prev_state.X = ts.X;
      18. prev_state.Y = ts.Y;
      19. }
      20. if (k_CalibrationIsDone())
      21. {
      22. TS_State.Layer = 1;
      23. TS_State.x = k_CalibrationGetX (prev_state.X);
      24. TS_State.y = k_CalibrationGetY (prev_state.Y);
      25. }
      26. else
      27. {
      28. TS_State.Layer = 1;
      29. TS_State.x = prev_state.X;
      30. TS_State.y = prev_state.Y;
      31. }
      32. GUI_TOUCH_StoreStateEx(&TS_State);
      33. }
      34. }
      Display All
    • Hi,

      Please check if you pass the up events from the touch controller with the same (or at least very close to) coordinates as the last down event. Otherwise it might happen that emWin doesn't create WM_NOTIFICATION_RELEASED messages.

      Imagine a button which gets pressed in the middle of the screen. Now the touch gets released but with coordinates somewhere else (not in the area of the button). This button won't get a release message.

      Here is an example on how to pass touch to emWin. This function is called in a task every 25ms.

      Source Code

      1. /*********************************************************************
      2. *
      3. * PID_X_Exec
      4. */
      5. static void PID_X_Exec(void) {
      6. TS_StateTypeDef TS_State;
      7. static GUI_PID_STATE StatePID;
      8. static int IsTouched;
      9. if (_IsInitialized) {
      10. BSP_TS_GetState(&TS_State);
      11. StatePID.Layer = _LayerIndex;
      12. if (TS_State.touchDetected) {
      13. IsTouched = 1;
      14. StatePID.Pressed = 1;
      15. StatePID.x = (int)(TS_State.touchX[0]);
      16. StatePID.y = (int)(TS_State.touchY[0]);
      17. GUI_PID_StoreState(&StatePID);
      18. } else {
      19. if (IsTouched == 1) {
      20. IsTouched = 0;
      21. StatePID.Pressed = 0;
      22. GUI_PID_StoreState(&StatePID);
      23. }
      24. }
      25. }
      26. }
      Display All

      Regards,
      Sven
    • Hi Sven,
      Thanks for your responses. My BSP_TS_GetState() always returns the last 'touch' position, so when the button is released, it will always be the last touch position.
      However, you pointed me to the solution. The touch driver starts returning a very large Y value after 60 seconds or so, so it will never match a button on the screen. I still don't know why the touch driver is acting up, but I'll find it.

      Thanks again for your help,
      Lee