c est celui ci le poirier
Fork of SeeedStudioTFTv2 by
SeeedStudioTFTv2.h@8:36ea6be5182e, 2013-10-21 (annotated)
- Committer:
- mazgch
- Date:
- Mon Oct 21 19:38:34 2013 +0000
- Revision:
- 8:36ea6be5182e
- Parent:
- 7:dfd69b3be5b6
remove unavailable reset signal
Who changed what in which revision?
User | Revision | Line number | New 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 |