Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers touch_tft.h Source File

touch_tft.h

00001 #ifndef MBED_TOUCH_H
00002 #define MBED_TOUCH_H
00003 
00004 #include "mbed.h"
00005 #include "SPI_TFT.h"
00006 
00007 struct point{
00008        unsigned short x;
00009        unsigned short y;
00010        };
00011 
00012 
00013 class touch_tft : public  SPI_TFT{
00014 public:
00015     /** create a TFT with touch object connected to the pins:
00016      *
00017      * @param pin xp resistiv touch x+
00018      * @param pin xm resistiv touch x-
00019      * @param pin yp resistiv touch y+
00020      * @param pin ym resistiv touch y-
00021      * @param mosi,miso,sclk SPI connection to TFT
00022      * @param cs pin connected to CS of display
00023      * @param reset pin connected to RESET of display 
00024      * based on my SPI_TFT lib
00025      */
00026     touch_tft(PinName xp, PinName xm, PinName yp, PinName ym,PinName mosi, PinName miso, PinName sclk, PinName cs, PinName reset, PinName bk, const char* name ="TFT");
00027     
00028     /** calibrate the touch display
00029      *
00030      * User is asked to touch on two points on the screen
00031      */   
00032     void calibrate(void);
00033     
00034     /** read x and y analog samples
00035      *
00036      * @returns point(x,y)
00037      */
00038     point get_touch(void);
00039     
00040     /** calculate coord on screen
00041      *
00042      * @param a_point point(analog x, analog y)
00043      * @returns point(pixel x, pixel y)
00044      *
00045      */
00046     point to_pixel(point a_point);
00047     
00048     /** test if screen is touched
00049      * 
00050      * @param point analog x,y
00051      * @returns true is touched
00052      *
00053      */   
00054    point shared_pointer(unsigned int xo, unsigned int xf, unsigned int speed, unsigned repetitions);  
00055    
00056      
00057      
00058     bool is_touched(point a);    
00059     
00060 protected:
00061     DigitalInOut _xp;
00062     DigitalInOut _xm;
00063     DigitalInOut _yp;
00064     DigitalInOut _ym;
00065     AnalogIn     _ax;
00066     AnalogIn     _ay;
00067     PinName xa;
00068     PinName ya;
00069     
00070     
00071     unsigned short x_a,y_a;
00072     unsigned short x_off,y_off;
00073     unsigned short pp_tx,pp_ty;
00074     
00075     
00076            
00077     };
00078 
00079 #endif