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:
Thu Feb 16 23:56:02 2017 +0000
Revision:
8:855884782f67
Parent:
7:8aa9cdab4a07
Child:
9:a3cb458d7b1c
GPS ISR Wrapper Working?

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Rhyme 0:cd5e3d371b54 1 /* mbed main.cpp to test adafruit 2.8" TFT LCD shiled w Touchscreen
Rhyme 0:cd5e3d371b54 2 * Copyright (c) 2014, 2015 Motoo Tanaka @ Design Methodology Lab
Rhyme 0:cd5e3d371b54 3 *
Rhyme 0:cd5e3d371b54 4 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Rhyme 0:cd5e3d371b54 5 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Rhyme 0:cd5e3d371b54 6 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Rhyme 0:cd5e3d371b54 7 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Rhyme 0:cd5e3d371b54 8 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Rhyme 0:cd5e3d371b54 9 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
Rhyme 0:cd5e3d371b54 10 * THE SOFTWARE.
Rhyme 0:cd5e3d371b54 11 */
Rhyme 0:cd5e3d371b54 12
Rhyme 0:cd5e3d371b54 13 /*
Rhyme 0:cd5e3d371b54 14 * Note: This program is derived from the SeeeStudioTFTv2 program.
Rhyme 0:cd5e3d371b54 15 * Although both program share same ILI9341 TFT driver,
Rhyme 0:cd5e3d371b54 16 * the touch sensor was not same with the Display I purchased from Akizuki.
Rhyme 0:cd5e3d371b54 17 * http://akizukidenshi.com/catalog/g/gM-07747/
Rhyme 0:cd5e3d371b54 18 * The touch sensor on the display is STMPE610,
Rhyme 0:cd5e3d371b54 19 * so I hacked the minimum spi driver for it (polling mode only).
Rhyme 0:cd5e3d371b54 20 */
Rhyme 0:cd5e3d371b54 21
Rhyme 0:cd5e3d371b54 22 #include "mbed.h"
Rhyme 0:cd5e3d371b54 23 #include <math.h>
Rhyme 0:cd5e3d371b54 24 #include "ILI9341.h"
trevieze 2:c5085faf2aa5 25 #include "SeeedStudioTFTv2.h"
trevieze 5:6eb4b9322931 26 #include "BNO055.h"
trevieze 5:6eb4b9322931 27 #include "HTU21D.h"
trevieze 5:6eb4b9322931 28 #include "BMP180.h"
trevieze 7:8aa9cdab4a07 29 #include "SDFileSystem.h"
trevieze 7:8aa9cdab4a07 30 #include "GPSISR.h"
trevieze 8:855884782f67 31
trevieze 5:6eb4b9322931 32
Rhyme 0:cd5e3d371b54 33 #include "Arial12x12.h"
Rhyme 0:cd5e3d371b54 34 #include "Arial24x23.h"
Rhyme 0:cd5e3d371b54 35 #include "Arial28x28.h"
Rhyme 0:cd5e3d371b54 36 #include "Arial43x48_numb.h"
Rhyme 0:cd5e3d371b54 37
trevieze 7:8aa9cdab4a07 38 //#define PIN_CS_TSC PA_9
trevieze 7:8aa9cdab4a07 39 //#define PIN_TSC_INTR PA_8
Rhyme 0:cd5e3d371b54 40 #define PIN_RESET_TFT PC_13 /* place holder */
trevieze 7:8aa9cdab4a07 41 //ILI9341 SPI PINS
trevieze 1:e265e7245ab8 42 #define PIN_XP A3
trevieze 1:e265e7245ab8 43 #define PIN_XM A1
trevieze 1:e265e7245ab8 44 #define PIN_YP A2
trevieze 1:e265e7245ab8 45 #define PIN_YM A0
trevieze 7:8aa9cdab4a07 46 #define PIN_MOSI_SPI1 D11 //SPI 1 MOSI
trevieze 7:8aa9cdab4a07 47 #define PIN_MISO_SPI1 D12 //SPI 1 MISO
trevieze 7:8aa9cdab4a07 48 #define PIN_SCLK_SPI1 D13 //SPI 1 SLCK
trevieze 7:8aa9cdab4a07 49 #define PIN_CS_SPI1 D5 // SPI CS D10 Was D5
trevieze 1:e265e7245ab8 50 #define PIN_DC_TFT D6
trevieze 1:e265e7245ab8 51 #define PIN_CS_SD D4
trevieze 5:6eb4b9322931 52 #define PIN_RESET D7
trevieze 7:8aa9cdab4a07 53 // SD Card on GPS shield PINS
trevieze 7:8aa9cdab4a07 54 #define PIN_MOSI_SPI3 PB_15 //SPI 1 MOSI
trevieze 7:8aa9cdab4a07 55 #define PIN_MISO_SPI3 PB_14 //SPI 1 MISO
trevieze 7:8aa9cdab4a07 56 #define PIN_SCLK_SPI3 PB_13 //SPI 1 SLCK
trevieze 7:8aa9cdab4a07 57 #define PIN_CS_SPI3 D2 // SPI CS
trevieze 7:8aa9cdab4a07 58 #define PIN_RX_GPS PA_12 //GPS Shield RX pin
trevieze 7:8aa9cdab4a07 59 #define PIN_TX_GPS PA_11 //GPS Shield TX pin
trevieze 7:8aa9cdab4a07 60
trevieze 5:6eb4b9322931 61
trevieze 5:6eb4b9322931 62 BNO055_ID_INF_TypeDef bno055_id_inf;
trevieze 5:6eb4b9322931 63 BNO055_EULER_TypeDef euler_angles;
trevieze 5:6eb4b9322931 64 BNO055_QUATERNION_TypeDef quaternion;
trevieze 5:6eb4b9322931 65 BNO055_LIN_ACC_TypeDef linear_acc;
trevieze 5:6eb4b9322931 66 BNO055_GRAVITY_TypeDef gravity;
trevieze 5:6eb4b9322931 67 BNO055_TEMPERATURE_TypeDef chip_temp;
trevieze 1:e265e7245ab8 68
Rhyme 0:cd5e3d371b54 69 #define DEVICE_NAME "F411RE"
Rhyme 0:cd5e3d371b54 70
Rhyme 0:cd5e3d371b54 71 #ifndef TARGET_NECLEO_F411RE
Rhyme 0:cd5e3d371b54 72 #define TARGET_NECLEO_F411RE
Rhyme 0:cd5e3d371b54 73 #endif
Rhyme 0:cd5e3d371b54 74
trevieze 6:b78ff34209e5 75
trevieze 6:b78ff34209e5 76 //DigitalOut backlight(PB_3) ;
trevieze 5:6eb4b9322931 77 // DigitalOut tsc_cs(PA_9, 1) ;
trevieze 5:6eb4b9322931 78 // DigitalOut tft_cs(PB_6, 1) ;
Rhyme 0:cd5e3d371b54 79
trevieze 7:8aa9cdab4a07 80 Serial pc(USBTX, USBRX);
trevieze 7:8aa9cdab4a07 81
trevieze 5:6eb4b9322931 82 // Display
Rhyme 0:cd5e3d371b54 83 ILI9341 TFT(SPI_8, 10000000,
trevieze 7:8aa9cdab4a07 84 PIN_MOSI_SPI1, PIN_MISO_SPI1, PIN_SCLK_SPI1,
trevieze 7:8aa9cdab4a07 85 PIN_CS_SPI1, PIN_RESET_TFT, PIN_DC_TFT, "Adafruit2.8") ;
trevieze 5:6eb4b9322931 86
trevieze 5:6eb4b9322931 87 // TouchScreen
trevieze 2:c5085faf2aa5 88 TouchScreen TSC(PIN_XP, PIN_XM, PIN_YP, PIN_YM);
Rhyme 0:cd5e3d371b54 89
trevieze 5:6eb4b9322931 90 // 3 Axis IMU
trevieze 6:b78ff34209e5 91 BNO055 imu(I2C_SDA, I2C_SCL, PIN_RESET); // Reset =D7, addr = BNO055_G_CHIP_ADDR, mode = MODE_NDOF <- as default
trevieze 5:6eb4b9322931 92
trevieze 5:6eb4b9322931 93 // Humidity and Temperature
trevieze 5:6eb4b9322931 94 HTU21D temphumid(I2C_SDA, I2C_SCL);
trevieze 5:6eb4b9322931 95
trevieze 5:6eb4b9322931 96 // Pressure
trevieze 6:b78ff34209e5 97 BMP180 bmp180(I2C_SDA, I2C_SCL);
trevieze 5:6eb4b9322931 98
trevieze 7:8aa9cdab4a07 99 // SD Card Reader On Adafruit GPS Shield
trevieze 7:8aa9cdab4a07 100 SDFileSystem sd(PIN_MOSI_SPI3, PIN_MISO_SPI3, PIN_SCLK_SPI3, PIN_CS_SPI3, "sd"); // the pinout on the mbed Cool Components workshop board
trevieze 7:8aa9cdab4a07 101
trevieze 8:855884782f67 102 // Set up serial interrupe service handler for gps characters.
trevieze 7:8aa9cdab4a07 103 GPS MyGPS(PIN_TX_GPS,PIN_RX_GPS, 9600);
trevieze 8:855884782f67 104
trevieze 7:8aa9cdab4a07 105
Rhyme 0:cd5e3d371b54 106 int page = 0 ;
Rhyme 0:cd5e3d371b54 107 int numPage = 2 ;
Rhyme 0:cd5e3d371b54 108
Rhyme 0:cd5e3d371b54 109 void initTFT(void)
Rhyme 0:cd5e3d371b54 110 {
Rhyme 0:cd5e3d371b54 111 //Configure the display driver
Rhyme 0:cd5e3d371b54 112 TFT.BusEnable(true) ;
Rhyme 0:cd5e3d371b54 113 TFT.FastWindow(true) ;
Rhyme 0:cd5e3d371b54 114 TFT.background(Black);
Rhyme 0:cd5e3d371b54 115 TFT.foreground(White);
Rhyme 0:cd5e3d371b54 116 wait(0.01) ;
Rhyme 0:cd5e3d371b54 117 TFT.cls();
Rhyme 0:cd5e3d371b54 118 TFT.BusEnable(false) ;
Rhyme 0:cd5e3d371b54 119 }
Rhyme 0:cd5e3d371b54 120
Rhyme 0:cd5e3d371b54 121 void screen1(void) // Welcome Screen
Rhyme 0:cd5e3d371b54 122 {
Rhyme 0:cd5e3d371b54 123 TFT.BusEnable(true) ;
trevieze 6:b78ff34209e5 124 //backlight = 0 ;
Rhyme 0:cd5e3d371b54 125 TFT.background(White) ;
Rhyme 0:cd5e3d371b54 126 wait(0.1) ;
Rhyme 0:cd5e3d371b54 127 TFT.cls() ;
Rhyme 0:cd5e3d371b54 128 wait(0.1) ;
Rhyme 0:cd5e3d371b54 129
Rhyme 0:cd5e3d371b54 130 TFT.set_font((unsigned char*) Arial24x23);
Rhyme 0:cd5e3d371b54 131 TFT.foreground(Red) ;
Rhyme 0:cd5e3d371b54 132 TFT.locate(80, 40) ;
trevieze 7:8aa9cdab4a07 133 TFT.printf("MBED") ;
Rhyme 0:cd5e3d371b54 134 TFT.foreground(Blue);
Rhyme 0:cd5e3d371b54 135 TFT.locate(60, 80) ;
Rhyme 0:cd5e3d371b54 136 TFT.printf("2.8\"TFT") ;
Rhyme 0:cd5e3d371b54 137 TFT.locate(40, 120) ;
Rhyme 0:cd5e3d371b54 138 TFT.printf("with touch") ;
Rhyme 0:cd5e3d371b54 139 TFT.foreground(Black);
Rhyme 0:cd5e3d371b54 140 TFT.set_font((unsigned char*) Arial12x12);
Rhyme 0:cd5e3d371b54 141 TFT.foreground(Blue) ;
Rhyme 0:cd5e3d371b54 142 TFT.locate(30, 180) ;
Rhyme 0:cd5e3d371b54 143 TFT.printf("This program is running on") ;
Rhyme 0:cd5e3d371b54 144 TFT.locate(30, 200) ;
Rhyme 0:cd5e3d371b54 145 TFT.printf("ST Nucleo F411RE with") ;
Rhyme 0:cd5e3d371b54 146 TFT.locate(30, 220) ;
Rhyme 0:cd5e3d371b54 147 TFT.printf("a program developed in mbed") ;
Rhyme 0:cd5e3d371b54 148 TFT.foreground(Green) ;
Rhyme 0:cd5e3d371b54 149 TFT.locate(30, 260) ;
Rhyme 0:cd5e3d371b54 150 TFT.printf("To advance demo page, touch") ;
Rhyme 0:cd5e3d371b54 151 TFT.locate(30, 280) ;
Rhyme 0:cd5e3d371b54 152 TFT.printf("and hold right side of screen") ;
Rhyme 0:cd5e3d371b54 153 TFT.locate(30, 300) ;
Rhyme 0:cd5e3d371b54 154 TFT.printf("until the next screen starts") ;
Rhyme 0:cd5e3d371b54 155 TFT.BusEnable(false) ;
trevieze 6:b78ff34209e5 156 //backlight = 1 ;
Rhyme 0:cd5e3d371b54 157 }
Rhyme 0:cd5e3d371b54 158
Rhyme 0:cd5e3d371b54 159 void screen2(void) // Graphics
Rhyme 0:cd5e3d371b54 160 {
Rhyme 0:cd5e3d371b54 161 //Draw some graphics
Rhyme 0:cd5e3d371b54 162 int i, x[2], y[2] ;
trevieze 6:b78ff34209e5 163 //backlight = 0 ;
Rhyme 0:cd5e3d371b54 164 TFT.BusEnable(true) ;
Rhyme 0:cd5e3d371b54 165 TFT.background(Black);
Rhyme 0:cd5e3d371b54 166 wait(0.1) ;
Rhyme 0:cd5e3d371b54 167 TFT.foreground(White);
Rhyme 0:cd5e3d371b54 168 wait(0.1) ;
Rhyme 0:cd5e3d371b54 169 TFT.cls() ;
Rhyme 0:cd5e3d371b54 170 wait(0.1) ;
Rhyme 0:cd5e3d371b54 171 TFT.set_font((unsigned char*) Arial12x12);
Rhyme 0:cd5e3d371b54 172 TFT.locate(90,0);
Rhyme 0:cd5e3d371b54 173 TFT.printf("Graphics");
Rhyme 0:cd5e3d371b54 174
Rhyme 0:cd5e3d371b54 175 x[0] = 25 ; x[1] = 224 ;
Rhyme 0:cd5e3d371b54 176 y[0] = 20 ; y[1] = 219 ;
Rhyme 0:cd5e3d371b54 177 for (i = 20 ; i < 220 ; i += 10) {
Rhyme 0:cd5e3d371b54 178 TFT.line(i+5, y[0], i+5, y[1], Blue) ;
Rhyme 0:cd5e3d371b54 179 TFT.line(x[0], i, x[1], i, Blue) ;
Rhyme 0:cd5e3d371b54 180 }
Rhyme 0:cd5e3d371b54 181 TFT.line(125, y[0], 125, y[1], Green) ;
Rhyme 0:cd5e3d371b54 182 TFT.line(x[0], 120, x[1], 120, Green) ;
Rhyme 0:cd5e3d371b54 183 TFT.rect(x[0],y[0], x[1], y[1], Green) ;
Rhyme 0:cd5e3d371b54 184 TFT.locate(10, 20) ;
Rhyme 0:cd5e3d371b54 185 TFT.printf("V") ;
Rhyme 0:cd5e3d371b54 186 TFT.locate(0, 115) ;
Rhyme 0:cd5e3d371b54 187 TFT.printf("0.0") ;
Rhyme 0:cd5e3d371b54 188 TFT.locate(115, 225) ;
Rhyme 0:cd5e3d371b54 189 TFT.printf("0.0") ;
Rhyme 0:cd5e3d371b54 190 TFT.locate(215, 225) ;
Rhyme 0:cd5e3d371b54 191 TFT.printf("T") ;
Rhyme 0:cd5e3d371b54 192
Rhyme 0:cd5e3d371b54 193 double s;
Rhyme 0:cd5e3d371b54 194 for (int i = x[0]; i < 225; i++) {
Rhyme 0:cd5e3d371b54 195 s = 40 * sin((long double)i / 20);
Rhyme 0:cd5e3d371b54 196 TFT.pixel(i, 120 + (int)s, White);
Rhyme 0:cd5e3d371b54 197 }
Rhyme 0:cd5e3d371b54 198
Rhyme 0:cd5e3d371b54 199 TFT.fillrect(10, 240, 229, 309, White) ;
Rhyme 0:cd5e3d371b54 200 TFT.rect(10, 240, 229, 309, Red) ;
Rhyme 0:cd5e3d371b54 201 TFT.rect(11, 241, 228, 308, Red) ;
Rhyme 0:cd5e3d371b54 202
Rhyme 0:cd5e3d371b54 203 TFT.background(White) ;
Rhyme 0:cd5e3d371b54 204 TFT.foreground(Black) ;
Rhyme 0:cd5e3d371b54 205 TFT.locate(20, 250) ;
Rhyme 0:cd5e3d371b54 206 TFT.printf("With QVGA resolution") ;
Rhyme 0:cd5e3d371b54 207 TFT.locate(20, 270) ;
Rhyme 0:cd5e3d371b54 208 TFT.printf("simple graphics drawing") ;
Rhyme 0:cd5e3d371b54 209 TFT.locate(20, 290) ;
Rhyme 0:cd5e3d371b54 210 TFT.printf("capability is provided") ;
Rhyme 0:cd5e3d371b54 211 TFT.BusEnable(false) ;
trevieze 6:b78ff34209e5 212 //backlight = 1 ;
Rhyme 0:cd5e3d371b54 213 }
Rhyme 0:cd5e3d371b54 214
Rhyme 0:cd5e3d371b54 215 double clip(double src)
Rhyme 0:cd5e3d371b54 216 {
Rhyme 0:cd5e3d371b54 217 double value ;
Rhyme 0:cd5e3d371b54 218 value = src ;
Rhyme 0:cd5e3d371b54 219 if (value < 0.0) {
Rhyme 0:cd5e3d371b54 220 value = 0.0 ;
Rhyme 0:cd5e3d371b54 221 } else if (value > 2.0) {
Rhyme 0:cd5e3d371b54 222 value = 2.0 ;
Rhyme 0:cd5e3d371b54 223 }
Rhyme 0:cd5e3d371b54 224 return( value ) ;
Rhyme 0:cd5e3d371b54 225 }
Rhyme 0:cd5e3d371b54 226
Rhyme 0:cd5e3d371b54 227 void incPage(void)
Rhyme 0:cd5e3d371b54 228 {
Rhyme 0:cd5e3d371b54 229 page++ ;
Rhyme 0:cd5e3d371b54 230 if (page >= numPage) {
Rhyme 0:cd5e3d371b54 231 page = 0 ;
Rhyme 0:cd5e3d371b54 232 }
Rhyme 0:cd5e3d371b54 233 }
Rhyme 0:cd5e3d371b54 234
Rhyme 0:cd5e3d371b54 235 void decPage(void)
Rhyme 0:cd5e3d371b54 236 {
Rhyme 0:cd5e3d371b54 237 page-- ;
Rhyme 0:cd5e3d371b54 238 if (page < 0) {
Rhyme 0:cd5e3d371b54 239 page = numPage - 1 ;
Rhyme 0:cd5e3d371b54 240 }
Rhyme 0:cd5e3d371b54 241 }
Rhyme 0:cd5e3d371b54 242
trevieze 7:8aa9cdab4a07 243
Rhyme 0:cd5e3d371b54 244 int main()
Rhyme 0:cd5e3d371b54 245 {
trevieze 7:8aa9cdab4a07 246 Timer refresh_Timer; //sets up a timer for use in loop; how often do we print GPS info?
trevieze 8:855884782f67 247 const int refresh_Time = 1000; //refresh time in ms
trevieze 7:8aa9cdab4a07 248 refresh_Timer.start(); //starts the clock on the timer
trevieze 7:8aa9cdab4a07 249 TFT.BusEnable(true) ;
trevieze 7:8aa9cdab4a07 250 //backlight = 0 ;
trevieze 7:8aa9cdab4a07 251 TFT.background(White) ;
trevieze 7:8aa9cdab4a07 252 wait(0.1) ;
trevieze 7:8aa9cdab4a07 253 TFT.cls() ;
trevieze 7:8aa9cdab4a07 254 wait(0.1) ;
trevieze 7:8aa9cdab4a07 255 while (1) {
trevieze 7:8aa9cdab4a07 256 //check if we recieved a new message from GPS, if so, attempt to parse it,
trevieze 7:8aa9cdab4a07 257 if (refresh_Timer.read_ms() >= refresh_Time) {
trevieze 7:8aa9cdab4a07 258 refresh_Timer.reset();
trevieze 7:8aa9cdab4a07 259 //pc.printf("Time: %f\n", myGPS.time);
trevieze 7:8aa9cdab4a07 260 //MyGPS.getline();
trevieze 7:8aa9cdab4a07 261 //pc.printf("%s", MyGPS.msg[0]);
trevieze 8:855884782f67 262 pc.printf("rx_int: %c \n", MyGPS.rx_in);
trevieze 8:855884782f67 263
trevieze 8:855884782f67 264 if (MyGPS.isdatardy()) {
trevieze 8:855884782f67 265 pc.printf("NMEA has valid data");
trevieze 8:855884782f67 266 pc.printf("Sats : %d \n", MyGPS.getSats());
trevieze 8:855884782f67 267 }
trevieze 8:855884782f67 268 else {
trevieze 8:855884782f67 269 pc.printf("NMEA has no valid data");
trevieze 8:855884782f67 270 }
trevieze 8:855884782f67 271
trevieze 7:8aa9cdab4a07 272 TFT.set_font((unsigned char*) Arial12x12);
trevieze 7:8aa9cdab4a07 273 TFT.foreground(Blue);
trevieze 7:8aa9cdab4a07 274 TFT.locate(2, 2);
trevieze 7:8aa9cdab4a07 275 //TFT.printf("Time: %f\n", myGPS.time);
trevieze 7:8aa9cdab4a07 276 TFT.BusEnable(false) ;
trevieze 7:8aa9cdab4a07 277 }
trevieze 7:8aa9cdab4a07 278 }
trevieze 6:b78ff34209e5 279
trevieze 5:6eb4b9322931 280 // uint16_t x, y, z ;
Rhyme 0:cd5e3d371b54 281 int prevPage = 99 ;
Rhyme 0:cd5e3d371b54 282 bool waitTouch = false ;
trevieze 2:c5085faf2aa5 283 point p;
Rhyme 0:cd5e3d371b54 284
Rhyme 0:cd5e3d371b54 285 printf("Hello World\n") ;
trevieze 6:b78ff34209e5 286
trevieze 5:6eb4b9322931 287 // screen0() ;
Rhyme 0:cd5e3d371b54 288
Rhyme 0:cd5e3d371b54 289 printf("Program Started!\n\r") ;
Rhyme 0:cd5e3d371b54 290
Rhyme 0:cd5e3d371b54 291 for(;;) {
Rhyme 0:cd5e3d371b54 292 // printf("TFT width = %d, height = %d\n\r", TFT.width(), TFT.height()) ;
trevieze 5:6eb4b9322931 293 // tft_cs = 0 ;
Rhyme 0:cd5e3d371b54 294 switch(page) {
Rhyme 0:cd5e3d371b54 295 case 0:
Rhyme 0:cd5e3d371b54 296 if (prevPage != page) {
Rhyme 0:cd5e3d371b54 297 screen1() ;
Rhyme 0:cd5e3d371b54 298 }
Rhyme 0:cd5e3d371b54 299 waitTouch = true ;
Rhyme 0:cd5e3d371b54 300 break ;
Rhyme 0:cd5e3d371b54 301 case 1:
Rhyme 0:cd5e3d371b54 302 if (prevPage != page) {
Rhyme 0:cd5e3d371b54 303 screen2() ;
Rhyme 0:cd5e3d371b54 304 }
Rhyme 0:cd5e3d371b54 305 waitTouch = true ;
Rhyme 0:cd5e3d371b54 306 break ;
Rhyme 0:cd5e3d371b54 307 default:
Rhyme 0:cd5e3d371b54 308 page = 0 ;
Rhyme 0:cd5e3d371b54 309 break ;
Rhyme 0:cd5e3d371b54 310 }
Rhyme 0:cd5e3d371b54 311 prevPage = page ;
Rhyme 0:cd5e3d371b54 312
trevieze 5:6eb4b9322931 313 // tft_cs = 1 ;
Rhyme 0:cd5e3d371b54 314 do {
trevieze 2:c5085faf2aa5 315 TSC.getTouch(p);
trevieze 6:b78ff34209e5 316 //printf("Touched X %d\n\r", p.x) ;
trevieze 6:b78ff34209e5 317 //printf("Touched Y %d\n\r", p.y) ;
trevieze 6:b78ff34209e5 318 //printf("Touched Z %d\n\r", p.z) ;
trevieze 4:25554dc066a0 319 wait(3) ;
trevieze 2:c5085faf2aa5 320 if (p.z > __PRESURE) {
trevieze 2:c5085faf2aa5 321 if (p.y < 30000) { // left
Rhyme 0:cd5e3d371b54 322 decPage() ;
trevieze 2:c5085faf2aa5 323 } else if (p.y > 90000) { // right
Rhyme 0:cd5e3d371b54 324 incPage() ;
Rhyme 0:cd5e3d371b54 325 }
Rhyme 0:cd5e3d371b54 326 waitTouch = false ;
Rhyme 0:cd5e3d371b54 327 }
trevieze 2:c5085faf2aa5 328 //tsc_cs = 1 ;
trevieze 2:c5085faf2aa5 329 }
trevieze 2:c5085faf2aa5 330 while(waitTouch != false) ;
trevieze 3:6f47fcd415ab 331 //wait(1) ;
Rhyme 0:cd5e3d371b54 332 }
Rhyme 0:cd5e3d371b54 333 }