seed

Dependencies:   SPI_TFT_ILI9341

Fork of SeeedStudioTFTv2 by Components

Files at this revision

API Documentation at this revision

Comitter:
Ganstrich
Date:
Mon Apr 18 06:59:46 2016 +0000
Parent:
13:362765fdf287
Child:
15:23288c15e11d
Commit message:
Test des menus pr?sents mais non affich?s. Tentative de debug et r?solution

Changed in this revision

SeeedStudioTFTv2.cpp Show annotated file Show diff for this revision Revisions of this file
SeeedStudioTFTv2.h Show annotated file Show diff for this revision Revisions of this file
--- a/SeeedStudioTFTv2.cpp	Tue May 06 18:12:49 2014 +0000
+++ b/SeeedStudioTFTv2.cpp	Mon Apr 18 06:59:46 2016 +0000
@@ -12,44 +12,26 @@
  * THE SOFTWARE.
  */
 
-
+ 
 #include "mbed.h"
 #include "SeeedStudioTFTv2.h"
 
 SeeedStudioTFTv2::SeeedStudioTFTv2(PinName xp, PinName xm, PinName yp, PinName ym,
                                    PinName mosi, PinName miso, PinName sclk,
-                                   PinName csTft, PinName dcTft, PinName blTft,
-                                   PinName csSd):
-#ifdef USE_SDCARD
-    SDFileSystem(mosi,miso,sclk,csSd, "sdc"),
-#endif
-    SPI_TFT_ILI9341(mosi,miso,sclk,csTft,NC,dcTft, "tft"),
-    bl(blTft)
+                                   PinName csTft, PinName rstTft, PinName dcTft):
+    SPI_TFT_ILI9341(mosi,miso,sclk,csTft,rstTft,dcTft, "tft")
 {
-#ifndef USE_SDCARD
-    // sd card
-    DigitalOut cs(csSd);
-    cs = 1;
-#endif
-    // backlight
-    bl = 1;
-    font = NULL;
     // touch screen pins
     _xp = xp;
     _yp = yp;
     _xm = xm;
     _ym = ym;
     // default touch calibration
-    // orientation     //      0      1      2      3
-    x_off = 108000;  //  17252  16605 108755 108000
-    y_off =  22000;  //  22330 105819  97167  22000
-    pp_tx =   -291;  //    378    289   -390   -291
-    pp_ty =    356;  //    261   -355   -239    356
-}
-
-void SeeedStudioTFTv2::setBacklight(bool enabled)
-{
-    bl = enabled;
+    // orientation  //      0      1      2      3
+    x_off =  16605 ;  //  17252  16605 108755 108000
+    y_off =  105819 ;  //  22330 105819  97167  22000
+    pp_tx =   289;  //    378    289   -390   -291
+    pp_ty =    -355;  //    261   -355   -239    356
 }
 
 int SeeedStudioTFTv2::readTouch(PinName p, PinName m, PinName a, PinName i)
@@ -102,6 +84,7 @@
     } else {
         touch = YES;
     }
+    //debug
     //locate(0,50);
     //printf("x: %6i y: %6i",p.x,p.y);
     return touch;
@@ -183,6 +166,8 @@
     while (getTouch(p) != NO)
         /*nothing*/;
     cls();
+    
+    Ecrire_Calibration(x_off, y_off, pp_tx, pp_ty);
 }
 
 point SeeedStudioTFTv2::toPixel(point p)
@@ -206,3 +191,36 @@
     p = toPixel(p);
     return touch == YES;
 }
+
+void SeeedStudioTFTv2::Ecrire_Calibration(unsigned short x_off, unsigned short y_off, unsigned short pp_tx, unsigned short pp_ty)
+{
+    FILE* fichier = fopen("/local/calib.txt", "w");
+    
+    fprintf(fichier,"%d %d %d %d", x_off, y_off, pp_tx, pp_ty);
+    
+    fclose(fichier);    
+}
+
+void SeeedStudioTFTv2::Lire_Calibration(void)
+{
+    FILE* fichier = fopen("/local/calib.txt", "r");
+
+    fscanf(fichier,"%d %d %d %d", &x_off, &y_off, &pp_tx, &pp_ty);
+    
+    fclose(fichier);
+     
+}
+void SeeedStudioTFTv2::CheckCalibTXT(void)
+{
+    FILE* fpi = fopen("/local/calib.txt", "r");
+
+    if (fpi == NULL) 
+    {
+        calibrate();          // calibrate the touch
+    } 
+    else
+    {
+        fclose(fpi);
+        Lire_Calibration();
+    }
+}
\ No newline at end of file
--- a/SeeedStudioTFTv2.h	Tue May 06 18:12:49 2014 +0000
+++ b/SeeedStudioTFTv2.h	Mon Apr 18 06:59:46 2016 +0000
@@ -16,9 +16,6 @@
 
 #include "mbed.h"
 #include "SPI_TFT_ILI9341.h"
-#ifdef USE_SDCARD
-#include "SDFileSystem.h" // import the SDFileSystem library 
-#endif
 
 struct point {
     int x;
@@ -26,9 +23,6 @@
 };
 
 class SeeedStudioTFTv2 : public  
-#ifdef USE_SDCARD
-    SDFileSystem,
-#endif
     SPI_TFT_ILI9341
 {
 public:
@@ -45,10 +39,8 @@
      */
     SeeedStudioTFTv2(PinName xp, PinName xm, PinName yp, PinName ym,
                      PinName mosi, PinName miso, PinName sclk,
-                     PinName csTft, PinName dcTft, PinName blTft,
-                     PinName csSd);
+                     PinName csTft, PinName rstTft, PinName dcTft);
 
-    void setBacklight(bool enabled);
     
     /** calibrate the touch display
      *
@@ -60,8 +52,7 @@
      *
      * @returns point(x,y)
      */
-    bool
-    getPixel(point& p);
+    bool getPixel(point& p);
 
     /** calculate coord on screen
     *
@@ -70,20 +61,30 @@
     *
     */
     point toPixel(point p);
-
+    
+    /* Ecrit les paramètres de calibrage dans un fichier à la racine du LPC*/
+    
+    void Ecrire_Calibration(unsigned short x_off, unsigned short y_off, unsigned short pp_tx, unsigned short pp_ty);
+    
+    /*Lit les paramètres de calibrage*/
+    
+    void Lire_Calibration(void);
+    
+    /*Lance le calibrage s'il n'y a pas de fichier sinon lit le calibrage enregistré*/
+    
+    void CheckCalibTXT(void);
+    
+    typedef enum { YES, MAYBE, NO } TOUCH;
+    TOUCH getTouch(point& p);
+    int readTouch(PinName p, PinName m, PinName a, PinName i);
+    int x_off,y_off;
+    int pp_tx,pp_ty;
+    
 protected:
     PinName _xm;
     PinName _ym;
     PinName _xp;
-    PinName _yp;
-    DigitalOut bl;
-
-    typedef enum { YES, MAYBE, NO } TOUCH;
-    TOUCH getTouch(point& p);
-    int readTouch(PinName p, PinName m, PinName a, PinName i);
-
-    int x_off,y_off;
-    int pp_tx,pp_ty;
+    PinName _yp;    
 };
 
 #endif