Works

Dependencies:   BMP180 BNO055_fusion Fonts GPSISR HTU21D SDFileSystem UniGraphic mbed uGUI

Fork of Bicycl_Computer_NUCLEO-F411RE by Darren Ulrich

Revision:
2:c5085faf2aa5
Parent:
1:e265e7245ab8
Child:
3:6f47fcd415ab
--- a/main.cpp	Thu Dec 15 19:49:36 2016 +0000
+++ b/main.cpp	Sat Dec 17 18:55:31 2016 +0000
@@ -22,7 +22,8 @@
 #include "mbed.h"
 #include <math.h>
 #include "ILI9341.h"
-#include "SPI_STMPE610.h"
+#include "SeeedStudioTFTv2.h"
+//#include "SPI_STMPE610.h"
 #include "Arial12x12.h"
 #include "Arial24x23.h"
 #include "Arial28x28.h"
@@ -67,7 +68,8 @@
 ILI9341 TFT(SPI_8, 10000000, 
     PIN_MOSI, PIN_MISO,  PIN_SCLK, 
     PIN_CS_TFT, PIN_RESET_TFT, PIN_DC_TFT, "Adafruit2.8") ;
-SPI_STMPE610 TSC(PIN_MOSI, PIN_MISO, PIN_SCLK, PIN_CS_TSC) ;
+//SPI_STMPE610 TSC(PIN_MOSI, PIN_MISO, PIN_SCLK, PIN_CS_TSC) ;
+TouchScreen TSC(PIN_XP, PIN_XM, PIN_YP, PIN_YM);
 
 int page = 0 ;
 int numPage = 2 ;
@@ -211,17 +213,18 @@
     uint16_t x, y, z ;
     int prevPage = 99 ;
     bool waitTouch = false ;
+    point p;
     
     printf("Hello World\n") ;
     
-    tsc_cs = 1 ;
+    //tsc_cs = 1 ;
     tft_cs = 0 ;
-    initTFT() ;
+    //initTFT() ;
     tft_cs = 1 ;
 
-    tsc_cs = 0 ;
-    TSC.spi_format(8, 1) ; // for Nucleo F411RE
-    tsc_cs = 1 ;
+    //tsc_cs = 0 ;
+    //TSC.spi_format(8, 1) ; // for Nucleo F411RE
+    //tsc_cs = 1 ;
     
  //   screen0() ;
         
@@ -251,18 +254,21 @@
 
         tft_cs = 1 ;
         do {
-            tsc_cs = 0 ;
-            TSC.getRAWPoint(&x, &y, &z) ;
-            if ((x != 0)||(y != 0) || (z != 0)) {
-                if (x < 1000) { // left
+            TSC.getTouch(p);
+            printf("Touched X %d\n\r", p.x) ;
+            printf("Touched Y %d\n\r", p.y) ;
+            printf("Touched Z %d\n\r", p.z) ;
+            if (p.z > __PRESURE) {
+                if (p.y < 30000) { // left
                     decPage() ;
-                } else if (x > 3000) { // right
+                } else if (p.y > 90000) { // right
                     incPage() ;
                 }
                 waitTouch = false ;
             }
-            tsc_cs = 1 ;
-        } while(waitTouch != false) ;
- //       wait(1) ;
+            //tsc_cs = 1 ;
+        } 
+        while(waitTouch != false) ;
+        wait(1) ;
     }
 }