Works
Dependencies: BMP180 BNO055_fusion Fonts GPSISR HTU21D SDFileSystem UniGraphic mbed uGUI
Fork of Bicycl_Computer_NUCLEO-F411RE by
SeeedStudioTFTv2.h@16:e81bd672196b, 2018-05-25 (annotated)
- Committer:
- trevieze
- Date:
- Fri May 25 14:25:01 2018 +0000
- Revision:
- 16:e81bd672196b
- Parent:
- 15:b174ec6e3ca0
Works
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
trevieze | 2:c5085faf2aa5 | 1 | /* mbed library for touchscreen connected to 4 mbed pins |
trevieze | 2:c5085faf2aa5 | 2 | * derive from SPI_TFT lib |
trevieze | 2:c5085faf2aa5 | 3 | * Copyright (c) 2011 Peter Drescher - DC2PD |
trevieze | 2:c5085faf2aa5 | 4 | * |
trevieze | 2:c5085faf2aa5 | 5 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
trevieze | 2:c5085faf2aa5 | 6 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
trevieze | 2:c5085faf2aa5 | 7 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
trevieze | 2:c5085faf2aa5 | 8 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
trevieze | 2:c5085faf2aa5 | 9 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
trevieze | 2:c5085faf2aa5 | 10 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
trevieze | 2:c5085faf2aa5 | 11 | * THE SOFTWARE. |
trevieze | 2:c5085faf2aa5 | 12 | */ |
trevieze | 2:c5085faf2aa5 | 13 | |
trevieze | 2:c5085faf2aa5 | 14 | #ifndef MBED_TOUCH_H |
trevieze | 2:c5085faf2aa5 | 15 | #define MBED_TOUCH_H |
trevieze | 2:c5085faf2aa5 | 16 | |
trevieze | 2:c5085faf2aa5 | 17 | #include "mbed.h" |
trevieze | 2:c5085faf2aa5 | 18 | |
trevieze | 4:25554dc066a0 | 19 | #define __PRESURE 1000 |
trevieze | 2:c5085faf2aa5 | 20 | #define RXPLATE 300 |
trevieze | 2:c5085faf2aa5 | 21 | |
trevieze | 15:b174ec6e3ca0 | 22 | //Measured ADC values for (0,0) and (210-1,320-1) |
trevieze | 15:b174ec6e3ca0 | 23 | //TS_MINX corresponds to ADC value when X = 0 |
trevieze | 15:b174ec6e3ca0 | 24 | //TS_MINY corresponds to ADC value when Y = 0 |
trevieze | 15:b174ec6e3ca0 | 25 | //TS_MAXX corresponds to ADC value when X = 240 -1 |
trevieze | 15:b174ec6e3ca0 | 26 | //TS_MAXY corresponds to ADC value when Y = 320 -1 |
trevieze | 15:b174ec6e3ca0 | 27 | |
trevieze | 15:b174ec6e3ca0 | 28 | #define TS_MINX 10500 //116*2 |
trevieze | 15:b174ec6e3ca0 | 29 | #define TS_MAXX 116252 //890*2 |
trevieze | 15:b174ec6e3ca0 | 30 | #define TS_MINY 12500 //83*2 |
trevieze | 15:b174ec6e3ca0 | 31 | #define TS_MAXY 116044 //913*2 |
trevieze | 15:b174ec6e3ca0 | 32 | |
trevieze | 2:c5085faf2aa5 | 33 | struct point { |
trevieze | 2:c5085faf2aa5 | 34 | int x; |
trevieze | 2:c5085faf2aa5 | 35 | int y; |
trevieze | 2:c5085faf2aa5 | 36 | int z; |
trevieze | 2:c5085faf2aa5 | 37 | }; |
trevieze | 2:c5085faf2aa5 | 38 | |
trevieze | 2:c5085faf2aa5 | 39 | class TouchScreen { |
trevieze | 2:c5085faf2aa5 | 40 | public: |
trevieze | 2:c5085faf2aa5 | 41 | /** create a TFT with touch object connected to the pins: |
trevieze | 2:c5085faf2aa5 | 42 | * |
trevieze | 2:c5085faf2aa5 | 43 | * @param pin xp resistiv touch x+ |
trevieze | 2:c5085faf2aa5 | 44 | * @param pin xm resistiv touch x- |
trevieze | 2:c5085faf2aa5 | 45 | * @param pin yp resistiv touch y+ |
trevieze | 2:c5085faf2aa5 | 46 | * @param pin ym resistiv touch y- |
trevieze | 2:c5085faf2aa5 | 47 | * @param mosi,miso,sclk SPI connection to TFT |
trevieze | 2:c5085faf2aa5 | 48 | * @param cs pin connected to CS of display |
trevieze | 2:c5085faf2aa5 | 49 | * @param reset pin connected to RESET of display |
trevieze | 2:c5085faf2aa5 | 50 | * based on my SPI_TFT lib |
trevieze | 2:c5085faf2aa5 | 51 | */ |
trevieze | 2:c5085faf2aa5 | 52 | TouchScreen(PinName xp, PinName xm, PinName yp, PinName ym); |
trevieze | 15:b174ec6e3ca0 | 53 | void getTouch(point& p); |
trevieze | 15:b174ec6e3ca0 | 54 | long map(long x, long in_min, long in_max, long out_min, long out_max); |
trevieze | 2:c5085faf2aa5 | 55 | protected: |
trevieze | 2:c5085faf2aa5 | 56 | PinName _xm; |
trevieze | 2:c5085faf2aa5 | 57 | PinName _ym; |
trevieze | 2:c5085faf2aa5 | 58 | PinName _xp; |
trevieze | 2:c5085faf2aa5 | 59 | PinName _yp; |
trevieze | 2:c5085faf2aa5 | 60 | //DigitalOut bl; |
trevieze | 2:c5085faf2aa5 | 61 | |
trevieze | 2:c5085faf2aa5 | 62 | typedef enum { YES, MAYBE, NO } TOUCH; |
trevieze | 2:c5085faf2aa5 | 63 | int readTouch(PinName p, PinName m, PinName a, PinName i); |
trevieze | 2:c5085faf2aa5 | 64 | int x_off,y_off; |
trevieze | 2:c5085faf2aa5 | 65 | int pp_tx,pp_ty; |
trevieze | 2:c5085faf2aa5 | 66 | }; |
trevieze | 2:c5085faf2aa5 | 67 | |
trevieze | 2:c5085faf2aa5 | 68 | #endif |