Ahmad Alkaff / Mbed 2 deprecated CS3237

Dependencies:   mbed

Revision:
3:a7396ed925e6
Parent:
2:17d5a74fc2c4
Child:
7:188bf08cfb44
--- a/main.cpp	Wed Oct 09 11:31:00 2019 +0000
+++ b/main.cpp	Mon Oct 14 09:45:36 2019 +0000
@@ -132,6 +132,7 @@
             ECG_Raw = (int32_t)(buffer[k] << 8);
             ECG_Raw = ECG_Raw >> 14;
             usbSerial.printf("ECG Raw: %d;%d\r\n", index, ECG_Raw);
+            usbSerial.printf("k is %d and number is %d\r\n", k, number);
             index++; 
         }
     }
@@ -175,7 +176,10 @@
     //bmp280_pres.init(BMP280::OVERSAMPLING_X16_P, BMP280::OVERSAMPLING_X2_T, BMP280::FILT_4, BMP280::NORMAL_MODE, BMP280::T_62_5);
 
     // LIS2DH initialize interrupt  
-    lis2dh.initStart(LIS2DH_DATARATE_10HZ, LIS2DH_FIFO_SIZE);
+    lis2dh.initStart(LIS2DH_DATARATE_50HZ, LIS2DH_FIFO_SIZE);
+    //lis2dh.init();
+    //lis2dh_Interrupt.fall(&LIS2DHIntHandler);
+    //lis2dh_Interrupt.mode(PullUp);
 
     // Interrupt priority    
     NVIC_SetPriority(GPIO_P0_IRQn, 5);
@@ -227,49 +231,41 @@
         MAX30001::MAX30001_INT_ODNR); // int2b_Type
         
     // MAX30001 initialize interrupt
+    /*
     max30001.max30001_ECG_InitStart(En_ecg, Openp, Openn, Pol, Calp_sel, Caln_sel, E_fit, Rate, Gain, Dhpf, Dlpf);
     max30001.max30001_synch();
     max30001.onDataAvailable(&StreamPacketUint32_ex);
+    */
     int a;
-    
+
     while (1) {
-        if (a == 65) {
+        /*
+        wait(5);
+        a = usbSerial._getc();
+        usbSerial.printf("WAIT 5 LIAO\n\n\n\r");
+        
+        if (a == 98) {
             max30001.max30001_Stop_ECG();
             index = 0;
         }
-       // if (a == 97)
+        // if (a == 97)
         // Read ECG
-        max30001.max30001_ECG_InitStart(En_ecg, Openp, Openn, Pol, Calp_sel, Caln_sel, E_fit, Rate, Gain, Dhpf, Dlpf);
-       
-        //Read Temperature
-        //MAX30205_top.readTemperature(&rawTemp_top);
-        //MAX30205_bottom.readTemperature(&rawTemp_bottom);
+        if (a == 97)
+        {
+            usbSerial.printf("-------------------------------------------------\n\n\n\r");
+            max30001.max30001_ECG_InitStart(En_ecg, Openp, Openn, Pol, Calp_sel, Caln_sel, E_fit, Rate, Gain, Dhpf, Dlpf);
+            max30001.max30001_synch();
+            max30001.onDataAvailable(&StreamPacketUint32_ex);
+            usbSerial.printf("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n\n\n\r");
+        }
+        */
+        lis2dh.int_handler();
 
-        // Convert to Celsius
-        //celsius_top = MAX30205_top.toCelsius(rawTemp_top);
-        //celsius_bottom = MAX30205_bottom.toCelsius(rawTemp_bottom);
-        // Convert to Fahrenheit
-        //fahrenheit_top = MAX30205_top.toFahrenheit(celsius_top);
-        //fahrenheit_bottom = MAX30205_bottom.toFahrenheit(celsius_bottom);
-         
-        // Read BMP280 Temp. and Pressure
-        //bmp280_pres.ReadCompDataRaw(&bmp280_rawData);
-        //bmp280_pres.ToFloat(&bmp280_rawData, &Temp_degC, &Press_Pa);    
-        //Press_Bar = Press_Pa / 100000; 
-
-        /* Printing various sensor values */
-        //usbSerial.printf("***** MAX30205 Temperature Sensor Reading *****\n\r");
-        //usbSerial.printf("Top Temperature: %.2f\370 C\n\rBottom Temperature: %.2f\370 C \n\rTop Temperature in Farenheit: %.2f\370 F\n\rBottom Temperature in Farenheit %.2f\370 F\n\n\r", celsius_top, celsius_bottom, fahrenheit_top, fahrenheit_bottom);
-        
-        //usbSerial.printf("***** BMP280 Barometric Sensor Reading *****\n\r");
-        //usbSerial.printf("Temp_degC : %.2f , Press_Bar is %.2f , Press_pa is %.2f\n\n\r",Temp_degC, Press_Bar, Press_Pa);
-
-        lis2dh.get_motion_cached(&accel_value[0], &accel_value[1], &accel_value[2]);
+        lis2dh.get_motion_fifo(&accel_value[0], &accel_value[1], &accel_value[2]);
 
         usbSerial.printf("***** LIS2DH Acclerometer Sensor Reading *****\n\r");
-        usbSerial.printf("X-Axis: %d\n\rY-Axis: %d\n\rZ-Axis: %d", &accel_value[0], &accel_value[1], &accel_value[2]);
+        usbSerial.printf("X-Axis: %d\n\rY-Axis: %d\n\rZ-Axis: %d", accel_value[0], accel_value[1], accel_value[2]);
         usbSerial.printf("-------------------------------------------------\n\n\n\r");
-
-        wait(1.5);
+        wait(1);
     }     
 }