Works

Dependencies:   BMP180 BNO055_fusion Fonts GPSISR HTU21D SDFileSystem UniGraphic mbed uGUI

Fork of Bicycl_Computer_NUCLEO-F411RE by Darren Ulrich

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