Works

Dependencies:   BMP180 BNO055_fusion Fonts GPSISR HTU21D SDFileSystem UniGraphic mbed uGUI

Fork of Bicycl_Computer_NUCLEO-F411RE by Darren Ulrich

Revision:
7:b78ff34209e5
Parent:
6:6eb4b9322931
Child:
8:8aa9cdab4a07
diff -r 6eb4b9322931 -r b78ff34209e5 main.cpp
--- a/main.cpp	Thu Jan 19 20:46:26 2017 +0000
+++ b/main.cpp	Fri Jan 20 20:46:41 2017 +0000
@@ -61,26 +61,27 @@
 #define TARGET_NECLEO_F411RE 
 #endif
 
-DigitalOut backlight(PB_3) ;
+
+//DigitalOut backlight(PB_3) ;
 // DigitalOut tsc_cs(PA_9, 1) ;
 // DigitalOut tft_cs(PB_6, 1) ;
 
 // Display
 ILI9341 TFT(SPI_8, 10000000, 
     PIN_MOSI, PIN_MISO,  PIN_SCLK, 
-    PIN_CS_TFT, PIN_RESET_TFT, PIN_DC_TFT, "Adafruit2.8") ;
+    PIN_CS_TFT, PIN_RESET_TFT, PIN_DC_TFT, "Adafruit2.8");
     
 // TouchScreen
 TouchScreen TSC(PIN_XP, PIN_XM, PIN_YP, PIN_YM);
 
 // 3 Axis IMU
-BNO055 imu(i2c, PIN_RESET);  // Reset =D7, addr = BNO055_G_CHIP_ADDR, mode = MODE_NDOF <- as default
+BNO055 imu(I2C_SDA, I2C_SCL, PIN_RESET);  // Reset =D7, addr = BNO055_G_CHIP_ADDR, mode = MODE_NDOF <- as default
 
 // Humidity and Temperature
 HTU21D temphumid(I2C_SDA, I2C_SCL);
 
 // Pressure
-BMP180 bmp180; // initialize BMP-180 altimeter
+BMP180 bmp180(I2C_SDA, I2C_SCL);
 
 int page = 0 ;
 int numPage = 2 ;
@@ -100,7 +101,7 @@
 void screen1(void) // Welcome Screen
 {
     TFT.BusEnable(true) ;
-    backlight = 0 ;
+    //backlight = 0 ;
     TFT.background(White) ;
     wait(0.1) ;
     TFT.cls() ;
@@ -109,7 +110,7 @@
     TFT.set_font((unsigned char*) Arial24x23);
     TFT.foreground(Red) ;
     TFT.locate(80, 40) ;
-    TFT.printf("MBED") ;
+    TFT.printf("MBED");
     TFT.foreground(Blue);
     TFT.locate(60, 80) ;
     TFT.printf("2.8\"TFT") ; 
@@ -132,14 +133,14 @@
     TFT.locate(30, 300) ;
     TFT.printf("until the next screen starts") ;
     TFT.BusEnable(false) ;
-    backlight = 1 ;
+    //backlight = 1 ;
 }
 
 void screen2(void) // Graphics
 {
     //Draw some graphics
     int i, x[2], y[2] ;
-    backlight = 0 ;
+    //backlight = 0 ;
     TFT.BusEnable(true) ;
     TFT.background(Black);
     wait(0.1) ;
@@ -188,7 +189,7 @@
     TFT.locate(20, 290) ;
     TFT.printf("capability is provided") ;
     TFT.BusEnable(false) ;
-    backlight = 1 ;
+    //backlight = 1 ;
 }    
 
 double clip(double src)
@@ -221,22 +222,24 @@
     
 int main()
 {
+    
+    if (bmp180.init() != 0) {
+        printf("Error communicating with BMP180\n");
+    } else {
+            printf("Initialized BMP180\n");
+           
+    }
+    wait(1);
+   
+    
+    
     // uint16_t x, y, z ;
     int prevPage = 99 ;
     bool waitTouch = false ;
     point p;
     
     printf("Hello World\n") ;
-    
-    // tsc_cs = 1 ;
-    // tft_cs = 0 ;
-    // initTFT() ;
-    // tft_cs = 1 ;
-
-    // tsc_cs = 0 ;
-    // TSC.spi_format(8, 1) ; // for Nucleo F411RE
-    // tsc_cs = 1 ;
-    
+   
     // screen0() ;
         
     printf("Program Started!\n\r") ;
@@ -266,9 +269,18 @@
         // tft_cs = 1 ;
         do {
             TSC.getTouch(p);
-            printf("Touched X %d\n\r", p.x) ;
-            printf("Touched Y %d\n\r", p.y) ;
-            printf("Touched Z %d\n\r", p.z) ;
+           
+            bmp180.startTemperature();
+            wait_ms(5);     // Wait for conversion to complete
+            float temp;
+            if(bmp180.getTemperature(&temp) != 0) {
+                printf("Error getting temperature\n");
+            }    
+            printf("Temperature is -> %.2f\n", temp);
+            
+            //printf("Touched X %d\n\r", p.x) ;
+            //printf("Touched Y %d\n\r", p.y) ;
+            //printf("Touched Z %d\n\r", p.z) ;
             wait(3) ;
             if (p.z > __PRESURE) {
                 if (p.y < 30000) { // left