Works
Dependencies: BMP180 BNO055_fusion Fonts GPSISR HTU21D SDFileSystem UniGraphic mbed uGUI
Fork of Bicycl_Computer_NUCLEO-F411RE by
main.cpp
00001 /* mbed main.cpp to test adafruit 2.8" TFT LCD shiled w Touchscreen 00002 * Copyright (c) 2014, 2015 Motoo Tanaka @ Design Methodology Lab 00003 * 00004 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00005 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00006 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00007 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00008 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00009 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00010 * THE SOFTWARE. 00011 */ 00012 00013 /* 00014 * Note: This program is derived from the SeeeStudioTFTv2 program. 00015 * Although both program share same ILI9341 TFT driver, 00016 * the touch sensor was not same with the Display I purchased from Akizuki. 00017 * http://akizukidenshi.com/catalog/g/gM-07747/ 00018 * The touch sensor on the display is STMPE610, 00019 * so I hacked the minimum spi driver for it (polling mode only). 00020 */ 00021 00022 #include "mbed.h" 00023 #include <math.h> 00024 #include "ILI9341.h" 00025 //#include "TFT.h" 00026 // Graphics GUI Library 00027 #include "ugui.h" 00028 00029 #include "SeeedStudioTFTv2.h" 00030 #include "BNO055.h" 00031 #include "HTU21D.h" 00032 #include "BMP180.h" 00033 #include "SDFileSystem.h" 00034 #include "GPSISR.h" 00035 #include "nav.h" 00036 00037 00038 #include "ArialR16x17.h" 00039 #include "Arial24x23i.h" 00040 #include "Arial28x28.h" 00041 #include "Neu44x36.h" 00042 #include "SCProSB31x55.h" 00043 #include "Arial12x12.h" 00044 #include "ArialR20x20.h" 00045 00046 //#define PIN_CS_TSC PA_9 00047 //#define PIN_TSC_INTR PA_8 00048 #define PIN_RESET_TFT PC_13 /* place holder */ 00049 //ILI9341 SPI PINS 00050 #define PIN_XP A3 00051 #define PIN_XM A1 00052 #define PIN_YP A2 00053 #define PIN_YM A0 00054 #define PIN_MOSI_SPI1 D11 //SPI 1 MOSI 00055 #define PIN_MISO_SPI1 D12 //SPI 1 MISO 00056 #define PIN_SCLK_SPI1 D13 //SPI 1 SLCK 00057 #define PIN_CS_SPI1 D5 // SPI CS D10 Was D5 00058 #define PIN_DC_TFT D6 00059 #define PIN_CS_SD D4 00060 #define PIN_RESET D7 00061 // SD Card on GPS shield PINS 00062 #define PIN_MOSI_SPI3 PB_15 //SPI 1 MOSI 00063 #define PIN_MISO_SPI3 PB_14 //SPI 1 MISO 00064 #define PIN_SCLK_SPI3 PB_13 //SPI 1 SLCK 00065 #define PIN_CS_SPI3 D2 // SPI CS 00066 #define PIN_RX_GPS PA_12 //GPS Shield RX pin 00067 #define PIN_TX_GPS PA_11 //GPS Shield TX pin 00068 00069 #define PI 3.14159265358979f 00070 BNO055_ID_INF_TypeDef bno055_id_inf; 00071 BNO055_EULER_TypeDef euler_angles; 00072 BNO055_QUATERNION_TypeDef quaternion; 00073 BNO055_LIN_ACC_TypeDef linear_acc; 00074 BNO055_GRAVITY_TypeDef gravity; 00075 BNO055_TEMPERATURE_TypeDef chip_temp; 00076 00077 #define DEVICE_NAME "F411RE" 00078 00079 #ifndef TARGET_NECLEO_F411RE 00080 #define TARGET_NECLEO_F411RE 00081 #endif 00082 00083 //DigitalOut backlight(PB_3) ; 00084 // DigitalOut tsc_cs(PA_9, 1) ; 00085 // DigitalOut tft_cs(PB_6, 1) ; 00086 00087 /** Height of display using default orientation */ 00088 #define ILI9341_DEFAULT_HEIGHT 240 00089 00090 /** Width of display using default orientation */ 00091 #define ILI9341_DEFAULT_WIDTH 320 00092 00093 /** Height of display using swapped X/Y orientation */ 00094 #define ILI9341_SWITCH_XY_HEIGHT 320 00095 00096 /** Width of display using swapped X/Y orientation */ 00097 #define ILI9341_SWITCH_XY_WIDTH 240 00098 00099 Serial pc(USBTX, USBRX); 00100 00101 // Display 00102 ILI9341 TFT(SPI_8, 20000000, 00103 PIN_MOSI_SPI1, PIN_MISO_SPI1, PIN_SCLK_SPI1, 00104 PIN_CS_SPI1, PIN_RESET_TFT, PIN_DC_TFT, "Adafruit2.8"); 00105 00106 // TouchScreen 00107 TouchScreen TOUCH(PIN_XP, PIN_XM, PIN_YP, PIN_YM); 00108 00109 // 3 Axis IMU 00110 BNO055 imu(I2C_SDA, I2C_SCL, PIN_RESET); // Reset =D7, addr = BNO055_G_CHIP_ADDR, mode = MODE_NDOF <- as default 00111 // Humidity and Temperature 00112 HTU21D humid(I2C_SDA, I2C_SCL); 00113 00114 // Pressure 00115 BMP180 bmp180(I2C_SDA, I2C_SCL); 00116 00117 // SD Card Reader On Adafruit GPS Shield 00118 SDFileSystem sd(PIN_MOSI_SPI3, PIN_MISO_SPI3, PIN_SCLK_SPI3, PIN_CS_SPI3, "sd"); // the pinout on the mbed Cool Components workshop board 00119 00120 // Set up serial interrupe service handler for gps characters. 00121 GPS MyGPS(PIN_TX_GPS,PIN_RX_GPS, 9600); 00122 00123 //Navigation Class. 00124 NAV nav; 00125 double plat = 42.826420; 00126 double plon = -84.219413; 00127 00128 void Draw_Compass_Rose(void); 00129 void arrow(int x2, int y2, int x1, int y1, int alength, int awidth, int colour); 00130 void ili9341_pset(UG_S16 ul_x,UG_S16 ul_y, UG_COLOR ul_color); 00131 void window_1_callback( UG_MESSAGE* msg ); 00132 void window_2_callback( UG_MESSAGE* msg ); 00133 void window_3_callback( UG_MESSAGE* msg ); 00134 void cb1(void); 00135 00136 const int centreX = 120; 00137 const int centreY = 150; 00138 const int radius = 40; 00139 float last_dx; 00140 float last_dy; 00141 00142 int pageid = 1; 00143 bool pageinit = 0; 00144 #define PAGE1 1 00145 #define PAGE2 2 00146 #define PAGE3 3 00147 00148 UG_GUI gui; 00149 00150 //Ticker to1; 00151 00152 int main() 00153 { 00154 //to1.attach(&cb1, 2.0); 00155 TFT.BusEnable(true) ; 00156 TFT.FastWindow(true) ; 00157 wait(0.1); 00158 TFT.cls(); 00159 wait(0.1); 00160 00161 UG_Init(&gui,ili9341_pset,ILI9341_DEFAULT_HEIGHT,ILI9341_DEFAULT_WIDTH); 00162 00163 Timer refresh_Timer; //sets up a timer for use in loop; how often do we print GPS info? 00164 const int refresh_Time = 2000; //refresh time in ms 00165 refresh_Timer.start(); //starts the clock on the timer 00166 //backlight = 0 ; 00167 wait(0.1); 00168 00169 // Draw_Compass_Rose(); 00170 /* Window 1 Bike Computer */ 00171 #define MAX_OBJECTS 10 00172 UG_WINDOW window_1 ; /* Window */ 00173 UG_BUTTON button_1; /* Button container */ 00174 UG_BUTTON button_2; /* Button container */ 00175 UG_OBJECT obj_buff_wnd_1 [MAX_OBJECTS] ; /* Object buffer */ 00176 UG_WindowCreate ( &window_1 , obj_buff_wnd_1 , MAX_OBJECTS, window_1_callback); 00177 UG_WindowSetTitleTextFont ( &window_1 , &FONT_8X8 ) ; 00178 UG_WindowSetTitleText ( &window_1 , "Bike Computer" ) ; 00179 UG_WindowSetBackColor( &window_1 , C_GRAY ) ; 00180 UG_ButtonCreate (&window_1, &button_1, BTN_ID_0, 10 , 230 , 115 , 290 ); 00181 UG_ButtonCreate (&window_1, &button_2, BTN_ID_1, 125 , 230 , 225 , 290 ); 00182 UG_ButtonSetBackColor (&window_1 ,BTN_ID_0 , C_BLUE ) ; 00183 UG_ButtonSetForeColor (&window_1 ,BTN_ID_0 , C_WHITE ) ; 00184 UG_ButtonSetBackColor (&window_1 ,BTN_ID_1 , C_BLUE ) ; 00185 UG_ButtonSetForeColor (&window_1 ,BTN_ID_1 , C_WHITE ) ; 00186 UG_ButtonSetFont (&window_1 , BTN_ID_0 , &FONT_8X8) ; 00187 UG_ButtonSetFont (&window_1 , BTN_ID_1 , &FONT_8X8) ; 00188 UG_ButtonSetText (&window_1 , BTN_ID_0 , "Prev" ); 00189 UG_ButtonSetText (&window_1 , BTN_ID_1 , "Next" ); 00190 00191 /* Window 2 e-Compass */ 00192 UG_WINDOW window_2 ; /* Window */ 00193 UG_BUTTON button_3; /* Button container */ 00194 UG_BUTTON button_4; /* Button container */ 00195 UG_OBJECT obj_buff_wnd_2 [MAX_OBJECTS] ; /* Object buffer */ 00196 UG_WindowCreate ( &window_2 , obj_buff_wnd_2 , MAX_OBJECTS, window_2_callback); 00197 UG_WindowSetTitleTextFont ( &window_2 , &FONT_8X8 ) ; 00198 UG_WindowSetTitleText ( &window_2 , "e-Compass" ) ; 00199 UG_WindowSetBackColor( &window_2 , C_GRAY ) ; 00200 UG_ButtonCreate (&window_2, &button_3, BTN_ID_2, 10 , 230 , 115 , 290 ); 00201 UG_ButtonCreate (&window_2, &button_4, BTN_ID_3, 125 , 230 , 225 , 290 ); 00202 UG_ButtonSetBackColor (&window_2 ,BTN_ID_2 , C_BLUE ) ; 00203 UG_ButtonSetForeColor (&window_2 ,BTN_ID_2 , C_WHITE ) ; 00204 UG_ButtonSetBackColor (&window_2 ,BTN_ID_3 , C_BLUE ) ; 00205 UG_ButtonSetForeColor (&window_2 ,BTN_ID_3 , C_WHITE ) ; 00206 UG_ButtonSetFont (&window_2 , BTN_ID_2 , &FONT_8X8) ; 00207 UG_ButtonSetFont (&window_2 , BTN_ID_3 , &FONT_8X8) ; 00208 UG_ButtonSetText (&window_2 , BTN_ID_2 , "Prev" ); 00209 UG_ButtonSetText (&window_2 , BTN_ID_3 , "Next" ); 00210 00211 /* Window 3 GSP */ 00212 UG_WINDOW window_3 ; /* Window */ 00213 UG_BUTTON button_5; /* Button container */ 00214 UG_BUTTON button_6; /* Button container */ 00215 UG_OBJECT obj_buff_wnd_3 [MAX_OBJECTS] ; /* Object buffer */ 00216 UG_WindowCreate ( &window_3 , obj_buff_wnd_3 , MAX_OBJECTS, window_3_callback); 00217 UG_WindowSetTitleTextFont ( &window_3 , &FONT_8X8 ) ; 00218 UG_WindowSetTitleText ( &window_3 , "GPS Waypoints" ) ; 00219 UG_WindowSetBackColor( &window_3 , C_GRAY ) ; 00220 UG_ButtonCreate (&window_3, &button_5, BTN_ID_4, 10 , 230 , 115 , 290 ); 00221 UG_ButtonCreate (&window_3, &button_6, BTN_ID_5, 125 , 230 , 225 , 290 ); 00222 UG_ButtonSetBackColor (&window_3 ,BTN_ID_4 , C_BLUE ) ; 00223 UG_ButtonSetForeColor (&window_3 ,BTN_ID_4 , C_WHITE ) ; 00224 UG_ButtonSetBackColor (&window_3 ,BTN_ID_5 , C_BLUE ) ; 00225 UG_ButtonSetForeColor (&window_3 ,BTN_ID_5 , C_WHITE ) ; 00226 UG_ButtonSetFont (&window_3 , BTN_ID_4 , &FONT_8X8) ; 00227 UG_ButtonSetFont (&window_3 , BTN_ID_5 , &FONT_8X8) ; 00228 UG_ButtonSetText (&window_3 , BTN_ID_4 , "Prev" ); 00229 UG_ButtonSetText (&window_3 , BTN_ID_5 , "Next" ); 00230 00231 /* Finally , show the window */ 00232 //UG_WindowShow(&window_1) ; 00233 //UG_WindowHide(&window_2); 00234 //UG_WindowHide(&window_3); 00235 00236 //UG_Update(); 00237 00238 while (1) { 00239 00240 cb1(); 00241 00242 TFT.set_font((unsigned char*) ArialR20x20); 00243 TFT.foreground(White); 00244 TFT.background(UG_WindowGetBackColor(&window_1)); 00245 //check if we recieved a new message from GPS, if so, attempt to parse it, 00246 if (refresh_Timer.read_ms() >= refresh_Time) { 00247 refresh_Timer.reset(); 00248 00249 switch ( pageid ) 00250 { 00251 case PAGE1: 00252 { 00253 if (!pageinit) { 00254 UG_WindowHide(&window_2); 00255 UG_WindowHide(&window_3); 00256 UG_WindowShow(&window_1); 00257 UG_Update(); 00258 } 00259 pageinit = 1; 00260 if (bmp180.init() != 0) { 00261 //pc.printf("Error communicating with BMP180\n"); 00262 } else { 00263 //pc.printf("Initialized BMP180\n"); 00264 bmp180.startTemperature(); 00265 wait(0.1); // Wait for conversion to complete 00266 float temp; 00267 if(bmp180.getTemperature(&temp) != 0) { 00268 //pc.printf("Error getting temperature\n"); 00269 } 00270 TFT.locate(10, 50) ; 00271 TFT.printf("%.1fF", ((temp* 9.0) / 5.0 + 32)); 00272 } 00273 int ftemp = humid.sample_ftemp(); 00274 int humidity = humid.sample_humid(); 00275 TFT.locate(10, 72) ; 00276 TFT.printf("%d%%RH",humidity); 00277 if (MyGPS.dataready()) { 00278 MyGPS.read(); 00279 TFT.locate(10, 26) ; 00280 TFT.foreground(UG_WindowGetBackColor(&window_1)); 00281 TFT.printf("No GPS Data"); 00282 TFT.foreground(White); 00283 TFT.locate(10, 26) ; 00284 TFT.printf("%d:%d:%d", MyGPS.buffer.hours, MyGPS.buffer.minutes, MyGPS.buffer.seconds); 00285 TFT.locate(100, 26) ; 00286 TFT.printf("%d-%d-%d", MyGPS.buffer.month, MyGPS.buffer.day, MyGPS.buffer.year); 00287 TFT.set_font((unsigned char*) SCProSB31x55); 00288 TFT.locate(130, 180) ; 00289 TFT.printf("%.1f", MyGPS.buffer.speed); 00290 TFT.locate(10, 180) ; 00291 TFT.printf("%.1f", MyGPS.buffer.speed); //Cadence 00292 TFT.set_font((unsigned char*) ArialR20x20); 00293 //TFT.locate(10, 50) ; 00294 //double waypoint = nav.CalculateDistance(MyGPS.buffer.latitude,MyGPS.buffer.longitude,plat,plon)/double(1609.344); 00295 //TFT.printf("%.1fMI From Perry", waypoint); 00296 } 00297 else { 00298 TFT.locate(10, 26) ; 00299 TFT.printf("No GPS Data"); 00300 //pc.printf("NMEA has no valid data"); 00301 } 00302 break; 00303 } 00304 case PAGE2: 00305 { 00306 if (!pageinit) { 00307 UG_WindowHide(&window_1); 00308 UG_WindowHide(&window_3); 00309 UG_WindowShow(&window_2); 00310 UG_Update(); 00311 } 00312 pageinit = 1; 00313 break; 00314 } 00315 case PAGE3: 00316 { 00317 if (!pageinit) { 00318 UG_WindowHide(&window_1); 00319 UG_WindowHide(&window_2); 00320 UG_WindowShow(&window_3); 00321 UG_Update(); 00322 } 00323 pageinit = 1; 00324 break; 00325 } 00326 } 00327 } 00328 /* 00329 TFT.locate(140, 260) ; 00330 TFT.printf("%.1fft", MyGPS.buffer.altitude/0.3048); 00331 TFT.locate(4, 280) ; 00332 int degree; 00333 int minutes; 00334 int seconds; 00335 degree = (int)abs(MyGPS.buffer.longitude); 00336 minutes = (int) ( (abs(MyGPS.buffer.longitude) - (double)degree) * 60.0); 00337 seconds = (int) ( (abs(MyGPS.buffer.longitude) - (double)degree - (double)minutes / 60.0) * 60.0 * 60.0 ); 00338 TFT.printf("%d %d' %d\" %c lon", degree, minutes,seconds, MyGPS.buffer.lonc); 00339 TFT.locate(4, 300) ; 00340 TFT.locate(4, 300) ; 00341 degree = (int)abs(MyGPS.buffer.latitude); 00342 minutes = (int) ( (abs(MyGPS.buffer.latitude) - (double)degree) * 60.0); 00343 seconds = (int) ( (abs(MyGPS.buffer.latitude) - (double)degree - (double)minutes / 60.0) * 60.0 * 60.0 ); 00344 TFT.printf("%d %d' %d\" %c lat", degree, minutes,seconds, MyGPS.buffer.latc); 00345 00346 00347 00348 //pc.printf("Dist to Perry %.4f ", nav.CalculateDistance(MyGPS.buffer.latitude,MyGPS.buffer.longitude,plat,plon)); 00349 00350 00351 } 00352 00353 00354 if (imu.chip_ready() == 0){ 00355 pc.printf("Bosch BNO055 is NOT avirable!!\r\n"); 00356 } else { 00357 00358 if (imu.read_calib_status() > 0x0){ 00359 TFT.foreground(White); 00360 TFT.locate(4, 260) ; 00361 TFT.printf("No Data"); 00362 TFT.foreground(Blue); 00363 imu.get_Euler_Angles(&euler_angles); 00364 TFT.locate(4, 260) ; 00365 TFT.printf("%.1f @ %.1f",euler_angles.h, euler_angles.p); 00366 //pc.printf("H %d",(int)euler_angles.h); 00367 //pc.printf("R %.1f",euler_angles.r); 00368 //pc.printf("P %.1f",euler_angles.p); 00369 00370 } else { 00371 TFT.locate(4, 260) ; 00372 TFT.printf("No Data"); 00373 } 00374 } 00375 00376 float angle = euler_angles.h; // Convert radians to degrees for more a more usual result 00377 // For the screen -X = up and +X = down and -Y = left and +Y = right, so does not follow coordinate conventions 00378 float dx = (radius * cos((angle-90)*PI/180)) + centreX; // calculate X position for the screen coordinates - can be confusing! 00379 float dy = (radius * sin((angle-90)*PI/180)) + centreY; // calculate Y position for the screen coordinates - can be confusing! 00380 arrow(last_dx,last_dy, centreX, centreY, 2,2,White); // Erase last arrow 00381 arrow(dx,dy, centreX, centreY, 2, 2,Blue); // Draw arrow in new position 00382 last_dx = dx; 00383 last_dy = dy; 00384 00385 00386 } 00387 */ 00388 } 00389 } 00390 00391 void arrow(int x2, int y2, int x1, int y1, int alength, int awidth, int colour) { 00392 float distance; 00393 int dx, dy, x2o,y2o,x3,y3,x4,y4,k; 00394 distance = sqrt(pow((double)(x1 - x2),2) + pow((double)(y1 - y2), 2)); 00395 dx = x2 + (x1 - x2) * alength / distance; 00396 dy = y2 + (y1 - y2) * alength / distance; 00397 k = awidth / alength; 00398 x2o = x2 - dx; 00399 y2o = dy - y2; 00400 x3 = y2o * k + dx; 00401 y3 = x2o * k + dy; 00402 x4 = dx - y2o * k; 00403 y4 = dy - x2o * k; 00404 TFT.line(x1, y1, x2, y2, colour); 00405 TFT.line(x1, y1, dx, dy, colour); 00406 TFT.line(x3, y3, x4, y4, colour); 00407 TFT.line(x3, y3, x2, y2, colour); 00408 TFT.line(x2, y2, x4, y4, colour); 00409 TFT.set_font((unsigned char*) Arial12x12); 00410 TFT.foreground(Blue); 00411 TFT.background(White); 00412 TFT.locate((centreX-2),(centreY-24)); 00413 TFT.printf("N"); 00414 TFT.locate((centreX-2),(centreY+17)); 00415 TFT.printf("S"); 00416 TFT.locate((centreX+19),(centreY-3)); 00417 TFT.printf("E"); 00418 TFT.locate((centreX-23),(centreY-3)); 00419 TFT.printf("W"); 00420 TFT.set_font((unsigned char*) ArialR20x20); 00421 } 00422 00423 void Draw_Compass_Rose(void) { 00424 int dxo, dyo, dxi, dyi; 00425 TFT.circle(centreX,centreY,radius,Blue); // Draw compass circle 00426 for (float i = 0; i <360; i = i + 22.5) { 00427 dxo = radius * cos(i*3.14/180); 00428 dyo = radius * sin(i*3.14/180); 00429 dxi = dxo * 0.95; 00430 dyi = dyo * 0.95; 00431 TFT.line(dxi+centreX,dyi+centreY,dxo+centreX,dyo+centreY,Blue); 00432 } 00433 TFT.set_font((unsigned char*) Arial12x12); 00434 TFT.foreground(Blue); 00435 TFT.background(White); 00436 TFT.locate((centreX-2),(centreY-24)); 00437 TFT.printf("N"); 00438 TFT.locate((centreX-2),(centreY+17)); 00439 TFT.printf("S"); 00440 TFT.locate((centreX+19),(centreY-3)); 00441 TFT.printf("E"); 00442 TFT.locate((centreX-23),(centreY-3)); 00443 TFT.printf("W"); 00444 } 00445 00446 void ili9341_pset(UG_S16 ul_x,UG_S16 ul_y, UG_COLOR ul_color) 00447 { 00448 TFT.pixel(ul_x, ul_y, ul_color); 00449 } 00450 00451 void window_1_callback( UG_MESSAGE* msg ) 00452 { 00453 if ( msg->type == MSG_TYPE_OBJECT ) 00454 { 00455 if ( msg->id == OBJ_TYPE_BUTTON ) 00456 { 00457 switch ( msg->sub_id ) 00458 { 00459 case BTN_ID_0: 00460 { 00461 pageid--; 00462 if (pageid < 1) { 00463 pageid = 3; 00464 } 00465 pageinit = 0; 00466 break; 00467 } 00468 case BTN_ID_1: 00469 { 00470 pageid++; 00471 if (pageid > 3) { 00472 pageid = 1; 00473 } 00474 pageinit = 0; 00475 break; 00476 } 00477 } 00478 } 00479 } 00480 } 00481 00482 void window_2_callback( UG_MESSAGE* msg ) 00483 { 00484 if ( msg->type == MSG_TYPE_OBJECT ) 00485 { 00486 if ( msg->id == OBJ_TYPE_BUTTON ) 00487 { 00488 switch ( msg->sub_id ) 00489 { 00490 case BTN_ID_2: 00491 { 00492 pageid--; 00493 if (pageid < 1) { 00494 pageid = 3; 00495 } 00496 pageinit = 0; 00497 break; 00498 } 00499 case BTN_ID_3: 00500 { 00501 pageid++; 00502 if (pageid > 3) { 00503 pageid = 1; 00504 } 00505 pageinit = 0; 00506 break; 00507 } 00508 } 00509 } 00510 } 00511 } 00512 00513 void window_3_callback( UG_MESSAGE* msg ) 00514 { 00515 if ( msg->type == MSG_TYPE_OBJECT ) 00516 { 00517 if ( msg->id == OBJ_TYPE_BUTTON ) 00518 { 00519 switch ( msg->sub_id ) 00520 { 00521 case BTN_ID_4: 00522 { 00523 pageid--; 00524 if (pageid < 1) { 00525 pageid = 3; 00526 } 00527 pageinit = 0; 00528 break; 00529 } 00530 case BTN_ID_5: 00531 { 00532 pageid++; 00533 if (pageid > 3) { 00534 pageid = 1; 00535 } 00536 pageinit = 0; 00537 break; 00538 } 00539 } 00540 } 00541 } 00542 } 00543 00544 void cb1(void) { 00545 point p; 00546 TOUCH.getTouch(p); 00547 if (p.z > __PRESURE) 00548 { 00549 UG_TouchUpdate ( p.x, p.y, TOUCH_STATE_PRESSED ) ; 00550 } 00551 else 00552 { 00553 UG_TouchUpdate (-1, -1, TOUCH_STATE_RELEASED ) ; 00554 } 00555 UG_Update(); 00556 }
Generated on Wed Jul 20 2022 23:31:42 by 1.7.2