Subversion Repositories HomeAutomation

Rev

Blame | Last modification | View Log | SVN | RSS feed

  1. /**
  2.  * @defgroup Touch gesture driver
  3.  * @code #include <drivers/touch/gesture/gesture.h> @endcode
  4.  *
  5.  * @brief Implementation of 'A new gesture recognition algorithm and segmentation method of Korean scripts for gesture-allowed ink editor' by Mi Gyung Cho
  6.  *
  7.  *
  8.  * @author  Linus Lundin, Jonas Andersson, Anders Runeson
  9.  * @date    2009
  10.  */
  11.  
  12. /**@{*/
  13.  
  14.  
  15. #ifndef GESTURE_H_
  16. #define GESTURE_H_
  17. #include <stdio.h>
  18. #include <config.h>
  19.  
  20. /* */
  21. typedef struct
  22. {
  23.     uint8_t x;
  24.     uint8_t y;
  25. } point;
  26.  
  27. /* */
  28. typedef struct
  29. {
  30.     uint8_t f1;
  31.     uint8_t f2;
  32.     uint8_t f3;
  33.     uint8_t f4;
  34.     uint8_t f5;
  35.     uint8_t f6;
  36.     uint8_t f7;
  37.     uint8_t f8;
  38.     uint8_t f9;
  39. } gesture;
  40.  
  41. /* */
  42. static __inline__ uint8_t min(uint8_t val1, uint8_t val2) {
  43.   if (val1 > val2)
  44.   {
  45.     return val2;
  46.   }
  47.   return val1;
  48. }
  49.  
  50. /* */
  51. static __inline__ uint8_t max(uint8_t val1, uint8_t val2) {
  52.   if (val1 > val2)
  53.   {
  54.     return val1;
  55.   }
  56.   return val2;
  57. }
  58.  
  59. #define F8_OFFSET   15
  60.  
  61. /**
  62.  * Touch gesture parser
  63.  * Implementation of 'A new gesture recognition algorithm and segmentation
  64.  * method of Korean scripts for gesture-allowed ink editor' by Mi Gyung Cho
  65.  *
  66.  * Call function parseBuffer with a buffer containing x/y coordinates, the buffer start and end.
  67.  * Returns function results that describe the gesture in 24bits
  68.  *
  69.  * @param buffer
  70.  *      Pointer to buffer to where to data to parse is stored
  71.  * @param startIndex
  72.  *      First value in buffer
  73.  * @param endIndex
  74.  *      Last value in buffer
  75.  * @return
  76.  *      Struct with parsed function results
  77.  */
  78.  gesture parseBuffer(point *buffer, uint8_t startIndex, uint8_t endIndex);
  79.  
  80. /**@}*/
  81. #endif /*GESTURE_H_*/
  82.