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