7inch Capative Touch LCD

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

    • Hi,


      Unfortunately, there is no such driver.

      In most cases we simply read the touch data from the touch controller (e.g. via I2C) and pass them forward to emWin.

      For single touch this is quite easy. The routine below which polls the touch and gets called periodically from a dedicated task:

      C Source Code

      1. /*********************************************************************
      2. *
      3. * PID_X_Exec
      4. */
      5. static void PID_X_Exec(void) {
      6. TS_StateTypeDef TS_State = {0};
      7. static GUI_PID_STATE StatePID;
      8. static int IsTouched;
      9. int IsMirrorX;
      10. int IsMirrorY;
      11. int xSize;
      12. int ySize;
      13. if (_IsInitialized) {
      14. BSP_TS_GetState(&TS_State); // Read touch input
      15. StatePID.Layer = _LayerIndex;
      16. if (TS_State.touchDetected) { // If touch detected, set up pid statte structure
      17. IsTouched = 1; // Remember that last even has been touch down
      18. StatePID.Pressed = 1; // Pressed, "down event"
      19. //
      20. // Get some information about the display orientation and its size
      21. //
      22. IsMirrorX = LCD_GetMirrorX();
      23. IsMirrorY = LCD_GetMirrorY();
      24. xSize = LCD_GetXSize(); // Depending on the orientation these values are swapped.
      25. ySize = LCD_GetYSize(); // Previous x size will y size vice versa
      26. if (LCD_GetSwapXYEx(_LayerIndex)) {
      27. //
      28. // If an axis is mirrored we have to suptract the input from the given axis, be aware that
      29. // the axis values might be swapped. That's why we use ySize for x and xSize for y...
      30. //
      31. StatePID.y = (IsMirrorX) ? ySize - TS_State.touchX[0] : TS_State.touchX[0]; // XY swapped, use x coordinates (ySize is formaer xSize) for the y coordinate
      32. StatePID.x = (IsMirrorY) ? xSize - TS_State.touchY[0] : TS_State.touchY[0]; // Same as above but for y
      33. } else {
      34. StatePID.x = (IsMirrorX) ? xSize - TS_State.touchX[0] : TS_State.touchX[0]; // Nothings swapped but maybe mirrored
      35. StatePID.y = (IsMirrorY) ? ySize - TS_State.touchY[0] : TS_State.touchY[0];
      36. }
      37. GUI_TOUCH_StoreStateEx(&StatePID); // Pass information to emWin
      38. } else {
      39. if (IsTouched == 1) { // No touch detected but last event was touch down
      40. IsTouched = 0; // Restore IsTouched variable
      41. StatePID.Pressed = 0; // Unpressed, "up event"
      42. GUI_TOUCH_StoreStateEx(&StatePID); // Since StatePID is declared as static we use the x/y coordinate
      43. // from the down event to create an up event.
      44. }
      45. }
      46. }
      47. }
      Display All

      With multitouch it is a bit more tricky, but works more or less the same (poll the touch data and pass to emWin). The difference are the multiple touch points and their IDs.

      emWin offers an API to pass multitouch touch input to emWin. Attached are some examples for different TCs.

      Regards,
      Sven




      Files
      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.