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 Apr 28 01:46:36 2017 +0000
Revision:
15:27e0a1721d13
Parent:
14:b174ec6e3ca0
Child:
17:4f10efd72d9d
Child:
18:50520438c129
Finished Bicycle Computer screen.

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 */
trevieze 15:27e0a1721d13 12
trevieze 15:27e0a1721d13 13 /*
trevieze 15:27e0a1721d13 14 * Note: This program is derived from the SeeeStudioTFTv2 program.
trevieze 15:27e0a1721d13 15 * Although both program share same ILI9341 TFT driver,
trevieze 15:27e0a1721d13 16 * the touch sensor was not same with the Display I purchased from Akizuki.
trevieze 15:27e0a1721d13 17 * http://akizukidenshi.com/catalog/g/gM-07747/
trevieze 15:27e0a1721d13 18 * The touch sensor on the display is STMPE610,
trevieze 15:27e0a1721d13 19 * so I hacked the minimum spi driver for it (polling mode only).
trevieze 15:27e0a1721d13 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 14:b174ec6e3ca0 25 //#include "TFT.h"
trevieze 14:b174ec6e3ca0 26 // Graphics GUI Library
trevieze 14:b174ec6e3ca0 27 #include "ugui.h"
trevieze 14:b174ec6e3ca0 28
trevieze 2:c5085faf2aa5 29 #include "SeeedStudioTFTv2.h"
trevieze 5:6eb4b9322931 30 #include "BNO055.h"
trevieze 5:6eb4b9322931 31 #include "HTU21D.h"
trevieze 5:6eb4b9322931 32 #include "BMP180.h"
trevieze 7:8aa9cdab4a07 33 #include "SDFileSystem.h"
trevieze 7:8aa9cdab4a07 34 #include "GPSISR.h"
trevieze 12:1a9c0f9d7128 35 #include "nav.h"
trevieze 8:855884782f67 36
trevieze 5:6eb4b9322931 37
trevieze 10:869a102dd31c 38 #include "ArialR16x17.h"
trevieze 10:869a102dd31c 39 #include "Arial24x23i.h"
trevieze 10:869a102dd31c 40 #include "Arial28x28.h"
trevieze 10:869a102dd31c 41 #include "Neu44x36.h"
trevieze 10:869a102dd31c 42 #include "SCProSB31x55.h"
Rhyme 0:cd5e3d371b54 43 #include "Arial12x12.h"
trevieze 10:869a102dd31c 44 #include "ArialR20x20.h"
trevieze 15:27e0a1721d13 45 #include "Compass.h"
Rhyme 0:cd5e3d371b54 46
trevieze 15:27e0a1721d13 47 //#define PIN_CS_TSC PA_9
trevieze 7:8aa9cdab4a07 48 //#define PIN_TSC_INTR PA_8
Rhyme 0:cd5e3d371b54 49 #define PIN_RESET_TFT PC_13 /* place holder */
trevieze 7:8aa9cdab4a07 50 //ILI9341 SPI PINS
trevieze 1:e265e7245ab8 51 #define PIN_XP A3
trevieze 1:e265e7245ab8 52 #define PIN_XM A1
trevieze 1:e265e7245ab8 53 #define PIN_YP A2
trevieze 1:e265e7245ab8 54 #define PIN_YM A0
trevieze 7:8aa9cdab4a07 55 #define PIN_MOSI_SPI1 D11 //SPI 1 MOSI
trevieze 7:8aa9cdab4a07 56 #define PIN_MISO_SPI1 D12 //SPI 1 MISO
trevieze 7:8aa9cdab4a07 57 #define PIN_SCLK_SPI1 D13 //SPI 1 SLCK
trevieze 7:8aa9cdab4a07 58 #define PIN_CS_SPI1 D5 // SPI CS D10 Was D5
trevieze 1:e265e7245ab8 59 #define PIN_DC_TFT D6
trevieze 1:e265e7245ab8 60 #define PIN_CS_SD D4
trevieze 5:6eb4b9322931 61 #define PIN_RESET D7
trevieze 7:8aa9cdab4a07 62 // SD Card on GPS shield PINS
trevieze 7:8aa9cdab4a07 63 #define PIN_MOSI_SPI3 PB_15 //SPI 1 MOSI
trevieze 7:8aa9cdab4a07 64 #define PIN_MISO_SPI3 PB_14 //SPI 1 MISO
trevieze 7:8aa9cdab4a07 65 #define PIN_SCLK_SPI3 PB_13 //SPI 1 SLCK
trevieze 7:8aa9cdab4a07 66 #define PIN_CS_SPI3 D2 // SPI CS
trevieze 7:8aa9cdab4a07 67 #define PIN_RX_GPS PA_12 //GPS Shield RX pin
trevieze 7:8aa9cdab4a07 68 #define PIN_TX_GPS PA_11 //GPS Shield TX pin
trevieze 7:8aa9cdab4a07 69
trevieze 10:869a102dd31c 70 #define PI 3.14159265358979f
trevieze 14:b174ec6e3ca0 71 BNO055_ID_INF_TypeDef bno055_id_inf;
trevieze 14:b174ec6e3ca0 72 BNO055_EULER_TypeDef euler_angles;
trevieze 14:b174ec6e3ca0 73 BNO055_QUATERNION_TypeDef quaternion;
trevieze 14:b174ec6e3ca0 74 BNO055_LIN_ACC_TypeDef linear_acc;
trevieze 14:b174ec6e3ca0 75 BNO055_GRAVITY_TypeDef gravity;
trevieze 14:b174ec6e3ca0 76 BNO055_TEMPERATURE_TypeDef chip_temp;
trevieze 10:869a102dd31c 77
Rhyme 0:cd5e3d371b54 78 #define DEVICE_NAME "F411RE"
Rhyme 0:cd5e3d371b54 79
Rhyme 0:cd5e3d371b54 80 #ifndef TARGET_NECLEO_F411RE
trevieze 15:27e0a1721d13 81 #define TARGET_NECLEO_F411RE
Rhyme 0:cd5e3d371b54 82 #endif
Rhyme 0:cd5e3d371b54 83
trevieze 6:b78ff34209e5 84 //DigitalOut backlight(PB_3) ;
trevieze 5:6eb4b9322931 85 // DigitalOut tsc_cs(PA_9, 1) ;
trevieze 5:6eb4b9322931 86 // DigitalOut tft_cs(PB_6, 1) ;
Rhyme 0:cd5e3d371b54 87
trevieze 14:b174ec6e3ca0 88 /** Height of display using default orientation */
trevieze 14:b174ec6e3ca0 89 #define ILI9341_DEFAULT_HEIGHT 240
trevieze 14:b174ec6e3ca0 90
trevieze 14:b174ec6e3ca0 91 /** Width of display using default orientation */
trevieze 14:b174ec6e3ca0 92 #define ILI9341_DEFAULT_WIDTH 320
trevieze 14:b174ec6e3ca0 93
trevieze 14:b174ec6e3ca0 94 /** Height of display using swapped X/Y orientation */
trevieze 14:b174ec6e3ca0 95 #define ILI9341_SWITCH_XY_HEIGHT 320
trevieze 14:b174ec6e3ca0 96
trevieze 14:b174ec6e3ca0 97 /** Width of display using swapped X/Y orientation */
trevieze 14:b174ec6e3ca0 98 #define ILI9341_SWITCH_XY_WIDTH 240
trevieze 14:b174ec6e3ca0 99
trevieze 7:8aa9cdab4a07 100 Serial pc(USBTX, USBRX);
trevieze 7:8aa9cdab4a07 101
trevieze 5:6eb4b9322931 102 // Display
trevieze 15:27e0a1721d13 103 ILI9341 TFT(SPI_8, 20000000,
trevieze 15:27e0a1721d13 104 PIN_MOSI_SPI1, PIN_MISO_SPI1, PIN_SCLK_SPI1,
trevieze 15:27e0a1721d13 105 PIN_CS_SPI1, PIN_RESET_TFT, PIN_DC_TFT, "Adafruit2.8") ;
trevieze 15:27e0a1721d13 106
trevieze 5:6eb4b9322931 107 // TouchScreen
trevieze 2:c5085faf2aa5 108 TouchScreen TSC(PIN_XP, PIN_XM, PIN_YP, PIN_YM);
Rhyme 0:cd5e3d371b54 109
trevieze 5:6eb4b9322931 110 // 3 Axis IMU
trevieze 14:b174ec6e3ca0 111 BNO055 imu(I2C_SDA, I2C_SCL, PIN_RESET); // Reset =D7, addr = BNO055_G_CHIP_ADDR, mode = MODE_NDOF <- as default
trevieze 5:6eb4b9322931 112 // Humidity and Temperature
trevieze 10:869a102dd31c 113 HTU21D humid(I2C_SDA, I2C_SCL);
trevieze 5:6eb4b9322931 114
trevieze 5:6eb4b9322931 115 // Pressure
trevieze 6:b78ff34209e5 116 BMP180 bmp180(I2C_SDA, I2C_SCL);
trevieze 5:6eb4b9322931 117
trevieze 7:8aa9cdab4a07 118 // SD Card Reader On Adafruit GPS Shield
trevieze 7:8aa9cdab4a07 119 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 120
trevieze 8:855884782f67 121 // Set up serial interrupe service handler for gps characters.
trevieze 7:8aa9cdab4a07 122 GPS MyGPS(PIN_TX_GPS,PIN_RX_GPS, 9600);
trevieze 8:855884782f67 123
trevieze 12:1a9c0f9d7128 124 //Navigation Class.
trevieze 12:1a9c0f9d7128 125 NAV nav;
trevieze 12:1a9c0f9d7128 126 double plat = 42.826420;
trevieze 12:1a9c0f9d7128 127 double plon = -84.219413;
trevieze 12:1a9c0f9d7128 128
trevieze 10:869a102dd31c 129 void Draw_Compass_Rose(void);
trevieze 10:869a102dd31c 130 void arrow(int x2, int y2, int x1, int y1, int alength, int awidth, int colour);
trevieze 14:b174ec6e3ca0 131 void ili9341_pset(UG_S16 ul_x,UG_S16 ul_y, UG_COLOR ul_color);
trevieze 14:b174ec6e3ca0 132 void window_1_callback( UG_MESSAGE* msg );
trevieze 14:b174ec6e3ca0 133 void window_2_callback( UG_MESSAGE* msg );
trevieze 14:b174ec6e3ca0 134 void window_3_callback( UG_MESSAGE* msg );
trevieze 14:b174ec6e3ca0 135 void cb1(void);
Rhyme 0:cd5e3d371b54 136
trevieze 10:869a102dd31c 137 const int centreX = 120;
trevieze 10:869a102dd31c 138 const int centreY = 150;
trevieze 15:27e0a1721d13 139 const int radius = 40;
trevieze 11:49600de70963 140 float last_dx;
trevieze 11:49600de70963 141 float last_dy;
Rhyme 0:cd5e3d371b54 142
trevieze 14:b174ec6e3ca0 143 int pageid = 1;
trevieze 14:b174ec6e3ca0 144 bool pageinit = 0;
trevieze 14:b174ec6e3ca0 145 #define PAGE1 1
trevieze 14:b174ec6e3ca0 146 #define PAGE2 2
trevieze 14:b174ec6e3ca0 147 #define PAGE3 3
trevieze 14:b174ec6e3ca0 148
trevieze 15:27e0a1721d13 149 const UG_BMP compass = {
trevieze 15:27e0a1721d13 150 (void*) compass_bmp ,
trevieze 15:27e0a1721d13 151 200 ,
trevieze 15:27e0a1721d13 152 200 ,
trevieze 15:27e0a1721d13 153 BMP_BPP_16 ,
trevieze 15:27e0a1721d13 154 BMP_RGB565
trevieze 15:27e0a1721d13 155 } ;
trevieze 15:27e0a1721d13 156
trevieze 14:b174ec6e3ca0 157 UG_GUI gui;
trevieze 14:b174ec6e3ca0 158
trevieze 14:b174ec6e3ca0 159 //Ticker to1;
trevieze 14:b174ec6e3ca0 160
Rhyme 0:cd5e3d371b54 161 int main()
Rhyme 0:cd5e3d371b54 162 {
trevieze 15:27e0a1721d13 163 //to1.attach(&cb1, 2.0);
trevieze 9:a3cb458d7b1c 164 TFT.BusEnable(true) ;
trevieze 9:a3cb458d7b1c 165 TFT.FastWindow(true) ;
trevieze 9:a3cb458d7b1c 166 wait(0.1);
trevieze 9:a3cb458d7b1c 167 TFT.cls();
trevieze 9:a3cb458d7b1c 168 wait(0.1);
trevieze 15:27e0a1721d13 169
trevieze 15:27e0a1721d13 170 UG_Init(&gui,ili9341_pset,ILI9341_DEFAULT_HEIGHT,ILI9341_DEFAULT_WIDTH);
trevieze 15:27e0a1721d13 171
trevieze 7:8aa9cdab4a07 172 Timer refresh_Timer; //sets up a timer for use in loop; how often do we print GPS info?
trevieze 9:a3cb458d7b1c 173 const int refresh_Time = 2000; //refresh time in ms
trevieze 7:8aa9cdab4a07 174 refresh_Timer.start(); //starts the clock on the timer
trevieze 7:8aa9cdab4a07 175 //backlight = 0 ;
trevieze 9:a3cb458d7b1c 176 wait(0.1);
trevieze 15:27e0a1721d13 177
trevieze 15:27e0a1721d13 178 // Draw_Compass_Rose();
trevieze 14:b174ec6e3ca0 179 /* Window 1 Bike Computer */
trevieze 15:27e0a1721d13 180 #define MAX_OBJECTS 10
trevieze 14:b174ec6e3ca0 181 UG_WINDOW window_1 ; /* Window */
trevieze 14:b174ec6e3ca0 182 UG_BUTTON button_1; /* Button container */
trevieze 14:b174ec6e3ca0 183 UG_BUTTON button_2; /* Button container */
trevieze 14:b174ec6e3ca0 184 UG_OBJECT obj_buff_wnd_1 [MAX_OBJECTS] ; /* Object buffer */
trevieze 14:b174ec6e3ca0 185 UG_WindowCreate ( &window_1 , obj_buff_wnd_1 , MAX_OBJECTS, window_1_callback);
trevieze 14:b174ec6e3ca0 186 UG_WindowSetTitleTextFont ( &window_1 , &FONT_8X8 ) ;
trevieze 14:b174ec6e3ca0 187 UG_WindowSetTitleText ( &window_1 , "Bike Computer" ) ;
trevieze 14:b174ec6e3ca0 188 UG_WindowSetBackColor( &window_1 , C_GRAY ) ;
trevieze 14:b174ec6e3ca0 189 UG_ButtonCreate (&window_1, &button_1, BTN_ID_0, 10 , 230 , 115 , 290 );
trevieze 14:b174ec6e3ca0 190 UG_ButtonCreate (&window_1, &button_2, BTN_ID_1, 125 , 230 , 225 , 290 );
trevieze 14:b174ec6e3ca0 191 UG_ButtonSetBackColor (&window_1 ,BTN_ID_0 , C_BLUE ) ;
trevieze 14:b174ec6e3ca0 192 UG_ButtonSetForeColor (&window_1 ,BTN_ID_0 , C_WHITE ) ;
trevieze 14:b174ec6e3ca0 193 UG_ButtonSetBackColor (&window_1 ,BTN_ID_1 , C_BLUE ) ;
trevieze 14:b174ec6e3ca0 194 UG_ButtonSetForeColor (&window_1 ,BTN_ID_1 , C_WHITE ) ;
trevieze 14:b174ec6e3ca0 195 UG_ButtonSetFont (&window_1 , BTN_ID_0 , &FONT_8X8) ;
trevieze 14:b174ec6e3ca0 196 UG_ButtonSetFont (&window_1 , BTN_ID_1 , &FONT_8X8) ;
trevieze 14:b174ec6e3ca0 197 UG_ButtonSetText (&window_1 , BTN_ID_0 , "Prev" );
trevieze 14:b174ec6e3ca0 198 UG_ButtonSetText (&window_1 , BTN_ID_1 , "Next" );
trevieze 15:27e0a1721d13 199
trevieze 14:b174ec6e3ca0 200 /* Window 2 e-Compass */
trevieze 14:b174ec6e3ca0 201 UG_WINDOW window_2 ; /* Window */
trevieze 14:b174ec6e3ca0 202 UG_BUTTON button_3; /* Button container */
trevieze 14:b174ec6e3ca0 203 UG_BUTTON button_4; /* Button container */
trevieze 14:b174ec6e3ca0 204 UG_OBJECT obj_buff_wnd_2 [MAX_OBJECTS] ; /* Object buffer */
trevieze 14:b174ec6e3ca0 205 UG_WindowCreate ( &window_2 , obj_buff_wnd_2 , MAX_OBJECTS, window_2_callback);
trevieze 14:b174ec6e3ca0 206 UG_WindowSetTitleTextFont ( &window_2 , &FONT_8X8 ) ;
trevieze 14:b174ec6e3ca0 207 UG_WindowSetTitleText ( &window_2 , "e-Compass" ) ;
trevieze 14:b174ec6e3ca0 208 UG_WindowSetBackColor( &window_2 , C_GRAY ) ;
trevieze 14:b174ec6e3ca0 209 UG_ButtonCreate (&window_2, &button_3, BTN_ID_2, 10 , 230 , 115 , 290 );
trevieze 14:b174ec6e3ca0 210 UG_ButtonCreate (&window_2, &button_4, BTN_ID_3, 125 , 230 , 225 , 290 );
trevieze 14:b174ec6e3ca0 211 UG_ButtonSetBackColor (&window_2 ,BTN_ID_2 , C_BLUE ) ;
trevieze 14:b174ec6e3ca0 212 UG_ButtonSetForeColor (&window_2 ,BTN_ID_2 , C_WHITE ) ;
trevieze 14:b174ec6e3ca0 213 UG_ButtonSetBackColor (&window_2 ,BTN_ID_3 , C_BLUE ) ;
trevieze 14:b174ec6e3ca0 214 UG_ButtonSetForeColor (&window_2 ,BTN_ID_3 , C_WHITE ) ;
trevieze 14:b174ec6e3ca0 215 UG_ButtonSetFont (&window_2 , BTN_ID_2 , &FONT_8X8) ;
trevieze 14:b174ec6e3ca0 216 UG_ButtonSetFont (&window_2 , BTN_ID_3 , &FONT_8X8) ;
trevieze 14:b174ec6e3ca0 217 UG_ButtonSetText (&window_2 , BTN_ID_2 , "Prev" );
trevieze 14:b174ec6e3ca0 218 UG_ButtonSetText (&window_2 , BTN_ID_3 , "Next" );
trevieze 15:27e0a1721d13 219 /*Create the image */
trevieze 15:27e0a1721d13 220 //UG_IMAGE image_1;
trevieze 15:27e0a1721d13 221 //UG_ImageCreate(&window_2 ,&image_1 ,IMG_ID_0 ,(UG_WindowGetInnerWidth(&
trevieze 15:27e0a1721d13 222 // window_2)>>1) - (compass.width>>1) ,10 ,0 ,0) ;
trevieze 15:27e0a1721d13 223 //UG_ImageSetBMP(&window_2, IMG_ID_0 ,&compass) ;
trevieze 15:27e0a1721d13 224
trevieze 14:b174ec6e3ca0 225
trevieze 14:b174ec6e3ca0 226 /* Window 3 GSP */
trevieze 14:b174ec6e3ca0 227 UG_WINDOW window_3 ; /* Window */
trevieze 14:b174ec6e3ca0 228 UG_BUTTON button_5; /* Button container */
trevieze 14:b174ec6e3ca0 229 UG_BUTTON button_6; /* Button container */
trevieze 14:b174ec6e3ca0 230 UG_OBJECT obj_buff_wnd_3 [MAX_OBJECTS] ; /* Object buffer */
trevieze 14:b174ec6e3ca0 231 UG_WindowCreate ( &window_3 , obj_buff_wnd_3 , MAX_OBJECTS, window_3_callback);
trevieze 14:b174ec6e3ca0 232 UG_WindowSetTitleTextFont ( &window_3 , &FONT_8X8 ) ;
trevieze 14:b174ec6e3ca0 233 UG_WindowSetTitleText ( &window_3 , "GPS Waypoints" ) ;
trevieze 14:b174ec6e3ca0 234 UG_WindowSetBackColor( &window_3 , C_GRAY ) ;
trevieze 14:b174ec6e3ca0 235 UG_ButtonCreate (&window_3, &button_5, BTN_ID_4, 10 , 230 , 115 , 290 );
trevieze 14:b174ec6e3ca0 236 UG_ButtonCreate (&window_3, &button_6, BTN_ID_5, 125 , 230 , 225 , 290 );
trevieze 14:b174ec6e3ca0 237 UG_ButtonSetBackColor (&window_3 ,BTN_ID_4 , C_BLUE ) ;
trevieze 14:b174ec6e3ca0 238 UG_ButtonSetForeColor (&window_3 ,BTN_ID_4 , C_WHITE ) ;
trevieze 14:b174ec6e3ca0 239 UG_ButtonSetBackColor (&window_3 ,BTN_ID_5 , C_BLUE ) ;
trevieze 14:b174ec6e3ca0 240 UG_ButtonSetForeColor (&window_3 ,BTN_ID_5 , C_WHITE ) ;
trevieze 14:b174ec6e3ca0 241 UG_ButtonSetFont (&window_3 , BTN_ID_4 , &FONT_8X8) ;
trevieze 14:b174ec6e3ca0 242 UG_ButtonSetFont (&window_3 , BTN_ID_5 , &FONT_8X8) ;
trevieze 14:b174ec6e3ca0 243 UG_ButtonSetText (&window_3 , BTN_ID_4 , "Prev" );
trevieze 14:b174ec6e3ca0 244 UG_ButtonSetText (&window_3 , BTN_ID_5 , "Next" );
trevieze 15:27e0a1721d13 245
trevieze 15:27e0a1721d13 246 /* Finally , show the window */
trevieze 14:b174ec6e3ca0 247 //UG_WindowShow(&window_1) ;
trevieze 14:b174ec6e3ca0 248 //UG_WindowHide(&window_2);
trevieze 14:b174ec6e3ca0 249 //UG_WindowHide(&window_3);
trevieze 15:27e0a1721d13 250
trevieze 14:b174ec6e3ca0 251 //UG_Update();
trevieze 14:b174ec6e3ca0 252
trevieze 15:27e0a1721d13 253 while (1) {
trevieze 15:27e0a1721d13 254
trevieze 15:27e0a1721d13 255 cb1();
trevieze 15:27e0a1721d13 256
trevieze 15:27e0a1721d13 257 TFT.set_font((unsigned char*) ArialR20x20);
trevieze 15:27e0a1721d13 258 TFT.foreground(White);
trevieze 15:27e0a1721d13 259 TFT.background(UG_WindowGetBackColor(&window_1));
trevieze 15:27e0a1721d13 260 //check if we recieved a new message from GPS, if so, attempt to parse it,
trevieze 7:8aa9cdab4a07 261 if (refresh_Timer.read_ms() >= refresh_Time) {
trevieze 7:8aa9cdab4a07 262 refresh_Timer.reset();
trevieze 15:27e0a1721d13 263
trevieze 15:27e0a1721d13 264 switch ( pageid ) {
trevieze 15:27e0a1721d13 265 case PAGE1: {
trevieze 15:27e0a1721d13 266 if (!pageinit) {
trevieze 15:27e0a1721d13 267 UG_WindowHide(&window_2);
trevieze 15:27e0a1721d13 268 UG_WindowHide(&window_3);
trevieze 15:27e0a1721d13 269 UG_WindowShow(&window_1);
trevieze 15:27e0a1721d13 270 UG_Update();
trevieze 15:27e0a1721d13 271 }
trevieze 15:27e0a1721d13 272 pageinit = 1;
trevieze 15:27e0a1721d13 273 if (bmp180.init() != 0) {
trevieze 15:27e0a1721d13 274 //pc.printf("Error communicating with BMP180\n");
trevieze 15:27e0a1721d13 275 } else {
trevieze 15:27e0a1721d13 276 //pc.printf("Initialized BMP180\n");
trevieze 15:27e0a1721d13 277 bmp180.startTemperature();
trevieze 15:27e0a1721d13 278 wait(0.1); // Wait for conversion to complete
trevieze 15:27e0a1721d13 279 float temp;
trevieze 15:27e0a1721d13 280 if(bmp180.getTemperature(&temp) != 0) {
trevieze 15:27e0a1721d13 281 //pc.printf("Error getting temperature\n");
trevieze 14:b174ec6e3ca0 282 }
trevieze 15:27e0a1721d13 283 TFT.set_font((unsigned char*) Arial12x12);
trevieze 15:27e0a1721d13 284 TFT.locate(10, 65) ;
trevieze 15:27e0a1721d13 285 TFT.printf("Temperature");
trevieze 15:27e0a1721d13 286 TFT.set_font((unsigned char*) ArialR20x20);
trevieze 15:27e0a1721d13 287 TFT.locate(10, 80);
trevieze 15:27e0a1721d13 288 TFT.printf("%.1f*", ((temp* 9.0) / 5.0 + 32));
trevieze 15:27e0a1721d13 289 }
trevieze 15:27e0a1721d13 290 int ftemp = humid.sample_ftemp();
trevieze 15:27e0a1721d13 291 int humidity = humid.sample_humid();
trevieze 15:27e0a1721d13 292 TFT.set_font((unsigned char*) Arial12x12);
trevieze 15:27e0a1721d13 293 TFT.locate(150, 65) ;
trevieze 15:27e0a1721d13 294 TFT.printf("Humidity");
trevieze 15:27e0a1721d13 295 TFT.set_font((unsigned char*) ArialR20x20);
trevieze 15:27e0a1721d13 296 TFT.locate(150, 80) ;
trevieze 15:27e0a1721d13 297 TFT.printf("%d%%",humidity);
trevieze 15:27e0a1721d13 298 if (MyGPS.dataready()) {
trevieze 15:27e0a1721d13 299 MyGPS.read();
trevieze 15:27e0a1721d13 300 TFT.locate(10, 35) ;
trevieze 15:27e0a1721d13 301 TFT.foreground(UG_WindowGetBackColor(&window_1));
trevieze 15:27e0a1721d13 302 TFT.printf("No GPS Data");
trevieze 15:27e0a1721d13 303 TFT.foreground(White);
trevieze 15:27e0a1721d13 304 TFT.set_font((unsigned char*) Arial12x12);
trevieze 15:27e0a1721d13 305 TFT.locate(12, 25) ;
trevieze 15:27e0a1721d13 306 TFT.printf("Time");
trevieze 15:27e0a1721d13 307 TFT.locate(150, 25) ;
trevieze 15:27e0a1721d13 308 TFT.printf("Date");
trevieze 15:27e0a1721d13 309 TFT.set_font((unsigned char*) ArialR20x20);
trevieze 15:27e0a1721d13 310 TFT.locate(10, 40) ;
trevieze 15:27e0a1721d13 311 TFT.printf("%d:%d:%d", MyGPS.buffer.hours, MyGPS.buffer.minutes, MyGPS.buffer.seconds);
trevieze 15:27e0a1721d13 312 TFT.set_font((unsigned char*) ArialR20x20);
trevieze 15:27e0a1721d13 313 TFT.locate(150, 40) ;
trevieze 15:27e0a1721d13 314 TFT.printf("%d-%d-%d", MyGPS.buffer.month, MyGPS.buffer.day, MyGPS.buffer.year);
trevieze 15:27e0a1721d13 315 TFT.set_font((unsigned char*) SCProSB31x55);
trevieze 15:27e0a1721d13 316 TFT.locate(125, 180) ;
trevieze 15:27e0a1721d13 317 TFT.printf("%.1f", MyGPS.buffer.speed);
trevieze 15:27e0a1721d13 318 TFT.locate(10, 180);
trevieze 15:27e0a1721d13 319 TFT.printf("%d", 6); //Cadence
trevieze 15:27e0a1721d13 320 TFT.set_font((unsigned char*) Arial12x12);
trevieze 15:27e0a1721d13 321 TFT.locate(45, 212) ;
trevieze 15:27e0a1721d13 322 TFT.printf("rpm");
trevieze 15:27e0a1721d13 323 TFT.locate(10, 170) ;
trevieze 15:27e0a1721d13 324 TFT.printf("Cadence");
trevieze 15:27e0a1721d13 325 TFT.locate(207, 212) ;
trevieze 15:27e0a1721d13 326 TFT.printf("mph");
trevieze 15:27e0a1721d13 327 TFT.locate(125, 170) ;
trevieze 15:27e0a1721d13 328 TFT.printf("Speed");
trevieze 15:27e0a1721d13 329 TFT.set_font((unsigned char*) ArialR20x20);
trevieze 15:27e0a1721d13 330 //TFT.locate(10, 50) ;
trevieze 15:27e0a1721d13 331 //double waypoint = nav.CalculateDistance(MyGPS.buffer.latitude,MyGPS.buffer.longitude,plat,plon)/double(1609.344);
trevieze 15:27e0a1721d13 332 //TFT.printf("%.1fMI From Perry", waypoint);
trevieze 15:27e0a1721d13 333 } else {
trevieze 15:27e0a1721d13 334 TFT.locate(10, 26) ;
trevieze 15:27e0a1721d13 335 TFT.printf("No GPS Data");
trevieze 15:27e0a1721d13 336 //pc.printf("NMEA has no valid data");
trevieze 15:27e0a1721d13 337 }
trevieze 15:27e0a1721d13 338 break;
trevieze 15:27e0a1721d13 339 }
trevieze 15:27e0a1721d13 340 case PAGE2: {
trevieze 15:27e0a1721d13 341 if (!pageinit) {
trevieze 15:27e0a1721d13 342 UG_WindowHide(&window_1);
trevieze 15:27e0a1721d13 343 UG_WindowHide(&window_3);
trevieze 15:27e0a1721d13 344 UG_WindowShow(&window_2);
trevieze 15:27e0a1721d13 345 UG_Update();
trevieze 15:27e0a1721d13 346 TFT.Bitmap(10,20,200,200,(unsigned char*)compass_bmp);
trevieze 15:27e0a1721d13 347 }
trevieze 15:27e0a1721d13 348 pageinit = 1;
trevieze 15:27e0a1721d13 349 break;
trevieze 15:27e0a1721d13 350 }
trevieze 15:27e0a1721d13 351 case PAGE3: {
trevieze 15:27e0a1721d13 352 if (!pageinit) {
trevieze 15:27e0a1721d13 353 UG_WindowHide(&window_1);
trevieze 15:27e0a1721d13 354 UG_WindowHide(&window_2);
trevieze 15:27e0a1721d13 355 UG_WindowShow(&window_3);
trevieze 15:27e0a1721d13 356 UG_Update();
trevieze 15:27e0a1721d13 357 }
trevieze 15:27e0a1721d13 358 pageinit = 1;
trevieze 15:27e0a1721d13 359 break;
trevieze 15:27e0a1721d13 360 }
trevieze 15:27e0a1721d13 361 }
trevieze 14:b174ec6e3ca0 362 }
trevieze 15:27e0a1721d13 363 /*
trevieze 15:27e0a1721d13 364 TFT.locate(140, 260) ;
trevieze 15:27e0a1721d13 365 TFT.printf("%.1fft", MyGPS.buffer.altitude/0.3048);
trevieze 15:27e0a1721d13 366 TFT.locate(4, 280) ;
trevieze 15:27e0a1721d13 367 int degree;
trevieze 15:27e0a1721d13 368 int minutes;
trevieze 15:27e0a1721d13 369 int seconds;
trevieze 15:27e0a1721d13 370 degree = (int)abs(MyGPS.buffer.longitude);
trevieze 15:27e0a1721d13 371 minutes = (int) ( (abs(MyGPS.buffer.longitude) - (double)degree) * 60.0);
trevieze 15:27e0a1721d13 372 seconds = (int) ( (abs(MyGPS.buffer.longitude) - (double)degree - (double)minutes / 60.0) * 60.0 * 60.0 );
trevieze 15:27e0a1721d13 373 TFT.printf("%d %d' %d\" %c lon", degree, minutes,seconds, MyGPS.buffer.lonc);
trevieze 15:27e0a1721d13 374 TFT.locate(4, 300) ;
trevieze 15:27e0a1721d13 375 TFT.locate(4, 300) ;
trevieze 15:27e0a1721d13 376 degree = (int)abs(MyGPS.buffer.latitude);
trevieze 15:27e0a1721d13 377 minutes = (int) ( (abs(MyGPS.buffer.latitude) - (double)degree) * 60.0);
trevieze 15:27e0a1721d13 378 seconds = (int) ( (abs(MyGPS.buffer.latitude) - (double)degree - (double)minutes / 60.0) * 60.0 * 60.0 );
trevieze 15:27e0a1721d13 379 TFT.printf("%d %d' %d\" %c lat", degree, minutes,seconds, MyGPS.buffer.latc);
trevieze 15:27e0a1721d13 380
trevieze 15:27e0a1721d13 381
trevieze 15:27e0a1721d13 382
trevieze 15:27e0a1721d13 383 //pc.printf("Dist to Perry %.4f ", nav.CalculateDistance(MyGPS.buffer.latitude,MyGPS.buffer.longitude,plat,plon));
trevieze 15:27e0a1721d13 384
trevieze 15:27e0a1721d13 385
trevieze 15:27e0a1721d13 386 }
trevieze 15:27e0a1721d13 387
trevieze 15:27e0a1721d13 388
trevieze 15:27e0a1721d13 389 if (imu.chip_ready() == 0){
trevieze 15:27e0a1721d13 390 pc.printf("Bosch BNO055 is NOT avirable!!\r\n");
trevieze 15:27e0a1721d13 391 } else {
trevieze 15:27e0a1721d13 392
trevieze 15:27e0a1721d13 393 if (imu.read_calib_status() > 0x0){
trevieze 15:27e0a1721d13 394 TFT.foreground(White);
trevieze 15:27e0a1721d13 395 TFT.locate(4, 260) ;
trevieze 15:27e0a1721d13 396 TFT.printf("No Data");
trevieze 15:27e0a1721d13 397 TFT.foreground(Blue);
trevieze 15:27e0a1721d13 398 imu.get_Euler_Angles(&euler_angles);
trevieze 15:27e0a1721d13 399 TFT.locate(4, 260) ;
trevieze 15:27e0a1721d13 400 TFT.printf("%.1f @ %.1f",euler_angles.h, euler_angles.p);
trevieze 15:27e0a1721d13 401 //pc.printf("H %d",(int)euler_angles.h);
trevieze 15:27e0a1721d13 402 //pc.printf("R %.1f",euler_angles.r);
trevieze 15:27e0a1721d13 403 //pc.printf("P %.1f",euler_angles.p);
trevieze 15:27e0a1721d13 404
trevieze 15:27e0a1721d13 405 } else {
trevieze 15:27e0a1721d13 406 TFT.locate(4, 260) ;
trevieze 15:27e0a1721d13 407 TFT.printf("No Data");
trevieze 15:27e0a1721d13 408 }
trevieze 15:27e0a1721d13 409 }
trevieze 15:27e0a1721d13 410
trevieze 15:27e0a1721d13 411 float angle = euler_angles.h; // Convert radians to degrees for more a more usual result
trevieze 15:27e0a1721d13 412 // For the screen -X = up and +X = down and -Y = left and +Y = right, so does not follow coordinate conventions
trevieze 15:27e0a1721d13 413 float dx = (radius * cos((angle-90)*PI/180)) + centreX; // calculate X position for the screen coordinates - can be confusing!
trevieze 15:27e0a1721d13 414 float dy = (radius * sin((angle-90)*PI/180)) + centreY; // calculate Y position for the screen coordinates - can be confusing!
trevieze 15:27e0a1721d13 415 arrow(last_dx,last_dy, centreX, centreY, 2,2,White); // Erase last arrow
trevieze 15:27e0a1721d13 416 arrow(dx,dy, centreX, centreY, 2, 2,Blue); // Draw arrow in new position
trevieze 15:27e0a1721d13 417 last_dx = dx;
trevieze 15:27e0a1721d13 418 last_dy = dy;
trevieze 15:27e0a1721d13 419
trevieze 15:27e0a1721d13 420
trevieze 15:27e0a1721d13 421 }
trevieze 15:27e0a1721d13 422 */
trevieze 15:27e0a1721d13 423 }
trevieze 10:869a102dd31c 424 }
trevieze 10:869a102dd31c 425
trevieze 15:27e0a1721d13 426 void arrow(int x2, int y2, int x1, int y1, int alength, int awidth, int colour)
trevieze 15:27e0a1721d13 427 {
trevieze 15:27e0a1721d13 428 float distance;
trevieze 15:27e0a1721d13 429 int dx, dy, x2o,y2o,x3,y3,x4,y4,k;
trevieze 15:27e0a1721d13 430 distance = sqrt(pow((double)(x1 - x2),2) + pow((double)(y1 - y2), 2));
trevieze 15:27e0a1721d13 431 dx = x2 + (x1 - x2) * alength / distance;
trevieze 15:27e0a1721d13 432 dy = y2 + (y1 - y2) * alength / distance;
trevieze 15:27e0a1721d13 433 k = awidth / alength;
trevieze 15:27e0a1721d13 434 x2o = x2 - dx;
trevieze 15:27e0a1721d13 435 y2o = dy - y2;
trevieze 15:27e0a1721d13 436 x3 = y2o * k + dx;
trevieze 15:27e0a1721d13 437 y3 = x2o * k + dy;
trevieze 15:27e0a1721d13 438 x4 = dx - y2o * k;
trevieze 15:27e0a1721d13 439 y4 = dy - x2o * k;
trevieze 15:27e0a1721d13 440 TFT.line(x1, y1, x2, y2, colour);
trevieze 15:27e0a1721d13 441 TFT.line(x1, y1, dx, dy, colour);
trevieze 15:27e0a1721d13 442 TFT.line(x3, y3, x4, y4, colour);
trevieze 15:27e0a1721d13 443 TFT.line(x3, y3, x2, y2, colour);
trevieze 15:27e0a1721d13 444 TFT.line(x2, y2, x4, y4, colour);
trevieze 12:1a9c0f9d7128 445 TFT.set_font((unsigned char*) Arial12x12);
trevieze 15:27e0a1721d13 446 TFT.foreground(Blue);
trevieze 15:27e0a1721d13 447 TFT.background(White);
trevieze 12:1a9c0f9d7128 448 TFT.locate((centreX-2),(centreY-24));
trevieze 15:27e0a1721d13 449 TFT.printf("N");
trevieze 15:27e0a1721d13 450 TFT.locate((centreX-2),(centreY+17));
trevieze 15:27e0a1721d13 451 TFT.printf("S");
trevieze 15:27e0a1721d13 452 TFT.locate((centreX+19),(centreY-3));
trevieze 15:27e0a1721d13 453 TFT.printf("E");
trevieze 15:27e0a1721d13 454 TFT.locate((centreX-23),(centreY-3));
trevieze 15:27e0a1721d13 455 TFT.printf("W");
trevieze 12:1a9c0f9d7128 456 TFT.set_font((unsigned char*) ArialR20x20);
trevieze 15:27e0a1721d13 457 }
Rhyme 0:cd5e3d371b54 458
trevieze 15:27e0a1721d13 459 void Draw_Compass_Rose(void)
trevieze 15:27e0a1721d13 460 {
trevieze 15:27e0a1721d13 461 int dxo, dyo, dxi, dyi;
trevieze 15:27e0a1721d13 462 TFT.circle(centreX,centreY,radius,Blue); // Draw compass circle
trevieze 15:27e0a1721d13 463 for (float i = 0; i <360; i = i + 22.5) {
trevieze 15:27e0a1721d13 464 dxo = radius * cos(i*3.14/180);
trevieze 15:27e0a1721d13 465 dyo = radius * sin(i*3.14/180);
trevieze 15:27e0a1721d13 466 dxi = dxo * 0.95;
trevieze 15:27e0a1721d13 467 dyi = dyo * 0.95;
trevieze 15:27e0a1721d13 468 TFT.line(dxi+centreX,dyi+centreY,dxo+centreX,dyo+centreY,Blue);
trevieze 15:27e0a1721d13 469 }
trevieze 10:869a102dd31c 470 TFT.set_font((unsigned char*) Arial12x12);
trevieze 15:27e0a1721d13 471 TFT.foreground(Blue);
trevieze 15:27e0a1721d13 472 TFT.background(White);
trevieze 10:869a102dd31c 473 TFT.locate((centreX-2),(centreY-24));
trevieze 15:27e0a1721d13 474 TFT.printf("N");
trevieze 15:27e0a1721d13 475 TFT.locate((centreX-2),(centreY+17));
trevieze 15:27e0a1721d13 476 TFT.printf("S");
trevieze 15:27e0a1721d13 477 TFT.locate((centreX+19),(centreY-3));
trevieze 15:27e0a1721d13 478 TFT.printf("E");
trevieze 15:27e0a1721d13 479 TFT.locate((centreX-23),(centreY-3));
trevieze 15:27e0a1721d13 480 TFT.printf("W");
trevieze 14:b174ec6e3ca0 481 }
trevieze 14:b174ec6e3ca0 482
trevieze 14:b174ec6e3ca0 483 void ili9341_pset(UG_S16 ul_x,UG_S16 ul_y, UG_COLOR ul_color)
trevieze 14:b174ec6e3ca0 484 {
trevieze 14:b174ec6e3ca0 485 TFT.pixel(ul_x, ul_y, ul_color);
trevieze 14:b174ec6e3ca0 486 }
trevieze 14:b174ec6e3ca0 487
trevieze 14:b174ec6e3ca0 488 void window_1_callback( UG_MESSAGE* msg )
trevieze 14:b174ec6e3ca0 489 {
trevieze 15:27e0a1721d13 490 if ( msg->type == MSG_TYPE_OBJECT ) {
trevieze 15:27e0a1721d13 491 if ( msg->id == OBJ_TYPE_BUTTON ) {
trevieze 15:27e0a1721d13 492 switch ( msg->sub_id ) {
trevieze 15:27e0a1721d13 493 case BTN_ID_0: {
trevieze 14:b174ec6e3ca0 494 pageid--;
trevieze 14:b174ec6e3ca0 495 if (pageid < 1) {
trevieze 15:27e0a1721d13 496 pageid = 3;
trevieze 15:27e0a1721d13 497 }
trevieze 15:27e0a1721d13 498 pageinit = 0;
trevieze 14:b174ec6e3ca0 499 break;
trevieze 14:b174ec6e3ca0 500 }
trevieze 15:27e0a1721d13 501 case BTN_ID_1: {
trevieze 14:b174ec6e3ca0 502 pageid++;
trevieze 14:b174ec6e3ca0 503 if (pageid > 3) {
trevieze 15:27e0a1721d13 504 pageid = 1;
trevieze 15:27e0a1721d13 505 }
trevieze 15:27e0a1721d13 506 pageinit = 0;
trevieze 14:b174ec6e3ca0 507 break;
trevieze 14:b174ec6e3ca0 508 }
trevieze 14:b174ec6e3ca0 509 }
trevieze 14:b174ec6e3ca0 510 }
trevieze 14:b174ec6e3ca0 511 }
trevieze 14:b174ec6e3ca0 512 }
trevieze 14:b174ec6e3ca0 513
trevieze 14:b174ec6e3ca0 514 void window_2_callback( UG_MESSAGE* msg )
trevieze 14:b174ec6e3ca0 515 {
trevieze 15:27e0a1721d13 516 if ( msg->type == MSG_TYPE_OBJECT ) {
trevieze 15:27e0a1721d13 517 if ( msg->id == OBJ_TYPE_BUTTON ) {
trevieze 15:27e0a1721d13 518 switch ( msg->sub_id ) {
trevieze 15:27e0a1721d13 519 case BTN_ID_2: {
trevieze 14:b174ec6e3ca0 520 pageid--;
trevieze 14:b174ec6e3ca0 521 if (pageid < 1) {
trevieze 15:27e0a1721d13 522 pageid = 3;
trevieze 15:27e0a1721d13 523 }
trevieze 15:27e0a1721d13 524 pageinit = 0;
trevieze 14:b174ec6e3ca0 525 break;
trevieze 14:b174ec6e3ca0 526 }
trevieze 15:27e0a1721d13 527 case BTN_ID_3: {
trevieze 14:b174ec6e3ca0 528 pageid++;
trevieze 14:b174ec6e3ca0 529 if (pageid > 3) {
trevieze 15:27e0a1721d13 530 pageid = 1;
trevieze 14:b174ec6e3ca0 531 }
trevieze 15:27e0a1721d13 532 pageinit = 0;
trevieze 14:b174ec6e3ca0 533 break;
trevieze 14:b174ec6e3ca0 534 }
trevieze 14:b174ec6e3ca0 535 }
trevieze 14:b174ec6e3ca0 536 }
trevieze 14:b174ec6e3ca0 537 }
trevieze 14:b174ec6e3ca0 538 }
trevieze 14:b174ec6e3ca0 539
trevieze 14:b174ec6e3ca0 540 void window_3_callback( UG_MESSAGE* msg )
trevieze 14:b174ec6e3ca0 541 {
trevieze 15:27e0a1721d13 542 if ( msg->type == MSG_TYPE_OBJECT ) {
trevieze 15:27e0a1721d13 543 if ( msg->id == OBJ_TYPE_BUTTON ) {
trevieze 15:27e0a1721d13 544 switch ( msg->sub_id ) {
trevieze 15:27e0a1721d13 545 case BTN_ID_4: {
trevieze 14:b174ec6e3ca0 546 pageid--;
trevieze 14:b174ec6e3ca0 547 if (pageid < 1) {
trevieze 15:27e0a1721d13 548 pageid = 3;
trevieze 15:27e0a1721d13 549 }
trevieze 15:27e0a1721d13 550 pageinit = 0;
trevieze 14:b174ec6e3ca0 551 break;
trevieze 14:b174ec6e3ca0 552 }
trevieze 15:27e0a1721d13 553 case BTN_ID_5: {
trevieze 14:b174ec6e3ca0 554 pageid++;
trevieze 14:b174ec6e3ca0 555 if (pageid > 3) {
trevieze 15:27e0a1721d13 556 pageid = 1;
trevieze 14:b174ec6e3ca0 557 }
trevieze 15:27e0a1721d13 558 pageinit = 0;
trevieze 14:b174ec6e3ca0 559 break;
trevieze 14:b174ec6e3ca0 560 }
trevieze 14:b174ec6e3ca0 561 }
trevieze 14:b174ec6e3ca0 562 }
trevieze 14:b174ec6e3ca0 563 }
trevieze 14:b174ec6e3ca0 564 }
trevieze 14:b174ec6e3ca0 565
trevieze 15:27e0a1721d13 566 void cb1(void)
trevieze 15:27e0a1721d13 567 {
trevieze 14:b174ec6e3ca0 568 point p;
trevieze 14:b174ec6e3ca0 569 TSC.getTouch(p);
trevieze 15:27e0a1721d13 570 if (p.z > __PRESURE) {
trevieze 15:27e0a1721d13 571 UG_TouchUpdate ( p.x, p.y, TOUCH_STATE_PRESSED ) ;
trevieze 15:27e0a1721d13 572 } else {
trevieze 15:27e0a1721d13 573 UG_TouchUpdate (-1, -1, TOUCH_STATE_RELEASED ) ;
trevieze 15:27e0a1721d13 574 }
trevieze 14:b174ec6e3ca0 575 UG_Update();
trevieze 14:b174ec6e3ca0 576 }