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.

Revision:
14:b174ec6e3ca0
Parent:
13:4f0ebc5a4f00
Child:
15:27e0a1721d13
--- a/main.cpp	Fri Mar 03 02:56:25 2017 +0000
+++ b/main.cpp	Wed Apr 12 20:30:06 2017 +0000
@@ -22,6 +22,10 @@
 #include "mbed.h"
 #include <math.h>
 #include "ILI9341.h"
+//#include "TFT.h"
+// Graphics GUI Library
+#include    "ugui.h"
+
 #include "SeeedStudioTFTv2.h"
 #include "BNO055.h"
 #include "HTU21D.h"
@@ -63,6 +67,12 @@
 #define PIN_TX_GPS      PA_11 //GPS Shield TX pin
 
 #define PI                  3.14159265358979f
+BNO055_ID_INF_TypeDef       bno055_id_inf;
+BNO055_EULER_TypeDef        euler_angles;
+BNO055_QUATERNION_TypeDef   quaternion;
+BNO055_LIN_ACC_TypeDef      linear_acc;
+BNO055_GRAVITY_TypeDef      gravity;
+BNO055_TEMPERATURE_TypeDef  chip_temp;
 
 #define DEVICE_NAME     "F411RE"
 
@@ -74,10 +84,22 @@
 // DigitalOut tsc_cs(PA_9, 1) ;
 // DigitalOut tft_cs(PB_6, 1) ;
 
+/** Height of display using default orientation */
+#define ILI9341_DEFAULT_HEIGHT   240
+
+/** Width of display using default orientation */
+#define ILI9341_DEFAULT_WIDTH    320
+
+/** Height of display using swapped X/Y orientation */
+#define ILI9341_SWITCH_XY_HEIGHT 320
+
+/** Width of display using swapped X/Y orientation */
+#define ILI9341_SWITCH_XY_WIDTH  240
+
 Serial pc(USBTX, USBRX);
 
 // Display
-ILI9341 TFT(SPI_8, 10000000, 
+ILI9341 TFT(SPI_8, 20000000, 
     PIN_MOSI_SPI1, PIN_MISO_SPI1,  PIN_SCLK_SPI1, 
     PIN_CS_SPI1, PIN_RESET_TFT, PIN_DC_TFT, "Adafruit2.8") ;
     
@@ -85,8 +107,7 @@
 TouchScreen TSC(PIN_XP, PIN_XM, PIN_YP, PIN_YM);
 
 // 3 Axis IMU
-BNO055 imu(I2C_SDA, I2C_SCL);  // New Library Adafruit
-
+BNO055 imu(I2C_SDA, I2C_SCL, PIN_RESET);  // Reset =D7, addr = BNO055_G_CHIP_ADDR, mode = MODE_NDOF <- as default
 // Humidity and Temperature
 HTU21D humid(I2C_SDA, I2C_SCL);
 
@@ -106,6 +127,11 @@
 
 void Draw_Compass_Rose(void);
 void arrow(int x2, int y2, int x1, int y1, int alength, int awidth, int colour);
+void ili9341_pset(UG_S16 ul_x,UG_S16 ul_y, UG_COLOR ul_color);
+void window_1_callback( UG_MESSAGE* msg );
+void window_2_callback( UG_MESSAGE* msg );
+void window_3_callback( UG_MESSAGE* msg );
+void cb1(void);
 
 const int centreX = 120;
 const int centreY = 150;
@@ -113,131 +139,252 @@
 float last_dx;
 float last_dy;
 
+int pageid = 1;
+bool pageinit = 0;
+#define PAGE1       1
+#define PAGE2       2
+#define PAGE3       3
+
+UG_GUI   gui;
+
+//Ticker to1;
+
 int main()
 {
+        //to1.attach(&cb1, 2.0);
     TFT.BusEnable(true) ;
     TFT.FastWindow(true) ;
     wait(0.1);
     TFT.cls();
     wait(0.1);
+        
+        UG_Init(&gui,ili9341_pset,ILI9341_DEFAULT_HEIGHT,ILI9341_DEFAULT_WIDTH);
+    
     Timer refresh_Timer; //sets up a timer for use in loop; how often do we print GPS info?
     const int refresh_Time = 2000; //refresh time in ms
     refresh_Timer.start();  //starts the clock on the timer
     //backlight = 0 ;
-    TFT.set_font((unsigned char*) Arial24x23i);
-    TFT.fillrect(2, 2, 237, 317, White);
-    TFT.foreground(Blue);
-    TFT.background(White);
     wait(0.1);
-       
-    Draw_Compass_Rose(); 
-        
+     
+  // Draw_Compass_Rose(); 
+    /* Window 1 Bike Computer */
+    #define MAX_OBJECTS 10
+    UG_WINDOW window_1 ; /* Window */
+    UG_BUTTON button_1; /* Button container */
+    UG_BUTTON button_2; /* Button container */
+    UG_OBJECT obj_buff_wnd_1 [MAX_OBJECTS] ; /* Object buffer */
+    UG_WindowCreate ( &window_1 , obj_buff_wnd_1 , MAX_OBJECTS, window_1_callback);
+    UG_WindowSetTitleTextFont ( &window_1 , &FONT_8X8 ) ;
+    UG_WindowSetTitleText ( &window_1 , "Bike Computer" ) ;
+    UG_WindowSetBackColor( &window_1 , C_GRAY ) ;
+    UG_ButtonCreate (&window_1, &button_1, BTN_ID_0, 10 , 230 , 115 , 290 );
+    UG_ButtonCreate (&window_1, &button_2, BTN_ID_1, 125 , 230 , 225 , 290 );
+    UG_ButtonSetBackColor (&window_1 ,BTN_ID_0 , C_BLUE ) ;
+    UG_ButtonSetForeColor (&window_1 ,BTN_ID_0 , C_WHITE ) ;
+    UG_ButtonSetBackColor (&window_1 ,BTN_ID_1 , C_BLUE ) ;
+    UG_ButtonSetForeColor (&window_1 ,BTN_ID_1 , C_WHITE ) ;
+    UG_ButtonSetFont (&window_1 , BTN_ID_0 , &FONT_8X8) ;
+    UG_ButtonSetFont (&window_1 , BTN_ID_1 , &FONT_8X8) ;
+    UG_ButtonSetText (&window_1 , BTN_ID_0 , "Prev" );
+    UG_ButtonSetText (&window_1 , BTN_ID_1 , "Next" );
+    
+    /* Window 2 e-Compass */
+    UG_WINDOW window_2 ; /* Window */
+    UG_BUTTON button_3; /* Button container */
+    UG_BUTTON button_4; /* Button container */
+    UG_OBJECT obj_buff_wnd_2 [MAX_OBJECTS] ; /* Object buffer */
+    UG_WindowCreate ( &window_2 , obj_buff_wnd_2 , MAX_OBJECTS, window_2_callback);
+    UG_WindowSetTitleTextFont ( &window_2 , &FONT_8X8 ) ;
+    UG_WindowSetTitleText ( &window_2 , "e-Compass" ) ;
+    UG_WindowSetBackColor( &window_2 , C_GRAY ) ;
+    UG_ButtonCreate (&window_2, &button_3, BTN_ID_2, 10 , 230 , 115 , 290 );
+    UG_ButtonCreate (&window_2, &button_4, BTN_ID_3, 125 , 230 , 225 , 290 );
+    UG_ButtonSetBackColor (&window_2 ,BTN_ID_2 , C_BLUE ) ;
+    UG_ButtonSetForeColor (&window_2 ,BTN_ID_2 , C_WHITE ) ;
+    UG_ButtonSetBackColor (&window_2 ,BTN_ID_3 , C_BLUE ) ;
+    UG_ButtonSetForeColor (&window_2 ,BTN_ID_3 , C_WHITE ) ;
+    UG_ButtonSetFont (&window_2 , BTN_ID_2 , &FONT_8X8) ;
+    UG_ButtonSetFont (&window_2 , BTN_ID_3 , &FONT_8X8) ;
+    UG_ButtonSetText (&window_2 , BTN_ID_2 , "Prev" );
+    UG_ButtonSetText (&window_2 , BTN_ID_3 , "Next" );
+
+    /* Window 3 GSP */
+    UG_WINDOW window_3 ; /* Window */
+    UG_BUTTON button_5; /* Button container */
+    UG_BUTTON button_6; /* Button container */
+    UG_OBJECT obj_buff_wnd_3 [MAX_OBJECTS] ; /* Object buffer */
+    UG_WindowCreate ( &window_3 , obj_buff_wnd_3 , MAX_OBJECTS, window_3_callback);
+    UG_WindowSetTitleTextFont ( &window_3 , &FONT_8X8 ) ;
+    UG_WindowSetTitleText ( &window_3 , "GPS Waypoints" ) ;
+    UG_WindowSetBackColor( &window_3 , C_GRAY ) ;
+    UG_ButtonCreate (&window_3, &button_5, BTN_ID_4, 10 , 230 , 115 , 290 );
+    UG_ButtonCreate (&window_3, &button_6, BTN_ID_5, 125 , 230 , 225 , 290 );
+    UG_ButtonSetBackColor (&window_3 ,BTN_ID_4 , C_BLUE ) ;
+    UG_ButtonSetForeColor (&window_3 ,BTN_ID_4 , C_WHITE ) ;
+    UG_ButtonSetBackColor (&window_3 ,BTN_ID_5 , C_BLUE ) ;
+    UG_ButtonSetForeColor (&window_3 ,BTN_ID_5 , C_WHITE ) ;
+    UG_ButtonSetFont (&window_3 , BTN_ID_4 , &FONT_8X8) ;
+    UG_ButtonSetFont (&window_3 , BTN_ID_5 , &FONT_8X8) ;
+    UG_ButtonSetText (&window_3 , BTN_ID_4 , "Prev" );
+    UG_ButtonSetText (&window_3 , BTN_ID_5 , "Next" );
+    
+        /* Finally , show the window */
+    //UG_WindowShow(&window_1) ;
+    //UG_WindowHide(&window_2);
+    //UG_WindowHide(&window_3);
+    
+    //UG_Update();
+
     while (1) { 
+            
+            cb1();
              
-        TFT.set_font((unsigned char*) ArialR20x20);
-        //check if we recieved a new message from GPS, if so, attempt to parse it,
+                TFT.set_font((unsigned char*) ArialR20x20);
+                TFT.foreground(White);
+                TFT.background(UG_WindowGetBackColor(&window_1));
+                //check if we recieved a new message from GPS, if so, attempt to parse it,
         if (refresh_Timer.read_ms() >= refresh_Time) {
             refresh_Timer.reset();
-                        
-            if (bmp180.init() != 0) {
-                //pc.printf("Error communicating with BMP180\n");
-            } else {
-                //pc.printf("Initialized BMP180\n");
-                bmp180.startTemperature();
-                wait(0.1);     // Wait for conversion to complete
-                float temp;
-                if(bmp180.getTemperature(&temp) != 0) {
-                    //pc.printf("Error getting temperature\n");
-                }
-                //pc.printf("Temperature is : %f", temp);
-                TFT.locate(4, 26) ;
-                TFT.printf("%.1fF", ((temp* 9.0) / 5.0 + 32));
-            }
-            int ftemp = humid.sample_ftemp();
-            int humidity = humid.sample_humid();
-            TFT.locate(140, 26) ;
-            TFT.printf("%d%%RH",humidity);
-            //pc.printf("HTU21D Temp: %d",ftemp);
-            //pc.printf("HTU21D Humidity: %d",humidity);
-    
-            if (imu.check() == 0){
-                pc.printf("Bosch BNO055 is NOT avirable!!\r\n");
-            } else {
-                //printf("Cal %d", imu.read_calib_status());
-                imu.get_calib();
-                if (imu.cal.system > 0x0){
-                    TFT.foreground(White);
-                    TFT.locate(4, 260) ;
-                    TFT.printf("No Data");
-                    TFT.foreground(Blue);
-                    imu.get_angles();
-                    TFT.locate(4, 260) ;
-                    TFT.printf("%.1f",imu.euler.yaw);
-                    //pc.printf("H %.1f",euler_angles.h);
-                    //pc.printf("R %.1f",euler_angles.r);
-                    //pc.printf("P %.1f",euler_angles.p);
+            
+                        switch ( pageid )
+                            {
+                            case PAGE1: 
+                                {
+                                    if (!pageinit) {
+                                        UG_WindowHide(&window_2);
+                                        UG_WindowHide(&window_3);
+                                        UG_WindowShow(&window_1);
+                                        UG_Update();
+                                    }
+                                    pageinit = 1;
+                                    if (bmp180.init() != 0) {
+                                        //pc.printf("Error communicating with BMP180\n");
+                                } else {
+                                        //pc.printf("Initialized BMP180\n");
+                                        bmp180.startTemperature();
+                                        wait(0.1);     // Wait for conversion to complete
+                                        float temp;
+                                        if(bmp180.getTemperature(&temp) != 0) {
+                                            //pc.printf("Error getting temperature\n");
+                                        }
+                                        TFT.locate(10, 50) ;
+                                        TFT.printf("%.1fF", ((temp* 9.0) / 5.0 + 32));
+                                }
+                                int ftemp = humid.sample_ftemp();
+                                int humidity = humid.sample_humid();
+                                TFT.locate(10, 72) ;
+                                TFT.printf("%d%%RH",humidity);
+                                if (MyGPS.dataready()) {
+                                    MyGPS.read();
+                                    TFT.locate(10, 26) ;
+                                    TFT.foreground(UG_WindowGetBackColor(&window_1));
+                                    TFT.printf("No GPS Data");
+                                    TFT.foreground(White);
+                                    TFT.locate(10, 26) ;
+                                    TFT.printf("%d:%d:%d", MyGPS.buffer.hours, MyGPS.buffer.minutes, MyGPS.buffer.seconds);
+                                    TFT.locate(100, 26) ;
+                                    TFT.printf("%d-%d-%d", MyGPS.buffer.month, MyGPS.buffer.day, MyGPS.buffer.year);
+                                    TFT.set_font((unsigned char*) SCProSB31x55);    
+                                    TFT.locate(130, 180) ;
+                                    TFT.printf("%.1f", MyGPS.buffer.speed);
+                                    TFT.locate(10, 180) ;
+                                    TFT.printf("%.1f", MyGPS.buffer.speed); //Cadence
+                                    TFT.set_font((unsigned char*) ArialR20x20);
+                                    //TFT.locate(10, 50) ;
+                                    //double waypoint = nav.CalculateDistance(MyGPS.buffer.latitude,MyGPS.buffer.longitude,plat,plon)/double(1609.344);
+                                    //TFT.printf("%.1fMI From Perry", waypoint);
+                                }
+                                else {
+                                    TFT.locate(10, 26) ;
+                                    TFT.printf("No GPS Data");
+                                    //pc.printf("NMEA has no valid data");
+                                } 
+                                break;
+                            }
+                            case PAGE2: 
+                                {
+                                    if (!pageinit) {
+                                        UG_WindowHide(&window_1);
+                                        UG_WindowHide(&window_3);
+                                        UG_WindowShow(&window_2);
+                                        UG_Update();
+                                    }
+                                    pageinit = 1;
+                                    break;
+                                }
+                                case PAGE3: 
+                                {
+                                    if (!pageinit) {
+                                        UG_WindowHide(&window_1);
+                                        UG_WindowHide(&window_2);
+                                        UG_WindowShow(&window_3);
+                                        UG_Update();
+                                    }
+                                    pageinit = 1;
+                                    break;
+                                }   
+                        }   
+                }       
+                            /*
+                                TFT.locate(140, 260) ;
+                TFT.printf("%.1fft", MyGPS.buffer.altitude/0.3048);
+                                TFT.locate(4, 280) ;
+                                int degree;
+                                int minutes;
+                                int seconds;
+                                degree = (int)abs(MyGPS.buffer.longitude);
+                minutes = (int) ( (abs(MyGPS.buffer.longitude) - (double)degree) * 60.0);
+                seconds = (int) ( (abs(MyGPS.buffer.longitude) - (double)degree - (double)minutes / 60.0) * 60.0 * 60.0 );
+                TFT.printf("%d %d' %d\" %c lon", degree, minutes,seconds, MyGPS.buffer.lonc);
+                                TFT.locate(4, 300) ;
+                                TFT.locate(4, 300) ;
+                degree = (int)abs(MyGPS.buffer.latitude);
+                minutes = (int) ( (abs(MyGPS.buffer.latitude) - (double)degree) * 60.0);
+                seconds = (int) ( (abs(MyGPS.buffer.latitude) - (double)degree - (double)minutes / 60.0) * 60.0 * 60.0 );
+                TFT.printf("%d %d' %d\" %c lat", degree, minutes,seconds, MyGPS.buffer.latc);
+                                 
+                  
+        
+                                //pc.printf("Dist to Perry %.4f ", nav.CalculateDistance(MyGPS.buffer.latitude,MyGPS.buffer.longitude,plat,plon));
+                                
+               
+                }   
+                
+                    
+                        if (imu.chip_ready() == 0){
+                            pc.printf("Bosch BNO055 is NOT avirable!!\r\n");
+                } else {
                             
-                } else {
-                    TFT.locate(4, 260) ;
-                    TFT.printf("No Data");
-                }
-            }
-
-             float angle = int(imu.euler.yaw); // * 180/PI); // Convert radians to degrees for more a more usual result
-             // For the screen -X = up and +X = down and -Y = left and +Y = right, so does not follow coordinate conventions
-             float dx = (0.7*radius * cos((angle-90)*PI/180)) + centreX;  // calculate X position for the screen coordinates - can be confusing!
-             float dy = (0.7*radius * sin((angle-90)*PI/180)) + centreY;  // calculate Y position for the screen coordinates - can be confusing!
+                        if (imu.read_calib_status() > 0x0){
+                                TFT.foreground(White);
+                                TFT.locate(4, 260) ;
+                                TFT.printf("No Data");
+                                TFT.foreground(Blue);
+                                imu.get_Euler_Angles(&euler_angles);
+                                TFT.locate(4, 260) ;
+                                TFT.printf("%.1f @ %.1f",euler_angles.h, euler_angles.p);
+                                //pc.printf("H %d",(int)euler_angles.h);
+                                //pc.printf("R %.1f",euler_angles.r);
+                                //pc.printf("P %.1f",euler_angles.p);
+                            
+                            } else {
+                                    TFT.locate(4, 260) ;
+                                    TFT.printf("No Data");
+                            }
+                        }
+                    
+                         float angle = euler_angles.h; // Convert radians to degrees for more a more usual result
+                         // For the screen -X = up and +X = down and -Y = left and +Y = right, so does not follow coordinate conventions
+                         float dx = (radius * cos((angle-90)*PI/180)) + centreX;  // calculate X position for the screen coordinates - can be confusing!
+             float dy = (radius * sin((angle-90)*PI/180)) + centreY;  // calculate Y position for the screen coordinates - can be confusing!
              arrow(last_dx,last_dy, centreX, centreY, 2,2,White);      // Erase last arrow      
              arrow(dx,dy, centreX, centreY, 2, 2,Blue);               // Draw arrow in new position
              last_dx = dx; 
              last_dy = dy;
-                        
-            if (MyGPS.dataready()) {
-                MyGPS.read();
-                //pc.printf("NMEA has valid data");
-                //pc.printf("Sats : %d \n", MyGPS.buffer.satellites);
-                //pc.printf("%d-%d-%d\n", MyGPS.buffer.month, MyGPS.buffer.day, MyGPS.buffer.year);
-                //pc.printf("%d:%d:%d\n", MyGPS.buffer.hours, MyGPS.buffer.minutes, MyGPS.buffer.seconds);
-                
-                TFT.foreground(White);
-                TFT.locate(4, 2) ;
-                TFT.printf("No Data");
-                TFT.foreground(Blue);
-                TFT.locate(4, 2) ;
-                TFT.printf("%d-%d-%d", MyGPS.buffer.month, MyGPS.buffer.day, MyGPS.buffer.year);
-                TFT.locate(4, 50) ;
-                double waypoint = nav.CalculateDistance(MyGPS.buffer.latitude,MyGPS.buffer.longitude,plat,plon)/double(1609.344);
-                TFT.printf("%.1fMI From Perry", waypoint);
-                TFT.locate(140, 2) ;
-                TFT.printf("%d:%d:%d", MyGPS.buffer.hours, MyGPS.buffer.minutes, MyGPS.buffer.seconds);
-                TFT.locate(140, 260) ;
-                TFT.printf("%.1fft", MyGPS.buffer.altitude/0.3048);
-                TFT.locate(4, 280) ;
-                int degree;
-                int minutes;
-                int seconds;
-                degree = (int)abs(MyGPS.buffer.longitude);
-                minutes = (int) ( (abs(MyGPS.buffer.longitude) - (double)degree) * 60.0);
-                seconds = (int) ( (abs(MyGPS.buffer.longitude) - (double)degree - (double)minutes / 60.0) * 60.0 * 60.0 );
-                TFT.printf("%d %d' %d\" %c lon", degree, minutes,seconds, MyGPS.buffer.lonc);
-                TFT.locate(4, 300) ;
-                degree = (int)abs(MyGPS.buffer.latitude);
-                minutes = (int) ( (abs(MyGPS.buffer.latitude) - (double)degree) * 60.0);
-                seconds = (int) ( (abs(MyGPS.buffer.latitude) - (double)degree - (double)minutes / 60.0) * 60.0 * 60.0 );
-                TFT.printf("%d %d' %d\" %c lat", degree, minutes,seconds, MyGPS.buffer.latc);
-                TFT.set_font((unsigned char*) SCProSB31x55);     
-                TFT.locate(120, 200) ;
-                TFT.printf("%.1f", MyGPS.buffer.speed);    
-                                 
-                //pc.printf("Dist to Perry %.4f ", nav.CalculateDistance(MyGPS.buffer.latitude,MyGPS.buffer.longitude,plat,plon));
-                                
-            }
-            else {
-                TFT.locate(4, 2) ;
-                TFT.printf("No Data");
-                //pc.printf("NMEA has no valid data");
-            }     
-        }            
+                                                
+            
+        }
+        */              
     }  
 }
 
@@ -294,4 +441,116 @@
   TFT.printf("E");
   TFT.locate((centreX-23),(centreY-3));
   TFT.printf("W");
-}
\ No newline at end of file
+}
+
+void ili9341_pset(UG_S16 ul_x,UG_S16 ul_y, UG_COLOR ul_color)
+{
+    TFT.pixel(ul_x, ul_y, ul_color);
+}
+
+void window_1_callback( UG_MESSAGE* msg )
+{
+    if ( msg->type == MSG_TYPE_OBJECT )
+    {
+        if ( msg->id == OBJ_TYPE_BUTTON )
+        {
+            switch ( msg->sub_id )
+            {
+                case BTN_ID_0:
+                {
+                    pageid--;
+                    if (pageid < 1) {
+                            pageid = 3;
+                    }   
+                    pageinit = 0;   
+                    break;
+                }
+                case BTN_ID_1:
+                {
+                    pageid++;
+                    if (pageid > 3) {
+                            pageid = 1;
+                    }   
+                    pageinit = 0;   
+                    break;
+                }
+            }
+        }
+    }
+}
+
+void window_2_callback( UG_MESSAGE* msg )
+{
+    if ( msg->type == MSG_TYPE_OBJECT )
+    {
+        if ( msg->id == OBJ_TYPE_BUTTON )
+        {
+            switch ( msg->sub_id )
+            {
+                case BTN_ID_2:
+                {
+                    pageid--;
+                    if (pageid < 1) {
+                            pageid = 3;
+                    }   
+                    pageinit = 0;       
+                    break;
+                }
+                case BTN_ID_3:
+                {
+                    pageid++;
+                    if (pageid > 3) {
+                            pageid = 1;
+                    }
+                    pageinit = 0;   
+                    break;
+                }
+            }
+        }
+    }
+}
+
+void window_3_callback( UG_MESSAGE* msg )
+{
+    if ( msg->type == MSG_TYPE_OBJECT )
+    {
+        if ( msg->id == OBJ_TYPE_BUTTON )
+        {
+            switch ( msg->sub_id )
+            {
+                case BTN_ID_4:
+                {
+                    pageid--;
+                    if (pageid < 1) {
+                            pageid = 3;
+                    }   
+                    pageinit = 0;       
+                    break;
+                }
+                case BTN_ID_5:
+                {
+                    pageid++;
+                    if (pageid > 3) {
+                            pageid = 1;
+                    }
+                    pageinit = 0;   
+                    break;
+                }
+            }
+        }
+    }
+}
+
+void cb1(void) { 
+    point p;
+    TSC.getTouch(p);
+        if (p.z > __PRESURE)
+        {
+            UG_TouchUpdate ( p.x, p.y, TOUCH_STATE_PRESSED ) ;
+        }
+        else
+        {
+            UG_TouchUpdate (-1, -1, TOUCH_STATE_RELEASED ) ;
+        }
+    UG_Update();
+}