STMPE610 touch sensor driver library

Dependents:   TS_Eyes Tokei testUniGraphic_150217 AfficheurTFTAdafruit ... more

Files at this revision

API Documentation at this revision

Comitter:
Rhyme
Date:
Sat Dec 13 07:08:52 2014 +0000
Parent:
2:ee910b63c077
Child:
4:0aa8f72d3cdd
Commit message:
getPoint added

Changed in this revision

SPI_STMPE610.cpp Show annotated file Show diff for this revision Revisions of this file
SPI_STMPE610.h Show annotated file Show diff for this revision Revisions of this file
--- a/SPI_STMPE610.cpp	Sat Nov 08 07:07:23 2014 +0000
+++ b/SPI_STMPE610.cpp	Sat Dec 13 07:08:52 2014 +0000
@@ -221,3 +221,27 @@
     
     return( touched ) ;
 }
+
+// following values are measured 
+// by using test_SPI_STMPE610
+#define TOUCH_MIN_X 360
+#define TOUCH_MIN_Y 270
+#define TOUCH_MAX_X 3800
+#define TOUCH_MAX_Y 3700
+
+#define TFT_WIDTH 240
+#define TFT_HEIGHT 320
+
+int SPI_STMPE610::getPoint(uint16_t *x, uint16_t *y, uint16_t *z = 0)
+{
+    uint8_t touched = 0 ;
+    uint16_t tx, ty, tz ;
+    
+    touched = getRAWPoint(&tx, &ty, &tz) ;
+    *x = TFT_WIDTH * tx / (TOUCH_MAX_X - TOUCH_MIN_X) ;
+    *y = TFT_HEIGHT * ty / (TOUCH_MAX_Y - TOUCH_MIN_Y) ;
+    if (z != 0) {
+        *z = tz ;
+    }
+    return( touched ) ;
+}
--- a/SPI_STMPE610.h	Sat Nov 08 07:07:23 2014 +0000
+++ b/SPI_STMPE610.h	Sat Dec 13 07:08:52 2014 +0000
@@ -99,6 +99,17 @@
    */
   int getRAWPoint(uint16_t *x, uint16_t *y, uint16_t *z) ;
   
+  /**
+   * get value of x, y, z
+   * @param *x  x value relative to TFT 
+   * @param *y  y value relative to TFT
+   * @param *z  z RAW value if non-null pointer is passed
+   * @note default calibration was for my particular device
+   * @note for more accuracy measure your device and modify 
+   * @note those values in SPI_STMPE610.c
+   */
+  int getPoint(uint16_t *x, uint16_t *y, uint16_t *z = 0) ;
+  
   private:
 } ;