Committer:
apm_litoral
Date:
Tue Apr 10 03:34:09 2012 +0000
Revision:
0:d0e2979d7ed6

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
apm_litoral 0:d0e2979d7ed6 1 #ifndef MBED_TOUCH_H
apm_litoral 0:d0e2979d7ed6 2 #define MBED_TOUCH_H
apm_litoral 0:d0e2979d7ed6 3
apm_litoral 0:d0e2979d7ed6 4 #include "mbed.h"
apm_litoral 0:d0e2979d7ed6 5 #include "SPI_TFT.h"
apm_litoral 0:d0e2979d7ed6 6
apm_litoral 0:d0e2979d7ed6 7 struct point{
apm_litoral 0:d0e2979d7ed6 8 unsigned short x;
apm_litoral 0:d0e2979d7ed6 9 unsigned short y;
apm_litoral 0:d0e2979d7ed6 10 };
apm_litoral 0:d0e2979d7ed6 11
apm_litoral 0:d0e2979d7ed6 12
apm_litoral 0:d0e2979d7ed6 13 class touch_tft : public SPI_TFT{
apm_litoral 0:d0e2979d7ed6 14 public:
apm_litoral 0:d0e2979d7ed6 15 /** create a TFT with touch object connected to the pins:
apm_litoral 0:d0e2979d7ed6 16 *
apm_litoral 0:d0e2979d7ed6 17 * @param pin xp resistiv touch x+
apm_litoral 0:d0e2979d7ed6 18 * @param pin xm resistiv touch x-
apm_litoral 0:d0e2979d7ed6 19 * @param pin yp resistiv touch y+
apm_litoral 0:d0e2979d7ed6 20 * @param pin ym resistiv touch y-
apm_litoral 0:d0e2979d7ed6 21 * @param mosi,miso,sclk SPI connection to TFT
apm_litoral 0:d0e2979d7ed6 22 * @param cs pin connected to CS of display
apm_litoral 0:d0e2979d7ed6 23 * @param reset pin connected to RESET of display
apm_litoral 0:d0e2979d7ed6 24 * based on my SPI_TFT lib
apm_litoral 0:d0e2979d7ed6 25 */
apm_litoral 0:d0e2979d7ed6 26 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");
apm_litoral 0:d0e2979d7ed6 27
apm_litoral 0:d0e2979d7ed6 28 /** calibrate the touch display
apm_litoral 0:d0e2979d7ed6 29 *
apm_litoral 0:d0e2979d7ed6 30 * User is asked to touch on two points on the screen
apm_litoral 0:d0e2979d7ed6 31 */
apm_litoral 0:d0e2979d7ed6 32 void calibrate(void);
apm_litoral 0:d0e2979d7ed6 33
apm_litoral 0:d0e2979d7ed6 34 /** read x and y analog samples
apm_litoral 0:d0e2979d7ed6 35 *
apm_litoral 0:d0e2979d7ed6 36 * @returns point(x,y)
apm_litoral 0:d0e2979d7ed6 37 */
apm_litoral 0:d0e2979d7ed6 38 point get_touch(void);
apm_litoral 0:d0e2979d7ed6 39
apm_litoral 0:d0e2979d7ed6 40 /** calculate coord on screen
apm_litoral 0:d0e2979d7ed6 41 *
apm_litoral 0:d0e2979d7ed6 42 * @param a_point point(analog x, analog y)
apm_litoral 0:d0e2979d7ed6 43 * @returns point(pixel x, pixel y)
apm_litoral 0:d0e2979d7ed6 44 *
apm_litoral 0:d0e2979d7ed6 45 */
apm_litoral 0:d0e2979d7ed6 46 point to_pixel(point a_point);
apm_litoral 0:d0e2979d7ed6 47
apm_litoral 0:d0e2979d7ed6 48 /** test if screen is touched
apm_litoral 0:d0e2979d7ed6 49 *
apm_litoral 0:d0e2979d7ed6 50 * @param point analog x,y
apm_litoral 0:d0e2979d7ed6 51 * @returns true is touched
apm_litoral 0:d0e2979d7ed6 52 *
apm_litoral 0:d0e2979d7ed6 53 */
apm_litoral 0:d0e2979d7ed6 54 point shared_pointer(unsigned int xo, unsigned int xf, unsigned int speed, unsigned repetitions);
apm_litoral 0:d0e2979d7ed6 55
apm_litoral 0:d0e2979d7ed6 56
apm_litoral 0:d0e2979d7ed6 57
apm_litoral 0:d0e2979d7ed6 58 bool is_touched(point a);
apm_litoral 0:d0e2979d7ed6 59
apm_litoral 0:d0e2979d7ed6 60 protected:
apm_litoral 0:d0e2979d7ed6 61 DigitalInOut _xp;
apm_litoral 0:d0e2979d7ed6 62 DigitalInOut _xm;
apm_litoral 0:d0e2979d7ed6 63 DigitalInOut _yp;
apm_litoral 0:d0e2979d7ed6 64 DigitalInOut _ym;
apm_litoral 0:d0e2979d7ed6 65 AnalogIn _ax;
apm_litoral 0:d0e2979d7ed6 66 AnalogIn _ay;
apm_litoral 0:d0e2979d7ed6 67 PinName xa;
apm_litoral 0:d0e2979d7ed6 68 PinName ya;
apm_litoral 0:d0e2979d7ed6 69
apm_litoral 0:d0e2979d7ed6 70
apm_litoral 0:d0e2979d7ed6 71 unsigned short x_a,y_a;
apm_litoral 0:d0e2979d7ed6 72 unsigned short x_off,y_off;
apm_litoral 0:d0e2979d7ed6 73 unsigned short pp_tx,pp_ty;
apm_litoral 0:d0e2979d7ed6 74
apm_litoral 0:d0e2979d7ed6 75
apm_litoral 0:d0e2979d7ed6 76
apm_litoral 0:d0e2979d7ed6 77 };
apm_litoral 0:d0e2979d7ed6 78
apm_litoral 0:d0e2979d7ed6 79 #endif