seed

Dependencies:   SPI_TFT_ILI9341

Fork of SeeedStudioTFTv2 by Components

Committer:
Ganstrich
Date:
Thu Apr 28 19:28:01 2016 +0000
Revision:
15:23288c15e11d
Parent:
14:304b55ac904b
Versi 1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mazgch 4:4542d1ff81e4 1 /* mbed library for touchscreen connected to 4 mbed pins
mazgch 4:4542d1ff81e4 2 * derive from SPI_TFT lib
mazgch 4:4542d1ff81e4 3 * Copyright (c) 2011 Peter Drescher - DC2PD
mazgch 4:4542d1ff81e4 4 *
mazgch 4:4542d1ff81e4 5 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
mazgch 4:4542d1ff81e4 6 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
mazgch 4:4542d1ff81e4 7 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
mazgch 4:4542d1ff81e4 8 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
mazgch 4:4542d1ff81e4 9 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
mazgch 4:4542d1ff81e4 10 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
mazgch 4:4542d1ff81e4 11 * THE SOFTWARE.
mazgch 4:4542d1ff81e4 12 */
mazgch 4:4542d1ff81e4 13
mazgch 4:4542d1ff81e4 14 #ifndef MBED_TOUCH_H
mazgch 4:4542d1ff81e4 15 #define MBED_TOUCH_H
mazgch 4:4542d1ff81e4 16
mazgch 4:4542d1ff81e4 17 #include "mbed.h"
mazgch 4:4542d1ff81e4 18 #include "SPI_TFT_ILI9341.h"
mazgch 4:4542d1ff81e4 19
mazgch 4:4542d1ff81e4 20 struct point {
mazgch 4:4542d1ff81e4 21 int x;
mazgch 4:4542d1ff81e4 22 int y;
mazgch 4:4542d1ff81e4 23 };
mazgch 4:4542d1ff81e4 24
mazgch 7:dfd69b3be5b6 25 class SeeedStudioTFTv2 : public
mazgch 7:dfd69b3be5b6 26 SPI_TFT_ILI9341
mazgch 4:4542d1ff81e4 27 {
mazgch 4:4542d1ff81e4 28 public:
mazgch 4:4542d1ff81e4 29 /** create a TFT with touch object connected to the pins:
mazgch 4:4542d1ff81e4 30 *
mazgch 4:4542d1ff81e4 31 * @param pin xp resistiv touch x+
mazgch 4:4542d1ff81e4 32 * @param pin xm resistiv touch x-
mazgch 4:4542d1ff81e4 33 * @param pin yp resistiv touch y+
mazgch 4:4542d1ff81e4 34 * @param pin ym resistiv touch y-
mazgch 4:4542d1ff81e4 35 * @param mosi,miso,sclk SPI connection to TFT
mazgch 4:4542d1ff81e4 36 * @param cs pin connected to CS of display
mazgch 4:4542d1ff81e4 37 * @param reset pin connected to RESET of display
mazgch 4:4542d1ff81e4 38 * based on my SPI_TFT lib
mazgch 4:4542d1ff81e4 39 */
mazgch 4:4542d1ff81e4 40 SeeedStudioTFTv2(PinName xp, PinName xm, PinName yp, PinName ym,
mazgch 4:4542d1ff81e4 41 PinName mosi, PinName miso, PinName sclk,
Ganstrich 14:304b55ac904b 42 PinName csTft, PinName rstTft, PinName dcTft);
mazgch 4:4542d1ff81e4 43
mazgch 5:366bdc7a8315 44
mazgch 4:4542d1ff81e4 45 /** calibrate the touch display
mazgch 4:4542d1ff81e4 46 *
mazgch 4:4542d1ff81e4 47 * User is asked to touch on two points on the screen
mazgch 4:4542d1ff81e4 48 */
mazgch 4:4542d1ff81e4 49 void calibrate(void);
mazgch 4:4542d1ff81e4 50
mazgch 4:4542d1ff81e4 51 /** read x and y coord on screen
mazgch 4:4542d1ff81e4 52 *
mazgch 4:4542d1ff81e4 53 * @returns point(x,y)
mazgch 4:4542d1ff81e4 54 */
Ganstrich 14:304b55ac904b 55 bool getPixel(point& p);
mazgch 4:4542d1ff81e4 56
mazgch 4:4542d1ff81e4 57 /** calculate coord on screen
mazgch 4:4542d1ff81e4 58 *
mazgch 4:4542d1ff81e4 59 * @param a_point point(analog x, analog y)
mazgch 4:4542d1ff81e4 60 * @returns point(pixel x, pixel y)
mazgch 4:4542d1ff81e4 61 *
mazgch 4:4542d1ff81e4 62 */
mazgch 4:4542d1ff81e4 63 point toPixel(point p);
Ganstrich 14:304b55ac904b 64
Ganstrich 14:304b55ac904b 65 /* Ecrit les paramètres de calibrage dans un fichier à la racine du LPC*/
Ganstrich 14:304b55ac904b 66
Ganstrich 15:23288c15e11d 67 void Ecrire_Calibration(signed long x_off, signed long y_off, signed long pp_tx, signed long pp_ty);
Ganstrich 14:304b55ac904b 68
Ganstrich 14:304b55ac904b 69 /*Lit les paramètres de calibrage*/
Ganstrich 14:304b55ac904b 70
Ganstrich 14:304b55ac904b 71 void Lire_Calibration(void);
Ganstrich 14:304b55ac904b 72
Ganstrich 14:304b55ac904b 73 /*Lance le calibrage s'il n'y a pas de fichier sinon lit le calibrage enregistré*/
Ganstrich 14:304b55ac904b 74
Ganstrich 14:304b55ac904b 75 void CheckCalibTXT(void);
Ganstrich 14:304b55ac904b 76
Ganstrich 14:304b55ac904b 77 typedef enum { YES, MAYBE, NO } TOUCH;
Ganstrich 14:304b55ac904b 78 TOUCH getTouch(point& p);
Ganstrich 14:304b55ac904b 79 int readTouch(PinName p, PinName m, PinName a, PinName i);
Ganstrich 15:23288c15e11d 80 signed long x_off,y_off;
Ganstrich 15:23288c15e11d 81 signed long pp_tx,pp_ty;
Ganstrich 14:304b55ac904b 82
mazgch 4:4542d1ff81e4 83 protected:
mazgch 4:4542d1ff81e4 84 PinName _xm;
mazgch 4:4542d1ff81e4 85 PinName _ym;
mazgch 4:4542d1ff81e4 86 PinName _xp;
Ganstrich 14:304b55ac904b 87 PinName _yp;
mazgch 4:4542d1ff81e4 88 };
mazgch 4:4542d1ff81e4 89
mazgch 4:4542d1ff81e4 90 #endif