This is a fork of a functional ILI9341 display with a functional Seeed touch screen library.

Dependencies:   BMP180 UniGraphic mbed BNO055_fusionI_fixed HTU21D GPSISR Compass Fonts uGUI

Fork of TFT_test_NUCLEO-F411RE by Motoo Tanaka

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 
00019 #define __PRESURE 1000
00020 #define __NOPRESURE 500
00021 #define RXPLATE   300
00022 
00023 //Measured ADC values for (0,0) and (210-1,320-1)
00024 //TS_MINX corresponds to ADC value when X = 0
00025 //TS_MINY corresponds to ADC value when Y = 0
00026 //TS_MAXX corresponds to ADC value when X = 240 -1
00027 //TS_MAXY corresponds to ADC value when Y = 320 -1
00028 
00029 #define TS_MINX 10500  //116*2
00030 #define TS_MAXX 116252 //890*2
00031 #define TS_MINY 12500  //83*2
00032 #define TS_MAXY 116044 //913*2
00033 
00034 #define PIN_XP          A3
00035 #define PIN_XM          A1
00036 #define PIN_YP          A2
00037 #define PIN_YM          A0
00038 
00039 struct point {
00040     int x;
00041     int y;
00042     int z;
00043 };
00044 
00045 class TouchScreen {
00046    public:  
00047     /** create a TFT with touch object connected to the pins:
00048      *
00049      * @param pin xp resistiv touch x+
00050      * @param pin xm resistiv touch x-
00051      * @param pin yp resistiv touch y+
00052      * @param pin ym resistiv touch y-
00053      * @param mosi,miso,sclk SPI connection to TFT
00054      * @param cs pin connected to CS of display
00055      * @param reset pin connected to RESET of display
00056      * based on my SPI_TFT lib
00057      */
00058     TouchScreen(PinName xp, PinName xm, PinName yp, PinName ym);
00059         void getTouch(point& p);
00060         long map(long x, long in_min, long in_max, long out_min, long out_max);
00061 protected:
00062     PinName _xm;
00063     PinName _ym;
00064     PinName _xp;
00065     PinName _yp;
00066     //DigitalOut bl;
00067 
00068     typedef enum { YES, MAYBE, NO } TOUCH;
00069     int readTouch(PinName p, PinName m, PinName a, PinName i);
00070     int x_off,y_off;
00071     int pp_tx,pp_ty;
00072 };
00073 
00074 #endif