Library for SeeedStudioTFTv2 2.8 Zoll 240x360 pixel touch SD card

Dependencies:   SPI_TFT_ILI9341

Dependents:   SeeedStudioTFTv2_HelloWorld SeeedTouchLCD Seeed_TFT_Touch_Shield_v2_HelloWorld ... more

Fork of SeeedStudioTFTv2 by Michael Ammann

Committer:
mazgch
Date:
Mon Mar 24 09:06:41 2014 +0000
Revision:
12:8331742695ea
Parent:
8:36ea6be5182e
avoid some compiler errors on certain targets

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 #ifdef USE_SDCARD
mazgch 5:366bdc7a8315 20 #include "SDFileSystem.h" // import the SDFileSystem library
mazgch 4:4542d1ff81e4 21 #endif
mazgch 4:4542d1ff81e4 22
mazgch 4:4542d1ff81e4 23 struct point {
mazgch 4:4542d1ff81e4 24 int x;
mazgch 4:4542d1ff81e4 25 int y;
mazgch 4:4542d1ff81e4 26 };
mazgch 4:4542d1ff81e4 27
mazgch 7:dfd69b3be5b6 28 class SeeedStudioTFTv2 : public
mazgch 4:4542d1ff81e4 29 #ifdef USE_SDCARD
mazgch 7:dfd69b3be5b6 30 SDFileSystem,
mazgch 4:4542d1ff81e4 31 #endif
mazgch 7:dfd69b3be5b6 32 SPI_TFT_ILI9341
mazgch 4:4542d1ff81e4 33 {
mazgch 4:4542d1ff81e4 34 public:
mazgch 4:4542d1ff81e4 35 /** create a TFT with touch object connected to the pins:
mazgch 4:4542d1ff81e4 36 *
mazgch 4:4542d1ff81e4 37 * @param pin xp resistiv touch x+
mazgch 4:4542d1ff81e4 38 * @param pin xm resistiv touch x-
mazgch 4:4542d1ff81e4 39 * @param pin yp resistiv touch y+
mazgch 4:4542d1ff81e4 40 * @param pin ym resistiv touch y-
mazgch 4:4542d1ff81e4 41 * @param mosi,miso,sclk SPI connection to TFT
mazgch 4:4542d1ff81e4 42 * @param cs pin connected to CS of display
mazgch 4:4542d1ff81e4 43 * @param reset pin connected to RESET of display
mazgch 4:4542d1ff81e4 44 * based on my SPI_TFT lib
mazgch 4:4542d1ff81e4 45 */
mazgch 4:4542d1ff81e4 46 SeeedStudioTFTv2(PinName xp, PinName xm, PinName yp, PinName ym,
mazgch 4:4542d1ff81e4 47 PinName mosi, PinName miso, PinName sclk,
mazgch 8:36ea6be5182e 48 PinName csTft, PinName dcTft, PinName blTft,
mazgch 4:4542d1ff81e4 49 PinName csSd);
mazgch 4:4542d1ff81e4 50
mazgch 5:366bdc7a8315 51 void setBacklight(bool enabled);
mazgch 5:366bdc7a8315 52
mazgch 4:4542d1ff81e4 53 /** calibrate the touch display
mazgch 4:4542d1ff81e4 54 *
mazgch 4:4542d1ff81e4 55 * User is asked to touch on two points on the screen
mazgch 4:4542d1ff81e4 56 */
mazgch 4:4542d1ff81e4 57 void calibrate(void);
mazgch 4:4542d1ff81e4 58
mazgch 4:4542d1ff81e4 59 /** read x and y coord on screen
mazgch 4:4542d1ff81e4 60 *
mazgch 4:4542d1ff81e4 61 * @returns point(x,y)
mazgch 4:4542d1ff81e4 62 */
mazgch 4:4542d1ff81e4 63 bool
mazgch 4:4542d1ff81e4 64 getPixel(point& p);
mazgch 4:4542d1ff81e4 65
mazgch 4:4542d1ff81e4 66 /** calculate coord on screen
mazgch 4:4542d1ff81e4 67 *
mazgch 4:4542d1ff81e4 68 * @param a_point point(analog x, analog y)
mazgch 4:4542d1ff81e4 69 * @returns point(pixel x, pixel y)
mazgch 4:4542d1ff81e4 70 *
mazgch 4:4542d1ff81e4 71 */
mazgch 4:4542d1ff81e4 72 point toPixel(point p);
mazgch 4:4542d1ff81e4 73
mazgch 4:4542d1ff81e4 74 protected:
mazgch 4:4542d1ff81e4 75 PinName _xm;
mazgch 4:4542d1ff81e4 76 PinName _ym;
mazgch 4:4542d1ff81e4 77 PinName _xp;
mazgch 4:4542d1ff81e4 78 PinName _yp;
mazgch 5:366bdc7a8315 79 DigitalOut bl;
mazgch 4:4542d1ff81e4 80
mazgch 4:4542d1ff81e4 81 typedef enum { YES, MAYBE, NO } TOUCH;
mazgch 4:4542d1ff81e4 82 TOUCH getTouch(point& p);
mazgch 4:4542d1ff81e4 83 int readTouch(PinName p, PinName m, PinName a, PinName i);
mazgch 4:4542d1ff81e4 84
mazgch 4:4542d1ff81e4 85 int x_off,y_off;
mazgch 4:4542d1ff81e4 86 int pp_tx,pp_ty;
mazgch 4:4542d1ff81e4 87 };
mazgch 4:4542d1ff81e4 88
mazgch 4:4542d1ff81e4 89 #endif