Nucleo-transfer

Dependencies:   ADS1015 MPU6050 PixelArray PixelArray-Nucleo mbed WS2813

Fork of Nucleo-transfer by Momo Medical

Revision:
47:80cfc181f8b3
Parent:
46:a0e6e088a50a
Child:
48:aca02ef5cd01
--- a/Sensorplate/main.cpp	Thu Jan 11 10:28:38 2018 +0000
+++ b/Sensorplate/main.cpp	Mon Jan 15 12:15:29 2018 +0000
@@ -817,9 +817,9 @@
         if (connection_test_sensorplate == 1) {
             piezo_electric_array[0] = piezo_electric_adc.readADC_SingleEnded(0);            // First PE readout.
 
-            for (uint8_t k = 0; k < 4; ++k) {
-                piezo_resistive_array[k] =    piezo_resistive_adc1.readADC_SingleEnded(k);  // First 4 PR readout.
-            }
+//            for (uint8_t k = 0; k < 4; ++k) {
+//                piezo_resistive_array[k] =    piezo_resistive_adc1.readADC_SingleEnded(k);  // First 4 PR readout.
+//            }
             if (test_mode == 1) {
                 usb_serial.printf("Loop time: %d ms\n",piezo_electric_sample_timer.read_ms());
             }
@@ -827,9 +827,9 @@
 
             piezo_electric_array[1] = piezo_electric_adc.readADC_SingleEnded(0);            // Second PE readout.
 
-            for (uint8_t k = 0; k < 4; ++k) {
-                piezo_resistive_array[k+4] =  piezo_resistive_adc2.readADC_SingleEnded(k);  // Last 4 PR readout.
-            }
+//            for (uint8_t k = 0; k < 4; ++k) {
+//                piezo_resistive_array[k+4] =  piezo_resistive_adc2.readADC_SingleEnded(k);  // Last 4 PR readout.
+//            }
             if (test_mode == 1) {
                 usb_serial.printf("Loop time: %d ms\n",piezo_electric_sample_timer.read_ms());
             }
@@ -838,14 +838,14 @@
 
             piezo_electric_array[2] = piezo_electric_adc.readADC_SingleEnded(0);            // Third PE readout.
 
-            angle_device_sensorplate.getAccelero(accelerometer_sensorplate);                // Get accelerometer data.
-            angle = accelerometer_sensorplate[2]*100;
-            if(angle == 0) {
-                MPU6050 angle_device_sensorplate(PB_9, PB_8);
-                angle_device_sensorplate.getAccelero(accelerometer_sensorplate);
-                angle = accelerometer_sensorplate[2]*100;
-            }
-            angle_device_sensorplate.getGyro(gyroscope_sensorplate);                        // Get gyroscope data.
+//            angle_device_sensorplate.getAccelero(accelerometer_sensorplate);                // Get accelerometer data.
+//            angle = accelerometer_sensorplate[2]*100;
+//            if(angle == 0) {
+//                MPU6050 angle_device_sensorplate(PB_9, PB_8);
+//               angle_device_sensorplate.getAccelero(accelerometer_sensorplate);
+//                angle = accelerometer_sensorplate[2]*100;
+//            }
+//            angle_device_sensorplate.getGyro(gyroscope_sensorplate);                        // Get gyroscope data.
             if (test_mode == 1) {
                 usb_serial.printf("Loop time: %d ms\n",piezo_electric_sample_timer.read_ms());
             }
@@ -854,14 +854,14 @@
 //                angle_device_reference_belt.getAccelero(accelerometer_reference_belt);      // Get accelerometer data from belt.
 //            }
 
-            if (connection_test_sensorplate == 1) {
-                if (test_belt == 0) {                                                     // If statement for sending serial information sensorplate data when connection test is active.
-                    pi_serial.printf("?,%f,%f,%f,%f,%f,%f,0,0,0,0,0,0,\n", accelerometer_sensorplate[0], accelerometer_sensorplate[1], accelerometer_sensorplate[2], gyroscope_sensorplate[0], gyroscope_sensorplate[1], gyroscope_sensorplate[2]);
-                    } else{
-                // Receiving order sensor information: 3 accelero sensors & 3 gyroscope sensors from sensorplate; 3 accelero sensors & 3 gyroscope sensors from belt. Is splitted in two parts - part 2/2.
-                pi_serial.printf("?,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,\n", accelerometer_sensorplate[0], accelerometer_sensorplate[1], accelerometer_sensorplate[2], gyroscope_sensorplate[0], gyroscope_sensorplate[1], gyroscope_sensorplate[2], accelerometer_reference_belt[0], accelerometer_reference_belt[1], accelerometer_reference_belt[2], gyroscope_reference_belt[0], gyroscope_reference_belt[1], gyroscope_reference_belt[2]);
-                }
-            } // binair print and convert in pi
+//            if (connection_test_sensorplate == 1) {
+//                if (test_belt == 0) {                                                     // If statement for sending serial information sensorplate data when connection test is active.
+//                    pi_serial.printf("?,%f,%f,%f,%f,%f,%f,0,0,0,0,0,0,\n", accelerometer_sensorplate[0], accelerometer_sensorplate[1], accelerometer_sensorplate[2], gyroscope_sensorplate[0], gyroscope_sensorplate[1], gyroscope_sensorplate[2]);
+//                    } else{
+//                // Receiving order sensor information: 3 accelero sensors & 3 gyroscope sensors from sensorplate; 3 accelero sensors & 3 gyroscope sensors from belt. Is splitted in two parts - part 2/2.
+//                pi_serial.printf("?,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,\n", accelerometer_sensorplate[0], accelerometer_sensorplate[1], accelerometer_sensorplate[2], gyroscope_sensorplate[0], gyroscope_sensorplate[1], gyroscope_sensorplate[2], accelerometer_reference_belt[0], accelerometer_reference_belt[1], accelerometer_reference_belt[2], gyroscope_reference_belt[0], gyroscope_reference_belt[1], gyroscope_reference_belt[2]);
+//                }
+//            } // binair print and convert in pi
 
             while(piezo_electric_sample_timer.read_us()<(3*(total_readout_cycle_time_us/5))) {}  // Wait untill 60% of cycle. Energy efficiency is not fine in this situation, correct if low energy is needed.
 
@@ -914,6 +914,8 @@
         if (test_mode == 0) {                                                            // If statements for test purposal (untill * mark).
             usb_serial.printf("Loop time: %d ms\n",piezo_electric_sample_timer.read_ms());
         }
+        
+        while(piezo_electric_sample_timer.read_us()<(total_readout_cycle_time_us)) {}  // Wait untill 100% of cycle. Energy efficiency is not fine in this situation, correct if low energy is needed.
         //if (test_pin == 1) {
 //            test_mode = 1;
 //            usb_serial.printf("%d\n",test_mode);