STS2 Adafruit TFT ok

Dependencies:   SPI_STMPE610 SPI_TFT_ILI9341 TFT_fonts mbed

Fork of TS_Eyes by Motoo Tanaka

Revision:
2:344ee4288dd7
Parent:
1:7cc0446656ae
--- a/main.cpp	Sat Dec 06 09:54:42 2014 +0000
+++ b/main.cpp	Tue Mar 24 09:36:20 2015 +0000
@@ -7,59 +7,57 @@
  * @note program exits the staring loop and pretend to sleep.
  * @note Then touching the TFT starts the staring loop again.
  */
- 
- /* 
-  * Note: This program is derived from the SeeeStudioTFTv2 program.
-  * Although both program share same ILI9341 TFT driver,
-  * the touch sensor was not same with the Display I purchased from Akizuki.
-  * http://akizukidenshi.com/catalog/g/gM-07747/
-  * The touch sensor on the display is STMPE610,
-  * so I hacked the minimum spi driver for it (polling mode only).
-  */
+
+/*
+ * Note: This program is derived from the SeeeStudioTFTv2 program.
+ * Although both program share same ILI9341 TFT driver,
+ * the touch sensor was not same with the Display I purchased from Akizuki.
+ * http://akizukidenshi.com/catalog/g/gM-07747/
+ * The touch sensor on the display is STMPE610,
+ * so I hacked the minimum spi driver for it (polling mode only).
+ */
 
 #include "mbed.h"
-#include "TSISensor.h"
 #include "SPI_TFT_ILI9341.h"
-#include "SPI_STMPE610.h"
+//#include "SPI_STMPE610.h"
 #include "Arial12x12.h"
 #include "Arial24x23.h"
 #include "Arial28x28.h"
 #include "font_big.h"
 
-#define PIN_MOSI        PTD2
-#define PIN_MISO        PTD3 
-#define PIN_SCLK        PTD1 
-#define PIN_CS_TFT      PTD0 
-#define PIN_DC_TFT      PTD5 
-#define PIN_BL_TFT      PTC9 
-#define PIN_CS_SD       PTA4 
-#define PIN_CS_TSC      PTA13
-#define PIN_TSC_INTR    PTC9
+#define PIN_MOSI        p5
+#define PIN_MISO        p6
+#define PIN_SCLK        p7
+#define PIN_CS_TFT      p8
+#define PIN_RESET_TFT   p9
+#define PIN_DC_TFT      p10
+#define PIN_LIGHT_TFT      p21
+#define PIN_CS_SD p11
 
-TSISensor tsi;
+
+SPI_TFT_ILI9341 TFT(PIN_MOSI, PIN_MISO, PIN_SCLK, PIN_CS_TFT, PIN_RESET_TFT, PIN_DC_TFT) ;
 
-SPI_TFT_ILI9341 TFT(PIN_MOSI, PIN_MISO, PIN_SCLK, PIN_CS_TFT, PIN_BL_TFT, PIN_DC_TFT) ;
-SPI_STMPE610 TSC(PIN_MOSI, PIN_MISO, PIN_SCLK, PIN_CS_TSC) ;
-
-DigitalOut backlight(PTA12) ;
-
+DigitalOut backlight(PIN_LIGHT_TFT) ;
+DigitalOut CS_SD(PIN_CS_SD);
 void initTFT(void)
 {
+    CS_SD = 1;
     //Configure the display driver
-    TFT.background(Black);
+    TFT.background(Blue);
     TFT.foreground(White);
     wait(0.01) ;
     TFT.cls();
+    TFT.set_orientation(1);  
 }
 
 void moveEyes(void)
 {
-    int dx, px ;
-    float delta = 0.0 ;
-    dx = 0 ;
-    px = 0 ;
-    backlight = 0 ;
-    TFT.background(Black);
+//    int dx, px ;
+//    float delta = 0.0 ;
+ //   dx = 0 ;
+ //   px = 0 ;
+ //   backlight = 0 ;
+    TFT.background(Blue);
     wait(0.1) ;
     TFT.foreground(White);
     wait(0.1) ;
@@ -67,14 +65,14 @@
     wait(0.1) ;
 
     TFT.set_font((unsigned char*) Arial12x12);
-    TFT.foreground(Blue) ;
+    TFT.foreground(Red) ;
     TFT.locate(60, 10) ;
     TFT.printf("<< TS Eyes >>") ;
     TFT.locate(30, 280) ;
     TFT.printf("Use FRDM touch slider") ;
     TFT.locate(30, 300) ;
     TFT.printf("Touch right edge to end") ;
-    
+
     TFT.fillcircle(120, 160, 100, Green) ;
     TFT.fillcircle(60, 160, 50, Black) ;
     TFT.fillcircle(60, 160, 45, White) ;
@@ -84,18 +82,18 @@
     TFT.fillcircle(180, 160, 5, Black) ;
     backlight = 1 ;
 
-    while(dx < 38) {
-      delta = (80.0 * (tsi.readPercentage()-0.5)) ;
-      dx = (int)(delta + 0.5) ;
-      TFT.fillcircle(60+px, 160, 5, White) ;
-      TFT.fillcircle(180+px, 160, 5, White) ;
-      TFT.fillcircle(60+dx, 160, 5, Black) ;
-      TFT.fillcircle(180+dx, 160, 5, Black) ;
-      px = dx ;
-      wait(0.1) ;
-    }
+    /*  while(dx < 38) {
+     //   delta = (80.0 * (tsi.readPercentage()-0.5)) ;
+        dx = (int)(delta + 0.5) ;
+        TFT.fillcircle(60+px, 160, 5, White) ;
+        TFT.fillcircle(180+px, 160, 5, White) ;
+        TFT.fillcircle(60+dx, 160, 5, Black) ;
+        TFT.fillcircle(180+dx, 160, 5, Black) ;
+        px = dx ;
+        wait(0.1) ;
+      }
     TFT.fillcircle(60+px, 160, 5, White) ;
-    TFT.fillcircle(180+px, 160, 5, White) ;
+    TFT.fillcircle(180+px, 160, 5, White) ;*/
     TFT.line(15, 160, 105, 160, Black) ;
     TFT.line(135, 160, 225, 160, Black) ;
     TFT.locate(30, 280) ;
@@ -104,24 +102,26 @@
     TFT.foreground(Yellow) ;
     TFT.printf("  Touch TFT to wake up") ;
 }
-    
+
 int main()
 {
-    uint16_t x, y, z ;
-    bool awake = true ;
-    
+//    uint16_t x, y, z ;
+//    bool awake = true ;
+
+    backlight = 0 ;   
     initTFT() ;
-    
+    backlight = 1 ;   
+    moveEyes() ;
     for(;;) {
 
-        if (awake) {
-            moveEyes() ;
-            awake = false ;
-        }
-        
-        if ( TSC.getRAWPoint(&x, &y, &z)) {
-            awake = true ;
-        }
-        
+        /*       if (awake) {
+                  moveEyes() ;
+                   awake = false ;
+               }*/
+
+        /*      if ( TSC.getRAWPoint(&x, &y, &z)) {
+                  awake = true ;
+              }
+              */
     }
 }