bla

Dependencies:   SPI_TFT_ILI9341

Fork of SeeedStudioTFTv2 by Mbed Game

Committer:
alpali
Date:
Tue Apr 17 11:19:18 2018 +0000
Revision:
17:7108f1e0f033
Parent:
14:5421b9d45c5d
blah

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 */
lindaako 14:5421b9d45c5d 46 SeeedStudioTFTv2(PinName xp, PinName xm, PinName yp, PinName ym,
mazgch 4:4542d1ff81e4 47 PinName mosi, PinName miso, PinName sclk,
lindaako 14:5421b9d45c5d 48 PinName csTft, PinName dcTft, PinName blTft);
lindaako 14:5421b9d45c5d 49
lindaako 14:5421b9d45c5d 50 typedef enum { YES, MAYBE, NO } TOUCH;
lindaako 14:5421b9d45c5d 51 TOUCH getTouch(point& p);
mazgch 4:4542d1ff81e4 52
mazgch 5:366bdc7a8315 53 void setBacklight(bool enabled);
mazgch 5:366bdc7a8315 54
mazgch 4:4542d1ff81e4 55 /** calibrate the touch display
mazgch 4:4542d1ff81e4 56 *
mazgch 4:4542d1ff81e4 57 * User is asked to touch on two points on the screen
mazgch 4:4542d1ff81e4 58 */
mazgch 4:4542d1ff81e4 59 void calibrate(void);
mazgch 4:4542d1ff81e4 60
mazgch 4:4542d1ff81e4 61 /** read x and y coord on screen
mazgch 4:4542d1ff81e4 62 *
mazgch 4:4542d1ff81e4 63 * @returns point(x,y)
mazgch 4:4542d1ff81e4 64 */
mazgch 4:4542d1ff81e4 65 bool
mazgch 4:4542d1ff81e4 66 getPixel(point& p);
mazgch 4:4542d1ff81e4 67
mazgch 4:4542d1ff81e4 68 /** calculate coord on screen
mazgch 4:4542d1ff81e4 69 *
mazgch 4:4542d1ff81e4 70 * @param a_point point(analog x, analog y)
mazgch 4:4542d1ff81e4 71 * @returns point(pixel x, pixel y)
mazgch 4:4542d1ff81e4 72 *
mazgch 4:4542d1ff81e4 73 */
mazgch 4:4542d1ff81e4 74 point toPixel(point p);
mazgch 4:4542d1ff81e4 75
mazgch 4:4542d1ff81e4 76 protected:
mazgch 4:4542d1ff81e4 77 PinName _xm;
mazgch 4:4542d1ff81e4 78 PinName _ym;
mazgch 4:4542d1ff81e4 79 PinName _xp;
mazgch 4:4542d1ff81e4 80 PinName _yp;
mazgch 5:366bdc7a8315 81 DigitalOut bl;
mazgch 4:4542d1ff81e4 82
lindaako 14:5421b9d45c5d 83
mazgch 4:4542d1ff81e4 84 int readTouch(PinName p, PinName m, PinName a, PinName i);
mazgch 4:4542d1ff81e4 85
mazgch 4:4542d1ff81e4 86 int x_off,y_off;
mazgch 4:4542d1ff81e4 87 int pp_tx,pp_ty;
mazgch 4:4542d1ff81e4 88 };
mazgch 4:4542d1ff81e4 89
mazgch 4:4542d1ff81e4 90 #endif