MultiTouch (Sample)

From SEGGER Wiki
Jump to: navigation, search
GUI_MultiTouch.c
GUI MultiTouch.gif
File(s) required
  • GUI_MultiTouch.c
Runs in simulation Yes
Runs on target Yes
Download GUI_MultiTouch.c

This sample demonstrates the very basics of MultiTouch polling in emWin.

Code

/*********************************************************************
*                    SEGGER Microcontroller GmbH                     *
*        Solutions for real time microcontroller applications        *
**********************************************************************
*                                                                    *
*        (c) 1996 - 2020  SEGGER Microcontroller GmbH                *
*                                                                    *
*        Internet: www.segger.com    Support:  support@segger.com    *
*                                                                    *
**********************************************************************

** emWin V6.10 - Graphical user interface for embedded applications **
emWin is protected by international copyright laws.   Knowledge of the
source code may not be used to write a similar product.  This file may
only  be used  in accordance  with  a license  and should  not be  re-
distributed in any way. We appreciate your understanding and fairness.
----------------------------------------------------------------------
File        : GUI_MultiTouch.c
Purpose     : Sample that demonstrates how to poll multi touch points
              using emWin.
Requirements: WindowManager - ( )
              MemoryDevices - ( )
              AntiAliasing  - ( )
              VNC-Server    - ( )
              PNG-Library   - ( )
              TrueTypeFonts - ( )
---------------------------END-OF-HEADER------------------------------
*/

#include "DIALOG.h"

/*********************************************************************
*
*       Defines
*
**********************************************************************
*/

/*********************************************************************
*
*       Static data
*
**********************************************************************
*/

/*********************************************************************
*
*       Static code
*
**********************************************************************
*/

/*********************************************************************
*
*       Public code
*
**********************************************************************
*/
/*********************************************************************
*
*       MainTask
*/
void MainTask(void) {
  GUI_MTOUCH_EVENT Event;
  GUI_MTOUCH_INPUT Input;
  unsigned         i;

  //
  // Init emWin.
  //
  GUI_Init();
  //
  // Enable multi-touch support.
  //
  GUI_MTOUCH_Enable(1);
  //
  GUI_SetPenSize(5);
  do {
    //
    // Check if there is an event in the buffer.
    // If yes, it is removed from the buffer and copied to the variable.
    //
    if (GUI_MTOUCH_GetEvent(&Event) == 0) {
      for (i = 0; i < Event.NumPoints; i++) {
        //
        // Get information for each touch point.
        //
        GUI_MTOUCH_GetTouchInput(&Event, &Input, i);
        GUI_DrawPoint(Input.x, Input.y);
      }
    }
    GUI_Delay(1);
 } while (1);
}

/*************************** End of file ****************************/