Adam Benjelloun / SeeedStudioTFTv2

Dependencies:   SPI_TFT_ILI9341

Fork of SeeedStudioTFTv2 by Components

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SeeedStudioTFTv2.h Source File

SeeedStudioTFTv2.h

00001 /* mbed library for touchscreen connected to 4 mbed pins
00002  * derive from SPI_TFT lib
00003  * Copyright (c) 2011 Peter Drescher - DC2PD
00004  *
00005  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00006  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00007  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00008  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00009  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00010  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00011  * THE SOFTWARE.
00012  */
00013 
00014 #ifndef MBED_TOUCH_H
00015 #define MBED_TOUCH_H
00016 
00017 #include "mbed.h"
00018 #include "SPI_TFT_ILI9341.h"
00019 
00020 struct point {
00021     int x;
00022     int y;
00023 };
00024 
00025 class SeeedStudioTFTv2 : public  
00026     SPI_TFT_ILI9341
00027 {
00028 public:
00029     /** create a TFT with touch object connected to the pins:
00030      *
00031      * @param pin xp resistiv touch x+
00032      * @param pin xm resistiv touch x-
00033      * @param pin yp resistiv touch y+
00034      * @param pin ym resistiv touch y-
00035      * @param mosi,miso,sclk SPI connection to TFT
00036      * @param cs pin connected to CS of display
00037      * @param reset pin connected to RESET of display
00038      * based on my SPI_TFT lib
00039      */
00040     SeeedStudioTFTv2(PinName xp, PinName xm, PinName yp, PinName ym,
00041                      PinName mosi, PinName miso, PinName sclk,
00042                      PinName csTft, PinName rstTft, PinName dcTft);
00043 
00044     
00045     /** calibrate the touch display
00046      *
00047      * User is asked to touch on two points on the screen
00048      */
00049     void calibrate(void);
00050 
00051     /** read x and y coord on screen
00052      *
00053      * @returns point(x,y)
00054      */
00055     bool getPixel(point& p);
00056 
00057     /** calculate coord on screen
00058     *
00059     * @param a_point point(analog x, analog y)
00060     * @returns point(pixel x, pixel y)
00061     *
00062     */
00063     point toPixel(point p);
00064     
00065     /* Ecrit les paramètres de calibrage dans un fichier à la racine du LPC*/
00066     
00067     void Ecrire_Calibration(signed long x_off, signed long y_off, signed long pp_tx, signed long pp_ty);
00068     
00069     /*Lit les paramètres de calibrage*/
00070     
00071     void Lire_Calibration(void);
00072     
00073     /*Lance le calibrage s'il n'y a pas de fichier sinon lit le calibrage enregistré*/
00074     
00075     void CheckCalibTXT(void);
00076     
00077     typedef enum { YES, MAYBE, NO } TOUCH;
00078     TOUCH getTouch(point& p);
00079     int readTouch(PinName p, PinName m, PinName a, PinName i);
00080     signed long x_off,y_off;
00081     signed long pp_tx,pp_ty;
00082     
00083 protected:
00084     PinName _xm;
00085     PinName _ym;
00086     PinName _xp;
00087     PinName _yp;    
00088 };
00089 
00090 #endif