This is a fork of a functional ILI9341 display with a functional Seeed touch screen library.

Dependencies:   BMP180 UniGraphic mbed BNO055_fusionI_fixed HTU21D GPSISR Compass Fonts uGUI

Fork of TFT_test_NUCLEO-F411RE by Motoo Tanaka

/media/uploads/trevieze/win_20170427_21_31_20_pro.jpg

Had to move sensors to a remote board because of interference. Added spi burst mode to supported displays.

To do.... ugui buttons are slow. will need to add rtos to project. Finish other way points screen. Will have to rewrite portions of the touch screen class. Sense touch, delay, read values and then average, touch released, is the sequence. Add cadence input and logic to program for computer screen.

Committer:
trevieze
Date:
Fri May 18 18:26:36 2018 +0000
Revision:
22:39a8e5c47f3c
Parent:
20:3ada4387cc1b
Working on touch screen response. Loading new uGui class for a test drive.

Who changed what in which revision?

UserRevisionLine numberNew 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 20:3ada4387cc1b 20 #define __NOPRESURE 500
trevieze 2:c5085faf2aa5 21 #define RXPLATE 300
trevieze 2:c5085faf2aa5 22
trevieze 14:b174ec6e3ca0 23 //Measured ADC values for (0,0) and (210-1,320-1)
trevieze 14:b174ec6e3ca0 24 //TS_MINX corresponds to ADC value when X = 0
trevieze 14:b174ec6e3ca0 25 //TS_MINY corresponds to ADC value when Y = 0
trevieze 14:b174ec6e3ca0 26 //TS_MAXX corresponds to ADC value when X = 240 -1
trevieze 14:b174ec6e3ca0 27 //TS_MAXY corresponds to ADC value when Y = 320 -1
trevieze 14:b174ec6e3ca0 28
trevieze 14:b174ec6e3ca0 29 #define TS_MINX 10500 //116*2
trevieze 14:b174ec6e3ca0 30 #define TS_MAXX 116252 //890*2
trevieze 14:b174ec6e3ca0 31 #define TS_MINY 12500 //83*2
trevieze 14:b174ec6e3ca0 32 #define TS_MAXY 116044 //913*2
trevieze 14:b174ec6e3ca0 33
trevieze 18:50520438c129 34 #define PIN_XP A3
trevieze 18:50520438c129 35 #define PIN_XM A1
trevieze 18:50520438c129 36 #define PIN_YP A2
trevieze 18:50520438c129 37 #define PIN_YM A0
trevieze 18:50520438c129 38
trevieze 2:c5085faf2aa5 39 struct point {
trevieze 2:c5085faf2aa5 40 int x;
trevieze 2:c5085faf2aa5 41 int y;
trevieze 2:c5085faf2aa5 42 int z;
trevieze 2:c5085faf2aa5 43 };
trevieze 2:c5085faf2aa5 44
trevieze 2:c5085faf2aa5 45 class TouchScreen {
trevieze 2:c5085faf2aa5 46 public:
trevieze 2:c5085faf2aa5 47 /** create a TFT with touch object connected to the pins:
trevieze 2:c5085faf2aa5 48 *
trevieze 2:c5085faf2aa5 49 * @param pin xp resistiv touch x+
trevieze 2:c5085faf2aa5 50 * @param pin xm resistiv touch x-
trevieze 2:c5085faf2aa5 51 * @param pin yp resistiv touch y+
trevieze 2:c5085faf2aa5 52 * @param pin ym resistiv touch y-
trevieze 2:c5085faf2aa5 53 * @param mosi,miso,sclk SPI connection to TFT
trevieze 2:c5085faf2aa5 54 * @param cs pin connected to CS of display
trevieze 2:c5085faf2aa5 55 * @param reset pin connected to RESET of display
trevieze 2:c5085faf2aa5 56 * based on my SPI_TFT lib
trevieze 2:c5085faf2aa5 57 */
trevieze 2:c5085faf2aa5 58 TouchScreen(PinName xp, PinName xm, PinName yp, PinName ym);
trevieze 14:b174ec6e3ca0 59 void getTouch(point& p);
trevieze 14:b174ec6e3ca0 60 long map(long x, long in_min, long in_max, long out_min, long out_max);
trevieze 2:c5085faf2aa5 61 protected:
trevieze 2:c5085faf2aa5 62 PinName _xm;
trevieze 2:c5085faf2aa5 63 PinName _ym;
trevieze 2:c5085faf2aa5 64 PinName _xp;
trevieze 2:c5085faf2aa5 65 PinName _yp;
trevieze 2:c5085faf2aa5 66 //DigitalOut bl;
trevieze 2:c5085faf2aa5 67
trevieze 2:c5085faf2aa5 68 typedef enum { YES, MAYBE, NO } TOUCH;
trevieze 2:c5085faf2aa5 69 int readTouch(PinName p, PinName m, PinName a, PinName i);
trevieze 2:c5085faf2aa5 70 int x_off,y_off;
trevieze 2:c5085faf2aa5 71 int pp_tx,pp_ty;
trevieze 2:c5085faf2aa5 72 };
trevieze 2:c5085faf2aa5 73
trevieze 2:c5085faf2aa5 74 #endif